From: Leo Izen <leo.izen@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Leo Izen <leo.izen@gmail.com>
Subject: [FFmpeg-devel] [PATCH v7 1/5] avcodec/libjxldec: fix errors when decoding grayscale after rgb
Date: Wed, 2 Aug 2023 16:33:30 -0400
Message-ID: <20230802203334.23640-2-leo.izen@gmail.com> (raw)
In-Reply-To: <20230802203334.23640-1-leo.izen@gmail.com>
Fixes an error that's caused by decoding a grayscale JXL image after an
RGB image is decoded, with the same decoder instance.
Signed-off-by: Leo Izen <leo.izen@gmail.com>
---
libavcodec/libjxldec.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index e45ac02c07..9be1d9295a 100644
--- a/libavcodec/libjxldec.c
+++ b/libavcodec/libjxldec.c
@@ -298,7 +298,7 @@ static int libjxl_color_encoding_event(AVCodecContext *avctx, AVFrame *frame)
}
avctx->color_range = frame->color_range = AVCOL_RANGE_JPEG;
- if (ctx->jxl_pixfmt.num_channels >= 3)
+ if (ctx->basic_info.num_color_channels > 1)
avctx->colorspace = AVCOL_SPC_RGB;
avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
avctx->color_trc = AVCOL_TRC_UNSPECIFIED;
@@ -334,7 +334,7 @@ static int libjxl_color_encoding_event(AVCodecContext *avctx, AVFrame *frame)
}
/* all colors will be in-gamut so we want accurate colors */
jxl_color.rendering_intent = JXL_RENDERING_INTENT_RELATIVE;
- jxl_color.color_space = avctx->colorspace == AVCOL_SPC_RGB ? JXL_COLOR_SPACE_RGB : JXL_COLOR_SPACE_GRAY;
+ jxl_color.color_space = ctx->basic_info.num_color_channels > 1 ? JXL_COLOR_SPACE_RGB : JXL_COLOR_SPACE_GRAY;
jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color);
if (jret != JXL_DEC_SUCCESS) {
av_log(avctx, AV_LOG_WARNING, "Unable to set fallback color encoding\n");
--
2.41.0
_______________________________________________
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".
next prev parent reply other threads:[~2023-08-02 20:33 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-02 20:33 [FFmpeg-devel] [PATCH v7 0/5] JPEG XL Parser (and bug fixes) Leo Izen
2023-08-02 20:33 ` Leo Izen [this message]
2023-08-02 20:33 ` [FFmpeg-devel] [PATCH v7 2/5] avcodec/libjxldec: use internal AVFrame as buffered space Leo Izen
2023-08-02 20:33 ` [FFmpeg-devel] [PATCH v7 3/5] avcodec/jpegxl_parser: add JPEG XL parser Leo Izen
2023-08-02 20:33 ` [FFmpeg-devel] [PATCH v7 4/5] avformat/jpegxl: remove jpegxl_probe, instead call avcodec/jpegxl_parse Leo Izen
2023-08-02 20:33 ` [FFmpeg-devel] [PATCH v7 5/5] fate/jpegxl_anim: add demuxer fate test for jpegxl_anim Leo Izen
2023-08-09 21:56 ` [FFmpeg-devel] [PATCH v7 0/5] JPEG XL Parser (and bug fixes) Leo Izen
2023-08-16 4:25 ` Leo Izen
2023-08-24 19:22 ` Leo Izen
2023-08-27 5:40 ` Leo Izen
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=20230802203334.23640-2-leo.izen@gmail.com \
--to=leo.izen@gmail.com \
--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