From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1609939-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
	(No client certificate requested)
	by finch.gentoo.org (Postfix) with ESMTPS id 0B1EE158041
	for <garchives@archives.gentoo.org>; Tue, 12 Mar 2024 03:37:28 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 1BA22E29C0;
	Tue, 12 Mar 2024 03:37:27 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id EC0A7E29C0
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Mar 2024 03:37:26 +0000 (UTC)
Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 3101D341E1C
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Mar 2024 03:37:26 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id AE13613DE
	for <gentoo-commits@lists.gentoo.org>; Tue, 12 Mar 2024 03:37:24 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1710214614.0b5305498974c036f83c71adc8fb4a40106858c7.sam@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: media-video/ffmpeg/files/, media-video/ffmpeg/
X-VCS-Repository: repo/gentoo
X-VCS-Files: media-video/ffmpeg/ffmpeg-6.0.1-r3.ebuild media-video/ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch
X-VCS-Directories: media-video/ffmpeg/files/ media-video/ffmpeg/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 0b5305498974c036f83c71adc8fb4a40106858c7
X-VCS-Branch: master
Date: Tue, 12 Mar 2024 03:37:24 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 8aad04a3-2fb8-49a6-95b9-60293469ccca
X-Archives-Hash: 84f32062bcda124e8cc2cadcfdb4b0df

commit:     0b5305498974c036f83c71adc8fb4a40106858c7
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 12 03:35:38 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Mar 12 03:36:54 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0b530549

media-video/ffmpeg: fix build w/ newer libjxl

Closes: https://bugs.gentoo.org/924431
Signed-off-by: Sam James <sam <AT> gentoo.org>

 media-video/ffmpeg/ffmpeg-6.0.1-r3.ebuild          |   1 +
 .../ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch     | 112 +++++++++++++++++++++
 2 files changed, 113 insertions(+)

diff --git a/media-video/ffmpeg/ffmpeg-6.0.1-r3.ebuild b/media-video/ffmpeg/ffmpeg-6.0.1-r3.ebuild
index 8cf74299df2e..4393adc2906b 100644
--- a/media-video/ffmpeg/ffmpeg-6.0.1-r3.ebuild
+++ b/media-video/ffmpeg/ffmpeg-6.0.1-r3.ebuild
@@ -348,6 +348,7 @@ PATCHES=(
 	"${FILESDIR}"/${PN}-6.0-fix-lto-type-mismatch.patch
 	"${FILESDIR}"/${PN}-4.4.4-opencl-parallel-gmake-fix.patch
 	"${FILESDIR}"/${PN}-6.0.1-alignment.patch
+	"${FILESDIR}"/${PN}-6.0.1-libjxl-0.9.patch
 )
 
 MULTILIB_WRAPPED_HEADERS=(

diff --git a/media-video/ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch b/media-video/ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch
new file mode 100644
index 000000000000..10c216ec4c88
--- /dev/null
+++ b/media-video/ffmpeg/files/ffmpeg-6.0.1-libjxl-0.9.patch
@@ -0,0 +1,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