Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXhmikosR <xhmikosr@users.sourceforge.net>2012-10-30 20:05:17 +0400
committerXhmikosR <xhmikosr@users.sourceforge.net>2012-10-31 22:01:24 +0400
commit2407c8f49fe0505055c8c069ac2fbef5498e8c4b (patch)
tree5af62b8b3915180629b634eb1f26591064fc5e4d /src/thirdparty/lcms2
parent2d1f6a0db4c5160b980f74d154f5c82dbe018d34 (diff)
update lcms2 to 886e2f5 git
Diffstat (limited to 'src/thirdparty/lcms2')
-rw-r--r--src/thirdparty/lcms2/src/cmscnvrt.c2
-rw-r--r--src/thirdparty/lcms2/src/cmsio0.c35
-rw-r--r--src/thirdparty/lcms2/src/cmslut.c4
-rw-r--r--src/thirdparty/lcms2/src/cmsnamed.c3
-rw-r--r--src/thirdparty/lcms2/src/cmsopt.c2
-rw-r--r--src/thirdparty/lcms2/src/cmssamp.c16
-rw-r--r--src/thirdparty/lcms2/src/cmstypes.c31
-rw-r--r--src/thirdparty/lcms2/src/cmswtpnt.c2
8 files changed, 56 insertions, 39 deletions
diff --git a/src/thirdparty/lcms2/src/cmscnvrt.c b/src/thirdparty/lcms2/src/cmscnvrt.c
index c419ca5d1..f077979c7 100644
--- a/src/thirdparty/lcms2/src/cmscnvrt.c
+++ b/src/thirdparty/lcms2/src/cmscnvrt.c
@@ -241,7 +241,7 @@ cmsBool ComputeAbsoluteIntent(cmsFloat64Number AdaptationState,
// m2 holds CHAD from output white to D50 times abs. col. scaling
// Observer is not adapted, undo the chromatic adaptation
- _cmsMAT3per(m, &m3, ChromaticAdaptationMatrixOut);
+ _cmsMAT3per(m, &m2, ChromaticAdaptationMatrixOut);
m3 = *ChromaticAdaptationMatrixIn;
if (!_cmsMAT3inverse(&m3, &m4)) return FALSE;
diff --git a/src/thirdparty/lcms2/src/cmsio0.c b/src/thirdparty/lcms2/src/cmsio0.c
index 030d701c8..9cc9dcf7f 100644
--- a/src/thirdparty/lcms2/src/cmsio0.c
+++ b/src/thirdparty/lcms2/src/cmsio0.c
@@ -360,13 +360,15 @@ cmsBool FileClose(cmsIOHANDLER* iohandler)
return TRUE;
}
-// Create a iohandler for disk based files. if FileName is NULL, then 'stream' member is also set
-// to NULL and no real writting is performed. This only happens in writting access mode
+// Create a iohandler for disk based files.
cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const char* FileName, const char* AccessMode)
{
cmsIOHANDLER* iohandler = NULL;
FILE* fm = NULL;
+ _cmsAssert(FileName != NULL);
+ _cmsAssert(AccessMode != NULL);
+
iohandler = (cmsIOHANDLER*) _cmsMallocZero(ContextID, sizeof(cmsIOHANDLER));
if (iohandler == NULL) return NULL;
@@ -402,12 +404,9 @@ cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromFile(cmsContext ContextID, const cha
iohandler ->stream = (void*) fm;
iohandler ->UsedSpace = 0;
- // Keep track of the original file
- if (FileName != NULL) {
-
- strncpy(iohandler -> PhysicalFile, FileName, sizeof(iohandler -> PhysicalFile)-1);
- iohandler -> PhysicalFile[sizeof(iohandler -> PhysicalFile)-1] = 0;
- }
+ // Keep track of the original file
+ strncpy(iohandler -> PhysicalFile, FileName, sizeof(iohandler -> PhysicalFile)-1);
+ iohandler -> PhysicalFile[sizeof(iohandler -> PhysicalFile)-1] = 0;
iohandler ->Read = FileRead;
iohandler ->Seek = FileSeek;
@@ -1056,8 +1055,9 @@ cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig)
cmsIOHANDLER* io = Icc ->IOhandler;
cmsTagDescriptor* TagDescriptor;
cmsTagTypeSignature TypeBase;
+ cmsTagTypeSignature Type;
cmsTagTypeHandler* TypeHandler;
-
+ cmsFloat64Number Version = cmsGetProfileVersion((cmsHPROFILE) Icc);
for (i=0; i < Icc -> TagCount; i++) {
@@ -1112,8 +1112,17 @@ cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig)
// Search for support on this tag
TagDescriptor = _cmsGetTagDescriptor(Icc -> TagNames[i]);
if (TagDescriptor == NULL) continue; // Unsupported, ignore it
+
+ if (TagDescriptor ->DecideType != NULL) {
+
+ Type = TagDescriptor ->DecideType(Version, Data);
+ }
+ else {
+
+ Type = TagDescriptor ->SupportedTypes[0];
+ }
- TypeHandler = Icc ->TagTypeHandlers[i];
+ TypeHandler = _cmsGetTagTypeHandler(Type);
if (TypeHandler == NULL) {
cmsSignalError(Icc ->ContextID, cmsERROR_INTERNAL, "(Internal) no handler for tag %x", Icc -> TagNames[i]);
@@ -1128,9 +1137,9 @@ cmsBool SaveTags(_cmsICCPROFILE* Icc, _cmsICCPROFILE* FileOrig)
TypeHandler ->ICCVersion = Icc ->Version;
if (!TypeHandler ->WritePtr(TypeHandler, io, Data, TagDescriptor ->ElemCount)) {
- char String[5];
+ char String[5];
- _cmsTagSignature2String(String, (cmsTagSignature) TypeBase);
+ _cmsTagSignature2String(String, (cmsTagSignature) TypeBase);
cmsSignalError(Icc ->ContextID, cmsERROR_WRITE, "Couldn't write type '%s'", String);
return FALSE;
}
@@ -1520,7 +1529,7 @@ cmsBool CMSEXPORT cmsWriteTag(cmsHPROFILE hProfile, cmsTagSignature sig, const v
// Let the tag descriptor to decide the type base on depending on
// the data. This is useful for example on parametric curves, where
// curves specified by a table cannot be saved as parametric and needs
- // to be revented to single v2-curves, even on v4 profiles.
+ // to be casted to single v2-curves, even on v4 profiles.
Type = TagDescriptor ->DecideType(Version, data);
}
diff --git a/src/thirdparty/lcms2/src/cmslut.c b/src/thirdparty/lcms2/src/cmslut.c
index c970c91c0..cb94090c9 100644
--- a/src/thirdparty/lcms2/src/cmslut.c
+++ b/src/thirdparty/lcms2/src/cmslut.c
@@ -756,6 +756,8 @@ cmsBool CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe, cmsSAMPLER16 Sampler, v
nInputs = clut->Params ->nInputs;
nOutputs = clut->Params ->nOutputs;
+ if (nInputs <= 0) return FALSE;
+ if (nOutputs <= 0) return FALSE;
if (nInputs >= cmsMAXCHANNELS) return FALSE;
if (nOutputs >= MAX_STAGE_CHANNELS) return FALSE;
@@ -1395,6 +1397,8 @@ cmsPipeline* CMSEXPORT cmsPipelineDup(const cmsPipeline* lut)
if (lut == NULL) return NULL;
NewLUT = cmsPipelineAlloc(lut ->ContextID, lut ->InputChannels, lut ->OutputChannels);
+ if (NewLUT == NULL) return NULL;
+
for (mpe = lut ->Elements;
mpe != NULL;
mpe = mpe ->Next) {
diff --git a/src/thirdparty/lcms2/src/cmsnamed.c b/src/thirdparty/lcms2/src/cmsnamed.c
index 98629bf85..38240f9e6 100644
--- a/src/thirdparty/lcms2/src/cmsnamed.c
+++ b/src/thirdparty/lcms2/src/cmsnamed.c
@@ -500,8 +500,9 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn
// Free a list
void CMSEXPORT cmsFreeNamedColorList(cmsNAMEDCOLORLIST* v)
{
+ if (v == NULL) return;
if (v ->List) _cmsFree(v ->ContextID, v ->List);
- if (v) _cmsFree(v ->ContextID, v);
+ _cmsFree(v ->ContextID, v);
}
cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v)
diff --git a/src/thirdparty/lcms2/src/cmsopt.c b/src/thirdparty/lcms2/src/cmsopt.c
index 111a6547e..9e79c13a7 100644
--- a/src/thirdparty/lcms2/src/cmsopt.c
+++ b/src/thirdparty/lcms2/src/cmsopt.c
@@ -385,7 +385,7 @@ cmsBool PatchLUT(cmsStage* CLUT, cmsUInt16Number At[], cmsUInt16Number Value[],
int i, index;
if (CLUT -> Type != cmsSigCLutElemType) {
- cmsSignalError(CLUT->ContextID, cmsERROR_INTERNAL, "(internal) Attempt to PatchLUT on non-lut MPE");
+ cmsSignalError(CLUT->ContextID, cmsERROR_INTERNAL, "(internal) Attempt to PatchLUT on non-lut stage");
return FALSE;
}
diff --git a/src/thirdparty/lcms2/src/cmssamp.c b/src/thirdparty/lcms2/src/cmssamp.c
index 3ea8e951c..2bc09eddc 100644
--- a/src/thirdparty/lcms2/src/cmssamp.c
+++ b/src/thirdparty/lcms2/src/cmssamp.c
@@ -112,8 +112,8 @@ cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput,
cmsCloseProfile(hLab);
if (xform == NULL) {
- // Something went wrong. Get rid of open resources and return zero as black
+ // Something went wrong. Get rid of open resources and return zero as black
BlackPoint -> X = BlackPoint ->Y = BlackPoint -> Z = 0.0;
return FALSE;
}
@@ -144,7 +144,6 @@ cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput,
// Lab (0, 0, 0) -> [Perceptual] Profile -> CMYK -> [Rel. colorimetric] Profile -> Lab
static
cmsBool BlackPointUsingPerceptualBlack(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfile)
-
{
cmsHTRANSFORM hRoundTrip;
cmsCIELab LabIn, LabOut;
@@ -199,7 +198,6 @@ cmsBool CMSEXPORT cmsDetectBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROFILE hProfil
// v4 + perceptual & saturation intents does have its own black point, and it is
// well specified enough to use it. Black point tag is deprecated in V4.
-
if ((cmsGetEncodedICCversion(hProfile) >= 0x4000000) &&
(Intent == INTENT_PERCEPTUAL || Intent == INTENT_SATURATION)) {
@@ -443,12 +441,15 @@ cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROF
// is good enough to be the DestinationBlackPoint,
NearlyStraightMidRange = TRUE;
- for (l=0; l <= 100; l++) {
+ for (l=0; l <= 255; l++) {
- Lab.L = l;
+ Lab.L = (l * 100.0) / 255.0;
Lab.a = InitialLab.a;
Lab.b = InitialLab.b;
+
+ // TODO: Clip a,b (-50, 50)
+
cmsDoTransform(hRoundTrip, &Lab, &destLab, 1);
L = destLab.L;
@@ -523,14 +524,15 @@ cmsBool CMSEXPORT cmsDetectDestinationBlackPoint(cmsCIEXYZ* BlackPoint, cmsHPROF
}
// This part is not on the Adobe paper, but I found is necessary for getting any result.
-
- if (IsMonotonic(n, y)) {
+
+ if (IsMonotonic(n, y)) {
// Monotonic means lower point is stil valid
cmsLab2XYZ(NULL, BlackPoint, &InitialLab);
cmsDeleteTransform(hRoundTrip);
return TRUE;
}
+
// No suitable points, regret and use safer algorithm
if (n == 0) {
diff --git a/src/thirdparty/lcms2/src/cmstypes.c b/src/thirdparty/lcms2/src/cmstypes.c
index 5f9ad67af..ddbd49be9 100644
--- a/src/thirdparty/lcms2/src/cmstypes.c
+++ b/src/thirdparty/lcms2/src/cmstypes.c
@@ -179,10 +179,10 @@ cmsBool ReadPositionTable(struct _cms_typehandler_struct* self,
cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL;
// Let's take the offsets to each element
- ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number *));
+ ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
if (ElementOffsets == NULL) goto Error;
- ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number *));
+ ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
if (ElementSizes == NULL) goto Error;
for (i=0; i < Count; i++) {
@@ -228,10 +228,10 @@ cmsBool WritePositionTable(struct _cms_typehandler_struct* self,
cmsUInt32Number *ElementOffsets = NULL, *ElementSizes = NULL;
// Create table
- ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number *));
+ ElementOffsets = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
if (ElementOffsets == NULL) goto Error;
- ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number *));
+ ElementSizes = (cmsUInt32Number *) _cmsCalloc(io ->ContextID, Count, sizeof(cmsUInt32Number));
if (ElementSizes == NULL) goto Error;
// Keep starting position of curve offsets
@@ -2004,17 +2004,15 @@ cmsBool Write16bitTables(cmsContext ContextID, cmsIOHANDLER* io, _cmsStageToneCu
cmsUInt16Number val;
int nEntries = 256;
+ _cmsAssert(Tables != NULL);
+
nEntries = Tables->TheCurves[0]->nEntries;
for (i=0; i < Tables ->nCurves; i++) {
for (j=0; j < nEntries; j++) {
- if (Tables != NULL)
- val = Tables->TheCurves[i]->Table16[j];
- else
- val = _cmsQuantizeVal(j, nEntries);
-
+ val = Tables->TheCurves[i]->Table16[j];
if (!_cmsWriteUInt16Number(io, val)) return FALSE;
}
}
@@ -3258,7 +3256,7 @@ void *Type_ProfileSequenceDesc_Read(struct _cms_typehandler_struct* self, cmsIOH
SizeOfTag -= sizeof(cmsUInt32Number);
if (!_cmsReadUInt64Number(io, &sec ->attributes)) goto Error;
- if (SizeOfTag < sizeof(cmsUInt32Number)) goto Error;
+ if (SizeOfTag < sizeof(cmsUInt64Number)) goto Error;
SizeOfTag -= sizeof(cmsUInt64Number);
if (!_cmsReadUInt32Number(io, (cmsUInt32Number *)&sec ->technology)) goto Error;
@@ -4263,6 +4261,9 @@ void *Type_MPEclut_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
if (!_cmsReadUInt16Number(io, &InputChans)) return NULL;
if (!_cmsReadUInt16Number(io, &OutputChans)) return NULL;
+ if (InputChans == 0) goto Error;
+ if (OutputChans == 0) goto Error;
+
if (io ->Read(io, Dimensions8, sizeof(cmsUInt8Number), 16) != 16)
goto Error;
@@ -4450,10 +4451,10 @@ cmsBool Type_MPE_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, v
outputChan = cmsPipelineOutputChannels(Lut);
ElemCount = cmsPipelineStageCount(Lut);
- ElementOffsets = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number *));
+ ElementOffsets = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
if (ElementOffsets == NULL) goto Error;
- ElementSizes = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number *));
+ ElementSizes = (cmsUInt32Number *) _cmsCalloc(self ->ContextID, ElemCount, sizeof(cmsUInt32Number));
if (ElementSizes == NULL) goto Error;
// Write the head
@@ -4796,10 +4797,10 @@ typedef struct {
static
cmsBool AllocElem(cmsContext ContextID, _cmsDICelem* e, cmsUInt32Number Count)
{
- e->Offsets = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number *));
+ e->Offsets = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number));
if (e->Offsets == NULL) return FALSE;
- e->Sizes = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number *));
+ e->Sizes = (cmsUInt32Number *) _cmsCalloc(ContextID, Count, sizeof(cmsUInt32Number));
if (e->Sizes == NULL) {
_cmsFree(ContextID, e -> Offsets);
@@ -4815,7 +4816,7 @@ static
void FreeElem(_cmsDICelem* e)
{
if (e ->Offsets != NULL) _cmsFree(e -> ContextID, e -> Offsets);
- if (e ->Sizes != NULL) _cmsFree(e -> ContextID, e ->Sizes);
+ if (e ->Sizes != NULL) _cmsFree(e -> ContextID, e -> Sizes);
e->Offsets = e ->Sizes = NULL;
}
diff --git a/src/thirdparty/lcms2/src/cmswtpnt.c b/src/thirdparty/lcms2/src/cmswtpnt.c
index 7c25aca2a..19dc67185 100644
--- a/src/thirdparty/lcms2/src/cmswtpnt.c
+++ b/src/thirdparty/lcms2/src/cmswtpnt.c
@@ -1,7 +1,7 @@
//---------------------------------------------------------------------------------
//
// Little Color Management System
-// Copyright (c) 1998-2010 Marti Maria Saguer
+// Copyright (c) 1998-2012 Marti Maria Saguer
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the "Software"),