From 8c9a7e88e5d359d4bdc27d77d33c31a40f372e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= Date: Wed, 24 Dec 2025 14:43:46 +0100 Subject: [PATCH] avif: YCgCo-Re decoding fix --- src/imageformats/avif.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/imageformats/avif.cpp b/src/imageformats/avif.cpp index fdfaef8..3b29349 100644 --- a/src/imageformats/avif.cpp +++ b/src/imageformats/avif.cpp @@ -265,9 +265,15 @@ bool QAVIFHandler::decode_one_frame() } } + uint32_t resultdepth = m_decoder->image->depth; + if (m_decoder->image->matrixCoefficients == 16 && m_decoder->image->yuvFormat == AVIF_PIXEL_FORMAT_YUV444 && resultdepth == 10) { + // 10-bit YCgCo-Re AVIF must be decoded to 8bit + resultdepth = 8; + } + QImage::Format resultformat; - if (m_decoder->image->depth > 8) { + if (resultdepth > 8) { if (loadalpha) { resultformat = QImage::Format_RGBA64; } else { @@ -405,7 +411,7 @@ bool QAVIFHandler::decode_one_frame() rgb.maxThreads = m_decoder->maxThreads; #endif - if (m_decoder->image->depth > 8) { + if (resultdepth > 8) { rgb.depth = 16; rgb.format = AVIF_RGB_FORMAT_RGBA;