8245400: Upgrade to LittleCMS 2.11
Reviewed-by: serb, jdv
This commit is contained in:
parent
1a480ab570
commit
62cc45c3df
@ -1,10 +1,10 @@
|
||||
## Little Color Management System (LCMS) v2.9
|
||||
## Little Color Management System (LCMS) v2.11
|
||||
|
||||
### LCMS License
|
||||
<pre>
|
||||
|
||||
Little Color Management System
|
||||
Copyright (c) 1998-2011 Marti Maria Saguer
|
||||
Copyright (c) 1998-2020 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"),
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -57,6 +57,10 @@
|
||||
|
||||
// Alpha copy ------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
// This macro return words stored as big endian
|
||||
#define CHANGE_ENDIAN(w) (cmsUInt16Number) ((cmsUInt16Number) ((w)<<8)|((w)>>8))
|
||||
|
||||
|
||||
// Floor to byte, taking care of saturation
|
||||
cmsINLINE cmsUInt8Number _cmsQuickSaturateByte(cmsFloat64Number d)
|
||||
{
|
||||
@ -103,6 +107,13 @@ void from8to16(void* dst, const void* src)
|
||||
*(cmsUInt16Number*) dst = FROM_8_TO_16(n);
|
||||
}
|
||||
|
||||
static
|
||||
void from8to16SE(void* dst, const void* src)
|
||||
{
|
||||
cmsUInt8Number n = *(cmsUInt8Number*)src;
|
||||
*(cmsUInt16Number*)dst = CHANGE_ENDIAN(FROM_8_TO_16(n));
|
||||
}
|
||||
|
||||
static
|
||||
void from8toFLT(void* dst, const void* src)
|
||||
{
|
||||
@ -136,22 +147,50 @@ void from16to8(void* dst, const void* src)
|
||||
*(cmsUInt8Number*) dst = FROM_16_TO_8(n);
|
||||
}
|
||||
|
||||
static
|
||||
void from16SEto8(void* dst, const void* src)
|
||||
{
|
||||
cmsUInt16Number n = *(cmsUInt16Number*)src;
|
||||
*(cmsUInt8Number*)dst = FROM_16_TO_8(CHANGE_ENDIAN(n));
|
||||
}
|
||||
|
||||
static
|
||||
void copy16(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, 2);
|
||||
}
|
||||
|
||||
static
|
||||
void from16to16(void* dst, const void* src)
|
||||
{
|
||||
cmsUInt16Number n = *(cmsUInt16Number*)src;
|
||||
*(cmsUInt16Number*)dst = CHANGE_ENDIAN(n);
|
||||
}
|
||||
|
||||
static
|
||||
void from16toFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from16SEtoFLT(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat32Number*)dst = (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from16toDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (*(cmsUInt16Number*)src) / 65535.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from16SEtoDBL(void* dst, const void* src)
|
||||
{
|
||||
*(cmsFloat64Number*)dst = (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0f;
|
||||
}
|
||||
|
||||
static
|
||||
void from16toHLF(void* dst, const void* src)
|
||||
{
|
||||
@ -164,33 +203,53 @@ void from16toHLF(void* dst, const void* src)
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
void from16SEtoHLF(void* dst, const void* src)
|
||||
{
|
||||
#ifndef CMS_NO_HALF_SUPPORT
|
||||
cmsFloat32Number n = (CHANGE_ENDIAN(*(cmsUInt16Number*)src)) / 65535.0f;
|
||||
*(cmsUInt16Number*)dst = _cmsFloat2Half(n);
|
||||
#else
|
||||
cmsUNUSED_PARAMETER(dst);
|
||||
cmsUNUSED_PARAMETER(src);
|
||||
#endif
|
||||
}
|
||||
// From Float
|
||||
|
||||
static
|
||||
void fromFLTto8(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f);
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt8Number*)dst = _cmsQuickSaturateByte(n * 255.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTto16(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTto16SE(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
|
||||
*(cmsUInt16Number*)dst = CHANGE_ENDIAN(i);
|
||||
}
|
||||
|
||||
static
|
||||
void copy32(void* dst, const void* src)
|
||||
{
|
||||
memmove(dst, src, sizeof(cmsFloat32Number));
|
||||
memmove(dst, src, sizeof(cmsFloat32Number));
|
||||
}
|
||||
|
||||
static
|
||||
void fromFLTtoDBL(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsFloat64Number*)dst = (cmsFloat64Number)n;
|
||||
cmsFloat32Number n = *(cmsFloat32Number*)src;
|
||||
*(cmsFloat64Number*)dst = (cmsFloat64Number)n;
|
||||
}
|
||||
|
||||
static
|
||||
@ -233,6 +292,19 @@ void fromHLFto16(void* dst, const void* src)
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFto16SE(void* dst, const void* src)
|
||||
{
|
||||
#ifndef CMS_NO_HALF_SUPPORT
|
||||
cmsFloat32Number n = _cmsHalf2Float(*(cmsUInt16Number*)src);
|
||||
cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
*(cmsUInt16Number*)dst = CHANGE_ENDIAN(i);
|
||||
#else
|
||||
cmsUNUSED_PARAMETER(dst);
|
||||
cmsUNUSED_PARAMETER(src);
|
||||
#endif
|
||||
}
|
||||
|
||||
static
|
||||
void fromHLFtoFLT(void* dst, const void* src)
|
||||
{
|
||||
@ -270,6 +342,14 @@ void fromDBLto16(void* dst, const void* src)
|
||||
*(cmsUInt16Number*)dst = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLto16SE(void* dst, const void* src)
|
||||
{
|
||||
cmsFloat64Number n = *(cmsFloat64Number*)src;
|
||||
cmsUInt16Number i = _cmsQuickSaturateWord(n * 65535.0f);
|
||||
*(cmsUInt16Number*)dst = CHANGE_ENDIAN(i);
|
||||
}
|
||||
|
||||
static
|
||||
void fromDBLtoFLT(void* dst, const void* src)
|
||||
{
|
||||
@ -303,37 +383,42 @@ int FormatterPos(cmsUInt32Number frm)
|
||||
cmsUInt32Number b = T_BYTES(frm);
|
||||
|
||||
if (b == 0 && T_FLOAT(frm))
|
||||
return 4; // DBL
|
||||
return 5; // DBL
|
||||
#ifndef CMS_NO_HALF_SUPPORT
|
||||
if (b == 2 && T_FLOAT(frm))
|
||||
return 2; // HLF
|
||||
return 3; // HLF
|
||||
#endif
|
||||
if (b == 4 && T_FLOAT(frm))
|
||||
return 3; // FLT
|
||||
return 4; // FLT
|
||||
if (b == 2 && !T_FLOAT(frm))
|
||||
return 1; // 16
|
||||
{
|
||||
if (T_ENDIAN16(frm))
|
||||
return 2; // 16SE
|
||||
else
|
||||
return 1; // 16
|
||||
}
|
||||
if (b == 1 && !T_FLOAT(frm))
|
||||
return 0; // 8
|
||||
|
||||
return -1; // not recognized
|
||||
}
|
||||
|
||||
// Obtains a alpha-to-alpha funmction formatter
|
||||
// Obtains an alpha-to-alpha function formatter
|
||||
static
|
||||
cmsFormatterAlphaFn _cmsGetFormatterAlpha(cmsContext id, cmsUInt32Number in, cmsUInt32Number out)
|
||||
{
|
||||
static cmsFormatterAlphaFn FormattersAlpha[5][5] = {
|
||||
static cmsFormatterAlphaFn FormattersAlpha[6][6] = {
|
||||
|
||||
/* from 8 */ { copy8, from8to16, from8toHLF, from8toFLT, from8toDBL },
|
||||
/* from 16*/ { from16to8, copy16, from16toHLF, from16toFLT, from16toDBL },
|
||||
/* from HLF*/ { fromHLFto8, fromHLFto16, copy16, fromHLFtoFLT, fromHLFtoDBL },
|
||||
/* from FLT*/ { fromFLTto8, fromFLTto16, fromFLTtoHLF, copy32, fromFLTtoDBL },
|
||||
/* from DBL*/ { fromDBLto8, fromDBLto16, fromDBLtoHLF, fromDBLtoFLT, copy64 }};
|
||||
/* from 8 */ { copy8, from8to16, from8to16SE, from8toHLF, from8toFLT, from8toDBL },
|
||||
/* from 16*/ { from16to8, copy16, from16to16, from16toHLF, from16toFLT, from16toDBL },
|
||||
/* from 16SE*/{ from16SEto8, from16to16, copy16, from16SEtoHLF,from16SEtoFLT, from16SEtoDBL },
|
||||
/* from HLF*/ { fromHLFto8, fromHLFto16, fromHLFto16SE, copy16, fromHLFtoFLT, fromHLFtoDBL },
|
||||
/* from FLT*/ { fromFLTto8, fromFLTto16, fromFLTto16SE, fromFLTtoHLF, copy32, fromFLTtoDBL },
|
||||
/* from DBL*/ { fromDBLto8, fromDBLto16, fromDBLto16SE, fromDBLtoHLF, fromDBLtoFLT, copy64 }};
|
||||
|
||||
int in_n = FormatterPos(in);
|
||||
int out_n = FormatterPos(out);
|
||||
|
||||
if (in_n < 0 || out_n < 0 || in_n > 4 || out_n > 4) {
|
||||
if (in_n < 0 || out_n < 0 || in_n > 5 || out_n > 5) {
|
||||
|
||||
cmsSignalError(id, cmsERROR_UNKNOWN_EXTENSION, "Unrecognized alpha channel width");
|
||||
return NULL;
|
||||
@ -515,6 +600,8 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
|
||||
|
||||
// Check for conversions 8, 16, half, float, dbl
|
||||
copyValueFn = _cmsGetFormatterAlpha(p->ContextID, p->InputFormat, p->OutputFormat);
|
||||
if (copyValueFn == NULL)
|
||||
return;
|
||||
|
||||
if (nExtra == 1) { // Optimized routine for copying a single extra channel quickly
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -158,7 +158,7 @@ typedef struct _Table {
|
||||
|
||||
// File stream being parsed
|
||||
typedef struct _FileContext {
|
||||
char FileName[cmsMAX_PATH]; // File name if being readed from file
|
||||
char FileName[cmsMAX_PATH]; // File name if being read from file
|
||||
FILE* Stream; // File stream or NULL if holded in memory
|
||||
} FILECTX;
|
||||
|
||||
@ -285,7 +285,7 @@ static PROPERTY PredefinedProperties[] = {
|
||||
// needed.
|
||||
|
||||
{"SAMPLE_BACKING", WRITE_STRINGIFY}, // Identifies the backing material used behind the sample during
|
||||
// measurement. Allowed values are “black”, “white”, or {"na".
|
||||
// measurement. Allowed values are "black", "white", or {"na".
|
||||
|
||||
{"CHISQ_DOF", WRITE_STRINGIFY}, // Degrees of freedom associated with the Chi squared statistic
|
||||
// below properties are new in recent specs:
|
||||
@ -300,7 +300,7 @@ static PROPERTY PredefinedProperties[] = {
|
||||
// denote the use of filters such as none, D65, Red, Green or Blue.
|
||||
|
||||
{"POLARIZATION", WRITE_STRINGIFY}, // Identifies the use of a physical polarization filter during measurement. Allowed
|
||||
// values are {"yes”, “white”, “none” or “na”.
|
||||
// values are {"yes", "white", "none" or "na".
|
||||
|
||||
{"WEIGHTING_FUNCTION", WRITE_PAIR}, // Indicates such functions as: the CIE standard observer functions used in the
|
||||
// calculation of various data parameters (2 degree and 10 degree), CIE standard
|
||||
@ -712,8 +712,8 @@ cmsFloat64Number ParseFloatNumber(const char *Buffer)
|
||||
static
|
||||
void InSymbol(cmsIT8* it8)
|
||||
{
|
||||
register char *idptr;
|
||||
register int k;
|
||||
CMSREGISTER char *idptr;
|
||||
CMSREGISTER int k;
|
||||
SYMBOL key;
|
||||
int sng;
|
||||
|
||||
@ -2195,67 +2195,49 @@ void CookPointers(cmsIT8* it8)
|
||||
if (cmsstrcasecmp(Fld, "SAMPLE_ID") == 0) {
|
||||
|
||||
t -> SampleID = idField;
|
||||
|
||||
for (i=0; i < t -> nPatches; i++) {
|
||||
|
||||
char *Data = GetData(it8, i, idField);
|
||||
if (Data) {
|
||||
char Buffer[256];
|
||||
|
||||
strncpy(Buffer, Data, 255);
|
||||
Buffer[255] = 0;
|
||||
|
||||
if (strlen(Buffer) <= strlen(Data))
|
||||
strcpy(Data, Buffer);
|
||||
else
|
||||
SetData(it8, i, idField, Buffer);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// "LABEL" is an extension. It keeps references to forward tables
|
||||
|
||||
if ((cmsstrcasecmp(Fld, "LABEL") == 0) || Fld[0] == '$' ) {
|
||||
if ((cmsstrcasecmp(Fld, "LABEL") == 0) || Fld[0] == '$') {
|
||||
|
||||
// Search for table references...
|
||||
for (i=0; i < t -> nPatches; i++) {
|
||||
// Search for table references...
|
||||
for (i = 0; i < t->nPatches; i++) {
|
||||
|
||||
char *Label = GetData(it8, i, idField);
|
||||
char* Label = GetData(it8, i, idField);
|
||||
|
||||
if (Label) {
|
||||
if (Label) {
|
||||
|
||||
cmsUInt32Number k;
|
||||
cmsUInt32Number k;
|
||||
|
||||
// This is the label, search for a table containing
|
||||
// this property
|
||||
// This is the label, search for a table containing
|
||||
// this property
|
||||
|
||||
for (k=0; k < it8 ->TablesCount; k++) {
|
||||
for (k = 0; k < it8->TablesCount; k++) {
|
||||
|
||||
TABLE* Table = it8 ->Tab + k;
|
||||
KEYVALUE* p;
|
||||
TABLE* Table = it8->Tab + k;
|
||||
KEYVALUE* p;
|
||||
|
||||
if (IsAvailableOnList(Table->HeaderList, Label, NULL, &p)) {
|
||||
if (IsAvailableOnList(Table->HeaderList, Label, NULL, &p)) {
|
||||
|
||||
// Available, keep type and table
|
||||
char Buffer[256];
|
||||
// Available, keep type and table
|
||||
char Buffer[256];
|
||||
|
||||
char *Type = p ->Value;
|
||||
int nTable = (int) k;
|
||||
char* Type = p->Value;
|
||||
int nTable = (int)k;
|
||||
|
||||
snprintf(Buffer, 255, "%s %d %s", Label, nTable, Type );
|
||||
|
||||
SetData(it8, i, idField, Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
snprintf(Buffer, 255, "%s %d %s", Label, nTable, Type);
|
||||
|
||||
SetData(it8, i, idField, Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -2349,6 +2331,11 @@ cmsHANDLE CMSEXPORT cmsIT8LoadFromMem(cmsContext ContextID, const void *Ptr, cm
|
||||
|
||||
it8 = (cmsIT8*) hIT8;
|
||||
it8 ->MemoryBlock = (char*) _cmsMalloc(ContextID, len + 1);
|
||||
if (it8->MemoryBlock == NULL)
|
||||
{
|
||||
cmsIT8Free(hIT8);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
strncpy(it8 ->MemoryBlock, (const char*) Ptr, len);
|
||||
it8 ->MemoryBlock[len] = 0;
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -56,19 +56,6 @@
|
||||
#include "lcms2_internal.h"
|
||||
|
||||
|
||||
// Link several profiles to obtain a single LUT modelling the whole color transform. Intents, Black point
|
||||
// compensation and Adaptation parameters may vary across profiles. BPC and Adaptation refers to the PCS
|
||||
// after the profile. I.e, BPC[0] refers to connexion between profile(0) and profile(1)
|
||||
cmsPipeline* _cmsLinkProfiles(cmsContext ContextID,
|
||||
cmsUInt32Number nProfiles,
|
||||
cmsUInt32Number Intents[],
|
||||
cmsHPROFILE hProfiles[],
|
||||
cmsBool BPC[],
|
||||
cmsFloat64Number AdaptationStates[],
|
||||
cmsUInt32Number dwFlags);
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
|
||||
// This is the default routine for ICC-style intents. A user may decide to override it by using a plugin.
|
||||
// Supported intents are perceptual, relative colorimetric, saturation and ICC-absolute colorimetric
|
||||
static
|
||||
@ -739,7 +726,7 @@ typedef struct {
|
||||
|
||||
// Preserve black only if that is the only ink used
|
||||
static
|
||||
int BlackPreservingGrayOnlySampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||
int BlackPreservingGrayOnlySampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
|
||||
{
|
||||
GrayOnlyParams* bp = (GrayOnlyParams*) Cargo;
|
||||
|
||||
@ -866,7 +853,7 @@ typedef struct {
|
||||
|
||||
// The CLUT will be stored at 16 bits, but calculations are performed at cmsFloat32Number precision
|
||||
static
|
||||
int BlackPreservingSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||
int BlackPreservingSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
|
||||
{
|
||||
int i;
|
||||
cmsFloat32Number Inf[4], Outf[4];
|
||||
@ -891,18 +878,18 @@ int BlackPreservingSampler(register const cmsUInt16Number In[], register cmsUInt
|
||||
}
|
||||
|
||||
// Try the original transform,
|
||||
cmsPipelineEvalFloat( Inf, Outf, bp ->cmyk2cmyk);
|
||||
cmsPipelineEvalFloat(Inf, Outf, bp ->cmyk2cmyk);
|
||||
|
||||
// Store a copy of the floating point result into 16-bit
|
||||
for (i=0; i < 4; i++)
|
||||
Out[i] = _cmsQuickSaturateWord(Outf[i] * 65535.0);
|
||||
|
||||
// Maybe K is already ok (mostly on K=0)
|
||||
if ( fabs(Outf[3] - LabK[3]) < (3.0 / 65535.0) ) {
|
||||
if (fabsf(Outf[3] - LabK[3]) < (3.0 / 65535.0)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// K differ, mesure and keep Lab measurement for further usage
|
||||
// K differ, measure and keep Lab measurement for further usage
|
||||
// this is done in relative colorimetric intent
|
||||
cmsDoTransform(bp->hProofOutput, Out, &ColorimetricLab, 1);
|
||||
|
||||
@ -923,7 +910,7 @@ int BlackPreservingSampler(register const cmsUInt16Number In[], register cmsUInt
|
||||
Outf[3] = LabK[3];
|
||||
|
||||
// Apply TAC if needed
|
||||
SumCMY = Outf[0] + Outf[1] + Outf[2];
|
||||
SumCMY = (cmsFloat64Number) Outf[0] + Outf[1] + Outf[2];
|
||||
SumCMYK = SumCMY + Outf[3];
|
||||
|
||||
if (SumCMYK > bp ->MaxTAC) {
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -67,7 +67,7 @@ int CMSEXPORT cmsGetEncodedCMMversion(void)
|
||||
// compare two strings ignoring case
|
||||
int CMSEXPORT cmsstrcasecmp(const char* s1, const char* s2)
|
||||
{
|
||||
register const unsigned char *us1 = (const unsigned char *)s1,
|
||||
CMSREGISTER const unsigned char *us1 = (const unsigned char *)s1,
|
||||
*us2 = (const unsigned char *)s2;
|
||||
|
||||
while (toupper(*us1) == toupper(*us2++))
|
||||
@ -464,7 +464,7 @@ void* _cmsSubAllocDup(_cmsSubAllocator* s, const void *ptr, cmsUInt32Number size
|
||||
// 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
|
||||
// for that reason, lcms2 does offer a logging function. This function does receive
|
||||
// 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
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2013 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -329,7 +329,8 @@ cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsUInt32Number nEnt
|
||||
return p;
|
||||
|
||||
Error:
|
||||
if (p -> Segments) _cmsFree(ContextID, p ->Segments);
|
||||
if (p -> SegInterp) _cmsFree(ContextID, p -> SegInterp);
|
||||
if (p -> Segments) _cmsFree(ContextID, p -> Segments);
|
||||
if (p -> Evals) _cmsFree(ContextID, p -> Evals);
|
||||
if (p ->Table16) _cmsFree(ContextID, p ->Table16);
|
||||
_cmsFree(ContextID, p);
|
||||
@ -846,7 +847,7 @@ cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cm
|
||||
//
|
||||
// Parameters goes as: Curve, a, b, c, d, e, f
|
||||
// Type is the ICC type +1
|
||||
// if type is negative, then the curve is analyticaly inverted
|
||||
// if type is negative, then the curve is analytically inverted
|
||||
cmsToneCurve* CMSEXPORT cmsBuildParametricToneCurve(cmsContext ContextID, cmsInt32Number Type, const cmsFloat64Number Params[])
|
||||
{
|
||||
cmsCurveSegment Seg0;
|
||||
@ -917,7 +918,7 @@ void CMSEXPORT cmsFreeToneCurve(cmsToneCurve* Curve)
|
||||
if (Curve -> Evals)
|
||||
_cmsFree(ContextID, Curve -> Evals);
|
||||
|
||||
if (Curve) _cmsFree(ContextID, Curve);
|
||||
_cmsFree(ContextID, Curve);
|
||||
}
|
||||
|
||||
// Utility function, free 3 gamma tables
|
||||
@ -1287,7 +1288,7 @@ cmsBool CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda
|
||||
}
|
||||
|
||||
// Is a table linear? Do not use parametric since we cannot guarantee some weird parameters resulting
|
||||
// in a linear table. This way assures it is linear in 12 bits, which should be enought in most cases.
|
||||
// in a linear table. This way assures it is linear in 12 bits, which should be enough in most cases.
|
||||
cmsBool CMSEXPORT cmsIsToneCurveLinear(const cmsToneCurve* Curve)
|
||||
{
|
||||
int i;
|
||||
@ -1460,3 +1461,14 @@ cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Num
|
||||
|
||||
return (sum / n); // The mean
|
||||
}
|
||||
|
||||
|
||||
// Retrieve parameters on one-segment tone curves
|
||||
|
||||
cmsFloat64Number* CMSEXPORT cmsGetToneCurveParams(const cmsToneCurve* t)
|
||||
{
|
||||
_cmsAssert(t != NULL);
|
||||
|
||||
if (t->nSegments != 1) return NULL;
|
||||
return t->Segments[0].Params;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -240,7 +240,7 @@ typedef struct {
|
||||
|
||||
|
||||
static
|
||||
int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||
int GamutSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
|
||||
{
|
||||
GAMUTCHAIN* t = (GAMUTCHAIN* ) Cargo;
|
||||
cmsCIELab LabIn1, LabOut1;
|
||||
@ -453,7 +453,7 @@ typedef struct {
|
||||
// This callback just accounts the maximum ink dropped in the given node. It does not populate any
|
||||
// memory, as the destination table is NULL. Its only purpose it to know the global maximum.
|
||||
static
|
||||
int EstimateTAC(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void * Cargo)
|
||||
int EstimateTAC(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void * Cargo)
|
||||
{
|
||||
cmsTACestimator* bp = (cmsTACestimator*) Cargo;
|
||||
cmsFloat32Number RoundTrip[cmsMAXCHANNELS];
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -60,7 +60,7 @@
|
||||
// This code is inspired in the paper "Fast Half Float Conversions"
|
||||
// by Jeroen van der Zijp
|
||||
|
||||
static cmsUInt32Number Mantissa[2048] = {
|
||||
static const cmsUInt32Number Mantissa[2048] = {
|
||||
|
||||
0x00000000, 0x33800000, 0x34000000, 0x34400000, 0x34800000, 0x34a00000,
|
||||
0x34c00000, 0x34e00000, 0x35000000, 0x35100000, 0x35200000, 0x35300000,
|
||||
@ -420,7 +420,7 @@ static cmsUInt16Number Offset[64] = {
|
||||
0x0400, 0x0400, 0x0400, 0x0400
|
||||
};
|
||||
|
||||
static cmsUInt32Number Exponent[64] = {
|
||||
static const cmsUInt32Number Exponent[64] = {
|
||||
0x00000000, 0x00800000, 0x01000000, 0x01800000, 0x02000000, 0x02800000,
|
||||
0x03000000, 0x03800000, 0x04000000, 0x04800000, 0x05000000, 0x05800000,
|
||||
0x06000000, 0x06800000, 0x07000000, 0x07800000, 0x08000000, 0x08800000,
|
||||
@ -434,7 +434,7 @@ static cmsUInt32Number Exponent[64] = {
|
||||
0x8e000000, 0x8e800000, 0x8f000000, 0xc7800000
|
||||
};
|
||||
|
||||
static cmsUInt16Number Base[512] = {
|
||||
static const cmsUInt16Number Base[512] = {
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
@ -489,7 +489,7 @@ static cmsUInt16Number Base[512] = {
|
||||
0xfc00, 0xfc00
|
||||
};
|
||||
|
||||
static cmsUInt8Number Shift[512] = {
|
||||
static const cmsUInt8Number Shift[512] = {
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -210,7 +210,7 @@ void CMSEXPORT _cmsFreeInterpParams(cmsInterpParams* p)
|
||||
|
||||
|
||||
// Inline fixed point interpolation
|
||||
cmsINLINE cmsUInt16Number LinearInterp(cmsS15Fixed16Number a, cmsS15Fixed16Number l, cmsS15Fixed16Number h)
|
||||
cmsINLINE CMS_NO_SANITIZE cmsUInt16Number LinearInterp(cmsS15Fixed16Number a, cmsS15Fixed16Number l, cmsS15Fixed16Number h)
|
||||
{
|
||||
cmsUInt32Number dif = (cmsUInt32Number) (h - l) * a + 0x8000;
|
||||
dif = (dif >> 16) + l;
|
||||
@ -220,9 +220,9 @@ cmsINLINE cmsUInt16Number LinearInterp(cmsS15Fixed16Number a, cmsS15Fixed16Numbe
|
||||
|
||||
// Linear interpolation (Fixed-point optimized)
|
||||
static
|
||||
void LinLerp1D(register const cmsUInt16Number Value[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p)
|
||||
void LinLerp1D(CMSREGISTER const cmsUInt16Number Value[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p)
|
||||
{
|
||||
cmsUInt16Number y1, y0;
|
||||
int cell0, rest;
|
||||
@ -233,20 +233,20 @@ void LinLerp1D(register const cmsUInt16Number Value[],
|
||||
if (Value[0] == 0xffff) {
|
||||
|
||||
Output[0] = LutTable[p -> Domain[0]];
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
val3 = p->Domain[0] * Value[0];
|
||||
val3 = _cmsToFixedDomain(val3); // To fixed 15.16
|
||||
|
||||
val3 = p -> Domain[0] * Value[0];
|
||||
val3 = _cmsToFixedDomain(val3); // To fixed 15.16
|
||||
cell0 = FIXED_TO_INT(val3); // Cell is 16 MSB bits
|
||||
rest = FIXED_REST_TO_INT(val3); // Rest is 16 LSB bits
|
||||
|
||||
cell0 = FIXED_TO_INT(val3); // Cell is 16 MSB bits
|
||||
rest = FIXED_REST_TO_INT(val3); // Rest is 16 LSB bits
|
||||
y0 = LutTable[cell0];
|
||||
y1 = LutTable[cell0 + 1];
|
||||
|
||||
y0 = LutTable[cell0];
|
||||
y1 = LutTable[cell0+1];
|
||||
|
||||
|
||||
Output[0] = LinearInterp(rest, y0, y1);
|
||||
Output[0] = LinearInterp(rest, y0, y1);
|
||||
}
|
||||
}
|
||||
|
||||
// To prevent out of bounds indexing
|
||||
@ -271,30 +271,31 @@ void LinLerp1Dfloat(const cmsFloat32Number Value[],
|
||||
// if last value...
|
||||
if (val2 == 1.0) {
|
||||
Output[0] = LutTable[p -> Domain[0]];
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
val2 *= p->Domain[0];
|
||||
|
||||
val2 *= p -> Domain[0];
|
||||
cell0 = (int)floor(val2);
|
||||
cell1 = (int)ceil(val2);
|
||||
|
||||
cell0 = (int) floor(val2);
|
||||
cell1 = (int) ceil(val2);
|
||||
// Rest is 16 LSB bits
|
||||
rest = val2 - cell0;
|
||||
|
||||
// Rest is 16 LSB bits
|
||||
rest = val2 - cell0;
|
||||
y0 = LutTable[cell0];
|
||||
y1 = LutTable[cell1];
|
||||
|
||||
y0 = LutTable[cell0] ;
|
||||
y1 = LutTable[cell1] ;
|
||||
|
||||
Output[0] = y0 + (y1 - y0) * rest;
|
||||
Output[0] = y0 + (y1 - y0) * rest;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Eval gray LUT having only one input channel
|
||||
static
|
||||
void Eval1Input(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p16)
|
||||
static CMS_NO_SANITIZE
|
||||
void Eval1Input(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p16)
|
||||
{
|
||||
cmsS15Fixed16Number fk;
|
||||
cmsS15Fixed16Number k0, k1, rk, K0, K1;
|
||||
@ -335,30 +336,36 @@ void Eval1InputFloat(const cmsFloat32Number Value[],
|
||||
|
||||
val2 = fclamp(Value[0]);
|
||||
|
||||
// if last value...
|
||||
if (val2 == 1.0) {
|
||||
Output[0] = LutTable[p -> Domain[0]];
|
||||
return;
|
||||
}
|
||||
// if last value...
|
||||
if (val2 == 1.0) {
|
||||
|
||||
val2 *= p -> Domain[0];
|
||||
y0 = LutTable[p->Domain[0]];
|
||||
|
||||
cell0 = (int) floor(val2);
|
||||
cell1 = (int) ceil(val2);
|
||||
for (OutChan = 0; OutChan < p->nOutputs; OutChan++) {
|
||||
Output[OutChan] = y0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
val2 *= p->Domain[0];
|
||||
|
||||
// Rest is 16 LSB bits
|
||||
rest = val2 - cell0;
|
||||
cell0 = (int)floor(val2);
|
||||
cell1 = (int)ceil(val2);
|
||||
|
||||
cell0 *= p -> opta[0];
|
||||
cell1 *= p -> opta[0];
|
||||
// Rest is 16 LSB bits
|
||||
rest = val2 - cell0;
|
||||
|
||||
for (OutChan=0; OutChan < p->nOutputs; OutChan++) {
|
||||
cell0 *= p->opta[0];
|
||||
cell1 *= p->opta[0];
|
||||
|
||||
y0 = LutTable[cell0 + OutChan] ;
|
||||
y1 = LutTable[cell1 + OutChan] ;
|
||||
for (OutChan = 0; OutChan < p->nOutputs; OutChan++) {
|
||||
|
||||
y0 = LutTable[cell0 + OutChan];
|
||||
y1 = LutTable[cell1 + OutChan];
|
||||
|
||||
Output[OutChan] = y0 + (y1 - y0) * rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Bilinear interpolation (16 bits) - cmsFloat32Number version
|
||||
@ -415,10 +422,10 @@ void BilinearInterpFloat(const cmsFloat32Number Input[],
|
||||
}
|
||||
|
||||
// Bilinear interpolation (16 bits) - optimized version
|
||||
static
|
||||
void BilinearInterp16(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p)
|
||||
static CMS_NO_SANITIZE
|
||||
void BilinearInterp16(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p)
|
||||
|
||||
{
|
||||
#define DENS(i,j) (LutTable[(i)+(j)+OutChan])
|
||||
@ -427,9 +434,9 @@ void BilinearInterp16(register const cmsUInt16Number Input[],
|
||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
|
||||
int OutChan, TotalOut;
|
||||
cmsS15Fixed16Number fx, fy;
|
||||
register int rx, ry;
|
||||
CMSREGISTER int rx, ry;
|
||||
int x0, y0;
|
||||
register int X0, X1, Y0, Y1;
|
||||
CMSREGISTER int X0, X1, Y0, Y1;
|
||||
int d00, d01, d10, d11,
|
||||
dx0, dx1,
|
||||
dxy;
|
||||
@ -546,10 +553,10 @@ void TrilinearInterpFloat(const cmsFloat32Number Input[],
|
||||
}
|
||||
|
||||
// Trilinear interpolation (16 bits) - optimized version
|
||||
static
|
||||
void TrilinearInterp16(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p)
|
||||
static CMS_NO_SANITIZE
|
||||
void TrilinearInterp16(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p)
|
||||
|
||||
{
|
||||
#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
|
||||
@ -558,9 +565,9 @@ void TrilinearInterp16(register const cmsUInt16Number Input[],
|
||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p ->Table;
|
||||
int OutChan, TotalOut;
|
||||
cmsS15Fixed16Number fx, fy, fz;
|
||||
register int rx, ry, rz;
|
||||
CMSREGISTER int rx, ry, rz;
|
||||
int x0, y0, z0;
|
||||
register int X0, X1, Y0, Y1, Z0, Z1;
|
||||
CMSREGISTER int X0, X1, Y0, Y1, Z0, Z1;
|
||||
int d000, d001, d010, d011,
|
||||
d100, d101, d110, d111,
|
||||
dx00, dx01, dx10, dx11,
|
||||
@ -726,10 +733,10 @@ void TetrahedralInterpFloat(const cmsFloat32Number Input[],
|
||||
|
||||
|
||||
|
||||
static
|
||||
void TetrahedralInterp16(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p)
|
||||
static CMS_NO_SANITIZE
|
||||
void TetrahedralInterp16(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p)
|
||||
{
|
||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p -> Table;
|
||||
cmsS15Fixed16Number fx, fy, fz;
|
||||
@ -860,10 +867,10 @@ void TetrahedralInterp16(register const cmsUInt16Number Input[],
|
||||
|
||||
|
||||
#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
|
||||
static
|
||||
void Eval4Inputs(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p16)
|
||||
static CMS_NO_SANITIZE
|
||||
void Eval4Inputs(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p16)
|
||||
{
|
||||
const cmsUInt16Number* LutTable;
|
||||
cmsS15Fixed16Number fk;
|
||||
@ -964,9 +971,9 @@ void Eval4Inputs(register const cmsUInt16Number Input[],
|
||||
c1 = c2 = c3 = 0;
|
||||
}
|
||||
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
|
||||
Tmp1[OutChan] = (cmsUInt16Number)(c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
Tmp1[OutChan] = (cmsUInt16Number)(c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
}
|
||||
|
||||
|
||||
@ -1028,9 +1035,9 @@ void Eval4Inputs(register const cmsUInt16Number Input[],
|
||||
c1 = c2 = c3 = 0;
|
||||
}
|
||||
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz;
|
||||
|
||||
Tmp2[OutChan] = (cmsUInt16Number) (c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
Tmp2[OutChan] = (cmsUInt16Number) (c0 + ROUND_FIXED_TO_INT(_cmsToFixedDomain(Rest)));
|
||||
}
|
||||
|
||||
|
||||
@ -1089,11 +1096,11 @@ void Eval4InputsFloat(const cmsFloat32Number Input[],
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void Eval5Inputs(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
static CMS_NO_SANITIZE
|
||||
void Eval5Inputs(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
|
||||
register const cmsInterpParams* p16)
|
||||
CMSREGISTER const cmsInterpParams* p16)
|
||||
{
|
||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
|
||||
cmsS15Fixed16Number fk;
|
||||
@ -1178,10 +1185,10 @@ void Eval5InputsFloat(const cmsFloat32Number Input[],
|
||||
|
||||
|
||||
|
||||
static
|
||||
void Eval6Inputs(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p16)
|
||||
static CMS_NO_SANITIZE
|
||||
void Eval6Inputs(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p16)
|
||||
{
|
||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
|
||||
cmsS15Fixed16Number fk;
|
||||
@ -1264,10 +1271,10 @@ void Eval6InputsFloat(const cmsFloat32Number Input[],
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void Eval7Inputs(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p16)
|
||||
static CMS_NO_SANITIZE
|
||||
void Eval7Inputs(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p16)
|
||||
{
|
||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
|
||||
cmsS15Fixed16Number fk;
|
||||
@ -1350,10 +1357,10 @@ void Eval7InputsFloat(const cmsFloat32Number Input[],
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
void Eval8Inputs(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const cmsInterpParams* p16)
|
||||
static CMS_NO_SANITIZE
|
||||
void Eval8Inputs(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const cmsInterpParams* p16)
|
||||
{
|
||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
|
||||
cmsS15Fixed16Number fk;
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -263,7 +263,7 @@ cmsBool MemoryClose(struct _cms_io_handler* iohandler)
|
||||
|
||||
// Create a iohandler for memory block. AccessMode=='r' assumes the iohandler is going to read, and makes
|
||||
// a copy of the memory block for letting user to free the memory after invoking open profile. In write
|
||||
// mode ("w"), Buffere points to the begin of memory block to be written.
|
||||
// mode ("w"), Buffer points to the begin of memory block to be written.
|
||||
cmsIOHANDLER* CMSEXPORT cmsOpenIOhandlerFromMem(cmsContext ContextID, void *Buffer, cmsUInt32Number size, const char* AccessMode)
|
||||
{
|
||||
cmsIOHANDLER* iohandler = NULL;
|
||||
@ -662,7 +662,6 @@ cmsBool _cmsNewTag(_cmsICCPROFILE* Icc, cmsTagSignature sig, int* NewPos)
|
||||
else {
|
||||
|
||||
// No, make a new one
|
||||
|
||||
if (Icc -> TagCount >= MAX_TABLE_TAG) {
|
||||
cmsSignalError(Icc ->ContextID, cmsERROR_RANGE, "Too many tags (%d)", MAX_TABLE_TAG);
|
||||
return FALSE;
|
||||
@ -683,8 +682,6 @@ cmsBool CMSEXPORT cmsIsTag(cmsHPROFILE hProfile, cmsTagSignature sig)
|
||||
return _cmsSearchTag(Icc, sig, FALSE) >= 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Enforces that the profile version is per. spec.
|
||||
// Operates on the big endian bytes from the profile.
|
||||
// Called before converting to platform endianness.
|
||||
@ -1596,7 +1593,7 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
|
||||
|
||||
if (!IsTypeSupported(TagDescriptor, BaseType)) goto Error;
|
||||
|
||||
TagSize -= 8; // Alredy read by the type base logic
|
||||
TagSize -= 8; // Already read by the type base logic
|
||||
|
||||
// Get type handler
|
||||
TypeHandler = _cmsGetTagTypeHandler(Icc ->ContextID, BaseType);
|
||||
@ -1631,6 +1628,7 @@ void* CMSEXPORT cmsReadTag(cmsHPROFILE hProfile, cmsTagSignature sig)
|
||||
_cmsTagSignature2String(String, sig);
|
||||
cmsSignalError(Icc ->ContextID, cmsERROR_CORRUPTION_DETECTED, "'%s' Inconsistent number of items: expected %d, got %d",
|
||||
String, TagDescriptor ->ElemCount, ElemCount);
|
||||
goto Error;
|
||||
}
|
||||
|
||||
|
||||
@ -1827,7 +1825,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si
|
||||
return Icc ->TagSizes[i];
|
||||
}
|
||||
|
||||
// The data has been already read, or written. But wait!, maybe the user choosed to save as
|
||||
// The data has been already read, or written. But wait!, maybe the user chose to save as
|
||||
// raw data. In this case, return the raw data directly
|
||||
if (Icc ->TagSaveAsRaw[i]) {
|
||||
|
||||
@ -1847,7 +1845,7 @@ cmsUInt32Number CMSEXPORT cmsReadRawTag(cmsHPROFILE hProfile, cmsTagSignature si
|
||||
return Icc ->TagSizes[i];
|
||||
}
|
||||
|
||||
// Already readed, or previously set by cmsWriteTag(). We need to serialize that
|
||||
// Already read, or previously set by cmsWriteTag(). We need to serialize that
|
||||
// data to raw in order to maintain consistency.
|
||||
|
||||
_cmsUnlockMutex(Icc->ContextID, Icc ->UsrMutex);
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -230,7 +230,6 @@ cmsPipeline* BuildGrayInputMatrixPipeline(cmsHPROFILE hProfile)
|
||||
return Lut;
|
||||
|
||||
Error:
|
||||
cmsFreeToneCurve(GrayTRC);
|
||||
cmsPipelineFree(Lut);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -426,37 +426,31 @@ cmsStage* CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number R
|
||||
|
||||
|
||||
NewElem = (_cmsStageMatrixData*) _cmsMallocZero(ContextID, sizeof(_cmsStageMatrixData));
|
||||
if (NewElem == NULL) return NULL;
|
||||
|
||||
if (NewElem == NULL) goto Error;
|
||||
NewMPE->Data = (void*)NewElem;
|
||||
|
||||
NewElem ->Double = (cmsFloat64Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat64Number));
|
||||
|
||||
if (NewElem->Double == NULL) {
|
||||
MatrixElemTypeFree(NewMPE);
|
||||
return NULL;
|
||||
}
|
||||
if (NewElem->Double == NULL) goto Error;
|
||||
|
||||
for (i=0; i < n; i++) {
|
||||
NewElem ->Double[i] = Matrix[i];
|
||||
}
|
||||
|
||||
|
||||
if (Offset != NULL) {
|
||||
|
||||
NewElem ->Offset = (cmsFloat64Number*) _cmsCalloc(ContextID, Rows, sizeof(cmsFloat64Number));
|
||||
if (NewElem->Offset == NULL) {
|
||||
MatrixElemTypeFree(NewMPE);
|
||||
return NULL;
|
||||
}
|
||||
if (NewElem->Offset == NULL) goto Error;
|
||||
|
||||
for (i=0; i < Rows; i++) {
|
||||
NewElem ->Offset[i] = Offset[i];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NewMPE ->Data = (void*) NewElem;
|
||||
return NewMPE;
|
||||
|
||||
Error:
|
||||
cmsStageFree(NewMPE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@ -729,7 +723,7 @@ cmsStage* CMSEXPORT cmsStageAllocCLutFloatGranular(cmsContext ContextID, const c
|
||||
|
||||
|
||||
static
|
||||
int IdentitySampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void * Cargo)
|
||||
int IdentitySampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void * Cargo)
|
||||
{
|
||||
int nChan = *(int*) Cargo;
|
||||
int i;
|
||||
@ -1346,7 +1340,7 @@ cmsBool BlessLUT(cmsPipeline* lut)
|
||||
|
||||
// Default to evaluate the LUT on 16 bit-basis. Precision is retained.
|
||||
static
|
||||
void _LUTeval16(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register const void* D)
|
||||
void _LUTeval16(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER const void* D)
|
||||
{
|
||||
cmsPipeline* lut = (cmsPipeline*) D;
|
||||
cmsStage *mpe;
|
||||
@ -1372,7 +1366,7 @@ void _LUTeval16(register const cmsUInt16Number In[], register cmsUInt16Number Ou
|
||||
|
||||
// Does evaluate the LUT on cmsFloat32Number-basis.
|
||||
static
|
||||
void _LUTevalFloat(register const cmsFloat32Number In[], register cmsFloat32Number Out[], const void* D)
|
||||
void _LUTevalFloat(CMSREGISTER const cmsFloat32Number In[], CMSREGISTER cmsFloat32Number Out[], const void* D)
|
||||
{
|
||||
cmsPipeline* lut = (cmsPipeline*) D;
|
||||
cmsStage *mpe;
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -94,10 +94,9 @@ typedef struct {
|
||||
|
||||
|
||||
static
|
||||
void MD5_Transform(cmsUInt32Number buf[4], cmsUInt32Number in[16])
|
||||
|
||||
void cmsMD5_Transform(cmsUInt32Number buf[4], cmsUInt32Number in[16])
|
||||
{
|
||||
register cmsUInt32Number a, b, c, d;
|
||||
CMSREGISTER cmsUInt32Number a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
@ -180,8 +179,8 @@ void MD5_Transform(cmsUInt32Number buf[4], cmsUInt32Number in[16])
|
||||
|
||||
|
||||
// Create a MD5 object
|
||||
static
|
||||
cmsHANDLE MD5alloc(cmsContext ContextID)
|
||||
|
||||
cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID)
|
||||
{
|
||||
_cmsMD5* ctx = (_cmsMD5*) _cmsMallocZero(ContextID, sizeof(_cmsMD5));
|
||||
if (ctx == NULL) return NULL;
|
||||
@ -199,9 +198,7 @@ cmsHANDLE MD5alloc(cmsContext ContextID)
|
||||
return (cmsHANDLE) ctx;
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
void MD5add(cmsHANDLE Handle, cmsUInt8Number* buf, cmsUInt32Number len)
|
||||
void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len)
|
||||
{
|
||||
_cmsMD5* ctx = (_cmsMD5*) Handle;
|
||||
cmsUInt32Number t;
|
||||
@ -227,7 +224,7 @@ void MD5add(cmsHANDLE Handle, cmsUInt8Number* buf, cmsUInt32Number len)
|
||||
memmove(p, buf, t);
|
||||
byteReverse(ctx->in, 16);
|
||||
|
||||
MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
@ -235,7 +232,7 @@ void MD5add(cmsHANDLE Handle, cmsUInt8Number* buf, cmsUInt32Number len)
|
||||
while (len >= 64) {
|
||||
memmove(ctx->in, buf, 64);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
@ -244,8 +241,7 @@ void MD5add(cmsHANDLE Handle, cmsUInt8Number* buf, cmsUInt32Number len)
|
||||
}
|
||||
|
||||
// Destroy the object and return the checksum
|
||||
static
|
||||
void MD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle)
|
||||
void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle)
|
||||
{
|
||||
_cmsMD5* ctx = (_cmsMD5*) Handle;
|
||||
cmsUInt32Number count;
|
||||
@ -262,7 +258,7 @@ void MD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle)
|
||||
|
||||
memset(p, 0, count);
|
||||
byteReverse(ctx->in, 16);
|
||||
MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
|
||||
memset(ctx->in, 0, 56);
|
||||
} else {
|
||||
@ -273,7 +269,7 @@ void MD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle)
|
||||
((cmsUInt32Number *) ctx->in)[14] = ctx->bits[0];
|
||||
((cmsUInt32Number *) ctx->in)[15] = ctx->bits[1];
|
||||
|
||||
MD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
cmsMD5_Transform(ctx->buf, (cmsUInt32Number *) ctx->in);
|
||||
|
||||
byteReverse((cmsUInt8Number *) ctx->buf, 4);
|
||||
memmove(ProfileID ->ID8, ctx->buf, 16);
|
||||
@ -319,11 +315,11 @@ cmsBool CMSEXPORT cmsMD5computeID(cmsHPROFILE hProfile)
|
||||
if (!cmsSaveProfileToMem(hProfile, Mem, &BytesNeeded)) goto Error;
|
||||
|
||||
// Create MD5 object
|
||||
MD5 = MD5alloc(ContextID);
|
||||
MD5 = cmsMD5alloc(ContextID);
|
||||
if (MD5 == NULL) goto Error;
|
||||
|
||||
// Add all bytes
|
||||
MD5add(MD5, Mem, BytesNeeded);
|
||||
cmsMD5add(MD5, Mem, BytesNeeded);
|
||||
|
||||
// Temp storage is no longer needed
|
||||
_cmsFree(ContextID, Mem);
|
||||
@ -332,7 +328,7 @@ cmsBool CMSEXPORT cmsMD5computeID(cmsHPROFILE hProfile)
|
||||
memmove(Icc, &Keep, sizeof(_cmsICCPROFILE));
|
||||
|
||||
// And store the ID
|
||||
MD5finish(&Icc ->ProfileID, MD5);
|
||||
cmsMD5finish(&Icc ->ProfileID, MD5);
|
||||
return TRUE;
|
||||
|
||||
Error:
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -567,7 +567,7 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsAllocNamedColorList(cmsContext ContextID, cmsUIn
|
||||
|
||||
while (v -> Allocated < n) {
|
||||
if (!GrowNamedColorList(v)) {
|
||||
_cmsFree(ContextID, (void*) v);
|
||||
cmsFreeNamedColorList(v);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
@ -600,7 +600,11 @@ cmsNAMEDCOLORLIST* CMSEXPORT cmsDupNamedColorList(const cmsNAMEDCOLORLIST* v)
|
||||
|
||||
// For really large tables we need this
|
||||
while (NewNC ->Allocated < v ->Allocated){
|
||||
if (!GrowNamedColorList(NewNC)) return NULL;
|
||||
if (!GrowNamedColorList(NewNC))
|
||||
{
|
||||
cmsFreeNamedColorList(NewNC);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
memmove(NewNC ->Prefix, v ->Prefix, sizeof(v ->Prefix));
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -317,9 +317,9 @@ cmsBool PreOptimize(cmsPipeline* Lut)
|
||||
}
|
||||
|
||||
static
|
||||
void Eval16nop1D(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const struct _cms_interp_struc* p)
|
||||
void Eval16nop1D(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const struct _cms_interp_struc* p)
|
||||
{
|
||||
Output[0] = Input[0];
|
||||
|
||||
@ -327,9 +327,9 @@ void Eval16nop1D(register const cmsUInt16Number Input[],
|
||||
}
|
||||
|
||||
static
|
||||
void PrelinEval16(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const void* D)
|
||||
void PrelinEval16(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const void* D)
|
||||
{
|
||||
Prelin16Data* p16 = (Prelin16Data*) D;
|
||||
cmsUInt16Number StageABC[MAX_INPUT_DIMENSIONS];
|
||||
@ -435,7 +435,7 @@ Prelin16Data* PrelinOpt16alloc(cmsContext ContextID,
|
||||
// Sampler implemented by another LUT. This is a clean way to precalculate the devicelink 3D CLUT for
|
||||
// almost any transform. We use floating point precision and then convert from floating point to 16 bits.
|
||||
static
|
||||
cmsInt32Number XFormSampler16(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||
cmsInt32Number XFormSampler16(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
|
||||
{
|
||||
cmsPipeline* Lut = (cmsPipeline*) Cargo;
|
||||
cmsFloat32Number InFloat[cmsMAXCHANNELS], OutFloat[cmsMAXCHANNELS];
|
||||
@ -552,10 +552,10 @@ cmsBool PatchLUT(cmsStage* CLUT, cmsUInt16Number At[], cmsUInt16Number Value[],
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = 0; i < (int) nChannelsOut; i++)
|
||||
Grid->Tab.T[index + i] = Value[i];
|
||||
for (i = 0; i < (int) nChannelsOut; i++)
|
||||
Grid->Tab.T[index + i] = Value[i];
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Auxiliary, to see if two values are equal or very different
|
||||
@ -673,7 +673,7 @@ cmsBool OptimizeByResampling(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
||||
cmsToneCurve** DataSetOut;
|
||||
Prelin16Data* p16;
|
||||
|
||||
// This is a loosy optimization! does not apply in floating-point cases
|
||||
// This is a lossy optimization! does not apply in floating-point cases
|
||||
if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
|
||||
|
||||
ColorSpace = _cmsICCcolorSpace((int) T_COLORSPACE(*InputFormat));
|
||||
@ -937,19 +937,19 @@ void* Prelin8dup(cmsContext ContextID, const void* ptr)
|
||||
|
||||
// A optimized interpolation for 8-bit input.
|
||||
#define DENS(i,j,k) (LutTable[(i)+(j)+(k)+OutChan])
|
||||
static
|
||||
void PrelinEval8(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const void* D)
|
||||
static CMS_NO_SANITIZE
|
||||
void PrelinEval8(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const void* D)
|
||||
{
|
||||
|
||||
cmsUInt8Number r, g, b;
|
||||
cmsS15Fixed16Number rx, ry, rz;
|
||||
cmsS15Fixed16Number c0, c1, c2, c3, Rest;
|
||||
int OutChan;
|
||||
register cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
|
||||
CMSREGISTER cmsS15Fixed16Number X0, X1, Y0, Y1, Z0, Z1;
|
||||
Prelin8Data* p8 = (Prelin8Data*) D;
|
||||
register const cmsInterpParams* p = p8 ->p;
|
||||
CMSREGISTER const cmsInterpParams* p = p8 ->p;
|
||||
int TotalOut = (int) p -> nOutputs;
|
||||
const cmsUInt16Number* LutTable = (const cmsUInt16Number*) p->Table;
|
||||
|
||||
@ -1020,8 +1020,8 @@ void PrelinEval8(register const cmsUInt16Number Input[],
|
||||
c1 = c2 = c3 = 0;
|
||||
}
|
||||
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
|
||||
Output[OutChan] = (cmsUInt16Number) (c0 + ((Rest + (Rest >> 16)) >> 16));
|
||||
Rest = c1 * rx + c2 * ry + c3 * rz + 0x8001;
|
||||
Output[OutChan] = (cmsUInt16Number) (c0 + ((Rest + (Rest >> 16)) >> 16));
|
||||
|
||||
}
|
||||
}
|
||||
@ -1070,7 +1070,7 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
|
||||
_cmsStageCLutData* OptimizedPrelinCLUT;
|
||||
|
||||
|
||||
// This is a loosy optimization! does not apply in floating-point cases
|
||||
// This is a lossy optimization! does not apply in floating-point cases
|
||||
if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
|
||||
|
||||
// Only on chunky RGB
|
||||
@ -1113,6 +1113,7 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
|
||||
{
|
||||
cmsStage* last = cmsPipelineGetPtrToLastStage(OriginalLut);
|
||||
|
||||
if (last == NULL) goto Error;
|
||||
if (cmsStageType(last) == cmsSigCurveSetElemType) {
|
||||
|
||||
_cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*)cmsStageData(last);
|
||||
@ -1221,10 +1222,7 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
|
||||
Prelin8Data* p8 = PrelinOpt8alloc(OptimizedLUT ->ContextID,
|
||||
OptimizedPrelinCLUT ->Params,
|
||||
OptimizedPrelinCurves);
|
||||
if (p8 == NULL) {
|
||||
cmsPipelineFree(OptimizedLUT);
|
||||
return FALSE;
|
||||
}
|
||||
if (p8 == NULL) return FALSE;
|
||||
|
||||
_cmsPipelineSetOptimizationParameters(OptimizedLUT, PrelinEval8, (void*) p8, Prelin8free, Prelin8dup);
|
||||
|
||||
@ -1234,10 +1232,7 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
|
||||
Prelin16Data* p16 = PrelinOpt16alloc(OptimizedLUT ->ContextID,
|
||||
OptimizedPrelinCLUT ->Params,
|
||||
3, OptimizedPrelinCurves, 3, NULL);
|
||||
if (p16 == NULL) {
|
||||
cmsPipelineFree(OptimizedLUT);
|
||||
return FALSE;
|
||||
}
|
||||
if (p16 == NULL) return FALSE;
|
||||
|
||||
_cmsPipelineSetOptimizationParameters(OptimizedLUT, PrelinEval16, (void*) p16, PrelinOpt16free, Prelin16dup);
|
||||
|
||||
@ -1365,9 +1360,9 @@ Curves16Data* CurvesAlloc(cmsContext ContextID, cmsUInt32Number nCurves, cmsUInt
|
||||
}
|
||||
|
||||
static
|
||||
void FastEvaluateCurves8(register const cmsUInt16Number In[],
|
||||
register cmsUInt16Number Out[],
|
||||
register const void* D)
|
||||
void FastEvaluateCurves8(CMSREGISTER const cmsUInt16Number In[],
|
||||
CMSREGISTER cmsUInt16Number Out[],
|
||||
CMSREGISTER const void* D)
|
||||
{
|
||||
Curves16Data* Data = (Curves16Data*) D;
|
||||
int x;
|
||||
@ -1382,9 +1377,9 @@ void FastEvaluateCurves8(register const cmsUInt16Number In[],
|
||||
|
||||
|
||||
static
|
||||
void FastEvaluateCurves16(register const cmsUInt16Number In[],
|
||||
register cmsUInt16Number Out[],
|
||||
register const void* D)
|
||||
void FastEvaluateCurves16(CMSREGISTER const cmsUInt16Number In[],
|
||||
CMSREGISTER cmsUInt16Number Out[],
|
||||
CMSREGISTER const void* D)
|
||||
{
|
||||
Curves16Data* Data = (Curves16Data*) D;
|
||||
cmsUInt32Number i;
|
||||
@ -1396,9 +1391,9 @@ void FastEvaluateCurves16(register const cmsUInt16Number In[],
|
||||
|
||||
|
||||
static
|
||||
void FastIdentity16(register const cmsUInt16Number In[],
|
||||
register cmsUInt16Number Out[],
|
||||
register const void* D)
|
||||
void FastIdentity16(CMSREGISTER const cmsUInt16Number In[],
|
||||
CMSREGISTER cmsUInt16Number Out[],
|
||||
CMSREGISTER const void* D)
|
||||
{
|
||||
cmsPipeline* Lut = (cmsPipeline*) D;
|
||||
cmsUInt32Number i;
|
||||
@ -1423,7 +1418,7 @@ cmsBool OptimizeByJoiningCurves(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUI
|
||||
cmsStage* ObtainedCurves = NULL;
|
||||
|
||||
|
||||
// This is a loosy optimization! does not apply in floating-point cases
|
||||
// This is a lossy optimization! does not apply in floating-point cases
|
||||
if (_cmsFormatterIsFloat(*InputFormat) || _cmsFormatterIsFloat(*OutputFormat)) return FALSE;
|
||||
|
||||
// Only curves in this LUT?
|
||||
@ -1473,14 +1468,15 @@ cmsBool OptimizeByJoiningCurves(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUI
|
||||
|
||||
// Maybe the curves are linear at the end
|
||||
if (!AllCurvesAreLinear(ObtainedCurves)) {
|
||||
_cmsStageToneCurvesData* Data;
|
||||
|
||||
if (!cmsPipelineInsertStage(Dest, cmsAT_BEGIN, ObtainedCurves))
|
||||
goto Error;
|
||||
Data = (_cmsStageToneCurvesData*) cmsStageData(ObtainedCurves);
|
||||
ObtainedCurves = NULL;
|
||||
|
||||
// If the curves are to be applied in 8 bits, we can save memory
|
||||
if (_cmsFormatterIs8bit(*InputFormat)) {
|
||||
|
||||
_cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) ObtainedCurves ->Data;
|
||||
Curves16Data* c16 = CurvesAlloc(Dest ->ContextID, Data ->nCurves, 256, Data ->TheCurves);
|
||||
|
||||
if (c16 == NULL) goto Error;
|
||||
@ -1489,8 +1485,6 @@ cmsBool OptimizeByJoiningCurves(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUI
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
_cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) cmsStageData(ObtainedCurves);
|
||||
Curves16Data* c16 = CurvesAlloc(Dest ->ContextID, Data ->nCurves, 65536, Data ->TheCurves);
|
||||
|
||||
if (c16 == NULL) goto Error;
|
||||
@ -1557,9 +1551,9 @@ void* DupMatShaper(cmsContext ContextID, const void* Data)
|
||||
// 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 boost is huge!
|
||||
static
|
||||
void MatShaperEval16(register const cmsUInt16Number In[],
|
||||
register cmsUInt16Number Out[],
|
||||
register const void* D)
|
||||
void MatShaperEval16(CMSREGISTER const cmsUInt16Number In[],
|
||||
CMSREGISTER cmsUInt16Number Out[],
|
||||
CMSREGISTER const void* D)
|
||||
{
|
||||
MatShaper8Data* p = (MatShaper8Data*) D;
|
||||
cmsS1Fixed14Number l1, l2, l3, r, g, b;
|
||||
@ -1799,8 +1793,8 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
|
||||
_cmsStageToneCurvesData* mpeC1 = (_cmsStageToneCurvesData*) cmsStageData(Curve1);
|
||||
_cmsStageToneCurvesData* mpeC2 = (_cmsStageToneCurvesData*) cmsStageData(Curve2);
|
||||
|
||||
// In this particular optimization, caché does not help as it takes more time to deal with
|
||||
// the caché that with the pixel handling
|
||||
// In this particular optimization, cache does not help as it takes more time to deal with
|
||||
// the cache that with the pixel handling
|
||||
*dwFlags |= cmsFLAGS_NOCACHE;
|
||||
|
||||
// Setup the optimizarion routines
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -62,7 +62,7 @@
|
||||
|
||||
// Little-Endian to Big-Endian
|
||||
|
||||
// Adjust a word value after being readed/ before being written from/to an ICC profile
|
||||
// Adjust a word value after being read/ before being written from/to an ICC profile
|
||||
cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word)
|
||||
{
|
||||
#ifndef CMS_USE_BIG_ENDIAN
|
||||
@ -128,8 +128,8 @@ void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number*
|
||||
_cmsAssert(Result != NULL);
|
||||
|
||||
# ifdef CMS_DONT_USE_INT64
|
||||
(*Result)[0] = QWord[0];
|
||||
(*Result)[1] = QWord[1];
|
||||
(*Result)[0] = (*QWord)[0];
|
||||
(*Result)[1] = (*QWord)[1];
|
||||
# else
|
||||
*Result = *QWord;
|
||||
# endif
|
||||
@ -216,6 +216,8 @@ cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n)
|
||||
return TRUE;
|
||||
#elif defined (__BORLANDC__)
|
||||
return TRUE;
|
||||
#elif !defined(_MSC_VER) && (defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L)
|
||||
return TRUE;
|
||||
#else
|
||||
|
||||
// fpclassify() required by C99 (only provided by MSVC >= 1800, VS2013 onwards)
|
||||
@ -702,15 +704,21 @@ struct _cmsContext_struct* _cmsGetContext(cmsContext ContextID)
|
||||
return &globalContext;
|
||||
|
||||
// Search
|
||||
_cmsEnterCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
|
||||
|
||||
for (ctx = _cmsContextPoolHead;
|
||||
ctx != NULL;
|
||||
ctx = ctx ->Next) {
|
||||
|
||||
// Found it?
|
||||
if (id == ctx)
|
||||
return ctx; // New-style context,
|
||||
if (id == ctx)
|
||||
{
|
||||
_cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
|
||||
return ctx; // New-style context
|
||||
}
|
||||
}
|
||||
|
||||
_cmsLeaveCriticalSectionPrimitive(&_cmsContextPoolHeadMutex);
|
||||
return &globalContext;
|
||||
}
|
||||
|
||||
@ -799,6 +807,7 @@ cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData)
|
||||
|
||||
// See the comments regarding locking in lcms2_internal.h
|
||||
// for an explanation of why we need the following code.
|
||||
#ifndef CMS_NO_PTHREADS
|
||||
#ifdef CMS_IS_WINDOWS_
|
||||
#ifndef CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
|
||||
{
|
||||
@ -819,6 +828,7 @@ cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData)
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
_cmsInstallAllocFunctions(_cmsFindMemoryPlugin(Plugin), &fakeContext.DefaultMemoryManager);
|
||||
@ -943,25 +953,6 @@ cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
static
|
||||
struct _cmsContext_struct* FindPrev(struct _cmsContext_struct* id)
|
||||
{
|
||||
struct _cmsContext_struct* prev;
|
||||
|
||||
// Search for previous
|
||||
for (prev = _cmsContextPoolHead;
|
||||
prev != NULL;
|
||||
prev = prev ->Next)
|
||||
{
|
||||
if (prev ->Next == id)
|
||||
return prev;
|
||||
}
|
||||
|
||||
return NULL; // List is empty or only one element!
|
||||
}
|
||||
*/
|
||||
|
||||
// Frees any resources associated with the given context,
|
||||
// and destroys the context placeholder.
|
||||
// The ContextID can no longer be used in any THR operation.
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -107,8 +107,8 @@
|
||||
Matrix-shaper based
|
||||
-------------------
|
||||
|
||||
This is implemented both with /CIEBasedABC or /CIEBasedDEF on dependig
|
||||
of profile implementation. Since here there are no interpolation tables, I do
|
||||
This is implemented both with /CIEBasedABC or /CIEBasedDEF depending on the
|
||||
profile implementation. Since here there are no interpolation tables, I do
|
||||
the conversion directly to XYZ
|
||||
|
||||
|
||||
@ -324,21 +324,7 @@ cmsUInt8Number Word2Byte(cmsUInt16Number w)
|
||||
}
|
||||
|
||||
|
||||
// Convert to byte (using ICC2 notation)
|
||||
/*
|
||||
static
|
||||
cmsUInt8Number L2Byte(cmsUInt16Number w)
|
||||
{
|
||||
int ww = w + 0x0080;
|
||||
|
||||
if (ww > 0xFFFF) return 0xFF;
|
||||
|
||||
return (cmsUInt8Number) ((cmsUInt16Number) (ww >> 8) & 0xFF);
|
||||
}
|
||||
*/
|
||||
|
||||
// Write a cooked byte
|
||||
|
||||
static
|
||||
void WriteByte(cmsIOHANDLER* m, cmsUInt8Number b)
|
||||
{
|
||||
@ -355,7 +341,8 @@ void WriteByte(cmsIOHANDLER* m, cmsUInt8Number b)
|
||||
// ----------------------------------------------------------------- PostScript generation
|
||||
|
||||
|
||||
// Removes offending Carriage returns
|
||||
// Removes offending carriage returns
|
||||
|
||||
static
|
||||
char* RemoveCR(const char* txt)
|
||||
{
|
||||
@ -453,21 +440,6 @@ void EmitIntent(cmsIOHANDLER* m, cmsUInt32Number RenderingIntent)
|
||||
// = Yn*( L* / 116) / 7.787 if (L*) < 6 / 29
|
||||
//
|
||||
|
||||
/*
|
||||
static
|
||||
void EmitL2Y(cmsIOHANDLER* m)
|
||||
{
|
||||
_cmsIOPrintf(m,
|
||||
"{ "
|
||||
"100 mul 16 add 116 div " // (L * 100 + 16) / 116
|
||||
"dup 6 29 div ge " // >= 6 / 29 ?
|
||||
"{ dup dup mul mul } " // yes, ^3 and done
|
||||
"{ 4 29 div sub 108 841 div mul } " // no, slope limiting
|
||||
"ifelse } bind ");
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
// Lab -> XYZ, see the discussion above
|
||||
|
||||
static
|
||||
@ -488,12 +460,28 @@ void EmitLab2XYZ(cmsIOHANDLER* m)
|
||||
_cmsIOPrintf(m, "]\n");
|
||||
}
|
||||
|
||||
static
|
||||
void EmitSafeGuardBegin(cmsIOHANDLER* m, const char* name)
|
||||
{
|
||||
_cmsIOPrintf(m, "%%LCMS2: Save previous definition of %s on the operand stack\n", name);
|
||||
_cmsIOPrintf(m, "currentdict /%s known { /%s load } { null } ifelse\n", name, name);
|
||||
}
|
||||
|
||||
static
|
||||
void EmitSafeGuardEnd(cmsIOHANDLER* m, const char* name, int depth)
|
||||
{
|
||||
_cmsIOPrintf(m, "%%LCMS2: Restore previous definition of %s\n", name);
|
||||
if (depth > 1) {
|
||||
// cycle topmost items on the stack to bring the previous definition to the front
|
||||
_cmsIOPrintf(m, "%d -1 roll ", depth);
|
||||
}
|
||||
_cmsIOPrintf(m, "dup null eq { pop currentdict /%s undef } { /%s exch def } ifelse\n", name, name);
|
||||
}
|
||||
|
||||
// Outputs a table of words. It does use 16 bits
|
||||
|
||||
static
|
||||
void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table)
|
||||
void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table, const char* name)
|
||||
{
|
||||
cmsUInt32Number i;
|
||||
cmsFloat64Number gamma;
|
||||
@ -508,28 +496,33 @@ void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table)
|
||||
// Check if is really an exponential. If so, emit "exp"
|
||||
gamma = cmsEstimateGamma(Table, 0.001);
|
||||
if (gamma > 0) {
|
||||
_cmsIOPrintf(m, "{ %g exp } bind ", gamma);
|
||||
_cmsIOPrintf(m, "/%s { %g exp } bind def\n", name, gamma);
|
||||
return;
|
||||
}
|
||||
|
||||
_cmsIOPrintf(m, "{ ");
|
||||
EmitSafeGuardBegin(m, "lcms2gammatable");
|
||||
_cmsIOPrintf(m, "/lcms2gammatable [");
|
||||
|
||||
for (i=0; i < Table->nEntries; i++) {
|
||||
if (i % 10 == 0)
|
||||
_cmsIOPrintf(m, "\n ");
|
||||
_cmsIOPrintf(m, "%d ", Table->Table16[i]);
|
||||
}
|
||||
|
||||
_cmsIOPrintf(m, "] def\n");
|
||||
|
||||
|
||||
// Emit interpolation code
|
||||
|
||||
// PostScript code Stack
|
||||
// =============== ========================
|
||||
// v
|
||||
_cmsIOPrintf(m, "/%s {\n ", name);
|
||||
|
||||
// Bounds check
|
||||
EmitRangeCheck(m);
|
||||
|
||||
// Emit intepolation code
|
||||
|
||||
// PostScript code Stack
|
||||
// =============== ========================
|
||||
// v
|
||||
_cmsIOPrintf(m, " [");
|
||||
|
||||
for (i=0; i < Table->nEntries; i++) {
|
||||
_cmsIOPrintf(m, "%d ", Table->Table16[i]);
|
||||
}
|
||||
|
||||
_cmsIOPrintf(m, "] "); // v tab
|
||||
|
||||
_cmsIOPrintf(m, "\n //lcms2gammatable "); // v tab
|
||||
_cmsIOPrintf(m, "dup "); // v tab tab
|
||||
_cmsIOPrintf(m, "length 1 sub "); // v tab dom
|
||||
_cmsIOPrintf(m, "3 -1 roll "); // tab dom v
|
||||
@ -541,7 +534,7 @@ void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table)
|
||||
_cmsIOPrintf(m, "ceiling cvi "); // tab val2 cell0 cell1
|
||||
_cmsIOPrintf(m, "3 index "); // tab val2 cell0 cell1 tab
|
||||
_cmsIOPrintf(m, "exch "); // tab val2 cell0 tab cell1
|
||||
_cmsIOPrintf(m, "get "); // tab val2 cell0 y1
|
||||
_cmsIOPrintf(m, "get\n "); // tab val2 cell0 y1
|
||||
_cmsIOPrintf(m, "4 -1 roll "); // val2 cell0 y1 tab
|
||||
_cmsIOPrintf(m, "3 -1 roll "); // val2 y1 tab cell0
|
||||
_cmsIOPrintf(m, "get "); // val2 y1 y0
|
||||
@ -554,9 +547,11 @@ void Emit1Gamma(cmsIOHANDLER* m, cmsToneCurve* Table)
|
||||
_cmsIOPrintf(m, "sub "); // y0 (y1-y0) rest
|
||||
_cmsIOPrintf(m, "mul "); // y0 t1
|
||||
_cmsIOPrintf(m, "add "); // y
|
||||
_cmsIOPrintf(m, "65535 div "); // result
|
||||
_cmsIOPrintf(m, "65535 div\n"); // result
|
||||
|
||||
_cmsIOPrintf(m, " } bind ");
|
||||
_cmsIOPrintf(m, "} bind def\n");
|
||||
|
||||
EmitSafeGuardEnd(m, "lcms2gammatable", 1);
|
||||
}
|
||||
|
||||
|
||||
@ -572,9 +567,10 @@ cmsBool GammaTableEquals(cmsUInt16Number* g1, cmsUInt16Number* g2, cmsUInt32Numb
|
||||
// Does write a set of gamma curves
|
||||
|
||||
static
|
||||
void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[])
|
||||
void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[], const char* nameprefix)
|
||||
{
|
||||
cmsUInt32Number i;
|
||||
static char buffer[2048];
|
||||
|
||||
for( i=0; i < n; i++ )
|
||||
{
|
||||
@ -582,19 +578,18 @@ void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[])
|
||||
|
||||
if (i > 0 && GammaTableEquals(g[i-1]->Table16, g[i]->Table16, g[i]->nEntries)) {
|
||||
|
||||
_cmsIOPrintf(m, "dup ");
|
||||
_cmsIOPrintf(m, "/%s%d /%s%d load def\n", nameprefix, i, nameprefix, i-1);
|
||||
}
|
||||
else {
|
||||
Emit1Gamma(m, g[i]);
|
||||
snprintf(buffer, sizeof(buffer), "%s%d", nameprefix, i);
|
||||
buffer[sizeof(buffer)-1] = '\0';
|
||||
Emit1Gamma(m, g[i], buffer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Following code dumps a LUT onto memory stream
|
||||
|
||||
|
||||
@ -611,7 +606,7 @@ void EmitNGamma(cmsIOHANDLER* m, cmsUInt32Number n, cmsToneCurve* g[])
|
||||
// component. -1 is used to mark beginning of whole block.
|
||||
|
||||
static
|
||||
int OutputValueSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||
int OutputValueSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
|
||||
{
|
||||
cmsPsSamplerCargo* sc = (cmsPsSamplerCargo*) Cargo;
|
||||
cmsUInt32Number i;
|
||||
@ -691,11 +686,11 @@ int OutputValueSampler(register const cmsUInt16Number In[], register cmsUInt16Nu
|
||||
|
||||
static
|
||||
void WriteCLUT(cmsIOHANDLER* m, cmsStage* mpe, const char* PreMaj,
|
||||
const char* PostMaj,
|
||||
const char* PreMin,
|
||||
const char* PostMin,
|
||||
int FixWhite,
|
||||
cmsColorSpaceSignature ColorSpace)
|
||||
const char* PostMaj,
|
||||
const char* PreMin,
|
||||
const char* PostMin,
|
||||
int FixWhite,
|
||||
cmsColorSpaceSignature ColorSpace)
|
||||
{
|
||||
cmsUInt32Number i;
|
||||
cmsPsSamplerCargo sc;
|
||||
@ -737,11 +732,11 @@ int EmitCIEBasedA(cmsIOHANDLER* m, cmsToneCurve* Curve, cmsCIEXYZ* BlackPoint)
|
||||
_cmsIOPrintf(m, "[ /CIEBasedA\n");
|
||||
_cmsIOPrintf(m, " <<\n");
|
||||
|
||||
_cmsIOPrintf(m, "/DecodeA ");
|
||||
EmitSafeGuardBegin(m, "lcms2gammaproc");
|
||||
Emit1Gamma(m, Curve, "lcms2gammaproc");
|
||||
|
||||
Emit1Gamma(m, Curve);
|
||||
|
||||
_cmsIOPrintf(m, " \n");
|
||||
_cmsIOPrintf(m, "/DecodeA /lcms2gammaproc load\n");
|
||||
EmitSafeGuardEnd(m, "lcms2gammaproc", 3);
|
||||
|
||||
_cmsIOPrintf(m, "/MatrixA [ 0.9642 1.0000 0.8249 ]\n");
|
||||
_cmsIOPrintf(m, "/RangeLMN [ 0.0 0.9642 0.0 1.0000 0.0 0.8249 ]\n");
|
||||
@ -765,11 +760,19 @@ int EmitCIEBasedABC(cmsIOHANDLER* m, cmsFloat64Number* Matrix, cmsToneCurve** Cu
|
||||
|
||||
_cmsIOPrintf(m, "[ /CIEBasedABC\n");
|
||||
_cmsIOPrintf(m, "<<\n");
|
||||
_cmsIOPrintf(m, "/DecodeABC [ ");
|
||||
|
||||
EmitNGamma(m, 3, CurveSet);
|
||||
|
||||
EmitSafeGuardBegin(m, "lcms2gammaproc0");
|
||||
EmitSafeGuardBegin(m, "lcms2gammaproc1");
|
||||
EmitSafeGuardBegin(m, "lcms2gammaproc2");
|
||||
EmitNGamma(m, 3, CurveSet, "lcms2gammaproc");
|
||||
_cmsIOPrintf(m, "/DecodeABC [\n");
|
||||
_cmsIOPrintf(m, " /lcms2gammaproc0 load\n");
|
||||
_cmsIOPrintf(m, " /lcms2gammaproc1 load\n");
|
||||
_cmsIOPrintf(m, " /lcms2gammaproc2 load\n");
|
||||
_cmsIOPrintf(m, "]\n");
|
||||
EmitSafeGuardEnd(m, "lcms2gammaproc2", 3);
|
||||
EmitSafeGuardEnd(m, "lcms2gammaproc1", 3);
|
||||
EmitSafeGuardEnd(m, "lcms2gammaproc0", 3);
|
||||
|
||||
_cmsIOPrintf(m, "/MatrixABC [ " );
|
||||
|
||||
@ -801,28 +804,31 @@ int EmitCIEBasedDEF(cmsIOHANDLER* m, cmsPipeline* Pipeline, cmsUInt32Number Inte
|
||||
{
|
||||
const char* PreMaj;
|
||||
const char* PostMaj;
|
||||
const char* PreMin, *PostMin;
|
||||
const char* PreMin, * PostMin;
|
||||
cmsStage* mpe;
|
||||
int i, numchans;
|
||||
static char buffer[2048];
|
||||
|
||||
mpe = Pipeline ->Elements;
|
||||
mpe = Pipeline->Elements;
|
||||
|
||||
switch (cmsStageInputChannels(mpe)) {
|
||||
case 3:
|
||||
_cmsIOPrintf(m, "[ /CIEBasedDEF\n");
|
||||
PreMaj = "<";
|
||||
PostMaj = ">\n";
|
||||
PreMin = PostMin = "";
|
||||
break;
|
||||
|
||||
_cmsIOPrintf(m, "[ /CIEBasedDEF\n");
|
||||
PreMaj ="<";
|
||||
PostMaj= ">\n";
|
||||
PreMin = PostMin = "";
|
||||
break;
|
||||
case 4:
|
||||
_cmsIOPrintf(m, "[ /CIEBasedDEFG\n");
|
||||
PreMaj = "[";
|
||||
PostMaj = "]\n";
|
||||
PreMin = "<";
|
||||
PostMin = ">\n";
|
||||
break;
|
||||
_cmsIOPrintf(m, "[ /CIEBasedDEFG\n");
|
||||
PreMaj = "[";
|
||||
PostMaj = "]\n";
|
||||
PreMin = "<";
|
||||
PostMin = ">\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
@ -830,18 +836,34 @@ int EmitCIEBasedDEF(cmsIOHANDLER* m, cmsPipeline* Pipeline, cmsUInt32Number Inte
|
||||
|
||||
if (cmsStageType(mpe) == cmsSigCurveSetElemType) {
|
||||
|
||||
_cmsIOPrintf(m, "/DecodeDEF [ ");
|
||||
EmitNGamma(m, cmsStageOutputChannels(mpe), _cmsStageGetPtrToCurveSet(mpe));
|
||||
numchans = cmsStageOutputChannels(mpe);
|
||||
for (i = 0; i < numchans; ++i) {
|
||||
snprintf(buffer, sizeof(buffer), "lcms2gammaproc%d", i);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
EmitSafeGuardBegin(m, buffer);
|
||||
}
|
||||
EmitNGamma(m, cmsStageOutputChannels(mpe), _cmsStageGetPtrToCurveSet(mpe), "lcms2gammaproc");
|
||||
_cmsIOPrintf(m, "/DecodeDEF [\n");
|
||||
for (i = 0; i < numchans; ++i) {
|
||||
snprintf(buffer, sizeof(buffer), " /lcms2gammaproc%d load\n", i);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
_cmsIOPrintf(m, buffer);
|
||||
}
|
||||
_cmsIOPrintf(m, "]\n");
|
||||
for (i = numchans - 1; i >= 0; --i) {
|
||||
snprintf(buffer, sizeof(buffer), "lcms2gammaproc%d", i);
|
||||
buffer[sizeof(buffer) - 1] = '\0';
|
||||
EmitSafeGuardEnd(m, buffer, 3);
|
||||
}
|
||||
|
||||
mpe = mpe ->Next;
|
||||
mpe = mpe->Next;
|
||||
}
|
||||
|
||||
if (cmsStageType(mpe) == cmsSigCLutElemType) {
|
||||
|
||||
_cmsIOPrintf(m, "/Table ");
|
||||
WriteCLUT(m, mpe, PreMaj, PostMaj, PreMin, PostMin, FALSE, (cmsColorSpaceSignature) 0);
|
||||
_cmsIOPrintf(m, "]\n");
|
||||
_cmsIOPrintf(m, "/Table ");
|
||||
WriteCLUT(m, mpe, PreMaj, PostMaj, PreMin, PostMin, FALSE, (cmsColorSpaceSignature)0);
|
||||
_cmsIOPrintf(m, "]\n");
|
||||
}
|
||||
|
||||
EmitLab2XYZ(m);
|
||||
@ -952,7 +974,7 @@ int WriteInputLUT(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsUInt32Number Intent,
|
||||
|
||||
default:
|
||||
|
||||
cmsSignalError(m ->ContextID, cmsERROR_COLORSPACE_CHECK, "Only 3, 4 channels supported for CSA. This profile has %d channels.", nChannels);
|
||||
cmsSignalError(m ->ContextID, cmsERROR_COLORSPACE_CHECK, "Only 3, 4 channels are supported for CSA. This profile has %d channels.", nChannels);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1011,7 +1033,7 @@ int WriteInputMatrixShaper(cmsIOHANDLER* m, cmsHPROFILE hProfile, cmsStage* Matr
|
||||
return 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
@ -1268,8 +1290,6 @@ void EmitPQRStage(cmsIOHANDLER* m, cmsHPROFILE hProfile, int DoBPC, int lIsAbsol
|
||||
"exch pop exch pop exch pop exch pop } bind\n]\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1299,7 +1319,7 @@ void EmitXYZ2Lab(cmsIOHANDLER* m)
|
||||
// Due to impedance mismatch between XYZ and almost all RGB and CMYK spaces
|
||||
// I choose to dump LUTS in Lab instead of XYZ. There is still a lot of wasted
|
||||
// space on 3D CLUT, but since space seems not to be a problem here, 33 points
|
||||
// would give a reasonable accurancy. Note also that CRD tables must operate in
|
||||
// would give a reasonable accuracy. Note also that CRD tables must operate in
|
||||
// 8 bits.
|
||||
|
||||
static
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -195,7 +195,7 @@ typedef cmsBool (* PositionTableEntryFn)(struct _cms_typehandler_struct* self,
|
||||
cmsUInt32Number SizeOfTag);
|
||||
|
||||
// Helper function to deal with position tables as described in ICC spec 4.3
|
||||
// A table of n elements is readed, where first comes n records containing offsets and sizes and
|
||||
// A table of n elements is read, where first comes n records containing offsets and sizes and
|
||||
// then a block containing the data itself. This allows to reuse same data in more than one entry
|
||||
static
|
||||
cmsBool ReadPositionTable(struct _cms_typehandler_struct* self,
|
||||
@ -1003,7 +1003,7 @@ cmsBool Type_Text_Description_Write(struct _cms_typehandler_struct* self, cmsIO
|
||||
len = cmsMLUgetASCII(mlu, cmsNoLanguage, cmsNoCountry, NULL, 0);
|
||||
|
||||
// Specification ICC.1:2001-04 (v2.4.0): It has been found that textDescriptionType can contain misaligned data
|
||||
//(see clause 4.1 for the definition of “aligned”). Because the Unicode language
|
||||
//(see clause 4.1 for the definition of 'aligned'). Because the Unicode language
|
||||
// code and Unicode count immediately follow the ASCII description, their
|
||||
// alignment is not correct if the ASCII count is not a multiple of four. The
|
||||
// ScriptCode code is misaligned when the ASCII count is odd. Profile reading and
|
||||
@ -1509,7 +1509,7 @@ void *Type_MLU_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsU
|
||||
// True begin of the string
|
||||
BeginOfThisString = Offset - SizeOfHeader - 8;
|
||||
|
||||
// Ajust to wchar_t elements
|
||||
// Adjust to wchar_t elements
|
||||
mlu ->Entries[i].Len = (Len * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
|
||||
mlu ->Entries[i].StrW = (BeginOfThisString * sizeof(wchar_t)) / sizeof(cmsUInt16Number);
|
||||
|
||||
@ -1882,7 +1882,7 @@ Error:
|
||||
static
|
||||
cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
|
||||
{
|
||||
cmsUInt32Number j, nTabSize;
|
||||
cmsUInt32Number j, nTabSize, i, n;
|
||||
cmsUInt8Number val;
|
||||
cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
|
||||
cmsStage* mpe;
|
||||
@ -1931,22 +1931,19 @@ cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
|
||||
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
|
||||
if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
|
||||
|
||||
n = NewLUT->InputChannels * NewLUT->OutputChannels;
|
||||
|
||||
if (MatMPE != NULL) {
|
||||
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE;
|
||||
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
if (n != 9) return FALSE;
|
||||
|
||||
if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
|
||||
@ -2170,7 +2167,7 @@ Error:
|
||||
// Some empty defaults are created for missing parts
|
||||
|
||||
static
|
||||
cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
|
||||
cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, void* Ptr, cmsUInt32Number nItems)
|
||||
{
|
||||
cmsUInt32Number nTabSize;
|
||||
cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
|
||||
@ -2185,6 +2182,7 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io
|
||||
if (mpe != NULL && mpe ->Type == cmsSigMatrixElemType) {
|
||||
|
||||
MatMPE = (_cmsStageMatrixData*) mpe ->Data;
|
||||
if (mpe->InputChannels != 3 || mpe->OutputChannels != 3) return FALSE;
|
||||
mpe = mpe -> Next;
|
||||
}
|
||||
|
||||
@ -2223,18 +2221,13 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER* io
|
||||
if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
|
||||
if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
|
||||
|
||||
|
||||
if (MatMPE != NULL) {
|
||||
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE;
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i])) return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
@ -2423,7 +2416,7 @@ cmsStage* ReadCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return CLUT;
|
||||
return CLUT;
|
||||
}
|
||||
|
||||
static
|
||||
@ -2579,31 +2572,31 @@ Error:
|
||||
static
|
||||
cmsBool WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsStage* mpe)
|
||||
{
|
||||
cmsUInt32Number i, n;
|
||||
|
||||
_cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data;
|
||||
|
||||
// Write the Matrix
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[0])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[1])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[2])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[3])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[4])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[5])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[6])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[7])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Double[8])) return FALSE;
|
||||
n = mpe->InputChannels * mpe->OutputChannels;
|
||||
|
||||
if (m ->Offset != NULL) {
|
||||
// Write the Matrix
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (!_cmsWrite15Fixed16Number(io, m->Double[i])) return FALSE;
|
||||
}
|
||||
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Offset[0])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Offset[1])) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, m -> Offset[2])) return FALSE;
|
||||
}
|
||||
else {
|
||||
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
|
||||
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
|
||||
if (m->Offset != NULL) {
|
||||
|
||||
}
|
||||
for (i = 0; i < mpe->OutputChannels; i++)
|
||||
{
|
||||
if (!_cmsWrite15Fixed16Number(io, m->Offset[i])) return FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < mpe->OutputChannels; i++)
|
||||
{
|
||||
if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
@ -2707,9 +2700,9 @@ cmsBool WriteCLUT(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUIn
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!_cmsWriteAlignment(io)) return FALSE;
|
||||
if (!_cmsWriteAlignment(io)) return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@ -3120,10 +3113,10 @@ void Type_ColorantTable_Free(struct _cms_typehandler_struct* self, void* Ptr)
|
||||
//The namedColor2Type is a count value and array of structures that provide color
|
||||
//coordinates for 7-bit ASCII color names. For each named color, a PCS and optional
|
||||
//device representation of the color are given. Both representations are 16-bit values.
|
||||
//The device representation corresponds to the header’s “color space of data” field.
|
||||
//This representation should be consistent with the “number of device components”
|
||||
//The device representation corresponds to the header's 'color space of data' field.
|
||||
//This representation should be consistent with the 'number of device components'
|
||||
//field in the namedColor2Type. If this field is 0, device coordinates are not provided.
|
||||
//The PCS representation corresponds to the header’s PCS field. The PCS representation
|
||||
//The PCS representation corresponds to the header's PCS field. The PCS representation
|
||||
//is always provided. Color names are fixed-length, 32-byte fields including null
|
||||
//termination. In order to maintain maximum portability, it is strongly recommended
|
||||
//that special characters of the 7-bit ASCII set not be used.
|
||||
@ -3868,7 +3861,7 @@ void Type_Screening_Free(struct _cms_typehandler_struct* self, void* Ptr)
|
||||
// ********************************************************************************
|
||||
//
|
||||
//This type represents a set of viewing condition parameters including:
|
||||
//CIE ’absolute’ illuminant white point tristimulus values and CIE ’absolute’
|
||||
//CIE 'absolute' illuminant white point tristimulus values and CIE 'absolute'
|
||||
//surround tristimulus values.
|
||||
|
||||
static
|
||||
@ -3955,7 +3948,7 @@ void GenericMPEfree(struct _cms_typehandler_struct* self, void *Ptr)
|
||||
}
|
||||
|
||||
// Each curve is stored in one or more curve segments, with break-points specified between curve segments.
|
||||
// The first curve segment always starts at –Infinity, and the last curve segment always ends at +Infinity. The
|
||||
// The first curve segment always starts at -Infinity, and the last curve segment always ends at +Infinity. The
|
||||
// first and last curve segments shall be specified in terms of a formula, whereas the other segments shall be
|
||||
// specified either in terms of a formula, or by a sampled curve.
|
||||
|
||||
@ -4236,7 +4229,7 @@ cmsBool Type_MPEcurve_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER*
|
||||
// The matrix is organized as an array of PxQ+Q elements, where P is the number of input channels to the
|
||||
// matrix, and Q is the number of output channels. The matrix elements are each float32Numbers. The array
|
||||
// is organized as follows:
|
||||
// array = [e11, e12, …, e1P, e21, e22, …, e2P, …, eQ1, eQ2, …, eQP, e1, e2, …, eQ]
|
||||
// array = [e11, e12, ..., e1P, e21, e22, ..., e2P, ..., eQ1, eQ2, ..., eQP, e1, e2, ..., eQ]
|
||||
|
||||
static
|
||||
void *Type_MPEmatrix_Read(struct _cms_typehandler_struct* self, cmsIOHANDLER* io, cmsUInt32Number* nItems, cmsUInt32Number SizeOfTag)
|
||||
@ -4759,10 +4752,10 @@ void *Type_vcgt_Read(struct _cms_typehandler_struct* self,
|
||||
// Y = cX + f | X < d
|
||||
|
||||
// vcgt formula is:
|
||||
// Y = (Max – Min) * (X ^ Gamma) + Min
|
||||
// Y = (Max - Min) * (X ^ Gamma) + Min
|
||||
|
||||
// So, the translation is
|
||||
// a = (Max – Min) ^ ( 1 / Gamma)
|
||||
// a = (Max - Min) ^ ( 1 / Gamma)
|
||||
// e = Min
|
||||
// b=c=d=f=0
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -390,7 +390,7 @@ cmsHPROFILE CMSEXPORT cmsCreateLinearizationDeviceLink(cmsColorSpaceSignature Co
|
||||
// K: Does not change
|
||||
|
||||
static
|
||||
int InkLimitingSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||
int InkLimitingSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
|
||||
{
|
||||
cmsFloat64Number InkLimit = *(cmsFloat64Number *) Cargo;
|
||||
cmsFloat64Number SumCMY, SumCMYK, Ratio;
|
||||
@ -641,18 +641,18 @@ cmsHPROFILE CMSEXPORT cmsCreateXYZProfile(void)
|
||||
|
||||
//sRGB Curves are defined by:
|
||||
//
|
||||
//If R’sRGB,G’sRGB, B’sRGB < 0.04045
|
||||
//If R'sRGB,G'sRGB, B'sRGB < 0.04045
|
||||
//
|
||||
// R = R’sRGB / 12.92
|
||||
// G = G’sRGB / 12.92
|
||||
// B = B’sRGB / 12.92
|
||||
// R = R'sRGB / 12.92
|
||||
// G = G'sRGB / 12.92
|
||||
// B = B'sRGB / 12.92
|
||||
//
|
||||
//
|
||||
//else if R’sRGB,G’sRGB, B’sRGB >= 0.04045
|
||||
//else if R'sRGB,G'sRGB, B'sRGB >= 0.04045
|
||||
//
|
||||
// R = ((R’sRGB + 0.055) / 1.055)^2.4
|
||||
// G = ((G’sRGB + 0.055) / 1.055)^2.4
|
||||
// B = ((B’sRGB + 0.055) / 1.055)^2.4
|
||||
// R = ((R'sRGB + 0.055) / 1.055)^2.4
|
||||
// G = ((G'sRGB + 0.055) / 1.055)^2.4
|
||||
// B = ((B'sRGB + 0.055) / 1.055)^2.4
|
||||
|
||||
static
|
||||
cmsToneCurve* Build_sRGBGamma(cmsContext ContextID)
|
||||
@ -715,7 +715,7 @@ typedef struct {
|
||||
|
||||
|
||||
static
|
||||
int bchswSampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void* Cargo)
|
||||
int bchswSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Number Out[], CMSREGISTER void* Cargo)
|
||||
{
|
||||
cmsCIELab LabIn, LabOut;
|
||||
cmsCIELCh LChIn, LChOut;
|
||||
@ -1125,9 +1125,10 @@ cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat
|
||||
goto Error;
|
||||
}
|
||||
|
||||
// On the output side too
|
||||
// On the output side too. Note that due to V2/V4 PCS encoding on lab we cannot fix white misalignments
|
||||
if ((xform ->ExitColorSpace) == cmsSigLabData && (Version < 4.0)) {
|
||||
|
||||
dwFlags |= cmsFLAGS_NOWHITEONWHITEFIXUP;
|
||||
if (!cmsPipelineInsertStage(LUT, cmsAT_END, _cmsStageAllocLabV4ToV2(ContextID)))
|
||||
goto Error;
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -104,19 +104,19 @@ cmsBool CMSEXPORT cmsWhitePointFromTemp(cmsCIExyY* WhitePoint, cmsFloat64Number
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Obtain y(x)
|
||||
y = -3.000*(x*x) + 2.870*x - 0.275;
|
||||
// Obtain y(x)
|
||||
y = -3.000*(x*x) + 2.870*x - 0.275;
|
||||
|
||||
// wave factors (not used, but here for futures extensions)
|
||||
// wave factors (not used, but here for futures extensions)
|
||||
|
||||
// M1 = (-1.3515 - 1.7703*x + 5.9114 *y)/(0.0241 + 0.2562*x - 0.7341*y);
|
||||
// M2 = (0.0300 - 31.4424*x + 30.0717*y)/(0.0241 + 0.2562*x - 0.7341*y);
|
||||
// M1 = (-1.3515 - 1.7703*x + 5.9114 *y)/(0.0241 + 0.2562*x - 0.7341*y);
|
||||
// M2 = (0.0300 - 31.4424*x + 30.0717*y)/(0.0241 + 0.2562*x - 0.7341*y);
|
||||
|
||||
WhitePoint -> x = x;
|
||||
WhitePoint -> y = y;
|
||||
WhitePoint -> Y = 1.0;
|
||||
WhitePoint -> x = x;
|
||||
WhitePoint -> y = y;
|
||||
WhitePoint -> Y = 1.0;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -200,6 +200,23 @@ void CMSEXPORT cmsDeleteTransform(cmsHTRANSFORM hTransform)
|
||||
_cmsFree(p ->ContextID, (void *) p);
|
||||
}
|
||||
|
||||
|
||||
static
|
||||
cmsUInt32Number PixelSize(cmsUInt32Number Format)
|
||||
{
|
||||
cmsUInt32Number fmt_bytes = T_BYTES(Format);
|
||||
|
||||
// For double, the T_BYTES field is zero
|
||||
if (fmt_bytes == 0)
|
||||
return sizeof(cmsUInt64Number);
|
||||
|
||||
// Otherwise, it is already correct for all formats
|
||||
return fmt_bytes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Apply transform.
|
||||
void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
|
||||
const void* InputBuffer,
|
||||
@ -212,8 +229,8 @@ void CMSEXPORT cmsDoTransform(cmsHTRANSFORM Transform,
|
||||
|
||||
stride.BytesPerLineIn = 0; // Not used
|
||||
stride.BytesPerLineOut = 0;
|
||||
stride.BytesPerPlaneIn = Size;
|
||||
stride.BytesPerPlaneOut = Size;
|
||||
stride.BytesPerPlaneIn = Size * PixelSize(p->InputFormat);
|
||||
stride.BytesPerPlaneOut = Size * PixelSize(p->OutputFormat);
|
||||
|
||||
p -> xform(p, InputBuffer, OutputBuffer, Size, 1, &stride);
|
||||
}
|
||||
@ -370,7 +387,7 @@ void NullFloatXFORM(_cmsTRANSFORM* p,
|
||||
|
||||
// 16 bit precision -----------------------------------------------------------------------------------------------------------
|
||||
|
||||
// Null transformation, only applies formatters. No caché
|
||||
// Null transformation, only applies formatters. No cache
|
||||
static
|
||||
void NullXFORM(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
@ -417,8 +434,8 @@ void PrecalculatedXFORM(_cmsTRANSFORM* p,
|
||||
cmsUInt32Number LineCount,
|
||||
const cmsStride* Stride)
|
||||
{
|
||||
register cmsUInt8Number* accum;
|
||||
register cmsUInt8Number* output;
|
||||
CMSREGISTER cmsUInt8Number* accum;
|
||||
CMSREGISTER cmsUInt8Number* output;
|
||||
cmsUInt16Number wIn[cmsMAXCHANNELS], wOut[cmsMAXCHANNELS];
|
||||
cmsUInt32Number i, j, strideIn, strideOut;
|
||||
|
||||
@ -471,7 +488,7 @@ void TransformOnePixelWithGamutCheck(_cmsTRANSFORM* p,
|
||||
p ->Lut ->Eval16Fn(wIn, wOut, p -> Lut->Data);
|
||||
}
|
||||
|
||||
// Gamut check, No caché, 16 bits.
|
||||
// Gamut check, No cache, 16 bits.
|
||||
static
|
||||
void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
@ -510,7 +527,7 @@ void PrecalculatedXFORMGamutCheck(_cmsTRANSFORM* p,
|
||||
}
|
||||
|
||||
|
||||
// No gamut check, Caché, 16 bits,
|
||||
// No gamut check, Cache, 16 bits,
|
||||
static
|
||||
void CachedXFORM(_cmsTRANSFORM* p,
|
||||
const void* in,
|
||||
@ -809,43 +826,46 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
|
||||
// Let's see if any plug-in want to do the transform by itself
|
||||
if (p->Lut != NULL) {
|
||||
|
||||
for (Plugin = ctx->TransformCollection;
|
||||
Plugin != NULL;
|
||||
Plugin = Plugin->Next) {
|
||||
if (!(*dwFlags & cmsFLAGS_NOOPTIMIZE))
|
||||
{
|
||||
for (Plugin = ctx->TransformCollection;
|
||||
Plugin != NULL;
|
||||
Plugin = Plugin->Next) {
|
||||
|
||||
if (Plugin->Factory(&p->xform, &p->UserData, &p->FreeUserData, &p->Lut, InputFormat, OutputFormat, dwFlags)) {
|
||||
if (Plugin->Factory(&p->xform, &p->UserData, &p->FreeUserData, &p->Lut, InputFormat, OutputFormat, dwFlags)) {
|
||||
|
||||
// Last plugin in the declaration order takes control. We just keep
|
||||
// the original parameters as a logging.
|
||||
// Note that cmsFLAGS_CAN_CHANGE_FORMATTER is not set, so by default
|
||||
// an optimized transform is not reusable. The plug-in can, however, change
|
||||
// the flags and make it suitable.
|
||||
// Last plugin in the declaration order takes control. We just keep
|
||||
// the original parameters as a logging.
|
||||
// Note that cmsFLAGS_CAN_CHANGE_FORMATTER is not set, so by default
|
||||
// an optimized transform is not reusable. The plug-in can, however, change
|
||||
// the flags and make it suitable.
|
||||
|
||||
p->ContextID = ContextID;
|
||||
p->InputFormat = *InputFormat;
|
||||
p->OutputFormat = *OutputFormat;
|
||||
p->dwOriginalFlags = *dwFlags;
|
||||
p->ContextID = ContextID;
|
||||
p->InputFormat = *InputFormat;
|
||||
p->OutputFormat = *OutputFormat;
|
||||
p->dwOriginalFlags = *dwFlags;
|
||||
|
||||
// Fill the formatters just in case the optimized routine is interested.
|
||||
// No error is thrown if the formatter doesn't exist. It is up to the optimization
|
||||
// factory to decide what to do in those cases.
|
||||
p->FromInput = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_16BITS).Fmt16;
|
||||
p->ToOutput = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
|
||||
p->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
|
||||
p->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
|
||||
// Fill the formatters just in case the optimized routine is interested.
|
||||
// No error is thrown if the formatter doesn't exist. It is up to the optimization
|
||||
// factory to decide what to do in those cases.
|
||||
p->FromInput = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_16BITS).Fmt16;
|
||||
p->ToOutput = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_16BITS).Fmt16;
|
||||
p->FromInputFloat = _cmsGetFormatter(ContextID, *InputFormat, cmsFormatterInput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
|
||||
p->ToOutputFloat = _cmsGetFormatter(ContextID, *OutputFormat, cmsFormatterOutput, CMS_PACK_FLAGS_FLOAT).FmtFloat;
|
||||
|
||||
// Save the day? (Ignore the warning)
|
||||
if (Plugin->OldXform) {
|
||||
p->OldXform = (_cmsTransformFn)(void*) p->xform;
|
||||
p->xform = _cmsTransform2toTransformAdaptor;
|
||||
}
|
||||
// Save the day? (Ignore the warning)
|
||||
if (Plugin->OldXform) {
|
||||
p->OldXform = (_cmsTransformFn)(void*)p->xform;
|
||||
p->xform = _cmsTransform2toTransformAdaptor;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Not suitable for the transform plug-in, let's check the pipeline plug-in
|
||||
_cmsOptimizePipeline(ContextID, &p->Lut, Intent, InputFormat, OutputFormat, dwFlags);
|
||||
// Not suitable for the transform plug-in, let's check the pipeline plug-in
|
||||
_cmsOptimizePipeline(ContextID, &p->Lut, Intent, InputFormat, OutputFormat, dwFlags);
|
||||
}
|
||||
|
||||
// Check whatever this is a true floating point transform
|
||||
@ -868,7 +888,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
|
||||
p ->xform = NullFloatXFORM;
|
||||
}
|
||||
else {
|
||||
// Float transforms don't use caché, always are non-NULL
|
||||
// Float transforms don't use cache, always are non-NULL
|
||||
p ->xform = FloatXFORM;
|
||||
}
|
||||
|
||||
@ -907,16 +927,16 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
|
||||
if (*dwFlags & cmsFLAGS_NOCACHE) {
|
||||
|
||||
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
|
||||
p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no caché
|
||||
p ->xform = PrecalculatedXFORMGamutCheck; // Gamut check, no cache
|
||||
else
|
||||
p ->xform = PrecalculatedXFORM; // No caché, no gamut check
|
||||
p ->xform = PrecalculatedXFORM; // No cache, no gamut check
|
||||
}
|
||||
else {
|
||||
|
||||
if (*dwFlags & cmsFLAGS_GAMUTCHECK)
|
||||
p ->xform = CachedXFORMGamutCheck; // Gamut check, caché
|
||||
p ->xform = CachedXFORMGamutCheck; // Gamut check, cache
|
||||
else
|
||||
p ->xform = CachedXFORM; // No gamut check, caché
|
||||
p ->xform = CachedXFORM; // No gamut check, cache
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -52,7 +52,7 @@
|
||||
//
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Version 2.9rc3
|
||||
// Version 2.11
|
||||
//
|
||||
|
||||
#ifndef _lcms2_H
|
||||
@ -90,6 +90,9 @@
|
||||
// Uncomment this for special windows mutex initialization (see lcms2_internal.h)
|
||||
// #define CMS_RELY_ON_WINDOWS_STATIC_MUTEX_INIT
|
||||
|
||||
// Uncomment this to remove the "register" storage class
|
||||
// #define CMS_NO_REGISTER_KEYWORD 1
|
||||
|
||||
// ********** End of configuration toggles ******************************
|
||||
|
||||
// Needed for streams
|
||||
@ -107,7 +110,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Version/release
|
||||
#define LCMS_VERSION 2090
|
||||
#define LCMS_VERSION 2100
|
||||
|
||||
// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
|
||||
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
|
||||
@ -177,6 +180,13 @@ typedef double cmsFloat64Number;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Handle "register" keyword
|
||||
#if defined(CMS_NO_REGISTER_KEYWORD) && !defined(CMS_DLL) && !defined(CMS_DLL_BUILD)
|
||||
# define CMSREGISTER
|
||||
#else
|
||||
# define CMSREGISTER register
|
||||
#endif
|
||||
|
||||
// In the case 64 bit numbers are not supported by the compiler
|
||||
#ifdef CMS_DONT_USE_INT64
|
||||
typedef cmsUInt32Number cmsUInt64Number[2];
|
||||
@ -1058,7 +1068,7 @@ CMSAPI long int CMSEXPORT cmsfilelength(FILE* f);
|
||||
typedef struct _cmsContext_struct* cmsContext;
|
||||
|
||||
CMSAPI cmsContext CMSEXPORT cmsCreateContext(void* Plugin, void* UserData);
|
||||
CMSAPI void CMSEXPORT cmsDeleteContext(cmsContext ContexID);
|
||||
CMSAPI void CMSEXPORT cmsDeleteContext(cmsContext ContextID);
|
||||
CMSAPI cmsContext CMSEXPORT cmsDupContext(cmsContext ContextID, void* NewUserData);
|
||||
CMSAPI void* CMSEXPORT cmsGetContextUserData(cmsContext ContextID);
|
||||
|
||||
@ -1210,6 +1220,7 @@ CMSAPI cmsBool CMSEXPORT cmsIsToneCurveMonotonic(const cmsToneCurve* t
|
||||
CMSAPI cmsBool CMSEXPORT cmsIsToneCurveDescending(const cmsToneCurve* t);
|
||||
CMSAPI cmsInt32Number CMSEXPORT cmsGetToneCurveParametricType(const cmsToneCurve* t);
|
||||
CMSAPI cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Number Precision);
|
||||
CMSAPI cmsFloat64Number* CMSEXPORT cmsGetToneCurveParams(const cmsToneCurve* t);
|
||||
|
||||
// Tone curve tabular estimation
|
||||
CMSAPI cmsUInt32Number CMSEXPORT cmsGetToneCurveEstimatedTableEntries(const cmsToneCurve* t);
|
||||
@ -1276,13 +1287,13 @@ CMSAPI cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe);
|
||||
CMSAPI void* CMSEXPORT cmsStageData(const cmsStage* mpe);
|
||||
|
||||
// Sampling
|
||||
typedef cmsInt32Number (* cmsSAMPLER16) (register const cmsUInt16Number In[],
|
||||
register cmsUInt16Number Out[],
|
||||
register void * Cargo);
|
||||
typedef cmsInt32Number (* cmsSAMPLER16) (CMSREGISTER const cmsUInt16Number In[],
|
||||
CMSREGISTER cmsUInt16Number Out[],
|
||||
CMSREGISTER void * Cargo);
|
||||
|
||||
typedef cmsInt32Number (* cmsSAMPLERFLOAT)(register const cmsFloat32Number In[],
|
||||
register cmsFloat32Number Out[],
|
||||
register void * Cargo);
|
||||
typedef cmsInt32Number (* cmsSAMPLERFLOAT)(CMSREGISTER const cmsFloat32Number In[],
|
||||
CMSREGISTER cmsFloat32Number Out[],
|
||||
CMSREGISTER void * Cargo);
|
||||
|
||||
// Use this flag to prevent changes being written to destination
|
||||
#define SAMPLER_INSPECT 0x01000000
|
||||
@ -1673,7 +1684,7 @@ CMSAPI cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID
|
||||
// Misc
|
||||
#define cmsFLAGS_BLACKPOINTCOMPENSATION 0x2000
|
||||
#define cmsFLAGS_NOWHITEONWHITEFIXUP 0x0004 // Don't fix scum dot
|
||||
#define cmsFLAGS_HIGHRESPRECALC 0x0400 // Use more memory to give better accurancy
|
||||
#define cmsFLAGS_HIGHRESPRECALC 0x0400 // Use more memory to give better accuracy
|
||||
#define cmsFLAGS_LOWRESPRECALC 0x0800 // Use less memory to minimize resources
|
||||
|
||||
// For devicelink creation
|
||||
|
@ -27,10 +27,10 @@
|
||||
// However, the following notice accompanied the original version of this
|
||||
// file:
|
||||
//
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -76,7 +76,7 @@
|
||||
#endif
|
||||
|
||||
// BorlandC 5.5, VC2003 are broken on that
|
||||
#if defined(__BORLANDC__) || (_MSC_VER < 1400) // 1400 == VC++ 8.0
|
||||
#if defined(__BORLANDC__) || (defined(_MSC_VER) && (_MSC_VER < 1400)) // 1400 == VC++ 8.0
|
||||
#define sinf(x) (float)sin((float)x)
|
||||
#define sqrtf(x) (float)sqrt((float)x)
|
||||
#endif
|
||||
@ -117,6 +117,13 @@
|
||||
# define cmsINLINE static inline
|
||||
#endif
|
||||
|
||||
// Allow signed overflow, we know this is harmless in this particular context
|
||||
#if defined(__clang__)
|
||||
# define CMS_NO_SANITIZE __attribute__((no_sanitize("signed-integer-overflow")))
|
||||
#else
|
||||
# define CMS_NO_SANITIZE
|
||||
#endif
|
||||
|
||||
// Other replacement functions
|
||||
#ifdef _MSC_VER
|
||||
# ifndef snprintf
|
||||
@ -128,12 +135,19 @@
|
||||
|
||||
/// Properly define some macros to accommodate
|
||||
/// older MSVC versions.
|
||||
# if _MSC_VER <= 1700
|
||||
# if defined(_MSC_VER) && _MSC_VER <= 1700
|
||||
#include <float.h>
|
||||
#define isnan _isnan
|
||||
#define isinf(x) (!_finite((x)))
|
||||
# endif
|
||||
|
||||
#if !defined(_MSC_VER) && (defined(__STDC_VERSION__) && __STDC_VERSION__ < 199901L)
|
||||
#if !defined(isinf)
|
||||
#define isinf(x) (!finite((x)))
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// A fast way to convert from/to 16 <-> 8 bits
|
||||
@ -964,6 +978,9 @@ cmsBool _cmsReadCHAD(cmsMAT3* Dest, cmsHPROFILE hProfile);
|
||||
|
||||
// Profile linker --------------------------------------------------------------------------------------------------
|
||||
|
||||
// Link several profiles to obtain a single LUT modelling the whole color transform. Intents, Black point
|
||||
// compensation and Adaptation parameters may vary across profiles. BPC and Adaptation refers to the PCS
|
||||
// after the profile. I.e, BPC[0] refers to connexion between profile(0) and profile(1)
|
||||
cmsPipeline* _cmsLinkProfiles(cmsContext ContextID,
|
||||
cmsUInt32Number nProfiles,
|
||||
cmsUInt32Number TheIntents[],
|
||||
|
@ -30,7 +30,7 @@
|
||||
//---------------------------------------------------------------------------------
|
||||
//
|
||||
// Little Color Management System
|
||||
// Copyright (c) 1998-2017 Marti Maria Saguer
|
||||
// Copyright (c) 1998-2020 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"),
|
||||
@ -123,6 +123,12 @@ CMSAPI cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC
|
||||
CMSAPI void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
|
||||
|
||||
|
||||
// MD5 low level -------------------------------------------------------------------------------------
|
||||
|
||||
CMSAPI cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID);
|
||||
CMSAPI void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len);
|
||||
CMSAPI void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle);
|
||||
|
||||
// Error logging -------------------------------------------------------------------------------------
|
||||
|
||||
CMSAPI void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
|
||||
@ -284,9 +290,9 @@ struct _cms_interp_struc;
|
||||
// 16 bits forward interpolation. This function performs precision-limited linear interpolation
|
||||
// and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
|
||||
// choose to implement any other interpolation algorithm.
|
||||
typedef void (* _cmsInterpFn16)(register const cmsUInt16Number Input[],
|
||||
register cmsUInt16Number Output[],
|
||||
register const struct _cms_interp_struc* p);
|
||||
typedef void (* _cmsInterpFn16)(CMSREGISTER const cmsUInt16Number Input[],
|
||||
CMSREGISTER cmsUInt16Number Output[],
|
||||
CMSREGISTER const struct _cms_interp_struc* p);
|
||||
|
||||
// Floating point forward interpolation. Full precision interpolation using floats. This is not a
|
||||
// time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
|
||||
@ -369,10 +375,10 @@ typedef struct {
|
||||
|
||||
struct _cmstransform_struct;
|
||||
|
||||
typedef cmsUInt8Number* (* cmsFormatter16)(register struct _cmstransform_struct* CMMcargo,
|
||||
register cmsUInt16Number Values[],
|
||||
register cmsUInt8Number* Buffer,
|
||||
register cmsUInt32Number Stride);
|
||||
typedef cmsUInt8Number* (* cmsFormatter16)(CMSREGISTER struct _cmstransform_struct* CMMcargo,
|
||||
CMSREGISTER cmsUInt16Number Values[],
|
||||
CMSREGISTER cmsUInt8Number* Buffer,
|
||||
CMSREGISTER cmsUInt32Number Stride);
|
||||
|
||||
typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
|
||||
cmsFloat32Number Values[],
|
||||
@ -570,9 +576,9 @@ typedef struct {
|
||||
// the optimization search. Or FALSE if it is unable to optimize and want to give a chance
|
||||
// to the rest of optimizers.
|
||||
|
||||
typedef void (* _cmsOPTeval16Fn)(register const cmsUInt16Number In[],
|
||||
register cmsUInt16Number Out[],
|
||||
register const void* Data);
|
||||
typedef void (* _cmsOPTeval16Fn)(CMSREGISTER const cmsUInt16Number In[],
|
||||
CMSREGISTER cmsUInt16Number Out[],
|
||||
CMSREGISTER const void* Data);
|
||||
|
||||
|
||||
typedef cmsBool (* _cmsOPToptimizeFn)(cmsPipeline** Lut,
|
||||
|
Loading…
x
Reference in New Issue
Block a user