[Ffmpeg-devel] PCM input frame size in samples

Joel Reymont joelr1
Fri Oct 27 17:17:50 CEST 2006


Is there a better way to calculate the PCM input frame size in  
samples than this?

   audio_outbuf_size = 10000;
   audio_outbuf = av_malloc(audio_outbuf_size);

   /* ugly hack for PCM codecs (will be removed ASAP with new PCM
      support to compute the input frame size in samples */
   if (c->frame_size <= 1)
   {
     audio_input_frame_size = audio_outbuf_size / c->channels;

     switch(st->codec->codec_id) {
     case CODEC_ID_PCM_S16LE:
     case CODEC_ID_PCM_S16BE:
     case CODEC_ID_PCM_U16LE:
     case CODEC_ID_PCM_U16BE:
       audio_input_frame_size >>= 1;
       break;
     default:
       break;
     }
   } else {
     audio_input_frame_size = c->frame_size;
   }
   samples = av_malloc(audio_input_frame_size * 2 * c->channels);

	Thanks, Joel

--
http://wagerlabs.com/









More information about the ffmpeg-devel mailing list