Commit 3a78197c4c for ffmpeg

commit 3a78197c4c969e7a493956733b340b68dcdb7fa0
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date:   Tue Nov 17 15:17:51 2026 -0800

    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

    Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>

diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index b287f59e1a..4fef8c426e 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);
         }
     }