]> git.sesse.net Git - mlt/commitdiff
Add mlt_audio_format_size().
authorDan Dennedy <dan@dennedy.org>
Mon, 7 Mar 2011 06:16:01 +0000 (22:16 -0800)
committerDan Dennedy <dan@dennedy.org>
Mon, 7 Mar 2011 06:16:01 +0000 (22:16 -0800)
src/framework/mlt_frame.c
src/framework/mlt_frame.h

index 71ea33e52623ef1c618e93f6cf087a68fd101a48..b67da15450b6737ceb240a7b03471287f473c3b9 100644 (file)
@@ -594,8 +594,7 @@ uint8_t *mlt_frame_get_alpha_mask( mlt_frame self )
  *
  * You do not need to deallocate the returned string.
  * \public \memberof mlt_frame_s
- * \param self a frame
- * \param format an image format enum
+ * \param format an audio format enum
  * \return a string for the name of the image format
  */
 
@@ -611,6 +610,27 @@ const char * mlt_audio_format_name( mlt_audio_format format )
        return "invalid";
 }
 
+/** Get the amount of bytes needed for a block of audio.
+  *
+  * \public \memberof mlt_frame_s
+  * \param format an audio format enum
+  * \param samples the number of samples per channel
+  * \param channels the number of channels
+  * \return the number of bytes
+  */
+
+int mlt_audio_format_size( mlt_audio_format format, int samples, int channels )
+{
+       switch ( format )
+       {
+               case mlt_audio_none:   return 0;
+               case mlt_audio_s16:    return samples * channels * sizeof( int16_t );
+               case mlt_audio_s32:    return samples * channels * sizeof( int32_t );
+               case mlt_audio_float:  return samples * channels * sizeof( float );
+       }
+       return 0;
+}
+
 /** Get the audio associated to the frame.
  *
  * You should express the desired format, frequency, channels, and samples as inputs. As long
index f54dee3a04414498723bffe185e5fb9c9b308afd..13d0e268a670e33c2143a13577d6247ebbe52d13 100644 (file)
@@ -137,6 +137,7 @@ extern int64_t mlt_sample_calculator_to_now( float fps, int frequency, int64_t p
 extern const char * mlt_image_format_name( mlt_image_format format );
 extern int mlt_image_format_size( mlt_image_format format, int width, int height, int *bpp );
 extern const char * mlt_audio_format_name( mlt_audio_format format );
+extern int mlt_audio_format_size( mlt_audio_format format, int samples, int channels );
 extern void mlt_frame_write_ppm( mlt_frame frame );
 
 /** This macro scales RGB into the YUV gamut - y is scaled by 219/255 and uv by 224/255. */