Commit 0f3d20ebf6 for ffmpeg
commit 0f3d20ebf6f04a38fa83cee6189eec82e7e3fcba
Author: Xiujun Wang <xiujunwang.dev@gmail.com>
Date: Thu Sep 24 20:15:18 2026 +0800
avformat/cavsvideodec: reduce probe score for prefixed streams
cavsvideo_probe() returns a high score whenever it finds a valid
sequence and picture start code, even when the sequence header appears
only after unrelated leading data. This can make valid JPEG files probe
as CAVS.
Keep the high score when the sequence header is at the start of the
probed stream. Otherwise return AVPROBE_SCORE_EXTENSION / 2 so stronger
probes can win.
Signed-off-by: Xiujun Wang <xiujunwang.dev@gmail.com>
diff --git a/libavformat/cavsvideodec.c b/libavformat/cavsvideodec.c
index 5c2ed4a94f..0028b7dcb1 100644
--- a/libavformat/cavsvideodec.c
+++ b/libavformat/cavsvideodec.c
@@ -33,7 +33,7 @@
static int cavsvideo_probe(const AVProbeData *p)
{
uint32_t code= -1;
- int pic=0, seq=0, slice_pos = 0;
+ int pic=0, seq=0, slice_pos = 0, seq_at_start = 0;
const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
while (ptr < end) {
@@ -49,6 +49,8 @@ static int cavsvideo_probe(const AVProbeData *p)
}
if (code == CAVS_SEQ_START_CODE) {
seq++;
+ if (ptr == p->buf + 4)
+ seq_at_start = 1;
if (*ptr != AV_PROFILE_CAVS_JIZHUN &&
*ptr != AV_PROFILE_CAVS_BROADCASTING)
return 0;
@@ -62,7 +64,8 @@ static int cavsvideo_probe(const AVProbeData *p)
}
}
if(seq && seq*9<=pic*10)
- return AVPROBE_SCORE_EXTENSION+1;
+ return seq_at_start ? AVPROBE_SCORE_EXTENSION + 1 :
+ AVPROBE_SCORE_EXTENSION / 2;
return 0;
}
diff --git a/tests/fate/probe.mak b/tests/fate/probe.mak
index 55a8729888..1bde37b0ab 100644
--- a/tests/fate/probe.mak
+++ b/tests/fate/probe.mak
@@ -32,6 +32,9 @@ fate-probe-format-png-concat: CMD = probefmt $(TARGET_SAMPLES)/png1/feed_4x_conc
FATE_PROBE_FORMAT-$(call ALLYES, IMAGE_TIFF_PIPE_DEMUXER MPEGTS_DEMUXER) += fate-probe-format-tiff-not-mpegts
fate-probe-format-tiff-not-mpegts: REF = tiff_pipe
+FATE_PROBE_FORMAT-$(call ALLYES, IMAGE_JPEG_PIPE_DEMUXER CAVSVIDEO_DEMUXER) += fate-probe-format-jpeg-not-cavsvideo
+fate-probe-format-jpeg-not-cavsvideo: REF = jpeg_pipe
+
FATE_PROBE_FORMAT = $(FATE_PROBE_FORMAT-yes)
FATE_SAMPLES_FFPROBE += $(FATE_PROBE_FORMAT)