Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v2 10/18] avcodec/jpegxl: parse and signal correct alpha mode
Date: Thu, 24 Jul 2025 13:13:45 +0200
Message-ID: <20250724131345.GD95314@haasn.xyz> (raw)
In-Reply-To: <CABPLASSExw-XBRok1qA0PuXt57Eg+1R6kqLjcBAqML-d52i12w@mail.gmail.com>

On Wed, 23 Jul 2025 18:19:03 +0200 Kacper Michajlow <kasper93@gmail.com> wrote:
> On Wed, 23 Jul 2025 at 15:57, Niklas Haas <ffmpeg@haasn.xyz> wrote:
> >
> > From: Niklas Haas <git@haasn.dev>
> >
> > 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".

  reply	other threads:[~2025-07-24 11:13 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 13:47 [FFmpeg-devel] (no subject) Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 01/18] avutil/frame: add AVFrame.alpha_mode Niklas Haas
2025-07-23 16:00   ` Kacper Michajlow
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 02/18] fftools/ffprobe: add support for AVFrame.alpha_mode Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 03/18] avfilter/vf_showinfo: print alpha mode when relevant Niklas Haas
2025-07-23 16:11   ` Kacper Michajlow
2025-07-24 11:19     ` Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 04/18] avcodec/avcodec: add AVCodecContext.alpha_mode Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 05/18] avcodec/encode: enforce alpha mode compatibility at encode time Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 06/18] avcodec/png: set correct alpha mode Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 07/18] avcodec/exr: " Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 08/18] avcodec/libjxl: " Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 09/18] avcodec/libjxlenc: also attach extra channel info Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 10/18] avcodec/jpegxl: parse and signal correct alpha mode Niklas Haas
2025-07-23 16:19   ` Kacper Michajlow
2025-07-24 11:13     ` Niklas Haas [this message]
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 11/18] avfilter/vf_scale: don't ignore incoming chroma location Niklas Haas
2025-07-24 11:16   ` Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 12/18] fftools/ffmpeg_enc: don't ignore user selected " Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 13/18] fftools/ffmpeg_enc: forward frame alpha mode to encoder Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 14/18] avfilter/vf_premultiply: tag correct alpha mode on result Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 15/18] avfilter/vf_alphamerge: tag correct alpha mode Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 16/18] avfilter/vf_overlay: respect alpha mode tagging by default Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 17/18] avfilter/vf_setparams: add alpha_mode parameter Niklas Haas
2025-07-23 13:47 ` [FFmpeg-devel] [PATCH v2 18/18] avfilter/vf_libplacebo: add an alpha_mode setting Niklas Haas
2025-07-23 14:11 ` [FFmpeg-devel] Again pre-multiplied alpha Nicolas George
2025-07-23 15:18   ` Niklas Haas
2025-07-23 17:02     ` Nicolas George
2025-07-24 11:11       ` Niklas Haas
2025-07-24 14:59         ` Nicolas George
2025-07-24 20:58           ` Niklas Haas

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=20250724131345.GD95314@haasn.xyz \
    --to=ffmpeg@haasn.xyz \
    --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