Commit 7b55912777 for ffmpeg

commit 7b55912777597208b0ecd23e8c9e033501c54f0a
Author: Mika1130 <ljzzjhz@gmail.com>
Date:   Wed Nov 18 14:26:34 2026 +0800

    avcodec/pngenc: fix mDCV primary coordinate offsets

    Each mDCV primary contains two 16-bit coordinates. Use a four-byte
    stride instead of two to avoid overlapping the coordinate pairs in
    PNG and APNG output.

    Update fate-png-mdcv, whose reference recorded the corrupted metadata
    and corresponding PNG checksum.

    Signed-off-by: Mika1130 <ljzzjhz@gmail.com>

diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index 86380e0c6e..ece6b4854a 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -466,8 +466,8 @@ static int encode_headers(AVCodecContext *avctx, const AVFrame *pict)
         AVMasteringDisplayMetadata *mdcv = (AVMasteringDisplayMetadata *) side_data->data;
         if (mdcv->has_luminance && mdcv->has_primaries) {
             for (int i = 0; i < 3; i++) {
-                AV_WB16(s->buf + 2*i, PNG_Q2D(mdcv->display_primaries[i][0], 50000));
-                AV_WB16(s->buf + 2*i + 2, PNG_Q2D(mdcv->display_primaries[i][1], 50000));
+                AV_WB16(s->buf + 4*i, PNG_Q2D(mdcv->display_primaries[i][0], 50000));
+                AV_WB16(s->buf + 4*i + 2, PNG_Q2D(mdcv->display_primaries[i][1], 50000));
             }
             AV_WB16(s->buf + 12, PNG_Q2D(mdcv->white_point[0], 50000));
             AV_WB16(s->buf + 14, PNG_Q2D(mdcv->white_point[1], 50000));
diff --git a/tests/ref/fate/png-mdcv b/tests/ref/fate/png-mdcv
index 32dfdfcf4e..27212336fa 100644
--- a/tests/ref/fate/png-mdcv
+++ b/tests/ref/fate/png-mdcv
@@ -1,4 +1,4 @@
-f4a586ca1ac51c3db64e58552b990234 *tests/data/fate/png-mdcv.image2pipe
+6dfb3ec17af14e304c882df92f5d3cc7 *tests/data/fate/png-mdcv.image2pipe
 495592 tests/data/fate/png-mdcv.image2pipe
 #tb 0: 1/25
 #media_type 0: video
@@ -11,11 +11,11 @@ frames.frame.0.side_data_list.side_data.0.max_content=1000
 frames.frame.0.side_data_list.side_data.0.max_average=200
 frames.frame.0.side_data_list.side_data.1.side_data_type="Mastering display metadata"
 frames.frame.0.side_data_list.side_data.1.red_x="13250/50000"
-frames.frame.0.side_data_list.side_data.1.red_y="7500/50000"
-frames.frame.0.side_data_list.side_data.1.green_x="34000/50000"
-frames.frame.0.side_data_list.side_data.1.green_y="16000/50000"
-frames.frame.0.side_data_list.side_data.1.blue_x="2/50000"
-frames.frame.0.side_data_list.side_data.1.blue_y="0/50000"
+frames.frame.0.side_data_list.side_data.1.red_y="34500/50000"
+frames.frame.0.side_data_list.side_data.1.green_x="7500/50000"
+frames.frame.0.side_data_list.side_data.1.green_y="3000/50000"
+frames.frame.0.side_data_list.side_data.1.blue_x="34000/50000"
+frames.frame.0.side_data_list.side_data.1.blue_y="16000/50000"
 frames.frame.0.side_data_list.side_data.1.white_point_x="15635/50000"
 frames.frame.0.side_data_list.side_data.1.white_point_y="16450/50000"
 frames.frame.0.side_data_list.side_data.1.min_luminance="50/10000"