From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 328974BD7E for ; Thu, 24 Jul 2025 11:13:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 6879168D765; Thu, 24 Jul 2025 14:13:52 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 9701C68C3BE for ; Thu, 24 Jul 2025 14:13:45 +0300 (EEST) Received: from haasn.dev (unknown [10.30.1.1]) by haasn.dev (Postfix) with UTF8SMTP id 6C3D2418EF for ; Thu, 24 Jul 2025 13:13:45 +0200 (CEST) Date: Thu, 24 Jul 2025 13:13:45 +0200 Message-ID: <20250724131345.GD95314@haasn.xyz> From: Niklas Haas To: FFmpeg development discussions and patches In-Reply-To: References: <20250723135626.1390296-1-ffmpeg@haasn.xyz> <20250723135626.1390296-11-ffmpeg@haasn.xyz> MIME-Version: 1.0 Content-Disposition: inline Subject: Re: [FFmpeg-devel] [PATCH v2 10/18] avcodec/jpegxl: parse and signal correct alpha mode X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On Wed, 23 Jul 2025 18:19:03 +0200 Kacper Michajlow wrote: > On Wed, 23 Jul 2025 at 15:57, Niklas Haas wrote: > > > > From: Niklas Haas > > > > This header bit ("alpha_associated") was incorrectly ignored. > > --- > > libavcodec/jpegxl_parse.c | 7 +++++-- > > libavcodec/jpegxl_parse.h | 1 + > > libavcodec/jpegxl_parser.c | 5 +++++ > > 3 files changed, 11 insertions(+), 2 deletions(-) > > > > diff --git a/libavcodec/jpegxl_parse.c b/libavcodec/jpegxl_parse.c > > index 022eed322d..47b831e2b4 100644 > > --- a/libavcodec/jpegxl_parse.c > > +++ b/libavcodec/jpegxl_parse.c > > @@ -190,6 +190,7 @@ static void jpegxl_get_bit_depth(GetBitContext *gb, FFJXLMetadata *meta) > > static int jpegxl_read_extra_channel_info(GetBitContext *gb, FFJXLMetadata *meta, int validate) > > { > > int default_alpha = get_bits1(gb); > > + int alpha_associated = 0; > > uint32_t type, name_len = 0; > > > > if (!default_alpha) { > > @@ -213,7 +214,7 @@ static int jpegxl_read_extra_channel_info(GetBitContext *gb, FFJXLMetadata *meta > > skip_bits_long(gb, name_len); > > > > if (!default_alpha && type == JPEGXL_CT_ALPHA) > > - skip_bits1(gb); > > + alpha_associated = get_bits1(gb); > > > > if (type == JPEGXL_CT_SPOT_COLOR) > > skip_bits_long(gb, 16 * 4); > > @@ -221,8 +222,10 @@ static int jpegxl_read_extra_channel_info(GetBitContext *gb, FFJXLMetadata *meta > > if (type == JPEGXL_CT_CFA) > > jxl_u32(gb, 1, 0, 3, 19, 0, 2, 4, 8); > > > > - if (meta && type == JPEGXL_CT_ALPHA) > > + if (meta && type == JPEGXL_CT_ALPHA) { > > meta->have_alpha = 1; > > + meta->alpha_associated = alpha_associated; > > + } > > > > return 0; > > } > > diff --git a/libavcodec/jpegxl_parse.h b/libavcodec/jpegxl_parse.h > > index 0602f4d409..bb929ccee1 100644 > > --- a/libavcodec/jpegxl_parse.h > > +++ b/libavcodec/jpegxl_parse.h > > @@ -35,6 +35,7 @@ typedef struct FFJXLMetadata { > > uint32_t coded_height; > > int bit_depth; > > int have_alpha; > > + int alpha_associated; > > /* > > * offset, in bits, of the animation header > > * zero if not animated > > diff --git a/libavcodec/jpegxl_parser.c b/libavcodec/jpegxl_parser.c > > index 75acc53708..c13601f3d7 100644 > > --- a/libavcodec/jpegxl_parser.c > > +++ b/libavcodec/jpegxl_parser.c > > @@ -1074,6 +1074,11 @@ static void populate_fields(AVCodecParserContext *s, AVCodecContext *avctx, cons > > else > > s->format = meta->have_alpha ? AV_PIX_FMT_RGBAF32 : AV_PIX_FMT_RGBF32; > > } > > + > > + if (meta->have_alpha) { > > + avctx->alpha_mode |= meta->alpha_associated ? AVALPHA_MODE_PREMULTIPLIED > > + : AVALPHA_MODE_STRAIGHT; > > Is this OR expected here? Setting (2 | 1) seems strange, no? Fixed, thanks. > > - Kacper > > > + } > > } > > > > static int skip_icc_profile(void *avctx, JXLParseContext *ctx, GetBitContext *gb) > > -- > > 2.50.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". > _______________________________________________ > 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". _______________________________________________ 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".