[Ffmpeg-devel] Increasing Audio Buffer Size

Michael Niedermayer michaelni
Tue May 9 16:33:23 CEST 2006


On Tue, May 09, 2006 at 06:38:51AM -0700, Mike Melanson wrote:
> Michael Niedermayer wrote:
> >and tomorrow yet another format will need 500k, no this is not ok, fix the
> That is how the process has worked so far...

yes, and iam unhappy about it

> >code, so that get/release_buffer() is used by the audio codecs to alloc
> >the buffer, and no a codec internal buffer which chops it below 192k is 
> >not ok either, actually thats a even worse hack
> So, modify the internal FFmpeg API? Will do. This also affects how 
> external programs view FFmpeg, right?

that depends, it can be done in a way which peserves compatibility but
IMHO it does nothing good, it will just cause people to keep using the
old API and cause everyone to get headache due to buffer overflows and
such ...

heres my thought on how it could be done (comments welcome...)

-int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+int avcodec_decode_audio(AVCodecContext *avctx, AVFrame *avframe,

optionally the above can be done in a way which doesnt break compatibility
be adding a new function and keeping the old ...

the audio decoders decode():
    calls avctx.release_buffer(avctx, avframe) if a previous buffer isnt 
    needed anymore

    calls avctx.get_buffer(avctx, avframe)

    audio sample i of channel c is stored in
    avframe.data[c][ i*avframe.linesize[c] ] cast to the format (always 
    int16_t currently)

    avframe.linesize[c] will only depend upon avctx.sample_format
    so a decoder doesnt need to care about it if it supports just
    one sample_format (which will generally be the case)

get_buffer(avctx, avframe)
    should allocate (or reuse) a buffer depending upon 
    the number of samples needed (probably need to add a field to 
    AVCodecContext unless we want to missuse width or height ...)

release_buffer() will free the buffer


In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is

More information about the ffmpeg-devel mailing list