PR #20122 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20122 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20122.patch
Fixes issue #20121 >From accb9128272882d713bfd1e8b87aa46ba5b8197c Mon Sep 17 00:00:00 2001 From: James Almer <jamr...@gmail.com> Date: Tue, 5 Aug 2025 13:33:08 -0300 Subject: [PATCH 1/4] avcodec/av1dec: don't overwrite color information if it's not coded Part of a fix for issue #20121 Signed-off-by: James Almer <jamr...@gmail.com> --- libavcodec/av1dec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 8ff1bf394c..d50f3eb548 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -775,9 +775,11 @@ static int set_context_with_sequence(AVCodecContext *avctx, avctx->color_range = seq->color_config.color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; - avctx->color_primaries = seq->color_config.color_primaries; - avctx->colorspace = seq->color_config.matrix_coefficients; - avctx->color_trc = seq->color_config.transfer_characteristics; + if (seq->color_config.color_description_present_flag) { + avctx->color_primaries = seq->color_config.color_primaries; + avctx->colorspace = seq->color_config.matrix_coefficients; + avctx->color_trc = seq->color_config.transfer_characteristics; + } switch (seq->color_config.chroma_sample_position) { case AV1_CSP_VERTICAL: -- 2.49.1 >From ef32a68355fed5459cc598549cd78b4385fde176 Mon Sep 17 00:00:00 2001 From: James Almer <jamr...@gmail.com> Date: Tue, 5 Aug 2025 13:31:37 -0300 Subject: [PATCH 2/4] avcodec/av1_parser: don't overwrite color information if it's not coded Part of a fix for issue #20121 Signed-off-by: James Almer <jamr...@gmail.com> --- libavcodec/av1_parser.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/av1_parser.c b/libavcodec/av1_parser.c index 1792e813f4..6b4acc15b5 100644 --- a/libavcodec/av1_parser.c +++ b/libavcodec/av1_parser.c @@ -159,9 +159,11 @@ static int av1_parser_parse(AVCodecParserContext *ctx, avctx->profile = seq->seq_profile; avctx->level = seq->seq_level_idx[0]; - avctx->colorspace = (enum AVColorSpace) color->matrix_coefficients; - avctx->color_primaries = (enum AVColorPrimaries) color->color_primaries; - avctx->color_trc = (enum AVColorTransferCharacteristic) color->transfer_characteristics; + if (color->color_description_present_flag) { + avctx->colorspace = (enum AVColorSpace) color->matrix_coefficients; + avctx->color_primaries = (enum AVColorPrimaries) color->color_primaries; + avctx->color_trc = (enum AVColorTransferCharacteristic) color->transfer_characteristics; + } avctx->color_range = color->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; if (seq->timing_info_present_flag) -- 2.49.1 >From 3f6a94364598585bd10b67c38d829b5c30b770aa Mon Sep 17 00:00:00 2001 From: James Almer <jamr...@gmail.com> Date: Tue, 5 Aug 2025 13:36:07 -0300 Subject: [PATCH 3/4] avcodec/libaomdec: don't overwrite color information if it's not coded Part of a fix for issue #20121 Signed-off-by: James Almer <jamr...@gmail.com> --- libavcodec/libaomdec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/libaomdec.c b/libavcodec/libaomdec.c index 69eec8b089..4fc368d0ba 100644 --- a/libavcodec/libaomdec.c +++ b/libavcodec/libaomdec.c @@ -68,9 +68,12 @@ static int set_pix_fmt(AVCodecContext *avctx, struct aom_image *img) AVCOL_RANGE_MPEG, AVCOL_RANGE_JPEG }; avctx->color_range = color_ranges[img->range]; - avctx->color_primaries = img->cp; - avctx->colorspace = img->mc; - avctx->color_trc = img->tc; + if (img->cp != AOM_CICP_CP_UNSPECIFIED) + avctx->color_primaries = img->cp; + if (img->mc != AOM_CICP_MC_UNSPECIFIED) + avctx->colorspace = img->mc; + if (img->tc != AOM_CICP_TC_UNSPECIFIED) + avctx->color_trc = img->tc; switch (img->fmt) { case AOM_IMG_FMT_I420: -- 2.49.1 >From dbc2831ee936b9df7a2e30d8c29930820d965028 Mon Sep 17 00:00:00 2001 From: James Almer <jamr...@gmail.com> Date: Tue, 5 Aug 2025 13:36:19 -0300 Subject: [PATCH 4/4] avcodec/libdav1d: don't overwrite color information if it's not coded Finishes fixing issue #20121 Signed-off-by: James Almer <jamr...@gmail.com> --- libavcodec/libdav1d.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c index f4cbc927b5..dae98d0bff 100644 --- a/libavcodec/libdav1d.c +++ b/libavcodec/libdav1d.c @@ -145,9 +145,11 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s c->chroma_sample_location = AVCHROMA_LOC_TOPLEFT; break; } - c->colorspace = (enum AVColorSpace) seq->mtrx; - c->color_primaries = (enum AVColorPrimaries) seq->pri; - c->color_trc = (enum AVColorTransferCharacteristic) seq->trc; + if (seq->color_description_present) { + c->colorspace = (enum AVColorSpace) seq->mtrx; + c->color_primaries = (enum AVColorPrimaries) seq->pri; + c->color_trc = (enum AVColorTransferCharacteristic) seq->trc; + } c->color_range = seq->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; if (seq->layout == DAV1D_PIXEL_LAYOUT_I444 && -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".