[FFmpeg-devel] avcodec_encode_audio() and libavcodec/pcm.c

Michael Niedermayer michaelni
Sun May 25 23:57:51 CEST 2008


On Sun, May 25, 2008 at 08:36:25PM +0200, Stefano Sabatini wrote:
> Hi all,
> 
> maybe this belongs to libav-user, anyway...
> 
> According to documentation for avcodec_encode_audio():
> 
>  * @param[in] samples the input buffer containing the samples
>  * The number of samples read from this buffer is frame_size*channels,
>  * both of which are defined in \p avctx.
> 
> This isn't true for PCM audio, for example with PCM 16 the function
> reads exactly a number of bytes which is buf_size/sample_size, and
> this causes also the strange switch in ffmpeg.c:
> 
>         /* output a pcm frame */
>         /* XXX: change encoding codec API to avoid this ? */
>         switch(enc->codec->id) {
>         case CODEC_ID_PCM_S32LE:
>         case CODEC_ID_PCM_S32BE:
>         case CODEC_ID_PCM_U32LE:
>         case CODEC_ID_PCM_U32BE:
>             size_out = size_out << 1;
>             break;
>         case CODEC_ID_PCM_S24LE:
>         case CODEC_ID_PCM_S24BE:
>         case CODEC_ID_PCM_U24LE:
>         case CODEC_ID_PCM_U24BE:
>         case CODEC_ID_PCM_S24DAUD:
>             size_out = size_out / 2 * 3;
>             break;
>         case CODEC_ID_PCM_S16LE:
>         case CODEC_ID_PCM_S16BE:
>         case CODEC_ID_PCM_U16LE:
>         case CODEC_ID_PCM_U16BE:
>             break;
>         default:
>             size_out = size_out >> 1;
>             break;
>         }
> 
> Can someone comment on this (pretty weird) behaviour, there is some
> hope to change it to make it match the documentation for
> avcodec_encode_audio() or application writers have to hardcode the
> above logic into every application which deals with PCM audio?

suggest an alternative

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080525/aa02d742/attachment.pgp>



More information about the ffmpeg-devel mailing list