Commit 3cc9d78dea for ffmpeg
commit 3cc9d78dea6888f1b0e48534a6dde906014215e6
Author: Romain Beauxis <romain.beauxis@gmail.com>
Date: Fri Oct 16 18:54:24 2026 +0200
tests/fate: check colour tags with unknown or reserved values
Some writers store 0 or another reserved value for the colour primaries and
the transfer characteristics. The ProRes, MPEG-2 and MPEG-4 Part 2 decoders
and the mov colr and vpcC parsers hand these over as they are, so the frames
and streams carry AVCOL_PRI_RESERVED0, AVCOL_TRC_RESERVED0 or another reserved
value and the swscale frame checks reject them. The references show that for
now.
The MPEG-4 Part 2, vpcC and ProRes fallback tests use new synthetic samples:
mpeg4/reserved-color-tags.m4v is one frame from the mpeg4 encoder with its
Visual Object header patched to carry primaries 0, transfer 3 and matrix 3;
mov/vpcc-reserved-color-tags.mp4 is one VP9 frame stream copied with all
three tags set to 3, its colr box renamed to free so only vpcC is read;
prores/color-tags-fallback.mov is two 16x16 prores_ks frames with colr set
to smpte170m and frame headers patched to 1/1/1, then 0/0/0.
diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak
index 8a2249dd50..7aabe980d3 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -47,6 +47,12 @@ FATE_MOV_FFPROBE-$(call DEMDEC, MOV, HEVC) += fate-mov-dovi-hvce-mp4-read
FATE_MOV_FFPROBE-$(call DEMDEC, MOV, H264) += fate-mov-vfr-bframes-duration
+# vpcC set to 3/3/3, with no colr box
+FATE_MOV_FFPROBE-$(call DEMDEC, MOV, VP9) += fate-mov-vpcc-reserved-color-tags
+fate-mov-vpcc-reserved-color-tags: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -v error \
+ -show_entries stream=color_primaries,color_transfer,color_space -of default=nw=1 \
+ $(TARGET_SAMPLES)/mov/vpcc-reserved-color-tags.mp4
+
FATE_MOV_FFPROBE-$(CONFIG_MOV_DEMUXER) += fate-ffprobe-stream-entries-tmcd \
fate-ffprobe-group-stream-entries-tmcd \
fate-ffprobe-show-groups-tmcd
@@ -352,6 +358,12 @@ FATE_MOV_FFMPEG_SAMPLES-$(call REMUX, MP4 MOV, AAC_PARSER) \
+= fate-mov-mp4-edst-remainder
fate-mov-mp4-edst-remainder: CMD = stream_remux mov $(TARGET_SAMPLES)/audiomatch/tones_fdkaac_44100_stereo_aac_lc.m4a "" mp4 "" "" "-c:a copy"
+# A colr box can carry reserved colour values; they must not reach the stream
+FATE_MOV_FFMPEG_FFPROBE_SAMPLES-$(call REMUX, MOV, QTRLE_DECODER) += fate-mov-colr-reserved-color-tags
+fate-mov-colr-reserved-color-tags: CMD = stream_remux mov $(TARGET_SAMPLES)/qtrle/aletrek-rle.mov "" mov \
+ "-map 0:v -frames:v 1 -color_primaries 3 -color_trc 3 -colorspace 3" "" "-c:v copy" \
+ "-select_streams v -show_entries stream=color_primaries,color_transfer,color_space -of default=nw=1"
+
# format-level branding: major_brand, minor_version, compatible_brands should be deleted on re-encode
FATE_MOV_FFMPEG_FFPROBE_SAMPLES-$(call ENCDEC, AAC AAC, NUT MOV) += fate-mov-reenc-delete-format-metadata
fate-mov-reenc-delete-format-metadata: CMD = transcode mov $(TARGET_SAMPLES)/cover_art/Owner-iTunes_9.0.3.15.m4a nut "-map 0:a:0 -c:a aac -bitexact -t 0.1" "-c copy -t 0.1" "-show_entries format_tags" "" "" "" null
diff --git a/tests/fate/mpeg4.mak b/tests/fate/mpeg4.mak
index c914f61731..d0c680bfc1 100644
--- a/tests/fate/mpeg4.mak
+++ b/tests/fate/mpeg4.mak
@@ -27,5 +27,12 @@ fate-m4v-cfr: CMD = framecrc -flags +bitexact -idct simple -i $(TARGET_SAMPLES)/
FATE_MPEG4-$(call FRAMECRC, MOV, H264, AAC_DECODER) += fate-mpeg4-fragmented-seek
fate-mpeg4-fragmented-seek: CMD = framecrc -use_mfra_for pts -ss 1.04 -copyts -noaccurate_seek -i $(TARGET_SAMPLES)/mpeg4/fragmented.mp4 -frames:v 1 -an
+# VO colour description with primaries 0 (forbidden), trc 3 and matrix 3 (reserved)
+FATE_MPEG4_FFPROBE-$(call DEMDEC, M4V, MPEG4) += fate-mpeg4-reserved-color-tags
+fate-mpeg4-reserved-color-tags: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -v error \
+ -show_entries frame=color_primaries,color_transfer,color_space -of default=nw=1 \
+ $(TARGET_SAMPLES)/mpeg4/reserved-color-tags.m4v
+
FATE_SAMPLES_AVCONV += $(FATE_MPEG4-yes)
-fate-mpeg4: $(FATE_MPEG4-yes)
+FATE_SAMPLES_FFPROBE += $(FATE_MPEG4_FFPROBE-yes)
+fate-mpeg4: $(FATE_MPEG4-yes) $(FATE_MPEG4_FFPROBE-yes)
diff --git a/tests/fate/mpegps.mak b/tests/fate/mpegps.mak
index a6114b1a8a..8f796960e3 100644
--- a/tests/fate/mpegps.mak
+++ b/tests/fate/mpegps.mak
@@ -5,3 +5,9 @@ fate-mpegps-remuxed-pcm-demux: CMD = stream_remux "mpeg" "$(TARGET_SAMPLES)/mpeg
FATE_SAMPLES_FFMPEG += $(FATE_MPEGPS-yes)
fate-mpegps: $(FATE_MPEGPS-yes)
+
+# A sequence display extension can carry reserved colour values; they must not reach the frame
+FATE_SAMPLES_FFMPEG_FFPROBE-$(call REMUX, MPEG2VIDEO MPEGVIDEO, MPEGVIDEO_PARSER MPEG2_METADATA_BSF EXTRACT_EXTRADATA_BSF MPEG2VIDEO_DECODER) += fate-mpeg2-reserved-color-tags
+fate-mpeg2-reserved-color-tags: CMD = stream_remux mpegvideo $(TARGET_SAMPLES)/mpeg2/tcela-6.bits "" mpeg2video \
+ "-map 0:v:0 -frames:v 3 -bsf:v mpeg2_metadata=colour_primaries=3:transfer_characteristics=3:matrix_coefficients=3" "" "-c:v copy" \
+ "-select_streams v -read_intervals %+\#1 -show_entries frame=color_primaries,color_transfer,color_space -of default=nw=1"
diff --git a/tests/fate/prores.mak b/tests/fate/prores.mak
index e3759dfb50..7bc7d7de87 100644
--- a/tests/fate/prores.mak
+++ b/tests/fate/prores.mak
@@ -28,4 +28,17 @@ fate-prores-metadata: CMD = md5 -i $(TARGET_SAMPLES)/prores/Sequence_1-Apple_Pro
FATE_SAMPLES_FFMPEG_FFPROBE-$(call FRAMECRC, MOV, PRORES,) += fate-prores-probe
fate-prores-probe: CMD = stream_demux mov $(TARGET_SAMPLES)/prores/Sequence_1-Apple_ProRes_422_HQ.mov "" "-c:v copy" "-show_frames"
+# A frame header can carry 0 for "unknown"; the colr tags must win over it
+FATE_SAMPLES_FFMPEG_FFPROBE-$(call REMUX, MOV, PRORES_METADATA_BSF PRORES_DECODER) += fate-prores-unknown-color-tags
+fate-prores-unknown-color-tags: CMD = stream_remux mov $(TARGET_SAMPLES)/prores/Sequence_1-Apple_ProRes_422_Proxy.mov "" mov \
+ "-map 0:v -bsf:v prores_metadata=color_primaries=0:color_trc=0:colorspace=0 -color_primaries smpte170m -color_trc smpte170m -colorspace smpte170m" "" "-c:v copy" \
+ "-select_streams v -read_intervals %+\#1 -show_entries frame=color_primaries,color_transfer,color_space -of default=nw=1"
+
+# colr set to smpte170m, frame headers set to 1/1/1 then 0/0/0: the second frame must not inherit the first's tags
+FATE_PRORES_FFPROBE-$(call DEMDEC, MOV, PRORES) += fate-prores-color-tags-fallback
+fate-prores-color-tags-fallback: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -v error \
+ -show_entries frame=color_primaries,color_transfer,color_space -of default=nw=1 \
+ $(TARGET_SAMPLES)/prores/color-tags-fallback.mov
+
FATE_SAMPLES_FFMPEG-$(call DEMMUX, MOV, MOV, PRORES_METADATA_BSF) += $(FATE_PRORES_METADATA_BSF)
+FATE_SAMPLES_FFPROBE += $(FATE_PRORES_FFPROBE-yes)
diff --git a/tests/ref/fate/mov-colr-reserved-color-tags b/tests/ref/fate/mov-colr-reserved-color-tags
new file mode 100644
index 0000000000..3d8ac8448a
--- /dev/null
+++ b/tests/ref/fate/mov-colr-reserved-color-tags
@@ -0,0 +1,11 @@
+c6b96e10140cb9554d1eb6a5dccc1c1b *tests/data/fate/mov-colr-reserved-color-tags.mov
+7552 tests/data/fate/mov-colr-reserved-color-tags.mov
+#tb 0: 1/19200
+#media_type 0: video
+#codec_id 0: qtrle
+#dimensions 0: 160x120
+#sar 0: 0/1
+0, 0, 0, 1920, 6838, 0x2d59b149
+color_space=reserved
+color_transfer=reserved
+color_primaries=reserved
diff --git a/tests/ref/fate/mov-vpcc-reserved-color-tags b/tests/ref/fate/mov-vpcc-reserved-color-tags
new file mode 100644
index 0000000000..b9422ea102
--- /dev/null
+++ b/tests/ref/fate/mov-vpcc-reserved-color-tags
@@ -0,0 +1,3 @@
+color_space=reserved
+color_transfer=reserved
+color_primaries=reserved
diff --git a/tests/ref/fate/mpeg2-reserved-color-tags b/tests/ref/fate/mpeg2-reserved-color-tags
new file mode 100644
index 0000000000..ce50a492dc
--- /dev/null
+++ b/tests/ref/fate/mpeg2-reserved-color-tags
@@ -0,0 +1,14 @@
+93a1216babef80cfb659958a2890fbfb *tests/data/fate/mpeg2-reserved-color-tags.mpeg2video
+268865 tests/data/fate/mpeg2-reserved-color-tags.mpeg2video
+#extradata 0: 150, 0x5e531c02
+#tb 0: 1/1200000
+#media_type 0: video
+#codec_id 0: mpeg2video
+#dimensions 0: 720x480
+#sar 0: 8/9
+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
diff --git a/tests/ref/fate/mpeg4-reserved-color-tags b/tests/ref/fate/mpeg4-reserved-color-tags
new file mode 100644
index 0000000000..55c9df3bad
--- /dev/null
+++ b/tests/ref/fate/mpeg4-reserved-color-tags
@@ -0,0 +1,3 @@
+color_space=reserved
+color_primaries=reserved
+color_transfer=reserved
diff --git a/tests/ref/fate/prores-color-tags-fallback b/tests/ref/fate/prores-color-tags-fallback
new file mode 100644
index 0000000000..f1ef232182
--- /dev/null
+++ b/tests/ref/fate/prores-color-tags-fallback
@@ -0,0 +1,6 @@
+color_space=bt709
+color_primaries=bt709
+color_transfer=bt709
+color_space=gbr
+color_primaries=reserved
+color_transfer=reserved
diff --git a/tests/ref/fate/prores-unknown-color-tags b/tests/ref/fate/prores-unknown-color-tags
new file mode 100644
index 0000000000..97a01650da
--- /dev/null
+++ b/tests/ref/fate/prores-unknown-color-tags
@@ -0,0 +1,12 @@
+e8fedc135d405134af2dada81b173cc9 *tests/data/fate/prores-unknown-color-tags.mov
+115303 tests/data/fate/prores-unknown-color-tags.mov
+#tb 0: 1/11988
+#media_type 0: video
+#codec_id 0: prores
+#dimensions 0: 1920x1080
+#sar 0: 0/1
+0, 0, 0, 400, 57296, 0x4cc02182
+0, 400, 400, 400, 57296, 0x4cc02182
+color_space=gbr
+color_primaries=reserved
+color_transfer=reserved