Commit 6d9374c8ce for ffmpeg

commit 6d9374c8ce017fbe08fb10e54d77e4095dff82ba
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date:   Fri Oct 16 19:01:08 2026 +0200

    avcodec/mpeg12dec: report reserved colour tags as unspecified

    The sequence display extension colour description is copied into the codec
    context as it is, so a reserved value reaches the decoded frames.

    The swscale frame checks reject reserved values, so scaling such a stream fails
    with ENOTSUP. h2645_vui.c reports them as unspecified since c80002aa81
    ("avcodec/h2645_vui: Ensure color primaries/trc/space isn't reserved value"),
    do the same here. Valid values are untouched.

    ffprobe now prints unknown for these fields instead of reserved.

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index e30fa843cc..f1ced4fb56 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -35,6 +35,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem_internal.h"
+#include "libavutil/pixdesc.h"
 #include "libavutil/reverse.h"
 #include "libavutil/stereo3d.h"
 #include "libavutil/timecode.h"
@@ -1081,6 +1082,19 @@ static void mpeg_decode_sequence_display_extension(Mpeg1Context *const s1,
         s->avctx->color_primaries = get_bits(gb, 8);
         s->avctx->color_trc       = get_bits(gb, 8);
         s->avctx->colorspace      = get_bits(gb, 8);
+
+        // Reserved and unassigned values carry no colour information
+        if (s->avctx->color_primaries == AVCOL_PRI_RESERVED0 ||
+            s->avctx->color_primaries == AVCOL_PRI_RESERVED  ||
+            !av_color_primaries_name(s->avctx->color_primaries))
+            s->avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
+        if (s->avctx->color_trc == AVCOL_TRC_RESERVED0 ||
+            s->avctx->color_trc == AVCOL_TRC_RESERVED  ||
+            !av_color_transfer_name(s->avctx->color_trc))
+            s->avctx->color_trc = AVCOL_TRC_UNSPECIFIED;
+        if (s->avctx->colorspace == AVCOL_SPC_RESERVED ||
+            !av_color_space_name(s->avctx->colorspace))
+            s->avctx->colorspace = AVCOL_SPC_UNSPECIFIED;
     }
     w = get_bits(gb, 14);
     skip_bits(gb, 1); // marker
diff --git a/tests/ref/fate/mpeg2-reserved-color-tags b/tests/ref/fate/mpeg2-reserved-color-tags
index ce50a492dc..33b7427d43 100644
--- a/tests/ref/fate/mpeg2-reserved-color-tags
+++ b/tests/ref/fate/mpeg2-reserved-color-tags
@@ -9,6 +9,6 @@
 0,          0, -9223372036854775808,    40000,   155871, 0x11269f42
 0,      40000, -9223372036854775808,    40000,    73388, 0x29d1370d, F=0x0
 0,      80000,      80000,    40000,    39606, 0x19f9a3d7, F=0x0
-color_space=reserved
-color_primaries=reserved
-color_transfer=reserved
+color_space=unknown
+color_primaries=unknown
+color_transfer=unknown