Skip to content

Commit

Permalink
Fix a big mess on premultiplied alpha
Browse files Browse the repository at this point in the history
Somehow experimental sources were used instead of production.
  • Loading branch information
mm2 committed Dec 11, 2023
1 parent e8136df commit ad55d55
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/cmspack.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit ad55d55

Please sign in to comment.