PR #26032 opened by Baptiste Coudurier (bcoudurier)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26032
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26032.patch

When film grain synthesis fails, ff_h264_field_end() cleared needs_fg only on 
the decoding thread's picture; copies already held by other frame threads kept 
it set and output the unwritten f_grain buffer.

Copy the decoded picture into f_grain instead, so all references output it.

Fixes: #25691

🤖 Generated with [Claude Code](https://claude.com/claude-code)



From a95fd90c28b7259d3e1e8863ad156140a191223c Mon Sep 17 00:00:00 2001
From: Baptiste Coudurier <[email protected]>
Date: Fri, 13 Nov 2026 12:59:09 -0800
Subject: [PATCH] avcodec/h264_picture: fix film grain fallback with frame
 threads

Other threads already hold needs_fg, so copy the decoded picture into f_grain 
instead.

Fixes: #25691
Regression since: 66845cffc3

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Baptiste Coudurier <[email protected]>
---
 libavcodec/h264_picture.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index b287f59e1ae..4fef8c426e8 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -219,8 +219,9 @@ int ff_h264_field_end(H264Context *h, H264SliceContext *sl, 
int in_setup)
         if (err < 0) {
             av_log(h->avctx, AV_LOG_WARNING, "Failed synthesizing film "
                    "grain, ignoring: %s\n", av_err2str(err));
-            cur->needs_fg = 0;
-            err = 0;
+            /* other threads may already hold a reference with needs_fg set,
+             * so output the decoded picture through the grain buffer */
+            err = av_frame_copy(cur->f_grain, cur->f);
         }
     }
 
-- 
2.54.0

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

Reply via email to