summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/LittleCMS2.0 API.pdfbin966905 -> 966710 bytes
-rw-r--r--include/lcms2.h37
-rw-r--r--src/cmscnvrt.c7
-rw-r--r--src/cmserr.c6
-rw-r--r--src/cmsgmt.c4
-rw-r--r--src/cmsopt.c8
-rw-r--r--src/cmspack.c38
-rw-r--r--src/cmsps2.c6
-rw-r--r--src/cmssamp.c2
-rw-r--r--src/cmsxform.c21
-rw-r--r--testbed/testcms2.c6
-rw-r--r--utils/transicc/transicc.c6
12 files changed, 79 insertions, 62 deletions
diff --git a/doc/LittleCMS2.0 API.pdf b/doc/LittleCMS2.0 API.pdf
index 5ad8ccc..5e7addb 100644
--- a/doc/LittleCMS2.0 API.pdf
+++ b/doc/LittleCMS2.0 API.pdf
Binary files differ
diff --git a/include/lcms2.h b/include/lcms2.h
index 16470f1..65254fd 100644
--- a/include/lcms2.h
+++ b/include/lcms2.h
@@ -23,7 +23,7 @@
//
//---------------------------------------------------------------------------------
//
-// Version 2.0-beta3
+// Version 2.0-beta4
//
#ifndef _lcms2_H
@@ -606,8 +606,9 @@ typedef void* cmsHTRANSFORM;
// Format of pixel is defined by one cmsUInt32Number, using bit fields as follows
//
-// O TTTTT U Y F P X S EEE CCCC BBB
+// A O TTTTT U Y F P X S EEE CCCC BBB
//
+// A: Floating point -- With this flag we can differentiate 16 bits as float and as int
// O: Optimized -- previous optimization already returns the final 8-bit value
// T: Pixeltype
// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
@@ -619,7 +620,7 @@ typedef void* cmsHTRANSFORM;
// B: bytes per sample
// Y: Swap first - changes ABGR to BGRA and KCMY to CMYK
-
+#define FLOAT_SH(a) ((a) << 22)
#define OPTIMIZED_SH(s) ((s) << 21)
#define COLORSPACE_SH(s) ((s) << 16)
#define SWAPFIRST_SH(s) ((s) << 14)
@@ -632,6 +633,7 @@ typedef void* cmsHTRANSFORM;
#define BYTES_SH(b) (b)
// These macros unpack format specifiers into integers
+#define T_FLOAT(a) (((a)>>22)&1)
#define T_OPTIMIZED(o) (((o)>>21)&1)
#define T_COLORSPACE(s) (((s)>>16)&31)
#define T_SWAPFIRST(s) (((s)>>14)&1)
@@ -841,18 +843,19 @@ typedef void* cmsHTRANSFORM;
#define TYPE_NAMED_COLOR_INDEX (CHANNELS_SH(1)|BYTES_SH(2))
// Float formatters.
-#define TYPE_XYZ_FLT (COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(4))
-#define TYPE_Lab_FLT (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(4))
-#define TYPE_GRAY_FLT (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4))
-#define TYPE_RGB_FLT (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4))
-#define TYPE_CMYK_FLT (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
-
-// Double formatters. NOTE THAT 'BYTES' FIELD IS SET TO ZERO!
-#define TYPE_XYZ_DBL (COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(0))
-#define TYPE_Lab_DBL (COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(0))
-#define TYPE_GRAY_DBL (COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(0))
-#define TYPE_RGB_DBL (COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
-#define TYPE_CMYK_DBL (COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
+#define TYPE_XYZ_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(4))
+#define TYPE_Lab_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(4))
+#define TYPE_GRAY_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(4))
+#define TYPE_RGB_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(4))
+#define TYPE_CMYK_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(4))
+
+// Floating point formatters.
+// NOTE THAT 'BYTES' FIELD IS SET TO ZERO ON DLB because 8 bytes overflows the bitfield
+#define TYPE_XYZ_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_XYZ)|CHANNELS_SH(3)|BYTES_SH(0))
+#define TYPE_Lab_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_Lab)|CHANNELS_SH(3)|BYTES_SH(0))
+#define TYPE_GRAY_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(0))
+#define TYPE_RGB_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
+#define TYPE_CMYK_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
#endif
@@ -1356,8 +1359,8 @@ CMSAPI int CMSEXPORT _cmsLCMScolorSpace(cmsColorSpaceSignat
CMSAPI cmsUInt32Number CMSEXPORT cmsChannelsOf(cmsColorSpaceSignature ColorSpace);
// Build a suitable formatter for the colorspace of this profile
-CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes);
-CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes);
+CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
+CMSAPI cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat);
// Localized info
diff --git a/src/cmscnvrt.c b/src/cmscnvrt.c
index 6281280..203f9bd 100644
--- a/src/cmscnvrt.c
+++ b/src/cmscnvrt.c
@@ -460,11 +460,13 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
cmsProfileClassSignature ClassSig;
cmsUInt32Number i, Intent;
+ // For safety
+ if (nProfiles == 0) return NULL;
+
// Allocate an empty LUT for holding the result. 0 as channel count means 'undefined'
Result = cmsPipelineAlloc(ContextID, 0, 0);
if (Result == NULL) return NULL;
-
CurrentColorSpace = cmsGetColorSpace(hProfiles[0]);
for (i=0; i < nProfiles; i++) {
@@ -875,7 +877,8 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
// Same as anterior, but lab in the 0..1 range
bp.cmyk2Lab = cmsCreateTransformTHR(ContextID, hProfiles[nProfiles-1],
- CHANNELS_SH(4)|BYTES_SH(4), hLab, CHANNELS_SH(3)|BYTES_SH(4),
+ FLOAT_SH(1)|CHANNELS_SH(4)|BYTES_SH(4), hLab,
+ FLOAT_SH(1)|CHANNELS_SH(3)|BYTES_SH(4),
INTENT_RELATIVE_COLORIMETRIC,
cmsFLAGS_NOCACHE|cmsFLAGS_NOOPTIMIZE);
cmsCloseProfile(hLab);
diff --git a/src/cmserr.c b/src/cmserr.c
index 260206e..4a55024 100644
--- a/src/cmserr.c
+++ b/src/cmserr.c
@@ -66,9 +66,9 @@ long int CMSEXPORT cmsfilelength(FILE* f)
// User may override this behaviour by using a memory plug-in, which basically replaces
// the default memory management functions. In this case, no check is performed and it
-// is up to the plug-in writter to keep in the safe side. There are only two functions
-// required to be implemented: malloc and free, although the user may want to replace
-// the optional mallocZero, realloc, calloc and dup as well.
+// is up to the plug-in writter to keep in the safe side. There are only three functions
+// required to be implemented: malloc, realloc and free, although the user may want to
+// replace the optional mallocZero, calloc and dup as well.
cmsBool _cmsRegisterMemHandlerPlugin(cmsPluginBase* Plugin);
diff --git a/src/cmsgmt.c b/src/cmsgmt.c
index 05d9653..fbec2d0 100644
--- a/src/cmsgmt.c
+++ b/src/cmsgmt.c
@@ -368,7 +368,7 @@ cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
// Does create the forward step. Lab double to cmsFloat32Number
- dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(4));
+ dwFormat = (FLOAT_SH(1)|CHANNELS_SH(nChannels)|BYTES_SH(4));
Chain.hForward = cmsCreateTransformTHR(ContextID,
hLab, TYPE_Lab_DBL,
hGamut, dwFormat,
@@ -471,7 +471,7 @@ cmsFloat64Number CMSEXPORT cmsDetectTAC(cmsHPROFILE hProfile)
}
// Create a fake formatter for result
- dwFormatter = cmsFormatterForColorspaceOfProfile(hProfile, 4);
+ dwFormatter = cmsFormatterForColorspaceOfProfile(hProfile, 4, TRUE);
bp.nOutputChans = T_CHANNELS(dwFormatter);
bp.MaxTAC = 0; // Initial TAC is 0
diff --git a/src/cmsopt.c b/src/cmsopt.c
index 8cf75a9..8670b4f 100644
--- a/src/cmsopt.c
+++ b/src/cmsopt.c
@@ -580,7 +580,6 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
}
// Allocate the CLUT
-
CLUT = cmsStageAllocCLut16bit(Src ->ContextID, nGridPoints, Src ->InputChannels, Src->OutputChannels, NULL);
if (CLUT == NULL) return FALSE;
@@ -611,7 +610,6 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
// Now its time to do the sampling. We have to ignore pre/post linearization
// The source LUT whithout pre/post curves is passed as parameter.
-
if (!cmsStageSampleCLut16bit(CLUT, XFormSampler16, (void*) Src, 0)) {
// Ops, something went wrong, Restore stages
@@ -695,7 +693,6 @@ void SlopeLimiting(cmsToneCurve* g)
BeginVal = 0; EndVal = 0xffff;
}
-
// Compute slope and offset for begin of curve
Val = g ->Table16[AtBegin];
Slope = (Val - BeginVal) / AtBegin;
@@ -1128,7 +1125,6 @@ Curves16Data* CurvesAlloc(cmsContext ContextID, int nCurves, int nElements, cmsT
c16 ->Curves[i][j] = cmsEvalToneCurve16(G[i], (cmsUInt16Number) j);
}
}
-
}
return c16;
@@ -1261,7 +1257,6 @@ cmsBool OptimizeByJoiningCurves(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUI
*dwFlags |= cmsFLAGS_NOCACHE;
_cmsPipelineSetOptimizationParameters(Dest, FastEvaluateCurves16, c16, CurvesFree, CurvesDup);
}
-
}
else {
@@ -1318,7 +1313,7 @@ void* DupMatShaper(cmsContext ContextID, const void* Data)
// A fast matrix-shaper evaluator for 8 bits. This is a bit ticky since I'm using 1.14 signed fixed point
// to accomplish some performance. Actually it takes 256x3 16 bits tables and 16385 x 3 tables of 8 bits,
-// in total about 50K, and the performance boot is huge!
+// in total about 50K, and the performance boost is huge!
static
void MatShaperEval16(register const cmsUInt16Number In[],
register cmsUInt16Number Out[],
@@ -1439,7 +1434,6 @@ cmsBool SetMatShaper(cmsPipeline* Dest, cmsToneCurve* Curve1[3], cmsMAT3* Mat, c
}
}
-
// Mark as optimized for faster formatter
if (Is8Bits)
*OutputFormat |= OPTIMIZED_SH(1);
diff --git a/src/cmspack.c b/src/cmspack.c
index 338daca..164b508 100644
--- a/src/cmspack.c
+++ b/src/cmspack.c
@@ -2240,8 +2240,8 @@ static cmsFormatters16 InputFormatters16[] = {
{ TYPE_Lab_DBL, ANYPLANAR, UnrollLabDoubleTo16},
{ TYPE_XYZ_DBL, ANYPLANAR, UnrollXYZDoubleTo16},
{ TYPE_GRAY_DBL, 0, UnrollDouble1Chan},
- { BYTES_SH(0), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, UnrollDoubleTo16},
- { BYTES_SH(4), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, UnrollFloatTo16},
+ { FLOAT_SH(1)|BYTES_SH(0), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, UnrollDoubleTo16},
+ { FLOAT_SH(1)|BYTES_SH(4), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, UnrollFloatTo16},
{ CHANNELS_SH(1)|BYTES_SH(1), ANYSPACE, Unroll1Byte},
@@ -2304,8 +2304,8 @@ static cmsFormattersFloat InputFormattersFloat[] = {
{ TYPE_XYZ_DBL, ANYPLANAR, UnrollXYZDoubleToFloat},
{ TYPE_XYZ_FLT, ANYPLANAR, UnrollXYZFloatToFloat},
- { BYTES_SH(4), ANYPLANAR|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollFloatsToFloat},
- { BYTES_SH(0), ANYPLANAR|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollDoublesToFloat},
+ { FLOAT_SH(1)|BYTES_SH(4), ANYPLANAR|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollFloatsToFloat},
+ { FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollDoublesToFloat},
};
@@ -2349,8 +2349,8 @@ static cmsFormatters16 OutputFormatters16[] = {
{ TYPE_Lab_DBL, ANYPLANAR, PackLabDoubleFrom16},
{ TYPE_XYZ_DBL, ANYPLANAR, PackXYZDoubleFrom16},
- { BYTES_SH(0), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackDoubleFrom16},
- { BYTES_SH(4), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackFloatFrom16},
+ { FLOAT_SH(1)|BYTES_SH(0), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackDoubleFrom16},
+ { FLOAT_SH(1)|BYTES_SH(4), ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackFloatFrom16},
{ CHANNELS_SH(1)|BYTES_SH(1), ANYSPACE, Pack1Byte},
{ CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(1), ANYSPACE, Pack1ByteSkip1},
@@ -2428,10 +2428,12 @@ static cmsFormattersFloat OutputFormattersFloat[] = {
{ TYPE_XYZ_FLT, ANYPLANAR, PackXYZFloatFromFloat},
{ TYPE_Lab_DBL, ANYPLANAR, PackLabDoubleFromFloat},
{ TYPE_XYZ_DBL, ANYPLANAR, PackXYZDoubleFromFloat},
- { BYTES_SH(4), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackChunkyFloatsFromFloat },
- { BYTES_SH(4)|PLANAR_SH(1), ANYEXTRA|ANYCHANNELS|ANYSPACE, PackPlanarFloatsFromFloat},
- { BYTES_SH(0), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackChunkyDoublesFromFloat },
- { BYTES_SH(0)|PLANAR_SH(1), ANYEXTRA|ANYCHANNELS|ANYSPACE, PackPlanarDoublesFromFloat},
+ { FLOAT_SH(1)|BYTES_SH(4),
+ ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackChunkyFloatsFromFloat },
+ { FLOAT_SH(1)|BYTES_SH(4)|PLANAR_SH(1), ANYEXTRA|ANYCHANNELS|ANYSPACE, PackPlanarFloatsFromFloat},
+ { FLOAT_SH(1)|BYTES_SH(0),
+ ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackChunkyDoublesFromFloat },
+ { FLOAT_SH(1)|BYTES_SH(0)|PLANAR_SH(1), ANYEXTRA|ANYCHANNELS|ANYSPACE, PackPlanarDoublesFromFloat},
};
@@ -2530,9 +2532,7 @@ cmsFormatter _cmsGetFormatter(cmsUInt32Number Type, // Specific type, i.
// Return whatever given formatter refers to float values
cmsBool _cmsFormatterIsFloat(cmsUInt32Number Type)
{
- int Bytes = T_BYTES(Type);
-
- return (Bytes == 4) || (Bytes == 0);
+ return T_FLOAT(Type) ? TRUE : FALSE;
}
// Return whatever given formatter refers to 8 bits
@@ -2544,26 +2544,28 @@ cmsBool _cmsFormatterIs8bit(cmsUInt32Number Type)
}
// Build a suitable formatter for the colorspace of this profile
-cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes)
+cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat)
{
cmsColorSpaceSignature ColorSpace = cmsGetColorSpace(hProfile);
- int ColorSpaceBits = _cmsLCMScolorSpace(ColorSpace);
+ cmsUInt32Number ColorSpaceBits = _cmsLCMScolorSpace(ColorSpace);
cmsUInt32Number nOutputChans = cmsChannelsOf(ColorSpace);
+ cmsUInt32Number Float = lIsFloat ? 1 : 0;
// Create a fake formatter for result
- return COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);
+ return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);
}
// Build a suitable formatter for the colorspace of this profile
-cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes)
+cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat)
{
cmsColorSpaceSignature ColorSpace = cmsGetPCS(hProfile);
int ColorSpaceBits = _cmsLCMScolorSpace(ColorSpace);
cmsUInt32Number nOutputChans = cmsChannelsOf(ColorSpace);
+ cmsUInt32Number Float = lIsFloat ? 1 : 0;
// Create a fake formatter for result
- return COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);
+ return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);
}
diff --git a/src/cmsps2.c b/src/cmsps2.c
index b197270..04a572d 100644
--- a/src/cmsps2.c
+++ b/src/cmsps2.c
@@ -870,7 +870,7 @@ int WriteInputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, int Intent, cmsUInt32Nu
// Does create a device-link based transform.
// The DeviceLink is next dumped as working CSA.
- InputFormat = cmsFormatterForColorspaceOfProfile(hProfile, 2);
+ InputFormat = cmsFormatterForColorspaceOfProfile(hProfile, 2, FALSE);
nChannels = T_CHANNELS(InputFormat);
@@ -1284,7 +1284,7 @@ int WriteOutputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, int Intent, cmsUInt32N
hLab = cmsCreateLab4ProfileTHR(m ->ContextID, NULL);
if (hLab == NULL) return 0;
- OutputFormat = cmsFormatterForColorspaceOfProfile(hProfile, 2);
+ OutputFormat = cmsFormatterForColorspaceOfProfile(hProfile, 2, FALSE);
nChannels = T_CHANNELS(OutputFormat);
ColorSpace = cmsGetColorSpace(hProfile);
@@ -1407,7 +1407,7 @@ int WriteNamedColorCRD(cmsIOHANDLER* m, cmsHPROFILE hNamedColor, int Intent, cms
cmsNAMEDCOLORLIST* NamedColorList;
- OutputFormat = cmsFormatterForColorspaceOfProfile(hNamedColor, 2);
+ OutputFormat = cmsFormatterForColorspaceOfProfile(hNamedColor, 2, FALSE);
nColorant = T_CHANNELS(OutputFormat);
diff --git a/src/cmssamp.c b/src/cmssamp.c
index 6444d38..090d96d 100644
--- a/src/cmssamp.c
+++ b/src/cmssamp.c
@@ -82,7 +82,7 @@ cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput,
}
// Create a formatter which has n channels and floating point
- dwFormat = cmsFormatterForColorspaceOfProfile(hInput, 2);
+ dwFormat = cmsFormatterForColorspaceOfProfile(hInput, 2, FALSE);
// Try to get black by using black colorant
Space = cmsGetColorSpace(hInput);
diff --git a/src/cmsxform.c b/src/cmsxform.c
index a0bf4c6..f9f3ff4 100644
--- a/src/cmsxform.c
+++ b/src/cmsxform.c
@@ -363,9 +363,6 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsUInt32Number InputFo
_cmsTRANSFORM* p = (_cmsTRANSFORM*) _cmsMallocZero(ContextID, sizeof(_cmsTRANSFORM));
if (!p) return NULL;
- // Create a mutex for shared memory
- LCMS_CREATE_LOCK(&p->rwlock);
-
// Check whatever this is a true floating point transform
if (_cmsFormatterIsFloat(InputFormat) && _cmsFormatterIsFloat(OutputFormat)) {
@@ -373,6 +370,13 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsUInt32Number InputFo
p ->FromInputFloat = _cmsGetFormatter(InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
p ->ToOutputFloat = _cmsGetFormatter(OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
+ if (p ->FromInputFloat == NULL || p ->ToOutputFloat == NULL) {
+
+ cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported raster format");
+ _cmsFree(ContextID, p);
+ return NULL;
+ }
+
// Float transforms don't use caché, always are non-NULL
p ->xform = FloatXFORM;
}
@@ -381,6 +385,13 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsUInt32Number InputFo
p ->FromInput = _cmsGetFormatter(InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_16BITS).Fmt16;
p ->ToOutput = _cmsGetFormatter(OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
+ if (p ->FromInput == NULL || p ->ToOutput == NULL) {
+
+ cmsSignalError(ContextID, cmsERROR_UNKNOWN_EXTENSION, "Unsupported raster format");
+ _cmsFree(ContextID, p);
+ return NULL;
+ }
+
if (dwFlags & cmsFLAGS_NULLTRANSFORM) {
p ->xform = NullXFORM;
@@ -404,6 +415,10 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsUInt32Number InputFo
}
}
+
+ // Create a mutex for shared memory
+ LCMS_CREATE_LOCK(&p->rwlock);
+
p ->InputFormat = InputFormat;
p ->OutputFormat = OutputFormat;
p ->dwOriginalFlags = dwFlags;
diff --git a/testbed/testcms2.c b/testbed/testcms2.c
index 7b7f0ed..17b2a1d 100644
--- a/testbed/testcms2.c
+++ b/testbed/testcms2.c
@@ -463,7 +463,7 @@ cmsHPROFILE CreateFakeCMYK(cmsFloat64Number InkLimit, cmsBool lUseAboveRGB)
cmsContext ContextID;
FakeCMYKParams p;
cmsHPROFILE hLab, hsRGB, hLimit;
- cmsUInt16Number cmykfrm;
+ cmsUInt32Number cmykfrm;
if (lUseAboveRGB)
@@ -474,7 +474,7 @@ cmsHPROFILE CreateFakeCMYK(cmsFloat64Number InkLimit, cmsBool lUseAboveRGB)
hLab = cmsCreateLab4Profile(NULL);
hLimit = cmsCreateInkLimitingDeviceLink(cmsSigCmykData, InkLimit);
- cmykfrm = BYTES_SH(0)|CHANNELS_SH(4);
+ cmykfrm = FLOAT_SH(1) | BYTES_SH(0)|CHANNELS_SH(4);
p.hLab2sRGB = cmsCreateTransform(hLab, TYPE_Lab_16, hsRGB, TYPE_RGB_DBL, INTENT_PERCEPTUAL, cmsFLAGS_NOOPTIMIZE|cmsFLAGS_NOCACHE);
p.sRGB2Lab = cmsCreateTransform(hsRGB, TYPE_RGB_DBL, hLab, TYPE_Lab_16, INTENT_PERCEPTUAL, cmsFLAGS_NOOPTIMIZE|cmsFLAGS_NOCACHE);
p.hIlimit = cmsCreateTransform(hLimit, cmykfrm, NULL, TYPE_CMYK_16, INTENT_PERCEPTUAL, cmsFLAGS_NOOPTIMIZE|cmsFLAGS_NOCACHE);
@@ -7380,7 +7380,7 @@ int main(int argc, char* argv[])
Check("CMYK roundtrip on perceptual transform", CheckCMYKRoundtrip);
Check("CMYK perceptual transform", CheckCMYKPerceptual);
- //Check("CMYK rel.col. transform", CheckCMYKRelCol);
+ // Check("CMYK rel.col. transform", CheckCMYKRelCol);
Check("Black ink only preservation", CheckKOnlyBlackPreserving);
Check("Black plane preservation", CheckKPlaneBlackPreserving);
diff --git a/utils/transicc/transicc.c b/utils/transicc/transicc.c
index 8f0d849..16aafaa 100644
--- a/utils/transicc/transicc.c
+++ b/utils/transicc/transicc.c
@@ -480,16 +480,16 @@ cmsBool OpenTransforms(void)
// Input is always in floating point
- dwIn = cmsFormatterForColorspaceOfProfile(hInput, 0);
+ dwIn = cmsFormatterForColorspaceOfProfile(hInput, 0, TRUE);
if (lIsDeviceLink) {
- dwOut = cmsFormatterForPCSOfProfile(hInput, lIsFloat ? 0 : 2);
+ dwOut = cmsFormatterForPCSOfProfile(hInput, lIsFloat ? 0 : 2, lIsFloat);
}
else {
// 16 bits or floating point (only on output)
- dwOut = cmsFormatterForColorspaceOfProfile(hOutput, lIsFloat ? 0 : 2);
+ dwOut = cmsFormatterForColorspaceOfProfile(hOutput, lIsFloat ? 0 : 2, lIsFloat);
}
// For named color, there is a specialized formatter