From ad55d55cab3ae7150389123efdb20e9741d03a98 Mon Sep 17 00:00:00 2001 From: Marti Maria Date: Mon, 11 Dec 2023 17:39:57 +0100 Subject: [PATCH] Fix a big mess on premultiplied alpha Somehow experimental sources were used instead of production. --- src/cmspack.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cmspack.c b/src/cmspack.c index 90c3720e..ac93bcd8 100644 --- a/src/cmspack.c +++ b/src/cmspack.c @@ -577,8 +577,8 @@ cmsUInt8Number* UnrollAnyWordsPremul(CMSREGISTER _cmsTRANSFORM* info, cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; cmsUInt32Number i; - cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[nChan - 1]); - cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha)); + cmsUInt16Number alpha = (ExtraFirst ? ((cmsUInt16Number*)accum)[0] : ((cmsUInt16Number*)accum)[nChan]); + cmsUInt32Number alpha_factor = _cmsToFixedDomain(alpha); if (ExtraFirst) { accum += sizeof(cmsUInt16Number); @@ -661,9 +661,9 @@ cmsUInt8Number* UnrollPlanarWordsPremul(CMSREGISTER _cmsTRANSFORM* info, cmsUInt32Number i; cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst; cmsUInt8Number* Init = accum; - - cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[(nChan - 1) * Stride]); - cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha)); + + cmsUInt16Number alpha = (ExtraFirst ? ((cmsUInt16Number*)accum)[0] : ((cmsUInt16Number*)accum)[nChan * Stride / 2]); + cmsUInt32Number alpha_factor = _cmsToFixedDomain(alpha); if (ExtraFirst) { accum += Stride; @@ -1358,7 +1358,7 @@ cmsUInt8Number* UnrollFloatsToFloat(_cmsTRANSFORM* info, if (Premul && Extra) { if (Planar) - alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan * Stride]) / maximum; + alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan * Stride / sizeof(cmsFloat32Number)]) / maximum; else alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum; } @@ -1425,7 +1425,7 @@ cmsUInt8Number* UnrollDoublesToFloat(_cmsTRANSFORM* info, if (Premul && Extra) { if (Planar) - alpha_factor = (ExtraFirst ? ptr[0] : ptr[(nChan) * Stride]) / maximum; + alpha_factor = (ExtraFirst ? ptr[0] : ptr[(nChan) * Stride / sizeof(cmsFloat64Number)]) / maximum; else alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum; }