From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1450054-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 2797D158020
	for <garchives@archives.gentoo.org>; Wed, 26 Oct 2022 09:04:45 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 2F396E08DD;
	Wed, 26 Oct 2022 09:04:44 +0000 (UTC)
Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id 127AEE08DD
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Oct 2022 09:04:43 +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 B3AC0341011
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Oct 2022 09:04:42 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 20CDE627
	for <gentoo-commits@lists.gentoo.org>; Wed, 26 Oct 2022 09:04:41 +0000 (UTC)
From: "Andreas Sturmlechner" <asturm@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, "Andreas Sturmlechner" <asturm@gentoo.org>
Message-ID: <1666775048.5ef4a48f6af400cd2416951cda2611804ee4e7e3.asturm@gentoo>
Subject: [gentoo-commits] repo/gentoo:master commit in: kde-frameworks/kimageformats/files/, kde-frameworks/kimageformats/
X-VCS-Repository: repo/gentoo
X-VCS-Files: kde-frameworks/kimageformats/files/kimageformats-5.99.0-jxl-perf.patch kde-frameworks/kimageformats/kimageformats-5.99.0-r3.ebuild
X-VCS-Directories: kde-frameworks/kimageformats/files/ kde-frameworks/kimageformats/
X-VCS-Committer: asturm
X-VCS-Committer-Name: Andreas Sturmlechner
X-VCS-Revision: 5ef4a48f6af400cd2416951cda2611804ee4e7e3
X-VCS-Branch: master
Date: Wed, 26 Oct 2022 09:04:41 +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: ac139909-8597-4e63-9f91-90d092e07f42
X-Archives-Hash: be51b1ea6e5982d1f6f2d18c24dacf51

commit:     5ef4a48f6af400cd2416951cda2611804ee4e7e3
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 26 09:03:15 2022 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Wed Oct 26 09:04:08 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5ef4a48f

kde-frameworks/kimageformats: Backport JXL performance fix

Upstream commit d734f2872745dd1ab5aab9dafb144130d7e9fdcc

Bug: https://bugs.gentoo.org/877501
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 .../files/kimageformats-5.99.0-jxl-perf.patch      | 116 +++++++++++++++++++++
 .../kimageformats/kimageformats-5.99.0-r3.ebuild   |  48 +++++++++
 2 files changed, 164 insertions(+)

diff --git a/kde-frameworks/kimageformats/files/kimageformats-5.99.0-jxl-perf.patch b/kde-frameworks/kimageformats/files/kimageformats-5.99.0-jxl-perf.patch
new file mode 100644
index 000000000000..7673c8c33653
--- /dev/null
+++ b/kde-frameworks/kimageformats/files/kimageformats-5.99.0-jxl-perf.patch
@@ -0,0 +1,116 @@
+From d734f2872745dd1ab5aab9dafb144130d7e9fdcc Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20Novomesk=C3=BD?= <dnovomesky@gmail.com>
+Date: Tue, 18 Oct 2022 15:20:16 +0200
+Subject: [PATCH] jxl: indicate when all frames have been read
+
+and return correct loop count
+---
+ src/imageformats/jxl.cpp | 23 ++++++++++++++++++++---
+ src/imageformats/jxl_p.h |  1 +
+ 2 files changed, 21 insertions(+), 3 deletions(-)
+
+diff --git a/src/imageformats/jxl.cpp b/src/imageformats/jxl.cpp
+index da2cd2e..2501086 100644
+--- a/src/imageformats/jxl.cpp
++++ b/src/imageformats/jxl.cpp
+@@ -48,6 +48,11 @@ bool QJpegXLHandler::canRead() const
+ 
+     if (m_parseState != ParseJpegXLError) {
+         setFormat("jxl");
++
++        if (m_parseState == ParseJpegXLFinished) {
++            return false;
++        }
++
+         return true;
+     }
+     return false;
+@@ -72,7 +77,7 @@ bool QJpegXLHandler::canRead(QIODevice *device)
+ 
+ bool QJpegXLHandler::ensureParsed() const
+ {
+-    if (m_parseState == ParseJpegXLSuccess || m_parseState == ParseJpegXLBasicInfoParsed) {
++    if (m_parseState == ParseJpegXLSuccess || m_parseState == ParseJpegXLBasicInfoParsed || m_parseState == ParseJpegXLFinished) {
+         return true;
+     }
+     if (m_parseState == ParseJpegXLError) {
+@@ -90,7 +95,7 @@ bool QJpegXLHandler::ensureALLCounted() const
+         return false;
+     }
+ 
+-    if (m_parseState == ParseJpegXLSuccess) {
++    if (m_parseState == ParseJpegXLSuccess || m_parseState == ParseJpegXLFinished) {
+         return true;
+     }
+ 
+@@ -401,7 +406,15 @@ bool QJpegXLHandler::decode_one_frame()
+             if (!rewind()) {
+                 return false;
+             }
++
++            // all frames in animation have been read
++            m_parseState = ParseJpegXLFinished;
++        } else {
++            m_parseState = ParseJpegXLSuccess;
+         }
++    } else {
++        // the static image has been read
++        m_parseState = ParseJpegXLFinished;
+     }
+ 
+     return true;
+@@ -860,6 +873,7 @@ bool QJpegXLHandler::jumpToNextImage()
+         }
+     }
+ 
++    m_parseState = ParseJpegXLSuccess;
+     return true;
+ }
+ 
+@@ -874,12 +888,14 @@ bool QJpegXLHandler::jumpToImage(int imageNumber)
+     }
+ 
+     if (imageNumber == m_currentimage_index) {
++        m_parseState = ParseJpegXLSuccess;
+         return true;
+     }
+ 
+     if (imageNumber > m_currentimage_index) {
+         JxlDecoderSkipFrames(m_decoder, imageNumber - m_currentimage_index);
+         m_currentimage_index = imageNumber;
++        m_parseState = ParseJpegXLSuccess;
+         return true;
+     }
+ 
+@@ -891,6 +907,7 @@ bool QJpegXLHandler::jumpToImage(int imageNumber)
+         JxlDecoderSkipFrames(m_decoder, imageNumber);
+     }
+     m_currentimage_index = imageNumber;
++    m_parseState = ParseJpegXLSuccess;
+     return true;
+ }
+ 
+@@ -914,7 +931,7 @@ int QJpegXLHandler::loopCount() const
+     }
+ 
+     if (m_basicinfo.have_animation) {
+-        return 1;
++        return (m_basicinfo.animation.num_loops > 0) ? m_basicinfo.animation.num_loops - 1 : -1;
+     } else {
+         return 0;
+     }
+diff --git a/src/imageformats/jxl_p.h b/src/imageformats/jxl_p.h
+index 8339d7e..7a4af0b 100644
+--- a/src/imageformats/jxl_p.h
++++ b/src/imageformats/jxl_p.h
+@@ -57,6 +57,7 @@ private:
+         ParseJpegXLNotParsed = 0,
+         ParseJpegXLSuccess = 1,
+         ParseJpegXLBasicInfoParsed = 2,
++        ParseJpegXLFinished = 3,
+     };
+ 
+     ParseJpegXLState m_parseState;
+-- 
+GitLab
+

diff --git a/kde-frameworks/kimageformats/kimageformats-5.99.0-r3.ebuild b/kde-frameworks/kimageformats/kimageformats-5.99.0-r3.ebuild
new file mode 100644
index 000000000000..feebf9696329
--- /dev/null
+++ b/kde-frameworks/kimageformats/kimageformats-5.99.0-r3.ebuild
@@ -0,0 +1,48 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+ECM_QTHELP="false"
+PVCUT=$(ver_cut 1-2)
+QTMIN=5.15.5
+VIRTUALX_REQUIRED="test"
+inherit ecm frameworks.kde.org
+
+DESCRIPTION="Framework providing additional format plugins for Qt's image I/O system"
+
+LICENSE="LGPL-2+"
+KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~x86"
+IUSE="avif eps heif jpegxl openexr raw"
+
+DEPEND="
+	>=dev-qt/qtgui-${QTMIN}:5
+	=kde-frameworks/karchive-${PVCUT}*:5
+	avif? ( >=media-libs/libavif-0.8.2:= )
+	eps? ( >=dev-qt/qtprintsupport-${QTMIN}:5 )
+	heif? ( >=media-libs/libheif-1.10.0:= )
+	jpegxl? ( media-libs/libjxl )
+	openexr? ( >=media-libs/openexr-3:= )
+	raw? ( media-libs/libraw:= )
+"
+RDEPEND="${DEPEND}"
+
+DOCS=( src/imageformats/AUTHORS )
+
+PATCHES=(
+	"${FILESDIR}"/${P}-avif-perf-{1,2,3}.patch
+	"${FILESDIR}"/${P}-avif-0.11.0.patch
+	"${FILESDIR}"/${P}-jxl-perf.patch
+)
+
+src_configure() {
+	local mycmakeargs=(
+		-DKIMAGEFORMATS_JXL=$(usex jpegxl)
+		$(cmake_use_find_package avif libavif)
+		$(cmake_use_find_package eps Qt5PrintSupport)
+		-DKIMAGEFORMATS_HEIF=$(usex heif)
+		$(cmake_use_find_package openexr OpenEXR)
+		$(cmake_use_find_package raw LibRaw)
+	)
+	ecm_src_configure
+}