[FFmpeg-devel] [PATCH] Remove check "output buffer size >= input buffer size" for decode_audio2()

Kostya kostya.shishkov
Thu Sep 13 08:10:06 CEST 2007


Here is trivial patch to remove unneeded check from decode_audio2().

I found this check unneeded because decoders may handle input greater
than output buffer size by either reducing its size (some badly-coded
lossless audio or decoding some insane 256-bit audio) or by splitting
into chunks itself (like Monkey Audio does and my decoder in order to
work with ffplay/other players needs this check dropped).

Also this check will not help when data is expanded. For examples,
different DPCM decoders do not check for input vs output buffer size,
so there is still overflow when when buf_size > out_buf_size/2.

I've committed some fixes for my decoders and looks like there are
these decoders in need of stricter check:
 all from dpcm.c (while adpcm.c performs check)
 dsicinaudio_decoder
 adpcm_adx_decoder
-------------- next part --------------
Index: libavcodec/utils.c
===================================================================
--- libavcodec/utils.c	(revision 10484)
+++ libavcodec/utils.c	(working copy)
@@ -960,8 +960,7 @@
             return -1;
         }
         if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
-        *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
-        *frame_size_ptr < buf_size){
+        *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t)){
             av_log(avctx, AV_LOG_ERROR, "buffer %d too small\n", *frame_size_ptr);
             return -1;
         }



More information about the ffmpeg-devel mailing list