Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to lcms 2.8 #808

Merged
merged 1 commit into from
Aug 6, 2016
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
6 changes: 3 additions & 3 deletions thirdparty/liblcms2/include/lcms2.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//
//---------------------------------------------------------------------------------
//
// Version 2.8beta0
// Version 2.8
//

#ifndef _lcms2_H
Expand Down Expand Up @@ -656,7 +656,7 @@ typedef void* cmsHTRANSFORM;
// T: Pixeltype
// F: Flavor 0=MinIsBlack(Chocolate) 1=MinIsWhite(Vanilla)
// P: Planar? 0=Chunky, 1=Planar
// X: swap 16 bps endianess?
// X: swap 16 bps endianness?
// S: Do swap? ie, BGR, KYMC
// E: Extra samples
// C: Channels (Samples per pixel)
Expand Down Expand Up @@ -1016,7 +1016,7 @@ CMSAPI long int CMSEXPORT cmsfilelength(FILE* f);
// Context handling --------------------------------------------------------------------------------------------------------

// Each context holds its owns globals and its own plug-ins. There is a global context with the id = 0 for lecacy compatibility
// though using the global context is not recomended. Proper context handling makes lcms more thread-safe.
// though using the global context is not recommended. Proper context handling makes lcms more thread-safe.

typedef struct _cmsContext_struct* cmsContext;

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/liblcms2/include/lcms2_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ struct _cms_io_handler {
const void* Buffer);
};

// Endianess adjust functions
// Endianness adjust functions
CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
Expand Down
153 changes: 95 additions & 58 deletions thirdparty/liblcms2/src/cmsalpha.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,74 +408,111 @@ void ComputeComponentIncrements(cmsUInt32Number Format,

// Handles extra channels copying alpha if requested by the flags
void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
void* out,
cmsUInt32Number PixelsPerLine,
cmsUInt32Number LineCount,
const cmsStride* Stride)
{
size_t i, j, k;
cmsUInt32Number nExtra;
cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
cmsUInt32Number DestIncrements[cmsMAXCHANNELS];
cmsUInt32Number SourceStrideIncrements[cmsMAXCHANNELS];
cmsUInt32Number DestStrideIncrements[cmsMAXCHANNELS];

cmsUInt8Number* SourcePtr[cmsMAXCHANNELS];
cmsUInt8Number* DestPtr[cmsMAXCHANNELS];

cmsFormatterAlphaFn copyValueFn;

// Make sure we need some copy
if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA))
return;

// Make sure we have same number of alpha channels. If not, just return as this should be checked at transform creation time.
nExtra = T_EXTRA(p->InputFormat);
if (nExtra != T_EXTRA(p->OutputFormat))
return;

// Anything to do?
if (nExtra == 0)
return;
void* out,
cmsUInt32Number PixelsPerLine,
cmsUInt32Number LineCount,
const cmsStride* Stride)
{
cmsUInt32Number i, j, k;
cmsUInt32Number nExtra;
cmsUInt32Number SourceStartingOrder[cmsMAXCHANNELS];
cmsUInt32Number SourceIncrements[cmsMAXCHANNELS];
cmsUInt32Number DestStartingOrder[cmsMAXCHANNELS];
cmsUInt32Number DestIncrements[cmsMAXCHANNELS];

// Compute the increments
ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements);
ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements);

// Check for conversions 8, 16, half, float, dbl
copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
cmsFormatterAlphaFn copyValueFn;

memset(SourceStrideIncrements, 0, sizeof(SourceStrideIncrements));
memset(DestStrideIncrements, 0, sizeof(DestStrideIncrements));
// Make sure we need some copy
if (!(p->dwOriginalFlags & cmsFLAGS_COPY_ALPHA))
return;

// The loop itself
for (i = 0; i < LineCount; i++) {
// Exit early if in-place color-management is occurring - no need to copy extra channels to themselves.
if (p->InputFormat == p->OutputFormat && in == out)
return;

// Prepare pointers for the loop
for (j = 0; j < nExtra; j++) {
// Make sure we have same number of alpha channels. If not, just return as this should be checked at transform creation time.
nExtra = T_EXTRA(p->InputFormat);
if (nExtra != T_EXTRA(p->OutputFormat))
return;

SourcePtr[j] = (cmsUInt8Number*)in + SourceStartingOrder[j] + SourceStrideIncrements[j];
DestPtr[j] = (cmsUInt8Number*)out + DestStartingOrder[j] + DestStrideIncrements[j];
}
// Anything to do?
if (nExtra == 0)
return;

for (j = 0; j < PixelsPerLine; j++) {
// Compute the increments
ComputeComponentIncrements(p->InputFormat, Stride->BytesPerPlaneIn, SourceStartingOrder, SourceIncrements);
ComputeComponentIncrements(p->OutputFormat, Stride->BytesPerPlaneOut, DestStartingOrder, DestIncrements);

for (k = 0; k < nExtra; k++) {
// Check for conversions 8, 16, half, float, dbl
copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);

copyValueFn(DestPtr[k], SourcePtr[k]);
if (nExtra == 1) { // Optimized routine for copying a single extra channel quickly

SourcePtr[k] += SourceIncrements[k];
DestPtr[k] += DestIncrements[k];
}
}
cmsUInt8Number* SourcePtr;
cmsUInt8Number* DestPtr;

for (j = 0; j < nExtra; j++) {
cmsUInt32Number SourceStrideIncrement = 0;
cmsUInt32Number DestStrideIncrement = 0;

SourceStrideIncrements[j] += Stride->BytesPerLineIn;
DestStrideIncrements[j] += Stride->BytesPerLineOut;
}
}
// The loop itself
for (i = 0; i < LineCount; i++) {

// Prepare pointers for the loop
SourcePtr = (cmsUInt8Number*)in + SourceStartingOrder[0] + SourceStrideIncrement;
DestPtr = (cmsUInt8Number*)out + DestStartingOrder[0] + DestStrideIncrement;

for (j = 0; j < PixelsPerLine; j++) {

copyValueFn(DestPtr, SourcePtr);

SourcePtr += SourceIncrements[0];
DestPtr += DestIncrements[0];
}

SourceStrideIncrement += Stride->BytesPerLineIn;
DestStrideIncrement += Stride->BytesPerLineOut;
}

}
else { // General case with more than one extra channel

cmsUInt8Number* SourcePtr[cmsMAXCHANNELS];
cmsUInt8Number* DestPtr[cmsMAXCHANNELS];

cmsUInt32Number SourceStrideIncrements[cmsMAXCHANNELS];
cmsUInt32Number DestStrideIncrements[cmsMAXCHANNELS];

memset(SourceStrideIncrements, 0, sizeof(SourceStrideIncrements));
memset(DestStrideIncrements, 0, sizeof(DestStrideIncrements));

// The loop itself
for (i = 0; i < LineCount; i++) {

// Prepare pointers for the loop
for (j = 0; j < nExtra; j++) {

SourcePtr[j] = (cmsUInt8Number*)in + SourceStartingOrder[j] + SourceStrideIncrements[j];
DestPtr[j] = (cmsUInt8Number*)out + DestStartingOrder[j] + DestStrideIncrements[j];
}

for (j = 0; j < PixelsPerLine; j++) {

for (k = 0; k < nExtra; k++) {

copyValueFn(DestPtr[k], SourcePtr[k]);

SourcePtr[k] += SourceIncrements[k];
DestPtr[k] += DestIncrements[k];
}
}

for (j = 0; j < nExtra; j++) {

SourceStrideIncrements[j] += Stride->BytesPerLineIn;
DestStrideIncrements[j] += Stride->BytesPerLineOut;
}
}
}
}


6 changes: 3 additions & 3 deletions thirdparty/liblcms2/src/cmscgats.c
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ void ReadReal(cmsIT8* it8, int inum)
}

// Parses a float number
// This can not call directly atof because it uses locale dependant
// This can not call directly atof because it uses locale dependent
// parsing, while CCMX files always use . as decimal separator
static
cmsFloat64Number ParseFloatNumber(const char *Buffer)
Expand Down Expand Up @@ -1817,7 +1817,7 @@ cmsBool CMSEXPORT cmsIT8SaveToMem(cmsHANDLE hIT8, void *MemPtr, cmsUInt32Number*
}


// -------------------------------------------------------------- Higer level parsing
// -------------------------------------------------------------- Higher level parsing

static
cmsBool DataFormatSection(cmsIT8* it8)
Expand Down Expand Up @@ -2120,7 +2120,7 @@ cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet)



// Init usefull pointers
// Init useful pointers

static
void CookPointers(cmsIT8* it8)
Expand Down
6 changes: 3 additions & 3 deletions thirdparty/liblcms2/src/cmscnvrt.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static cmsIntentsList DefaultIntents[] = {
};


// A pointer to the begining of the list
// A pointer to the beginning of the list
_cmsIntentsPluginChunkType _cmsIntentsPluginChunk = { NULL };

// Duplicates the zone of memory used by the plug-in in the new context
Expand Down Expand Up @@ -889,7 +889,7 @@ int BlackPreservingSampler(register const cmsUInt16Number In[], register cmsUInt
return TRUE;
}

// Make sure to pass thru K (which now is fixed)
// Make sure to pass through K (which now is fixed)
Outf[3] = LabK[3];

// Apply TAC if needed
Expand Down Expand Up @@ -957,7 +957,7 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
memset(&bp, 0, sizeof(bp));

// We need the input LUT of the last profile, assuming this one is responsible of
// black generation. This LUT will be seached in inverse order.
// black generation. This LUT will be searched in inverse order.
bp.LabK2cmyk = _cmsReadInputLUT(hProfiles[nProfiles-1], INTENT_RELATIVE_COLORIMETRIC);
if (bp.LabK2cmyk == NULL) goto Cleanup;

Expand Down
6 changes: 3 additions & 3 deletions thirdparty/liblcms2/src/cmserr.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ void _cmsAllocMemPluginChunk(struct _cmsContext_struct* ctx, const struct _cmsCo
}
}

// Auxiliar to fill memory management functions from plugin (or context 0 defaults)
// Auxiliary to fill memory management functions from plugin (or context 0 defaults)
void _cmsInstallAllocFunctions(cmsPluginMemHandler* Plugin, _cmsMemPluginChunkType* ptr)
{
if (Plugin == NULL) {
Expand Down Expand Up @@ -430,14 +430,14 @@ void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size

// Error logging ******************************************************************

// There is no error handling at all. When a funtion fails, it returns proper value.
// There is no error handling at all. When a function fails, it returns proper value.
// For example, all create functions does return NULL on failure. Other return FALSE
// It may be interesting, for the developer, to know why the function is failing.
// for that reason, lcms2 does offer a logging function. This function does recive
// a ENGLISH string with some clues on what is going wrong. You can show this
// info to the end user, or just create some sort of log.
// The logging function should NOT terminate the program, as this obviously can leave
// resources. It is the programmer's responsability to check each function return code
// resources. It is the programmer's responsibility to check each function return code
// to make sure it didn't fail.

// Error messages are limited to MAX_ERROR_MESSAGE_LEN
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/liblcms2/src/cmsgamma.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
return Val;
}

// Evaluate a segmented funtion for a single value. Return -1 if no valid segment found .
// Evaluate a segmented function for a single value. Return -1 if no valid segment found .
// If fn type is 0, perform an interpolation on the table
static
cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R)
Expand Down
6 changes: 3 additions & 3 deletions thirdparty/liblcms2/src/cmsgmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include "lcms2_internal.h"


// Auxiliar: append a Lab identity after the given sequence of profiles
// Auxiliary: append a Lab identity after the given sequence of profiles
// and return the transform. Lab profile is closed, rest of profiles are kept open.
cmsHTRANSFORM _cmsChain2Lab(cmsContext ContextID,
cmsUInt32Number nProfiles,
Expand Down Expand Up @@ -172,7 +172,7 @@ cmsToneCurve* _cmsBuildKToneCurve(cmsContext ContextID,
}

// Build the relationship. This effectively limits the maximum accuracy to 16 bits, but
// since this is used on black-preserving LUTs, we are not loosing accuracy in any case
// since this is used on black-preserving LUTs, we are not losing accuracy in any case
KTone = cmsJoinToneCurve(ContextID, in, out, nPoints);

// Get rid of components
Expand Down Expand Up @@ -278,7 +278,7 @@ int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number O
}

// Does compute a gamut LUT going back and forth across pcs -> relativ. colorimetric intent -> pcs
// the dE obtained is then annotated on the LUT. Values truely out of gamut are clipped to dE = 0xFFFE
// the dE obtained is then annotated on the LUT. Values truly out of gamut are clipped to dE = 0xFFFE
// and values changed are supposed to be handled by any gamut remapping, so, are out of gamut as well.
//
// **WARNING: This algorithm does assume that gamut remapping algorithms does NOT move in-gamut colors,
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/liblcms2/src/cmsintrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ cmsInterpParams* _cmsComputeInterpParams(cmsContext ContextID, int nSamples, int
int i;
cmsUInt32Number Samples[MAX_INPUT_DIMENSIONS];

// Fill the auxiliar array
// Fill the auxiliary array
for (i=0; i < MAX_INPUT_DIMENSIONS; i++)
Samples[i] = nSamples;

Expand Down
Loading