[FFmpeg-devel] [PATCH 1/3] lavf/format: handle max probe buffer sizes <2048

rcombs rcombs at rcombs.me
Fri May 22 08:41:58 EEST 2020


This can be useful in chained demuxers, where the header size is known.
---
 libavformat/format.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/libavformat/format.c b/libavformat/format.c
index c47490c8eb..7309b0019b 100644
--- a/libavformat/format.c
+++ b/libavformat/format.c
@@ -231,11 +231,6 @@ int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
 
     if (!max_probe_size)
         max_probe_size = PROBE_BUF_MAX;
-    else if (max_probe_size < PROBE_BUF_MIN) {
-        av_log(logctx, AV_LOG_ERROR,
-               "Specified probe size value %u cannot be < %u\n", max_probe_size, PROBE_BUF_MIN);
-        return AVERROR(EINVAL);
-    }
 
     if (offset >= max_probe_size)
         return AVERROR(EINVAL);
@@ -251,7 +246,7 @@ int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt,
         }
     }
 
-    for (probe_size = PROBE_BUF_MIN; probe_size <= max_probe_size && !*fmt;
+    for (probe_size = FFMIN(PROBE_BUF_MIN, max_probe_size); probe_size <= max_probe_size && !*fmt;
          probe_size = FFMIN(probe_size << 1,
                             FFMAX(max_probe_size, probe_size + 1))) {
         score = probe_size < max_probe_size ? AVPROBE_SCORE_RETRY : 0;
-- 
2.26.2



More information about the ffmpeg-devel mailing list