commit:     98cddc12ba0bbc204444db2162389fa1b430a14e
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Feb  3 10:50:10 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Feb  3 10:50:10 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=98cddc12

media-libs/lcms: backport grayscale regression fix

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

 .../files/lcms-2.13-grayscale-regression.patch     | 38 ++++++++++++++++++++++
 .../lcms/{lcms-2.13.ebuild => lcms-2.13-r1.ebuild} |  4 +++
 2 files changed, 42 insertions(+)

diff --git a/media-libs/lcms/files/lcms-2.13-grayscale-regression.patch 
b/media-libs/lcms/files/lcms-2.13-grayscale-regression.patch
new file mode 100644
index 000000000000..d1ce0483ee6f
--- /dev/null
+++ b/media-libs/lcms/files/lcms-2.13-grayscale-regression.patch
@@ -0,0 +1,38 @@
+https://github.com/mm2/Little-CMS/commit/fdbfb7694f9d7048d53674b79ddfc38068bfdaf7
+https://bugs.gentoo.org/832520
+
+From: Marti Maria <[email protected]>
+Date: Sun, 30 Jan 2022 16:56:48 +0100
+Subject: [PATCH] Fix for optimisation error on grayscale
+
+Thanks to Aaron Boxer for reporting this issue
+--- a/src/cmsintrp.c
++++ b/src/cmsintrp.c
+@@ -278,10 +278,10 @@ void Eval1Input(CMSREGISTER const cmsUInt16Number 
Input[],
+        // if last value...
+        if (Input[0] == 0xffff || p16->Domain[0] == 0) {
+ 
+-           cmsUInt16Number y0 = LutTable[p16->Domain[0]];
+-
++           cmsUInt32Number y0 = p16->Domain[0] * p16->opta[0];
++           
+            for (OutChan = 0; OutChan < p16->nOutputs; OutChan++) {
+-               Output[OutChan] = y0;
++               Output[OutChan] = LutTable[y0 + OutChan];
+            }
+        }
+        else
+@@ -324,10 +324,10 @@ void Eval1InputFloat(const cmsFloat32Number Value[],
+     // if last value...
+     if (val2 == 1.0 || p->Domain[0] == 0) {
+ 
+-        y0 = LutTable[p->Domain[0]];
++        cmsUInt32Number start = p->Domain[0] * p->opta[0];
+ 
+         for (OutChan = 0; OutChan < p->nOutputs; OutChan++) {
+-            Output[OutChan] = y0;
++            Output[OutChan] = LutTable[start + OutChan];
+         }        
+     }
+     else
+

diff --git a/media-libs/lcms/lcms-2.13.ebuild 
b/media-libs/lcms/lcms-2.13-r1.ebuild
similarity index 95%
rename from media-libs/lcms/lcms-2.13.ebuild
rename to media-libs/lcms/lcms-2.13-r1.ebuild
index 592a2703d159..5ffc35b8645b 100644
--- a/media-libs/lcms/lcms-2.13.ebuild
+++ b/media-libs/lcms/lcms-2.13-r1.ebuild
@@ -25,6 +25,10 @@ RDEPEND="
 "
 DEPEND="${RDEPEND}"
 
+PATCHES=(
+       "${FILESDIR}"/${P}-grayscale-regression.patch
+)
+
 src_prepare() {
        default
 

Reply via email to