Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions IccProfLib/IccMpeBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5383,6 +5383,19 @@ static icFloatNumber NoClip(icFloatNumber v)
return v;
}

// this isn't used yet, but want to have it ready
static icFloatNumber RealUnitClip(icFloatNumber v)
{
if (std::isnan(v))
return icFloatNumber(0);
if (std::isinf(v))
return icFloatNumber(1.0);
if (v < 0.0)
return 0.0;
if (v > 1.0)
return 1.0;
return v;
}

/**
******************************************************************************
Expand Down
114 changes: 86 additions & 28 deletions IccProfLib/IccTagLut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1718,7 +1718,7 @@ CIccCLUT::CIccCLUT(icUInt8Number nInputChannels, icUInt16Number nOutputChannels,
m_csOutput = icSigUnknownData;
memset(&m_nReserved2, 0 , sizeof(m_nReserved2));

UnitClip = ClutUnitClip;
m_UnitClipFunc = ClutUnitClip;
}


Expand Down Expand Up @@ -1753,7 +1753,7 @@ CIccCLUT::CIccCLUT(const CIccCLUT &ICLUT)
m_pData = new icFloatNumber[num];
memcpy(m_pData, ICLUT.m_pData, num*sizeof(icFloatNumber));

UnitClip = ICLUT.UnitClip;
m_UnitClipFunc = ICLUT.m_UnitClipFunc;
}


Expand Down Expand Up @@ -1792,7 +1792,7 @@ CIccCLUT &CIccCLUT::operator=(const CIccCLUT &CLUTTag)
m_pData = new icFloatNumber[num];
memcpy(m_pData, CLUTTag.m_pData, num*sizeof(icFloatNumber));

UnitClip = CLUTTag.UnitClip;
m_UnitClipFunc = CLUTTag.m_UnitClipFunc;

return *this;
}
Expand Down Expand Up @@ -2476,7 +2476,11 @@ void CIccCLUT::Interp1d(icFloatNumber *destPixel, const icFloatNumber *srcPixel)
{
icUInt8Number mx = m_MaxGridPoint[0];

icFloatNumber x = UnitClip(srcPixel[0]) * mx;
icFloatNumber x = m_UnitClipFunc(srcPixel[0]) * mx;

// m_UnitClipFunc points to NoClip
if (x < 0)
x = 0.0;

icUInt32Number ix = (icUInt32Number)x;

Expand Down Expand Up @@ -2522,8 +2526,8 @@ void CIccCLUT::Interp2d(icFloatNumber *destPixel, const icFloatNumber *srcPixel)
icUInt8Number my = m_MaxGridPoint[1];

// The UnitClip function pointer is calling "NoClip", but now removes NaN and Inf
icFloatNumber x = UnitClip(srcPixel[0]) * mx;
icFloatNumber y = UnitClip(srcPixel[1]) * my;
icFloatNumber x = m_UnitClipFunc(srcPixel[0]) * mx;
icFloatNumber y = m_UnitClipFunc(srcPixel[1]) * my;

if (x < 0.0)
x = 0.0;
Expand Down Expand Up @@ -2587,9 +2591,17 @@ void CIccCLUT::Interp3dTetra(icFloatNumber *destPixel, const icFloatNumber *srcP
icUInt8Number my = m_MaxGridPoint[1];
icUInt8Number mz = m_MaxGridPoint[2];

icFloatNumber x = UnitClip(srcPixel[0]) * mx;
icFloatNumber y = UnitClip(srcPixel[1]) * my;
icFloatNumber z = UnitClip(srcPixel[2]) * mz;
icFloatNumber x = m_UnitClipFunc(srcPixel[0]) * mx;
icFloatNumber y = m_UnitClipFunc(srcPixel[1]) * my;
icFloatNumber z = m_UnitClipFunc(srcPixel[2]) * mz;

// m_UnitClipFunc points to NoClip
if (x < 0)
x = 0.0;
if (y < 0)
y = 0.0;
if (z < 0)
z = 0.0;

icUInt32Number ix = (icUInt32Number)x;
icUInt32Number iy = (icUInt32Number)y;
Expand Down Expand Up @@ -2673,9 +2685,17 @@ void CIccCLUT::Interp3d(icFloatNumber *destPixel, const icFloatNumber *srcPixel)
icUInt8Number my = m_MaxGridPoint[1];
icUInt8Number mz = m_MaxGridPoint[2];

icFloatNumber x = UnitClip(srcPixel[0]) * mx;
icFloatNumber y = UnitClip(srcPixel[1]) * my;
icFloatNumber z = UnitClip(srcPixel[2]) * mz;
icFloatNumber x = m_UnitClipFunc(srcPixel[0]) * mx;
icFloatNumber y = m_UnitClipFunc(srcPixel[1]) * my;
icFloatNumber z = m_UnitClipFunc(srcPixel[2]) * mz;

// m_UnitClipFunc points to NoClip
if (x < 0)
x = 0.0;
if (y < 0)
y = 0.0;
if (z < 0)
z = 0.0;

icUInt32Number ix = (icUInt32Number)x;
icUInt32Number iy = (icUInt32Number)y;
Expand Down Expand Up @@ -2744,10 +2764,20 @@ void CIccCLUT::Interp4d(icFloatNumber *destPixel, const icFloatNumber *srcPixel)
icUInt8Number my = m_MaxGridPoint[2];
icUInt8Number mz = m_MaxGridPoint[3];

icFloatNumber w = UnitClip(srcPixel[0]) * mw;
icFloatNumber x = UnitClip(srcPixel[1]) * mx;
icFloatNumber y = UnitClip(srcPixel[2]) * my;
icFloatNumber z = UnitClip(srcPixel[3]) * mz;
icFloatNumber w = m_UnitClipFunc(srcPixel[0]) * mw;
icFloatNumber x = m_UnitClipFunc(srcPixel[1]) * mx;
icFloatNumber y = m_UnitClipFunc(srcPixel[2]) * my;
icFloatNumber z = m_UnitClipFunc(srcPixel[3]) * mz;

// m_UnitClipFunc points to NoClip
if (w < 0)
w = 0.0;
if (x < 0)
x = 0.0;
if (y < 0)
y = 0.0;
if (z < 0)
z = 0.0;

icUInt32Number iw = (icUInt32Number)w;
icUInt32Number ix = (icUInt32Number)x;
Expand Down Expand Up @@ -2831,11 +2861,23 @@ void CIccCLUT::Interp5d(icFloatNumber *destPixel, const icFloatNumber *srcPixel)
icUInt8Number m3 = m_MaxGridPoint[3];
icUInt8Number m4 = m_MaxGridPoint[4];

icFloatNumber g0 = UnitClip(srcPixel[0]) * m0;
icFloatNumber g1 = UnitClip(srcPixel[1]) * m1;
icFloatNumber g2 = UnitClip(srcPixel[2]) * m2;
icFloatNumber g3 = UnitClip(srcPixel[3]) * m3;
icFloatNumber g4 = UnitClip(srcPixel[4]) * m4;
icFloatNumber g0 = m_UnitClipFunc(srcPixel[0]) * m0;
icFloatNumber g1 = m_UnitClipFunc(srcPixel[1]) * m1;
icFloatNumber g2 = m_UnitClipFunc(srcPixel[2]) * m2;
icFloatNumber g3 = m_UnitClipFunc(srcPixel[3]) * m3;
icFloatNumber g4 = m_UnitClipFunc(srcPixel[4]) * m4;

// m_UnitClipFunc points to NoClip
if (g0 < 0)
g0 = 0.0;
if (g1 < 0)
g1 = 0.0;
if (g2 < 0)
g2 = 0.0;
if (g3 < 0)
g3 = 0.0;
if (g4 < 0)
g4 = 0.0;

icUInt32Number ig0 = (icUInt32Number)g0;
icUInt32Number ig1 = (icUInt32Number)g1;
Expand Down Expand Up @@ -2944,12 +2986,26 @@ void CIccCLUT::Interp6d(icFloatNumber *destPixel, const icFloatNumber *srcPixel)
icUInt8Number m4 = m_MaxGridPoint[4];
icUInt8Number m5 = m_MaxGridPoint[5];

icFloatNumber g0 = UnitClip(srcPixel[0]) * m0;
icFloatNumber g1 = UnitClip(srcPixel[1]) * m1;
icFloatNumber g2 = UnitClip(srcPixel[2]) * m2;
icFloatNumber g3 = UnitClip(srcPixel[3]) * m3;
icFloatNumber g4 = UnitClip(srcPixel[4]) * m4;
icFloatNumber g5 = UnitClip(srcPixel[5]) * m5;
icFloatNumber g0 = m_UnitClipFunc(srcPixel[0]) * m0;
icFloatNumber g1 = m_UnitClipFunc(srcPixel[1]) * m1;
icFloatNumber g2 = m_UnitClipFunc(srcPixel[2]) * m2;
icFloatNumber g3 = m_UnitClipFunc(srcPixel[3]) * m3;
icFloatNumber g4 = m_UnitClipFunc(srcPixel[4]) * m4;
icFloatNumber g5 = m_UnitClipFunc(srcPixel[5]) * m5;

// m_UnitClipFunc points to NoClip
if (g0 < 0)
g0 = 0.0;
if (g1 < 0)
g1 = 0.0;
if (g2 < 0)
g2 = 0.0;
if (g3 < 0)
g3 = 0.0;
if (g4 < 0)
g4 = 0.0;
if (g5 < 0)
g5 = 0.0;

icUInt32Number ig0 = (icUInt32Number)g0;
icUInt32Number ig1 = (icUInt32Number)g1;
Expand Down Expand Up @@ -3096,7 +3152,9 @@ void CIccCLUT::InterpND(icFloatNumber *destPixel, const icFloatNumber *srcPixel,
icUInt32Number* ig = pApply->m_ig;

for (i=0; i<m_nInput; i++) {
g[i] = UnitClip(srcPixel[i]) * m_MaxGridPoint[i];
g[i] = m_UnitClipFunc(srcPixel[i]) * m_MaxGridPoint[i];
if (g[i] < 0)
g[i] = 0.0;
ig[i] = (icUInt32Number)g[i];
s[m_nInput-1-i] = g[i] - ig[i];
if (ig[i]==m_MaxGridPoint[i]) {
Expand Down
4 changes: 2 additions & 2 deletions IccProfLib/IccTagLut.h
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ class ICCPROFLIB_API CIccCLUT
void Iterate(IIccCLUTExec* pExec);
icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccProfile* pProfile=NULL) const;

void SetClipFunc(icCLUTCLIPFUNC ClipFunc) { UnitClip = ClipFunc; }
void SetClipFunc(icCLUTCLIPFUNC ClipFunc) { m_UnitClipFunc = ClipFunc; }

icUInt8Number GetPrecision() { return m_nPrecision; }
void SetPrecision(icUInt8Number nPrecision) { m_nPrecision = nPrecision; }
Expand All @@ -381,7 +381,7 @@ class ICCPROFLIB_API CIccCLUT
void Iterate(std::string &sDescription, icUInt8Number nIndex, icUInt32Number nPos, size_t bufSize, bool bUseLegacy=false );
void SubIterate(IIccCLUTExec* pExec, icUInt8Number nIndex, icUInt32Number nPos);

icCLUTCLIPFUNC UnitClip;
icCLUTCLIPFUNC m_UnitClipFunc;

icUInt8Number m_nReserved2[3];

Expand Down
Loading