From: Niklas Haas <[email protected]>
Works around a bug where older versions of libjxl don't correctly forward
the alpha channel information to the extra channel info.
---
libavcodec/libjxlenc.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/libavcodec/libjxlenc.c b/libavcodec/libjxlenc.c
index 924a835436..5a062b8d0d 100644
--- a/libavcodec/libjxlenc.c
+++ b/libavcodec/libjxlenc.c
@@ -394,6 +394,19 @@ static int libjxl_preprocess_stream(AVCodecContext *avctx,
const AVFrame *frame,
return AVERROR_EXTERNAL;
}
+ if (info.alpha_bits) {
+ JxlExtraChannelInfo extra_info;
+ JxlEncoderInitExtraChannelInfo(JXL_CHANNEL_ALPHA, &extra_info);
+ extra_info.bits_per_sample = info.alpha_bits;
+ extra_info.exponent_bits_per_sample = info.alpha_exponent_bits;
+ extra_info.alpha_premultiplied = info.alpha_premultiplied;
+
+ if (JxlEncoderSetExtraChannelInfo(ctx->encoder, 0, &extra_info) !=
JXL_ENC_SUCCESS) {
+ av_log(avctx, AV_LOG_ERROR, "Failed to set JxlExtraChannelInfo for
channel %d\n", i);
+ return AVERROR_EXTERNAL;
+ }
+ }
+
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE);
if (sd && sd->size && JxlEncoderSetICCProfile(ctx->encoder, sd->data,
sd->size) != JXL_ENC_SUCCESS) {
av_log(avctx, AV_LOG_WARNING, "Could not set ICC Profile\n");
--
2.50.1
_______________________________________________
ffmpeg-devel mailing list
[email protected]
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".