mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-03 05:10:03 +02:00
avcodec/libjxldec: fix errors when decoding grayscale after rgb
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>
This commit is contained in:
parent
358919506d
commit
245910d5c9
@ -298,7 +298,7 @@ static int libjxl_color_encoding_event(AVCodecContext *avctx, AVFrame *frame)
|
|||||||
}
|
}
|
||||||
|
|
||||||
avctx->color_range = frame->color_range = AVCOL_RANGE_JPEG;
|
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->colorspace = AVCOL_SPC_RGB;
|
||||||
avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
|
avctx->color_primaries = AVCOL_PRI_UNSPECIFIED;
|
||||||
avctx->color_trc = AVCOL_TRC_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 */
|
/* all colors will be in-gamut so we want accurate colors */
|
||||||
jxl_color.rendering_intent = JXL_RENDERING_INTENT_RELATIVE;
|
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);
|
jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color);
|
||||||
if (jret != JXL_DEC_SUCCESS) {
|
if (jret != JXL_DEC_SUCCESS) {
|
||||||
av_log(avctx, AV_LOG_WARNING, "Unable to set fallback color encoding\n");
|
av_log(avctx, AV_LOG_WARNING, "Unable to set fallback color encoding\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user