Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: James Almer <code@ffmpeg.org>
Subject: [FFmpeg-devel] [PATCH] avcodec: fix setting GBR pixel format in AV1 decoders (PR #21306)
Date: Sun, 28 Dec 2025 18:34:48 -0000
Message-ID: <176694688873.25.6173297684350085297@4457048688e7> (raw)

PR #21306 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21306
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21306.patch

Fixes issue #21304


>From a8f1c2366e23ad35f34e2a9af0cd63f38e26fc00 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Sun, 28 Dec 2025 15:21:06 -0300
Subject: [PATCH 1/2] avcodec/libaomdec: don't overwrite color information from
 the container if unset in the bitstream

Fixes part of #21304.

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 9e9c4d18c5..79b299bac8 100644
--- a/libavcodec/libaomdec.c
+++ b/libavcodec/libaomdec.c
@@ -71,9 +71,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 = (enum AVColorPrimaries)img->cp;
-    avctx->colorspace  = (enum AVColorSpace)img->mc;
-    avctx->color_trc   = (enum AVColorTransferCharacteristic)img->tc;
+    if (img->cp != AOM_CICP_CP_UNSPECIFIED)
+        avctx->color_primaries = (enum AVColorPrimaries)img->cp;
+    if (img->mc != AOM_CICP_MC_UNSPECIFIED)
+        avctx->colorspace  = (enum AVColorSpace)img->mc;
+    if (img->tc != AOM_CICP_TC_UNSPECIFIED)
+        avctx->color_trc   = (enum AVColorTransferCharacteristic)img->tc;
 
     switch (img->fmt) {
     case AOM_IMG_FMT_I420:
-- 
2.49.1


>From fc5f45bd42c7f9cd203ca260765e549bd15ecaf2 Mon Sep 17 00:00:00 2001
From: James Almer <jamrial@gmail.com>
Date: Sun, 28 Dec 2025 15:20:03 -0300
Subject: [PATCH 2/2] avcodec/libdav1d: only consider colorspace when choosing
 between YUV and GBR

Several files use values for primaries and transfer characteristics other than
BT709 and IEC_61966 respectively, while still being GBR.
Also always set color_range while at it. It's always coded in the bistream.

Fixes part of #21304.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/libdav1d.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/libavcodec/libdav1d.c b/libavcodec/libdav1d.c
index 7f63bb1b15..14ec9842a0 100644
--- a/libavcodec/libdav1d.c
+++ b/libavcodec/libdav1d.c
@@ -147,13 +147,10 @@ static void libdav1d_init_params(AVCodecContext *c, const Dav1dSequenceHeader *s
         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;
     }
+    c->color_range = seq->color_range ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG;
 
-    if (seq->layout == DAV1D_PIXEL_LAYOUT_I444 &&
-        c->colorspace      == AVCOL_SPC_RGB &&
-        c->color_primaries == AVCOL_PRI_BT709 &&
-        c->color_trc       == AVCOL_TRC_IEC61966_2_1)
+    if (seq->layout == DAV1D_PIXEL_LAYOUT_I444 && c->colorspace == AVCOL_SPC_RGB)
         c->pix_fmt = pix_fmt_rgb[seq->hbd];
     else
         c->pix_fmt = pix_fmt[seq->layout][seq->hbd];
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

                 reply	other threads:[~2025-12-28 18:35 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=176694688873.25.6173297684350085297@4457048688e7 \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=code@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