PR #26219 opened by Pu Cheng (GeekQAQ)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26219
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26219.patch

With workaround_bugs set to FF_BUG_AUTODETECT (the default), the decoder
accumulates padding_bug_score over the frames of a stream and enables
FF_BUG_NO_PADDING from it, which relaxes the end-of-slice checks.
mpeg4_flush() does not reset the score, so after
avcodec_flush_buffers() the next stream is decoded with the previous
stream's score, and a damaged frame decodes differently than in a newly
opened decoder.

Signed-off-by: Pu Cheng <[email protected]>



>From ee4425857ad6383caa6fc1daeb0b35d3ab77c3e0 Mon Sep 17 00:00:00 2001
From: Pu Cheng <[email protected]>
Date: Fri, 20 Nov 2026 14:08:21 +0800
Subject: [PATCH] avcodec/mpeg4videodec: reset padding_bug_score on flush

With workaround_bugs set to FF_BUG_AUTODETECT (the default), the decoder
accumulates padding_bug_score over the frames of a stream and enables
FF_BUG_NO_PADDING from it, which relaxes the end-of-slice checks.
mpeg4_flush() does not reset the score, so after
avcodec_flush_buffers() the next stream is decoded with the previous
stream's score, and a damaged frame decodes differently than in a newly
opened decoder.

Signed-off-by: Pu Cheng <[email protected]>
---
 libavcodec/mpeg4videodec.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index 03b145379df..6a5c3efe732 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -4066,6 +4066,7 @@ static av_cold void mpeg4_flush(AVCodecContext *avctx)
     Mpeg4DecContext *const ctx = avctx->priv_data;
 
     av_buffer_unref(&ctx->bitstream_buffer);
+    ctx->h.padding_bug_score = 0;
     ff_mpeg_flush(avctx);
 }
 
-- 
2.54.1

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to