1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
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 <leo.izen@gmail.com>
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 <leo.izen@gmail.com>
--- 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 <leo.izen@gmail.com>
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
<jxl/decode.h> (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 <jxl/version.h> 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 <leo.izen@gmail.com>
--- a/libavcodec/libjxl.h
+++ b/libavcodec/libjxl.h
@@ -27,19 +27,8 @@
#ifndef AVCODEC_LIBJXL_H
#define AVCODEC_LIBJXL_H
-#include <jxl/decode.h>
#include <jxl/memory_manager.h>
-
-/*
- * 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 <jxl/version.h>
/**
* Transform threadcount in ffmpeg to one used by libjxl.
--
2.30.2
|