diff mbox series

[FFmpeg-devel] avcodec/libjxldec: build against libjxl 0.9

Message ID 20230708184502.66917-1-leo.izen@gmail.com
State Accepted
Commit 75b1a555a70c178a9166629e43ec2f6250219eb2
Headers show
Series [FFmpeg-devel] avcodec/libjxldec: build against libjxl 0.9 | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Leo Izen July 8, 2023, 6:45 p.m. UTC
Git master libjxl changed several function signatures, so this commit
adds some #ifdefs to handle the new signatures without breaking old
releases.
---
 libavcodec/libjxldec.c | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

Comments

Gyan Doshi July 8, 2023, 7:25 p.m. UTC | #1
On 2023-07-09 12:15 am, Leo Izen wrote:
> Git master libjxl changed several function signatures, so this commit
> adds some #ifdefs to handle the new signatures without breaking old
> releases.

Same objection as to the patch submitted a few days ago, pasted below:

----
0.9.0 is still unreleased and unfortunately the API change wasn't 
accompanied with a version bump.

The API changes were pushed on Jun 21st and the version bump to 0.9.0 
was pushed on Jan 12th.
So this will still break compilation with older git checkouts of libjxl. 
Ideally libjxl should bump once more to 0.9.1
----

Regards,
Gyan


> ---
>   libavcodec/libjxldec.c | 21 +++++++++++++++++++--
>   1 file changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
> index 50417bcb02..e45ac02c07 100644
> --- 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)
Leo Izen July 8, 2023, 7:30 p.m. UTC | #2
On 7/8/23 15:25, Gyan Doshi wrote:
> 
> 
> On 2023-07-09 12:15 am, Leo Izen wrote:
>> Git master libjxl changed several function signatures, so this commit
>> adds some #ifdefs to handle the new signatures without breaking old
>> releases.
> 
> Same objection as to the patch submitted a few days ago, pasted below:
> 
> ----
> 0.9.0 is still unreleased and unfortunately the API change wasn't 
> accompanied with a version bump.
> 
> The API changes were pushed on Jun 21st and the version bump to 0.9.0 
> was pushed on Jan 12th.
> So this will still break compilation with older git checkouts of libjxl. 
> Ideally libjxl should bump once more to 0.9.1
> ----
> 
> Regards,
> Gyan
> 

Oh, I missed that patch.

In either case, why do we care about breaking old development versions 
that aren't releases?

- Leo Izen
Gyan Doshi July 9, 2023, 3:44 a.m. UTC | #3
On 2023-07-09 01:00 am, Leo Izen wrote:
> On 7/8/23 15:25, Gyan Doshi wrote:
>>
>>
>> On 2023-07-09 12:15 am, Leo Izen wrote:
>>> Git master libjxl changed several function signatures, so this commit
>>> adds some #ifdefs to handle the new signatures without breaking old
>>> releases.
>>
>> Same objection as to the patch submitted a few days ago, pasted below:
>>
>> ----
>> 0.9.0 is still unreleased and unfortunately the API change wasn't 
>> accompanied with a version bump.
>>
>> The API changes were pushed on Jun 21st and the version bump to 0.9.0 
>> was pushed on Jan 12th.
>> So this will still break compilation with older git checkouts of 
>> libjxl. Ideally libjxl should bump once more to 0.9.1
>> ----
>>
>> Regards,
>> Gyan
>>
>
> Oh, I missed that patch.
>
> In either case, why do we care about breaking old development versions 
> that aren't releases?

Ok. Just make a note in the commit msg then.

Regards,
Gyan
Leo Izen July 10, 2023, 8:27 p.m. UTC | #4
On 7/8/23 23:44, Gyan Doshi wrote:
> 
> 
> On 2023-07-09 01:00 am, Leo Izen wrote:
>> On 7/8/23 15:25, Gyan Doshi wrote:
>>>
>>>
>>> On 2023-07-09 12:15 am, Leo Izen wrote:
>>>> Git master libjxl changed several function signatures, so this commit
>>>> adds some #ifdefs to handle the new signatures without breaking old
>>>> releases.
>>>
>>> Same objection as to the patch submitted a few days ago, pasted below:
>>>
>>> ----
>>> 0.9.0 is still unreleased and unfortunately the API change wasn't 
>>> accompanied with a version bump.
>>>
>>> The API changes were pushed on Jun 21st and the version bump to 0.9.0 
>>> was pushed on Jan 12th.
>>> So this will still break compilation with older git checkouts of 
>>> libjxl. Ideally libjxl should bump once more to 0.9.1
>>> ----
>>>
>>> Regards,
>>> Gyan
>>>
>>
>> Oh, I missed that patch.
>>
>> In either case, why do we care about breaking old development versions 
>> that aren't releases?
> 
> Ok. Just make a note in the commit msg then.
> 
> Regards,
> Gyan
> 

Noted. I pushed as 75b1a555a70c178a9166629e43ec2f6250219eb2 with a 
slightly amended commit message.

- Leo Izen
diff mbox series

Patch

diff --git a/libavcodec/libjxldec.c b/libavcodec/libjxldec.c
index 50417bcb02..e45ac02c07 100644
--- 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)