summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarti Maria <info@littlecms.com>2011-02-08 11:47:55 +0100
committerMarti Maria <info@littlecms.com>2011-02-08 11:47:55 +0100
commitff8d038056db6ba1d995e7efb77eb7d9406e63c3 (patch)
treeeb470bc08889b11e74b8d50c153eae5fc51f3ea5
parent85b4930a0d9c4bc885c90e2b880c0db907fe7915 (diff)
downloadlcms2-ff8d038056db6ba1d995e7efb77eb7d9406e63c3.tar.gz
Fix for a cache removal issue introduced by previous commit
-rw-r--r--src/cmsxform.c50
-rw-r--r--src/lcms2_internal.h9
2 files changed, 23 insertions, 36 deletions
diff --git a/src/cmsxform.c b/src/cmsxform.c
index 1782456..0b555e5 100644
--- a/src/cmsxform.c
+++ b/src/cmsxform.c
@@ -92,7 +92,7 @@ void CMSEXPORT cmsDeleteTransform(cmsHTRANSFORM hTransform)
_cmsFree(p ->ContextID, (void *) p);
}
-// Apply transform
+// Apply transform.
void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
const void* InputBuffer,
void* OutputBuffer,
@@ -100,9 +100,8 @@ void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
{
_cmsTRANSFORM* p = (_cmsTRANSFORM*) Transform;
- _cmsCACHE Cache;
- p -> xform(p, &Cache, InputBuffer, OutputBuffer, Size);
+ p -> xform(p, InputBuffer, OutputBuffer, Size);
}
@@ -112,7 +111,6 @@ void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
// Note that because extended range, we can use a -1.0 value for out of gamut in this case.
static
void FloatXFORM(_cmsTRANSFORM* p,
- _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -157,8 +155,6 @@ void FloatXFORM(_cmsTRANSFORM* p,
// Back to asked representation
output = p -> ToOutputFloat(p, fOut, output, Size);
}
-
- cmsUNUSED_PARAMETER(Cache);
}
// 16 bit precision -----------------------------------------------------------------------------------------------------------
@@ -166,7 +162,6 @@ void FloatXFORM(_cmsTRANSFORM* p,
// Null transformation, only applies formatters. No caché
static
void NullXFORM(_cmsTRANSFORM* p,
- _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -184,15 +179,12 @@ void NullXFORM(_cmsTRANSFORM* p,
accum = p -> FromInput(p, wIn, accum, Size);
output = p -> ToOutput(p, wIn, output, Size);
}
-
- cmsUNUSED_PARAMETER(Cache);
}
// No gamut check, no cache, 16 bits
static
void PrecalculatedXFORM(_cmsTRANSFORM* p,
- _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -211,8 +203,6 @@ void PrecalculatedXFORM(_cmsTRANSFORM* p,
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
output = p -> ToOutput(p, wOut, output, Size);
}
-
- cmsUNUSED_PARAMETER(Cache);
}
@@ -239,7 +229,6 @@ void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
// Gamut check, No caché, 16 bits.
static
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
- _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -258,15 +247,12 @@ void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
TransformOnePixelWithGamutCheck(p, wIn, wOut);
output = p -> ToOutput(p, wOut, output, Size);
}
-
- cmsUNUSED_PARAMETER(Cache);
}
// No gamut check, Caché, 16 bits,
static
void CachedXFORM(_cmsTRANSFORM* p,
- _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -274,6 +260,7 @@ void CachedXFORM(_cmsTRANSFORM* p,
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, n;
+ _cmsCACHE Cache;
accum = (cmsUInt8Number*) in;
output = (cmsUInt8Number*) out;
@@ -283,22 +270,23 @@ void CachedXFORM(_cmsTRANSFORM* p,
memset(wIn, 0, sizeof(wIn));
memset(wOut, 0, sizeof(wOut));
-
+ // Get copy of zero cache
+ memmove(&Cache, &p ->Cache, sizeof(Cache));
for (i=0; i < n; i++) {
accum = p -> FromInput(p, wIn, accum, Size);
- if (memcmp(wIn, Cache ->CacheIn, sizeof(Cache -> CacheIn)) == 0) {
+ if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
- memmove(wOut, Cache -> CacheOut, sizeof(Cache -> CacheOut));
+ memmove(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
}
else {
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
- memmove(Cache -> CacheIn, wIn, sizeof(Cache -> CacheIn));
- memmove(Cache -> CacheOut, wOut, sizeof(Cache -> CacheOut));
+ memmove(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
+ memmove(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
}
output = p -> ToOutput(p, wOut, output, Size);
@@ -310,7 +298,6 @@ void CachedXFORM(_cmsTRANSFORM* p,
// All those nice features together
static
void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
- _cmsCACHE* Cache,
const void* in,
void* out, cmsUInt32Number Size)
{
@@ -318,6 +305,7 @@ void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
cmsUInt8Number* output;
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
cmsUInt32Number i, n;
+ _cmsCACHE Cache;
accum = (cmsUInt8Number*) in;
output = (cmsUInt8Number*) out;
@@ -327,18 +315,20 @@ void CachedXFORMGamutCheck(_cmsTRANSFORM* p,
memset(wIn, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
memset(wOut, 0, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
+ // Get copy of zero cache
+ memmove(&Cache, &p ->Cache, sizeof(Cache));
for (i=0; i < n; i++) {
accum = p -> FromInput(p, wIn, accum, Size);
- if (memcmp(wIn, Cache -> CacheIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS) == 0) {
- memmove(wOut, Cache -> CacheOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
+ if (memcmp(wIn, Cache.CacheIn, sizeof(Cache.CacheIn)) == 0) {
+ memmove(wOut, Cache.CacheOut, sizeof(Cache.CacheOut));
}
else {
TransformOnePixelWithGamutCheck(p, wIn, wOut);
- memmove(Cache -> CacheIn, wIn, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
- memmove(Cache -> CacheOut, wOut, sizeof(cmsUInt16Number) * cmsMAXCHANNELS);
+ memmove(Cache.CacheIn, wIn, sizeof(Cache.CacheIn));
+ memmove(Cache.CacheOut, wOut, sizeof(Cache.CacheOut));
}
output = p -> ToOutput(p, wOut, output, Size);
@@ -559,7 +549,6 @@ cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
xform ->ExitColorSpace = ExitColorSpace;
xform ->Lut = Lut;
-
// Create a gamut check LUT if requested
if (hGamutProfile != NULL && (dwFlags & cmsFLAGS_GAMUTCHECK))
xform ->GamutCheck = _cmsCreateGamutCheckPipeline(ContextID, hProfiles,
@@ -604,14 +593,14 @@ cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
// If this is a cached transform, init first value, which is zero (16 bits only)
if (!(dwFlags & cmsFLAGS_NOCACHE)) {
- memset(&xform ->CacheIn, 0, sizeof(xform ->CacheIn));
+ memset(&xform ->Cache.CacheIn, 0, sizeof(xform ->Cache.CacheIn));
if (xform ->GamutCheck != NULL) {
- TransformOnePixelWithGamutCheck(xform, xform ->CacheIn, xform->CacheOut);
+ TransformOnePixelWithGamutCheck(xform, xform ->Cache.CacheIn, xform->Cache.CacheOut);
}
else {
- xform ->Lut ->Eval16Fn(xform ->CacheIn, xform->CacheOut, xform -> Lut->Data);
+ xform ->Lut ->Eval16Fn(xform ->Cache.CacheIn, xform->Cache.CacheOut, xform -> Lut->Data);
}
}
@@ -620,7 +609,6 @@ cmsHTRANSFORM CMSEXPORT cmsCreateExtendedTransform(cmsContext ContextID,
}
// Multiprofile transforms: Gamut check is not available here, as it is unclear from which profile the gamut comes.
-
cmsHTRANSFORM CMSEXPORT cmsCreateMultiprofileTransformTHR(cmsContext ContextID,
cmsHPROFILE hProfiles[],
cmsUInt32Number nProfiles,
diff --git a/src/lcms2_internal.h b/src/lcms2_internal.h
index a0f8117..61c2c65 100644
--- a/src/lcms2_internal.h
+++ b/src/lcms2_internal.h
@@ -530,16 +530,16 @@ cmsFormatter _cmsGetFormatter(cmsUInt32Number Type, // Specific type
struct _cmstransform_struct;
typedef struct {
+
// 1-pixel cache (16 bits only)
cmsUInt16Number CacheIn[cmsMAXCHANNELS];
cmsUInt16Number CacheOut[cmsMAXCHANNELS];
-} _cmsCACHE;
+} _cmsCACHE;
// Full xform
typedef void (* _cmsTransformFn)(struct _cmstransform_struct *Transform,
- _cmsCACHE* Cache,
const void* InputBuffer,
void* OutputBuffer,
cmsUInt32Number Size);
@@ -566,9 +566,8 @@ typedef struct _cmstransform_struct {
cmsFormatterFloat FromInputFloat;
cmsFormatterFloat ToOutputFloat;
- // 1-pixel cache (16 bits only)
- cmsUInt16Number CacheIn[cmsMAXCHANNELS];
- cmsUInt16Number CacheOut[cmsMAXCHANNELS];
+ // 1-pixel cache seed for zero as input (16 bits, read only)
+ _cmsCACHE Cache;
// A MPE LUT holding the full (optimized) transform
cmsPipeline* Lut;