Commit 131919a040 for ffmpeg

commit 131919a040867b390891eca5290f10db8c038c1e
Author: Baptiste Coudurier <baptiste.coudurier@gmail.com>
Date:   Thu Nov 12 18:10:21 2026 -0800

    avformat/mxfenc: write the RGBA color range

    Component Min/Max Ref were always full range.
    Write nominal black and white levels from color_range, matching Resolve.

    Omit references for unknown DNxHD RGB range and skip integer levels for
    float samples.

    Signed-off-by: Baptiste Coudurier <baptiste.coudurier@gmail.com>
    Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 52feae7271..15af21f41b 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -1393,18 +1393,26 @@ static int64_t mxf_write_generic_picture_desc(AVFormatContext *s, AVStream *st)
             'G', component_depth,
             'B', component_depth,
         };
-
         // pixel layout
         mxf_write_local_tag(s, 16, 0x3401);
         avio_write(pb, rgb_layout, 16);

-        // component max ref
-        mxf_write_local_tag(s, 4, 0x3406);
-        avio_wb32(pb, (1<<component_depth) - 1);
+        /* unknown DNxHD range is not assumed to be full range */
+        if (!(pix_desc->flags & AV_PIX_FMT_FLAG_FLOAT) &&
+            !(st->codecpar->codec_id == AV_CODEC_ID_DNXHD &&
+              sc->color_range == AVCOL_RANGE_UNSPECIFIED)) {
+            uint32_t max_ref = (UINT64_C(1) << component_depth) - 1;
+            uint32_t min_ref = 0;

-        // component min ref
-        mxf_write_local_tag(s, 4, 0x3407);
-        avio_wb32(pb, 0);
+            if (sc->color_range == AVCOL_RANGE_MPEG) {
+                max_ref = 235U << (component_depth - 8);
+                min_ref = 16U  << (component_depth - 8);
+            }
+            mxf_write_local_tag(s, 4, 0x3406);
+            avio_wb32(pb, max_ref);
+            mxf_write_local_tag(s, 4, 0x3407);
+            avio_wb32(pb, min_ref);
+        }
     } else {
         int h_chroma_sub_sample = 1 << pix_desc->log2_chroma_w;
         int v_chroma_sub_sample = 1 << pix_desc->log2_chroma_h;