[PR] avformat/demux: restore container color fields individually (PR #24002)
adorn via ffmpeg-devel <[email protected]> Tue, 04 Aug 2026 08:44:13 -0000
| Newsgroups | gmane.comp.video.ffmpeg.devel |
|---|---|
| Message-ID | <178583305438.59.15133256944257935288@29965ddac10e> |
PR #24002 opened by adorn
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24002
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24002.patch
Fixes issue #23717
The upstream change 9b709532d5 ("avformat/demux: don't overwrite
container level color information if set") restores color_primaries,
color_trc and color_space from the container as an all-or-nothing
group: as soon as one of the three is signaled at container level,
all three are taken from the container.
MXF files written by some devices only carry the TransferCharacteristic
UL (MXF local tag 0x3210) but no ColorPrimaries (0x3219) or
CodingEquations (0x321a). For an H.264 essence whose VUI correctly
signals bt709 for all three, the grouped logic overwrites
color_primaries and color_space with the container's UNSPECIFIED
values, so ffprobe reports:
color_space=unknown / color_primaries=unknown / color_transfer=bt709
instead of the bitstream's bt709/bt709/bt709.
Restore each of the three fields only when it is actually set at the
container level. This keeps container priority where a value is
signaled and falls back to the bitstream (decoder/parser) value
otherwise.
# Summary of changes
Briefly describe what this PR does and why.
<!--
If this PR requires new FATE test samples, attach them to the PR and
list their target paths below (relative to the fate-suite root).
Attached filenames must match the sample's filename:
```fate-samples
# e.g. vorbis/new-sample.ogg
```
-->
>From 7018f4df1ce31ec4dd78650c7a0d9d1afeeba920 Mon Sep 17 00:00:00 2001
From: adorn <[email protected]>
Date: Mon, 29 Jun 2026 14:50:10 +0200
Subject: [PATCH] avformat/demux: restore container color fields individually
Fixes issue #23717
The upstream change 9b709532d5 ("avformat/demux: don't overwrite
container level color information if set") restores color_primaries,
color_trc and color_space from the container as an all-or-nothing
group: as soon as one of the three is signaled at container level,
all three are taken from the container.
MXF files written by some devices only carry the TransferCharacteristic
UL (MXF local tag 0x3210) but no ColorPrimaries (0x3219) or
CodingEquations (0x321a). For an H.264 essence whose VUI correctly
signals bt709 for all three, the grouped logic overwrites
color_primaries and color_space with the container's UNSPECIFIED
values, so ffprobe reports:
color_space=unknown / color_primaries=unknown / color_transfer=bt709
instead of the bitstream's bt709/bt709/bt709.
Restore each of the three fields only when it is actually set at the
container level. This keeps container priority where a value is
signaled and falls back to the bitstream (decoder/parser) value
otherwise.
---
libavformat/demux.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 193fd17739..2375b277e4 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -2587,13 +2587,12 @@ static int parameters_from_context(AVFormatContext *ic, AVCodecParameters *par,
*/
if (par_tmp->color_range != AVCOL_RANGE_UNSPECIFIED)
par->color_range = par_tmp->color_range;
- if (par_tmp->color_primaries != AVCOL_PRI_UNSPECIFIED ||
- par_tmp->color_trc != AVCOL_TRC_UNSPECIFIED ||
- par_tmp->color_space != AVCOL_SPC_UNSPECIFIED) {
+ if (par_tmp->color_primaries != AVCOL_PRI_UNSPECIFIED)
par->color_primaries = par_tmp->color_primaries;
+ if (par_tmp->color_trc != AVCOL_TRC_UNSPECIFIED)
par->color_trc = par_tmp->color_trc;
+ if (par_tmp->color_space != AVCOL_SPC_UNSPECIFIED)
par->color_space = par_tmp->color_space;
- }
if (par_tmp->chroma_location != AVCHROMA_LOC_UNSPECIFIED)
par->chroma_location = par_tmp->chroma_location;
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]