https://bugs.gentoo.org/924431 https://git.videolan.org/?p=ffmpeg.git;a=commit;h=75b1a555a70c178a9166629e43ec2f6250219eb2 https://git.videolan.org/?p=ffmpeg.git;a=commit;h=ac06190a5a11f2b170e7719d769d7c0d65bff3e0 From 75b1a555a70c178a9166629e43ec2f6250219eb2 Mon Sep 17 00:00:00 2001 From: Leo Izen Date: Sat, 8 Jul 2023 14:43:31 -0400 Subject: [PATCH] avcodec/libjxldec: build against libjxl 0.9 Git master libjxl changed several function signatures, so this commit adds some #ifdefs to handle the new signatures without breaking old releases. Do note that old git master development versions of libjxl will be broken, but no releases will be. Signed-off-by: Leo Izen --- a/libavcodec/libjxldec.c +++ b/libavcodec/libjxldec.c @@ -210,14 +210,22 @@ static int libjxl_get_icc(AVCodecContext *avctx) JxlDecoderStatus jret; /* an ICC profile is present, and we can meaningfully get it, * because the pixel data is not XYB-encoded */ +#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) jret = JxlDecoderGetICCProfileSize(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, &icc_len); +#else + jret = JxlDecoderGetICCProfileSize(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, &icc_len); +#endif if (jret == JXL_DEC_SUCCESS && icc_len > 0) { av_buffer_unref(&ctx->iccp); ctx->iccp = av_buffer_alloc(icc_len); if (!ctx->iccp) return AVERROR(ENOMEM); +#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, - ctx->iccp->data, icc_len); + ctx->iccp->data, icc_len); +#else + jret = JxlDecoderGetColorAsICCProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, ctx->iccp->data, icc_len); +#endif if (jret != JXL_DEC_SUCCESS) { av_log(avctx, AV_LOG_WARNING, "Unable to obtain ICC Profile\n"); av_buffer_unref(&ctx->iccp); @@ -253,12 +261,21 @@ static int libjxl_color_encoding_event(AVCodecContext *avctx, AVFrame *frame) /* set this flag if we need to fall back on wide gamut */ int fallback = 0; +#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, NULL, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color); +#else + jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_ORIGINAL, &jxl_color); +#endif if (jret == JXL_DEC_SUCCESS) { /* enum values describe the colors of this image */ jret = JxlDecoderSetPreferredColorProfile(ctx->decoder, &jxl_color); if (jret == JXL_DEC_SUCCESS) - jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, &ctx->jxl_pixfmt, JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color); +#if JPEGXL_NUMERIC_VERSION < JPEGXL_COMPUTE_NUMERIC_VERSION(0, 9, 0) + jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, &ctx->jxl_pixfmt, + JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color); +#else + jret = JxlDecoderGetColorAsEncodedProfile(ctx->decoder, JXL_COLOR_PROFILE_TARGET_DATA, &jxl_color); +#endif /* if we couldn't successfully request the pixel data space, we fall back on wide gamut */ /* this code path is very unlikely to happen in practice */ if (jret != JXL_DEC_SUCCESS) -- 2.30.2 From ac06190a5a11f2b170e7719d769d7c0d65bff3e0 Mon Sep 17 00:00:00 2001 From: Leo Izen Date: Tue, 23 Jan 2024 17:29:14 -0500 Subject: [PATCH] avcodec/libjxl.h: include version.h This file has been exported since our minimum required version (0.7.0), but it wasn't documented. Instead it was transitively included by (but not jxl/encode.h), which ffmpeg relied on. libjxl broke its API in libjxl/libjxl@66b959239355aef5255 by removing the transitive include of version.h, and they do not plan on adding it back. Instead they are choosing to leave the API backwards- incompatible with downstream callers written for some fairly recent versions of their API. As a result, we include to continue to build against more recent versions of libjxl. The version macros removed are also present in that file, so we no longer need to redefine them. Signed-off-by: Leo Izen --- a/libavcodec/libjxl.h +++ b/libavcodec/libjxl.h @@ -27,19 +27,8 @@ #ifndef AVCODEC_LIBJXL_H #define AVCODEC_LIBJXL_H -#include #include - -/* - * libjxl version 0.7.0 and earlier doesn't contain these macros at all - * so to detect version 0.7.0 versus 0.8.0 we need to define them ourselves - */ -#ifndef JPEGXL_COMPUTE_NUMERIC_VERSION - #define JPEGXL_COMPUTE_NUMERIC_VERSION(major,minor,patch) ((major<<24) | (minor<<16) | (patch<<8) | 0) -#endif -#ifndef JPEGXL_NUMERIC_VERSION - #define JPEGXL_NUMERIC_VERSION JPEGXL_COMPUTE_NUMERIC_VERSION(0, 7, 0) -#endif +#include /** * Transform threadcount in ffmpeg to one used by libjxl. -- 2.30.2