Commit 2bfdd2a0a6 for ffmpeg

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

    avcodec/h264dec: do not duplicate side data when outputting f_grain

    f_grain gets its own side data on allocation, which av_frame_copy_props() appended to.

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

diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index fea2e2a616..b2ff1241c9 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -947,8 +947,13 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
     if (ret < 0)
         return ret;

-    if (srcp->needs_fg && (ret = av_frame_copy_props(dst, srcp->f)) < 0)
-        return ret;
+    if (srcp->needs_fg) {
+        /* f_grain got its own copy of the side data on allocation */
+        av_frame_side_data_free(&dst->side_data, &dst->nb_side_data);
+        ret = av_frame_copy_props(dst, srcp->f);
+        if (ret < 0)
+            return ret;
+    }

     if (srcp->decode_error_flags) {
         atomic_int *decode_error = srcp->decode_error_flags;