From: James Almer <code@ffmpeg.org> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH] avcodec/av1*: don't overwrite color information values if not it's coded (PR #20122) Date: Tue, 5 Aug 2025 19:41:11 +0300 (EEST) Message-ID: <20250805164111.43E8068C6E9@ffbox0-bg.ffmpeg.org> (raw) 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 <jamrial@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 <jamrial@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 <jamrial@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 <jamrial@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 <jamrial@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 <jamrial@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 <jamrial@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 <jamrial@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-request@ffmpeg.org with subject "unsubscribe".
reply other threads:[~2025-08-05 16:41 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20250805164111.43E8068C6E9@ffbox0-bg.ffmpeg.org \ --to=code@ffmpeg.org \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git