From 510dbddd523dd8aca25fdfe2d5e01803f4145bf1 Mon Sep 17 00:00:00 2001 From: Martin Mirchev Date: Wed, 21 Oct 2026 18:24:34 +0800 Subject: [PATCH] avcodec/h264_parse: return SPS/PPS errors from avcC with explode decode_extradata_ps_mp4() skips the retry with an escaped NAL when AV_EF_EXPLODE is set, but then returns 0 regardless, so a parameter set that fails to parse in avcC extradata is silently ignored exactly when the caller asked for errors to be fatal. h264_decode_init() fails on extradata errors only with explode, so avcodec_open2() succeeded with -err_detect explode on avcC extradata with a broken SPS, and the "Decoding sps %d from avcC failed" path was unreachable. Return the error when explode is set. Signed-off-by: Martin Mirchev --- libavcodec/h264_parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c index c6f9b3cea7..80573ae251 100644 --- a/libavcodec/h264_parse.c +++ b/libavcodec/h264_parse.c @@ -424,7 +424,9 @@ static int decode_extradata_ps_mp4(const uint8_t *buf, int buf_size, H264ParamSe int ret; ret = decode_extradata_ps(buf, buf_size, ps, 1, logctx); - if (ret < 0 && !(err_recognition & AV_EF_EXPLODE)) { + if (ret < 0 && (err_recognition & AV_EF_EXPLODE)) + return ret; + if (ret < 0) { GetByteContext gbc; PutByteContext pbc; uint8_t *escaped_buf;