Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
b15d0120
Commit
b15d0120
authored
Feb 17, 2024
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lcms2: Import upstream release 2.16.
parent
041167b2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
738 additions
and
128 deletions
+738
-128
AUTHORS
libs/lcms2/AUTHORS
+1
-0
lcms2.h
libs/lcms2/include/lcms2.h
+46
-7
lcms2_plugin.h
libs/lcms2/include/lcms2_plugin.h
+4
-4
cmsalpha.c
libs/lcms2/src/cmsalpha.c
+16
-14
cmscnvrt.c
libs/lcms2/src/cmscnvrt.c
+28
-16
cmserr.c
libs/lcms2/src/cmserr.c
+4
-3
cmsgamma.c
libs/lcms2/src/cmsgamma.c
+18
-9
cmsgmt.c
libs/lcms2/src/cmsgmt.c
+2
-3
cmsio0.c
libs/lcms2/src/cmsio0.c
+21
-10
cmsio1.c
libs/lcms2/src/cmsio1.c
+11
-1
cmslut.c
libs/lcms2/src/cmslut.c
+10
-3
cmsnamed.c
libs/lcms2/src/cmsnamed.c
+230
-20
cmsopt.c
libs/lcms2/src/cmsopt.c
+10
-7
cmspack.c
libs/lcms2/src/cmspack.c
+184
-2
cmsplugin.c
libs/lcms2/src/cmsplugin.c
+2
-19
cmssamp.c
libs/lcms2/src/cmssamp.c
+1
-1
cmstypes.c
libs/lcms2/src/cmstypes.c
+0
-0
cmsvirt.c
libs/lcms2/src/cmsvirt.c
+130
-7
cmsxform.c
libs/lcms2/src/cmsxform.c
+14
-1
lcms2_internal.h
libs/lcms2/src/lcms2_internal.h
+6
-1
No files found.
libs/lcms2/AUTHORS
View file @
b15d0120
...
...
@@ -42,6 +42,7 @@ Philipp Knechtges
Amyspark
Lovell Fuller
Eli Schwartz
Diogo Teles Sant'Anna
Special Thanks
--------------
...
...
libs/lcms2/include/lcms2.h
View file @
b15d0120
...
...
@@ -23,7 +23,7 @@
//
//---------------------------------------------------------------------------------
//
// Version 2.1
5
// Version 2.1
6
//
#ifndef _lcms2_H
...
...
@@ -76,12 +76,15 @@
#ifndef CMS_USE_CPP_API
# ifdef __cplusplus
# if __cplusplus >= 201703L
# define CMS_NO_REGISTER_KEYWORD 1
# endif
extern
"C"
{
# endif
#endif
// Version/release
#define LCMS_VERSION 21
5
0
#define LCMS_VERSION 21
6
0
// I will give the chance of redefining basic types for compilers that are not fully C99 compliant
#ifndef CMS_BASIC_TYPES_ALREADY_DEFINED
...
...
@@ -325,7 +328,8 @@ typedef enum {
cmsSigUInt8ArrayType
=
0x75693038
,
// 'ui08'
cmsSigVcgtType
=
0x76636774
,
// 'vcgt'
cmsSigViewingConditionsType
=
0x76696577
,
// 'view'
cmsSigXYZType
=
0x58595A20
// 'XYZ '
cmsSigXYZType
=
0x58595A20
,
// 'XYZ '
cmsSigMHC2Type
=
0x4D484332
// 'MHC2'
}
cmsTagTypeSignature
;
...
...
@@ -403,7 +407,8 @@ typedef enum {
cmsSigVcgtTag
=
0x76636774
,
// 'vcgt'
cmsSigMetaTag
=
0x6D657461
,
// 'meta'
cmsSigcicpTag
=
0x63696370
,
// 'cicp'
cmsSigArgyllArtsTag
=
0x61727473
// 'arts'
cmsSigArgyllArtsTag
=
0x61727473
,
// 'arts'
cmsSigMHC2Tag
=
0x4D484332
// 'MHC2'
}
cmsTagSignature
;
...
...
@@ -948,6 +953,7 @@ typedef void* cmsHTRANSFORM;
#define TYPE_RGB_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0))
#define TYPE_BGR_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_RGB)|CHANNELS_SH(3)|BYTES_SH(0)|DOSWAP_SH(1))
#define TYPE_CMYK_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_CMYK)|CHANNELS_SH(4)|BYTES_SH(0))
#define TYPE_OKLAB_DBL (FLOAT_SH(1)|COLORSPACE_SH(PT_MCH3)|CHANNELS_SH(3)|BYTES_SH(0))
// IEEE 754-2008 "half"
#define TYPE_GRAY_HALF_FLT (FLOAT_SH(1)|COLORSPACE_SH(PT_GRAY)|CHANNELS_SH(1)|BYTES_SH(2))
...
...
@@ -1048,6 +1054,19 @@ typedef struct {
}
cmsVideoSignalType
;
typedef
struct
{
cmsUInt32Number
CurveEntries
;
cmsFloat64Number
*
RedCurve
;
cmsFloat64Number
*
GreenCurve
;
cmsFloat64Number
*
BlueCurve
;
cmsFloat64Number
MinLuminance
;
// ST.2086 min luminance in nits
cmsFloat64Number
PeakLuminance
;
// ST.2086 peak luminance in nits
cmsFloat64Number
XYZ2XYZmatrix
[
3
][
4
];
}
cmsMHC2Type
;
// Get LittleCMS version (for shared objects) -----------------------------------------------------------------------------
...
...
@@ -1220,7 +1239,8 @@ 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
);
CMSAPI
const
cmsCurveSegment
*
CMSEXPORT
cmsGetToneCurveSegment
(
cmsInt32Number
n
,
const
cmsToneCurve
*
t
);
// Tone curve tabular estimation
CMSAPI
cmsUInt32Number
CMSEXPORT
cmsGetToneCurveEstimatedTableEntries
(
const
cmsToneCurve
*
t
);
...
...
@@ -1314,8 +1334,11 @@ CMSAPI cmsBool CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, c
typedef
struct
_cms_MLU_struct
cmsMLU
;
#define cmsNoLanguage "\0\0"
#define cmsNoCountry "\0\0"
#define cmsNoLanguage "\0\0"
#define cmsNoCountry "\0\0"
// Special language/country to retrieve unicode field for description in V2 profiles. Use with care.
#define cmsV2Unicode "\xff\xff"
CMSAPI
cmsMLU
*
CMSEXPORT
cmsMLUalloc
(
cmsContext
ContextID
,
cmsUInt32Number
nItems
);
CMSAPI
void
CMSEXPORT
cmsMLUfree
(
cmsMLU
*
mlu
);
...
...
@@ -1327,6 +1350,9 @@ CMSAPI cmsBool CMSEXPORT cmsMLUsetASCII(cmsMLU* mlu,
CMSAPI
cmsBool
CMSEXPORT
cmsMLUsetWide
(
cmsMLU
*
mlu
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
const
wchar_t
*
WideString
);
CMSAPI
cmsBool
CMSEXPORT
cmsMLUsetUTF8
(
cmsMLU
*
mlu
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
const
char
*
UTF8String
);
CMSAPI
cmsUInt32Number
CMSEXPORT
cmsMLUgetASCII
(
const
cmsMLU
*
mlu
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
...
...
@@ -1335,6 +1361,10 @@ CMSAPI cmsUInt32Number CMSEXPORT cmsMLUgetASCII(const cmsMLU* mlu,
CMSAPI
cmsUInt32Number
CMSEXPORT
cmsMLUgetWide
(
const
cmsMLU
*
mlu
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
wchar_t
*
Buffer
,
cmsUInt32Number
BufferSize
);
CMSAPI
cmsUInt32Number
CMSEXPORT
cmsMLUgetUTF8
(
const
cmsMLU
*
mlu
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
char
*
Buffer
,
cmsUInt32Number
BufferSize
);
CMSAPI
cmsBool
CMSEXPORT
cmsMLUgetTranslation
(
const
cmsMLU
*
mlu
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
...
...
@@ -1559,6 +1589,10 @@ CMSAPI cmsUInt32Number CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
char
*
Buffer
,
cmsUInt32Number
BufferSize
);
CMSAPI
cmsUInt32Number
CMSEXPORT
cmsGetProfileInfoUTF8
(
cmsHPROFILE
hProfile
,
cmsInfoType
Info
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
char
*
Buffer
,
cmsUInt32Number
BufferSize
);
// IO handlers ----------------------------------------------------------------------------------------------------------
typedef
struct
_cms_io_handler
cmsIOHANDLER
;
...
...
@@ -1621,6 +1655,9 @@ CMSAPI cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext C
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreateInkLimitingDeviceLink
(
cmsColorSpaceSignature
ColorSpace
,
cmsFloat64Number
Limit
);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreateDeviceLinkFromCubeFile
(
const
char
*
cFileName
);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreateDeviceLinkFromCubeFileTHR
(
cmsContext
ContextID
,
const
char
*
cFileName
);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreateLab2ProfileTHR
(
cmsContext
ContextID
,
const
cmsCIExyY
*
WhitePoint
);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreateLab2Profile
(
const
cmsCIExyY
*
WhitePoint
);
...
...
@@ -1633,6 +1670,8 @@ CMSAPI cmsHPROFILE CMSEXPORT cmsCreateXYZProfile(void);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreate_sRGBProfileTHR
(
cmsContext
ContextID
);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreate_sRGBProfile
(
void
);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreate_OkLabProfile
(
cmsContext
ctx
);
CMSAPI
cmsHPROFILE
CMSEXPORT
cmsCreateBCHSWabstractProfileTHR
(
cmsContext
ContextID
,
cmsUInt32Number
nLUTPoints
,
cmsFloat64Number
Bright
,
...
...
libs/lcms2/include/lcms2_plugin.h
View file @
b15d0120
...
...
@@ -603,9 +603,9 @@ typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo, //
typedef
void
(
*
_cmsTransform2Fn
)(
struct
_cmstransform_struct
*
CMMcargo
,
const
void
*
InputBuffer
,
void
*
OutputBuffer
,
cmsUInt32Number
PixelsPerLine
,
cmsUInt32Number
LineCount
,
const
cmsStride
*
Stride
);
cmsUInt32Number
PixelsPerLine
,
cmsUInt32Number
LineCount
,
const
cmsStride
*
Stride
);
typedef
cmsBool
(
*
_cmsTransformFactory
)(
_cmsTransformFn
*
xform
,
void
**
UserData
,
...
...
@@ -648,7 +648,7 @@ typedef struct {
}
cmsPluginTransform
;
//----------------------------------------------------------------------------------------------------------
// Mutex
// Mutex
typedef
void
*
(
*
_cmsCreateMutexFnPtrType
)(
cmsContext
ContextID
);
typedef
void
(
*
_cmsDestroyMutexFnPtrType
)(
cmsContext
ContextID
,
void
*
mtx
);
...
...
libs/lcms2/src/cmsalpha.c
View file @
b15d0120
...
...
@@ -402,7 +402,7 @@ static cmsFormatterAlphaFn FormattersAlpha[6][6] = {
// This function computes the distance from each component to the next one in bytes.
static
void
ComputeIncrementsForChunky
(
cmsUInt32Number
Format
,
cmsBool
ComputeIncrementsForChunky
(
cmsUInt32Number
Format
,
cmsUInt32Number
ComponentStartingOrder
[],
cmsUInt32Number
ComponentPointerIncrements
[])
{
...
...
@@ -416,7 +416,7 @@ void ComputeIncrementsForChunky(cmsUInt32Number Format,
// Sanity check
if
(
total_chans
<=
0
||
total_chans
>=
cmsMAXCHANNELS
)
return
;
return
FALSE
;
memset
(
channels
,
0
,
sizeof
(
channels
));
...
...
@@ -453,13 +453,15 @@ void ComputeIncrementsForChunky(cmsUInt32Number Format,
for
(
i
=
0
;
i
<
extra
;
i
++
)
ComponentStartingOrder
[
i
]
=
channels
[
i
+
nchannels
];
return
TRUE
;
}
// On planar configurations, the distance is the stride added to any non-negative
static
void
ComputeIncrementsForPlanar
(
cmsUInt32Number
Format
,
cmsBool
ComputeIncrementsForPlanar
(
cmsUInt32Number
Format
,
cmsUInt32Number
BytesPerPlane
,
cmsUInt32Number
ComponentStartingOrder
[],
cmsUInt32Number
ComponentPointerIncrements
[])
...
...
@@ -473,7 +475,7 @@ void ComputeIncrementsForPlanar(cmsUInt32Number Format,
// Sanity check
if
(
total_chans
<=
0
||
total_chans
>=
cmsMAXCHANNELS
)
return
;
return
FALSE
;
memset
(
channels
,
0
,
sizeof
(
channels
));
...
...
@@ -509,29 +511,29 @@ void ComputeIncrementsForPlanar(cmsUInt32Number Format,
for
(
i
=
0
;
i
<
extra
;
i
++
)
ComponentStartingOrder
[
i
]
=
channels
[
i
+
nchannels
];
return
TRUE
;
}
// Dispatcher por chunky and planar RGB
static
void
ComputeComponentIncrements
(
cmsUInt32Number
Format
,
cmsBool
ComputeComponentIncrements
(
cmsUInt32Number
Format
,
cmsUInt32Number
BytesPerPlane
,
cmsUInt32Number
ComponentStartingOrder
[],
cmsUInt32Number
ComponentPointerIncrements
[])
{
if
(
T_PLANAR
(
Format
))
{
ComputeIncrementsForPlanar
(
Format
,
BytesPerPlane
,
ComponentStartingOrder
,
ComponentPointerIncrements
);
return
ComputeIncrementsForPlanar
(
Format
,
BytesPerPlane
,
ComponentStartingOrder
,
ComponentPointerIncrements
);
}
else
{
ComputeIncrementsForChunky
(
Format
,
ComponentStartingOrder
,
ComponentPointerIncrements
);
return
ComputeIncrementsForChunky
(
Format
,
ComponentStartingOrder
,
ComponentPointerIncrements
);
}
}
// Handles extra channels copying alpha if requested by the flags
void
_cmsHandleExtraChannels
(
_cmsTRANSFORM
*
p
,
const
void
*
in
,
void
*
out
,
...
...
@@ -565,9 +567,11 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
if
(
nExtra
==
0
)
return
;
// Compute the increments
ComputeComponentIncrements
(
p
->
InputFormat
,
Stride
->
BytesPerPlaneIn
,
SourceStartingOrder
,
SourceIncrements
);
ComputeComponentIncrements
(
p
->
OutputFormat
,
Stride
->
BytesPerPlaneOut
,
DestStartingOrder
,
DestIncrements
);
// Compute the increments
if
(
!
ComputeComponentIncrements
(
p
->
InputFormat
,
Stride
->
BytesPerPlaneIn
,
SourceStartingOrder
,
SourceIncrements
))
return
;
if
(
!
ComputeComponentIncrements
(
p
->
OutputFormat
,
Stride
->
BytesPerPlaneOut
,
DestStartingOrder
,
DestIncrements
))
return
;
// Check for conversions 8, 16, half, float, dbl
copyValueFn
=
_cmsGetFormatterAlpha
(
p
->
ContextID
,
p
->
InputFormat
,
p
->
OutputFormat
);
...
...
@@ -642,5 +646,3 @@ void _cmsHandleExtraChannels(_cmsTRANSFORM* p, const void* in,
}
}
}
libs/lcms2/src/cmscnvrt.c
View file @
b15d0120
...
...
@@ -715,6 +715,16 @@ int BlackPreservingGrayOnlySampler(CMSREGISTER const cmsUInt16Number In[], CMSRE
return
TRUE
;
}
// Check whatever the profile is a CMYK->CMYK devicelink
static
cmsBool
is_cmyk_devicelink
(
cmsHPROFILE
hProfile
)
{
return
cmsGetDeviceClass
(
hProfile
)
==
cmsSigLinkClass
&&
cmsGetColorSpace
(
hProfile
)
==
cmsSigCmykData
&&
cmsGetColorSpace
(
hProfile
)
==
cmsSigCmykData
;
}
// This is the entry for black-preserving K-only intents, which are non-ICC
static
cmsPipeline
*
BlackPreservingKOnlyIntents
(
cmsContext
ContextID
,
...
...
@@ -747,14 +757,16 @@ cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID,
lastProfilePos
=
nProfiles
-
1
;
hLastProfile
=
hProfiles
[
lastProfilePos
];
while
(
lastProfilePos
>
1
)
// Skip CMYK->CMYK devicelinks on ending
while
(
is_cmyk_devicelink
(
hLastProfile
))
{
hLastProfile
=
hProfiles
[
--
lastProfilePos
];
if
(
cmsGetColorSpace
(
hLastProfile
)
!=
cmsSigCmykData
||
cmsGetDeviceClass
(
hLastProfile
)
!=
cmsSigLinkClass
)
if
(
lastProfilePos
<
2
)
break
;
hLastProfile
=
hProfiles
[
--
lastProfilePos
];
}
preservationProfilesCount
=
lastProfilePos
+
1
;
// Check for non-cmyk profiles
...
...
@@ -771,7 +783,7 @@ cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID,
// Create a LUT holding normal ICC transform
bp
.
cmyk2cmyk
=
DefaultICCintents
(
ContextID
,
preservationProfilesCount
,
preservationProfilesCount
,
ICCIntents
,
hProfiles
,
BPC
,
...
...
@@ -783,7 +795,7 @@ cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID,
// Now, compute the tone curve
bp
.
KTone
=
_cmsBuildKToneCurve
(
ContextID
,
4096
,
preservationProfilesCount
,
preservationProfilesCount
,
ICCIntents
,
hProfiles
,
BPC
,
...
...
@@ -973,13 +985,14 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
lastProfilePos
=
nProfiles
-
1
;
hLastProfile
=
hProfiles
[
lastProfilePos
];
while
(
lastProfilePos
>
1
)
{
// Skip CMYK->CMYK devicelinks on ending
while
(
is_cmyk_devicelink
(
hLastProfile
))
{
if
(
lastProfilePos
<
2
)
break
;
hLastProfile
=
hProfiles
[
--
lastProfilePos
];
if
(
cmsGetColorSpace
(
hLastProfile
)
!=
cmsSigCmykData
||
cmsGetDeviceClass
(
hLastProfile
)
!=
cmsSigLinkClass
)
break
;
}
}
preservationProfilesCount
=
lastProfilePos
+
1
;
...
...
@@ -1148,8 +1161,7 @@ cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUIn
cmsIntentsList
*
pt
;
cmsUInt32Number
nIntents
;
for
(
nIntents
=
0
,
pt
=
ctx
->
Intents
;
pt
!=
NULL
;
pt
=
pt
->
Next
)
for
(
nIntents
=
0
,
pt
=
DefaultIntents
;
pt
!=
NULL
;
pt
=
pt
->
Next
)
{
if
(
nIntents
<
nMax
)
{
if
(
Codes
!=
NULL
)
...
...
@@ -1162,7 +1174,7 @@ cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUIn
nIntents
++
;
}
for
(
nIntents
=
0
,
pt
=
Default
Intents
;
pt
!=
NULL
;
pt
=
pt
->
Next
)
for
(
pt
=
ctx
->
Intents
;
pt
!=
NULL
;
pt
=
pt
->
Next
)
{
if
(
nIntents
<
nMax
)
{
if
(
Codes
!=
NULL
)
...
...
@@ -1174,6 +1186,7 @@ cmsUInt32Number CMSEXPORT cmsGetSupportedIntentsTHR(cmsContext ContextID, cmsUIn
nIntents
++
;
}
return
nIntents
;
}
...
...
@@ -1211,4 +1224,3 @@ cmsBool _cmsRegisterRenderingIntentPlugin(cmsContext id, cmsPluginBase* Data)
return
TRUE
;
}
libs/lcms2/src/cmserr.c
View file @
b15d0120
...
...
@@ -72,7 +72,7 @@ long int CMSEXPORT cmsfilelength(FILE* f)
//
// This is the interface to low-level memory management routines. By default a simple
// wrapping to malloc/free/realloc is provided, although there is a limit on the max
// amount of memo
y that can be reclaimed. This is mostly as a safety feature to prevent
// amount of memo
ry that can be reclaimed. This is mostly as a safety feature to prevent
// bogus or evil code to allocate huge blocks that otherwise lcms would never need.
#define MAX_MEMORY_FOR_ALLOC ((cmsUInt32Number)(1024U*1024U*512U))
...
...
@@ -92,7 +92,8 @@ cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase* Plug
static
void
*
_cmsMallocDefaultFn
(
cmsContext
ContextID
,
cmsUInt32Number
size
)
{
if
(
size
>
MAX_MEMORY_FOR_ALLOC
)
return
NULL
;
// Never allow over maximum
// Never allow 0 or over maximum
if
(
size
==
0
||
size
>
MAX_MEMORY_FOR_ALLOC
)
return
NULL
;
return
(
void
*
)
malloc
(
size
);
...
...
@@ -234,7 +235,7 @@ cmsBool _cmsRegisterMemHandlerPlugin(cmsContext ContextID, cmsPluginBase *Data)
// NULL forces to reset to defaults. In this special case, the defaults are stored in the context structure.
// Remaining plug-ins does NOT have any copy in the context structure, but this is somehow special as the
// context internal data should be malloc
e'd by using those functions.
// context internal data should be malloc
'ed by using those functions.
if
(
Data
==
NULL
)
{
struct
_cmsContext_struct
*
ctx
=
(
struct
_cmsContext_struct
*
)
ContextID
;
...
...
libs/lcms2/src/cmsgamma.c
View file @
b15d0120
...
...
@@ -300,6 +300,10 @@ cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsUInt32Number nEnt
return
p
;
Error:
for
(
i
=
0
;
i
<
nSegments
;
i
++
)
{
if
(
p
->
Segments
&&
p
->
Segments
[
i
].
SampledPoints
)
_cmsFree
(
ContextID
,
p
->
Segments
[
i
].
SampledPoints
);
if
(
p
->
SegInterp
&&
p
->
SegInterp
[
i
])
_cmsFree
(
ContextID
,
p
->
SegInterp
[
i
]);
}
if
(
p
->
SegInterp
)
_cmsFree
(
ContextID
,
p
->
SegInterp
);
if
(
p
->
Segments
)
_cmsFree
(
ContextID
,
p
->
Segments
);
if
(
p
->
Evals
)
_cmsFree
(
ContextID
,
p
->
Evals
);
...
...
@@ -593,10 +597,16 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
case
6
:
e
=
Params
[
1
]
*
R
+
Params
[
2
];
if
(
e
<
0
)
Val
=
Params
[
3
];
else
Val
=
pow
(
e
,
Params
[
0
])
+
Params
[
3
];
// On gamma 1.0, don't clamp
if
(
Params
[
0
]
==
1
.
0
)
{
Val
=
e
+
Params
[
3
];
}
else
{
if
(
e
<
0
)
Val
=
Params
[
3
];
else
Val
=
pow
(
e
,
Params
[
0
])
+
Params
[
3
];
}
break
;
// ((Y - c) ^1/Gamma - b) / a
...
...
@@ -1491,13 +1501,12 @@ cmsFloat64Number CMSEXPORT cmsEstimateGamma(const cmsToneCurve* t, cmsFloat64Num
return
(
sum
/
n
);
// The mean
}
// Retrieve segments on tone curves
// Retrieve parameters on one-segment tone curves
cmsFloat64Number
*
CMSEXPORT
cmsGetToneCurveParams
(
const
cmsToneCurve
*
t
)
const
cmsCurveSegment
*
CMSEXPORT
cmsGetToneCurveSegment
(
cmsInt32Number
n
,
const
cmsToneCurve
*
t
)
{
_cmsAssert
(
t
!=
NULL
);
if
(
t
->
nSegments
!=
1
)
return
NULL
;
return
t
->
Segments
[
0
].
Params
;
if
(
n
<
0
||
n
>=
(
cmsInt32Number
)
t
->
nSegments
)
return
NULL
;
return
t
->
Segments
+
n
;
}
libs/lcms2/src/cmsgmt.c
View file @
b15d0120
...
...
@@ -219,7 +219,7 @@ int GamutSampler(CMSREGISTER const cmsUInt16Number In[], CMSREGISTER cmsUInt16Nu
cmsUInt16Number
Proof
[
cmsMAXCHANNELS
],
Proof2
[
cmsMAXCHANNELS
];
cmsFloat64Number
dE1
,
dE2
,
ErrorRatio
;
// Assume in-gamut by default.
// Assume in-gamut by default.
NEVER READ, USED FOR DEBUG PURPOSES.
ErrorRatio
=
1
.
0
;
// Convert input to Lab
...
...
@@ -596,7 +596,7 @@ cmsBool CMSEXPORT cmsDesaturateLab(cmsCIELab* Lab,
// Actually, doing that "well" is quite hard, since every component may behave completely different.
// Since the true point of this function is to detect suitable optimizations, I am imposing some requirements
// that simplifies things: only RGB, and only profiles that can got in both directions.
// The algorithm obtains Y from a synt
etical gray R=G=B. Then least squares fitting is used to estimate gamma.
// The algorithm obtains Y from a synt
hetical gray R=G=B. Then least squares fitting is used to estimate gamma.
// For gamma close to 1.0, RGB is linear. On profiles not supported, -1 is returned.
cmsFloat64Number
CMSEXPORT
cmsDetectRGBProfileGamma
(
cmsHPROFILE
hProfile
,
cmsFloat64Number
threshold
)
...
...
@@ -656,4 +656,3 @@ cmsFloat64Number CMSEXPORT cmsDetectRGBProfileGamma(cmsHPROFILE hProfile, cmsFlo
return
gamma
;
}
libs/lcms2/src/cmsio0.c
View file @
b15d0120
...
...
@@ -530,7 +530,21 @@ cmsHPROFILE CMSEXPORT cmsCreateProfilePlaceholder(cmsContext ContextID)
// Set default version
Icc
->
Version
=
0x02100000
;
// Set default CMM (that's me!)
Icc
->
CMM
=
lcmsSignature
;
// Set default creator
// Created by LittleCMS (that's me!)
Icc
->
creator
=
lcmsSignature
;
// Set default platform
#ifdef CMS_IS_WINDOWS_
Icc
->
platform
=
cmsSigMicrosoft
;
#else
Icc
->
platform
=
cmsSigMacintosh
;
#endif
// Set default device class
Icc
->
DeviceClass
=
cmsSigDisplayClass
;
...
...
@@ -784,16 +798,18 @@ cmsBool _cmsReadHeader(_cmsICCPROFILE* Icc)
}
// Adjust endianness of the used parameters
Icc
->
CMM
=
_cmsAdjustEndianess32
(
Header
.
cmmId
);
Icc
->
DeviceClass
=
(
cmsProfileClassSignature
)
_cmsAdjustEndianess32
(
Header
.
deviceClass
);
Icc
->
ColorSpace
=
(
cmsColorSpaceSignature
)
_cmsAdjustEndianess32
(
Header
.
colorSpace
);
Icc
->
PCS
=
(
cmsColorSpaceSignature
)
_cmsAdjustEndianess32
(
Header
.
pcs
);
Icc
->
RenderingIntent
=
_cmsAdjustEndianess32
(
Header
.
renderingIntent
);
Icc
->
platform
=
(
cmsPlatformSignature
)
_cmsAdjustEndianess32
(
Header
.
platform
);
Icc
->
flags
=
_cmsAdjustEndianess32
(
Header
.
flags
);
Icc
->
manufacturer
=
_cmsAdjustEndianess32
(
Header
.
manufacturer
);
Icc
->
model
=
_cmsAdjustEndianess32
(
Header
.
model
);
Icc
->
creator
=
_cmsAdjustEndianess32
(
Header
.
creator
);
_cmsAdjustEndianess64
(
&
Icc
->
attributes
,
&
Header
.
attributes
);
Icc
->
Version
=
_cmsAdjustEndianess32
(
_validatedVersion
(
Header
.
version
));
...
...
@@ -893,7 +909,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
cmsUInt32Number
Count
;
Header
.
size
=
_cmsAdjustEndianess32
(
UsedSpace
);
Header
.
cmmId
=
_cmsAdjustEndianess32
(
lcmsSignature
);
Header
.
cmmId
=
_cmsAdjustEndianess32
(
Icc
->
CMM
);
Header
.
version
=
_cmsAdjustEndianess32
(
Icc
->
Version
);
Header
.
deviceClass
=
(
cmsProfileClassSignature
)
_cmsAdjustEndianess32
(
Icc
->
DeviceClass
);
...
...
@@ -905,11 +921,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
Header
.
magic
=
_cmsAdjustEndianess32
(
cmsMagicNumber
);
#ifdef CMS_IS_WINDOWS_
Header
.
platform
=
(
cmsPlatformSignature
)
_cmsAdjustEndianess32
(
cmsSigMicrosoft
);
#else
Header
.
platform
=
(
cmsPlatformSignature
)
_cmsAdjustEndianess32
(
cmsSigMacintosh
);
#endif
Header
.
platform
=
(
cmsPlatformSignature
)
_cmsAdjustEndianess32
(
Icc
->
platform
);
Header
.
flags
=
_cmsAdjustEndianess32
(
Icc
->
flags
);
Header
.
manufacturer
=
_cmsAdjustEndianess32
(
Icc
->
manufacturer
);
...
...
@@ -925,8 +937,7 @@ cmsBool _cmsWriteHeader(_cmsICCPROFILE* Icc, cmsUInt32Number UsedSpace)
Header
.
illuminant
.
Y
=
(
cmsS15Fixed16Number
)
_cmsAdjustEndianess32
((
cmsUInt32Number
)
_cmsDoubleTo15Fixed16
(
cmsD50_XYZ
()
->
Y
));
Header
.
illuminant
.
Z
=
(
cmsS15Fixed16Number
)
_cmsAdjustEndianess32
((
cmsUInt32Number
)
_cmsDoubleTo15Fixed16
(
cmsD50_XYZ
()
->
Z
));
// Created by LittleCMS (that's me!)
Header
.
creator
=
_cmsAdjustEndianess32
(
lcmsSignature
);
Header
.
creator
=
_cmsAdjustEndianess32
(
Icc
->
creator
);
memset
(
&
Header
.
reserved
,
0
,
sizeof
(
Header
.
reserved
));
...
...
libs/lcms2/src/cmsio1.c
View file @
b15d0120
...
...
@@ -578,7 +578,7 @@ Error:
return
NULL
;
}
// Create an output MPE LUT from agiven profile. Version mismatches are handled here
// Create an output MPE LUT from a
given profile. Version mismatches are handled here
cmsPipeline
*
CMSEXPORT
_cmsReadOutputLUT
(
cmsHPROFILE
hProfile
,
cmsUInt32Number
Intent
)
{
cmsTagTypeSignature
OriginalType
;
...
...
@@ -1027,3 +1027,13 @@ cmsUInt32Number CMSEXPORT cmsGetProfileInfoASCII(cmsHPROFILE hProfile, cmsInfoT
return
cmsMLUgetASCII
(
mlu
,
LanguageCode
,
CountryCode
,
Buffer
,
BufferSize
);
}
cmsUInt32Number
CMSEXPORT
cmsGetProfileInfoUTF8
(
cmsHPROFILE
hProfile
,
cmsInfoType
Info
,
const
char
LanguageCode
[
3
],
const
char
CountryCode
[
3
],
char
*
Buffer
,
cmsUInt32Number
BufferSize
)
{
const
cmsMLU
*
mlu
=
GetInfo
(
hProfile
,
Info
);
if
(
mlu
==
NULL
)
return
0
;
return
cmsMLUgetUTF8
(
mlu
,
LanguageCode
,
CountryCode
,
Buffer
,
BufferSize
);
}
libs/lcms2/src/cmslut.c
View file @
b15d0120
...
...
@@ -475,6 +475,9 @@ cmsUInt32Number CubeSize(const cmsUInt32Number Dims[], cmsUInt32Number b)
if
(
rv
>
UINT_MAX
/
dim
)
return
0
;
}
// Again, prevent overflow
if
(
rv
>
UINT_MAX
/
15
)
return
0
;
return
rv
;
}
...
...
@@ -814,7 +817,13 @@ cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler
cmsUInt32Number
nInputs
,
nOutputs
;
cmsUInt32Number
*
nSamples
;
cmsFloat32Number
In
[
MAX_INPUT_DIMENSIONS
+
1
],
Out
[
MAX_STAGE_CHANNELS
];
_cmsStageCLutData
*
clut
=
(
_cmsStageCLutData
*
)
mpe
->
Data
;
_cmsStageCLutData
*
clut
;
if
(
mpe
==
NULL
)
return
FALSE
;
clut
=
(
_cmsStageCLutData
*
)
mpe
->
Data
;
if
(
clut
==
NULL
)
return
FALSE
;
nSamples
=
clut
->
Params
->
nSamples
;
nInputs
=
clut
->
Params
->
nInputs
;
...
...
@@ -1838,5 +1847,3 @@ cmsBool CMSEXPORT cmsPipelineEvalReverseFloat(cmsFloat32Number Target[],
return
TRUE
;
}
libs/lcms2/src/cmsnamed.c
View file @
b15d0120
This diff is collapsed.
Click to expand it.
libs/lcms2/src/cmsopt.c
View file @
b15d0120
...
...
@@ -183,6 +183,7 @@ cmsBool isFloatMatrixIdentity(const cmsMAT3* a)
return
TRUE
;
}
// if two adjacent matrices are found, multiply them.
static
cmsBool
_MultiplyMatrix
(
cmsPipeline
*
Lut
)
...
...
@@ -1113,14 +1114,17 @@ cmsBool OptimizeByComputingLinearization(cmsPipeline** Lut, cmsUInt32Number Inte
// Store result in curve
for
(
t
=
0
;
t
<
OriginalLut
->
InputChannels
;
t
++
)
Trans
[
t
]
->
Table16
[
i
]
=
_cmsQuickSaturateWord
(
Out
[
t
]
*
65535
.
0
);
{
if
(
Trans
[
t
]
->
Table16
!=
NULL
)
Trans
[
t
]
->
Table16
[
i
]
=
_cmsQuickSaturateWord
(
Out
[
t
]
*
65535
.
0
);
}
}
// Slope-limit the obtained curves
for
(
t
=
0
;
t
<
OriginalLut
->
InputChannels
;
t
++
)
SlopeLimiting
(
Trans
[
t
]);
// Check for validity
// Check for validity
. lIsLinear is here for debug purposes
lIsSuitable
=
TRUE
;
lIsLinear
=
TRUE
;
for
(
t
=
0
;
(
lIsSuitable
&&
(
t
<
OriginalLut
->
InputChannels
));
t
++
)
{
...
...
@@ -1724,6 +1728,8 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
_cmsStageMatrixData
*
Data
=
(
_cmsStageMatrixData
*
)
cmsStageData
(
Matrix1
);
if
(
Matrix1
->
InputChannels
!=
3
||
Matrix1
->
OutputChannels
!=
3
)
return
FALSE
;
// Copy the matrix to our result
memcpy
(
&
res
,
Data
->
Double
,
sizeof
(
res
));
...
...
@@ -1768,7 +1774,7 @@ cmsBool OptimizeMatrixShaper(cmsPipeline** Lut, cmsUInt32Number Intent, cmsUInt3
_cmsStageToneCurvesData
*
mpeC2
=
(
_cmsStageToneCurvesData
*
)
cmsStageData
(
Curve2
);
// In this particular optimization, cache does not help as it takes more time to deal with
// the cache tha
t
with the pixel handling
// the cache tha
n
with the pixel handling
*
dwFlags
|=
cmsFLAGS_NOCACHE
;
// Setup the optimizarion routines
...
...
@@ -1925,7 +1931,7 @@ cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID,
for
(
mpe
=
cmsPipelineGetPtrToFirstStage
(
*
PtrLut
);
mpe
!=
NULL
;
mpe
=
cmsStageNext
(
mpe
))
{
if
(
cmsStageType
(
mpe
)
==
cmsSigNamedColorElemType
)
return
FALSE
;
if
(
cmsStageType
(
mpe
)
==
cmsSigNamedColorElemType
)
return
FALSE
;
}
// Try to get rid of identities and trivial conversions.
...
...
@@ -1967,6 +1973,3 @@ cmsBool CMSEXPORT _cmsOptimizePipeline(cmsContext ContextID,
// Only simple optimizations succeeded
return
AnySuccess
;
}
libs/lcms2/src/cmspack.c
View file @
b15d0120
...
...
@@ -2952,6 +2952,108 @@ cmsUInt8Number* PackFloatFrom16(CMSREGISTER _cmsTRANSFORM* info,
// --------------------------------------------------------------------------------------------------------
static
cmsUInt8Number
*
PackBytesFromFloat
(
_cmsTRANSFORM
*
info
,
cmsFloat32Number
wOut
[],
cmsUInt8Number
*
output
,
cmsUInt32Number
Stride
)
{
cmsUInt32Number
nChan
=
T_CHANNELS
(
info
->
OutputFormat
);
cmsUInt32Number
DoSwap
=
T_DOSWAP
(
info
->
OutputFormat
);
cmsUInt32Number
Reverse
=
T_FLAVOR
(
info
->
OutputFormat
);
cmsUInt32Number
Extra
=
T_EXTRA
(
info
->
OutputFormat
);
cmsUInt32Number
SwapFirst
=
T_SWAPFIRST
(
info
->
OutputFormat
);
cmsUInt32Number
Planar
=
T_PLANAR
(
info
->
OutputFormat
);
cmsUInt32Number
ExtraFirst
=
DoSwap
^
SwapFirst
;
cmsUInt8Number
*
swap1
=
(
cmsUInt8Number
*
)
output
;
cmsFloat64Number
v
=
0
;
cmsUInt8Number
vv
=
0
;
cmsUInt32Number
i
,
start
=
0
;
if
(
ExtraFirst
)
start
=
Extra
;
for
(
i
=
0
;
i
<
nChan
;
i
++
)
{
cmsUInt32Number
index
=
DoSwap
?
(
nChan
-
i
-
1
)
:
i
;
v
=
wOut
[
index
]
*
65535
.
0
;
if
(
Reverse
)
v
=
65535
.
0
-
v
;
vv
=
FROM_16_TO_8
(
_cmsQuickSaturateWord
(
v
));
if
(
Planar
)
((
cmsUInt8Number
*
)
output
)[(
i
+
start
)
*
Stride
]
=
vv
;
else
((
cmsUInt8Number
*
)
output
)[
i
+
start
]
=
vv
;
}
if
(
Extra
==
0
&&
SwapFirst
)
{
memmove
(
swap1
+
1
,
swap1
,
(
nChan
-
1
)
*
sizeof
(
cmsUInt8Number
));
*
swap1
=
vv
;
}
if
(
T_PLANAR
(
info
->
OutputFormat
))
return
output
+
sizeof
(
cmsUInt8Number
);
else
return
output
+
(
nChan
+
Extra
)
*
sizeof
(
cmsUInt8Number
);
}
static
cmsUInt8Number
*
PackWordsFromFloat
(
_cmsTRANSFORM
*
info
,
cmsFloat32Number
wOut
[],
cmsUInt8Number
*
output
,
cmsUInt32Number
Stride
)
{
cmsUInt32Number
nChan
=
T_CHANNELS
(
info
->
OutputFormat
);
cmsUInt32Number
DoSwap
=
T_DOSWAP
(
info
->
OutputFormat
);
cmsUInt32Number
Reverse
=
T_FLAVOR
(
info
->
OutputFormat
);
cmsUInt32Number
Extra
=
T_EXTRA
(
info
->
OutputFormat
);
cmsUInt32Number
SwapFirst
=
T_SWAPFIRST
(
info
->
OutputFormat
);
cmsUInt32Number
Planar
=
T_PLANAR
(
info
->
OutputFormat
);
cmsUInt32Number
ExtraFirst
=
DoSwap
^
SwapFirst
;
cmsUInt16Number
*
swap1
=
(
cmsUInt16Number
*
)
output
;
cmsFloat64Number
v
=
0
;
cmsUInt16Number
vv
=
0
;
cmsUInt32Number
i
,
start
=
0
;
if
(
ExtraFirst
)
start
=
Extra
;
for
(
i
=
0
;
i
<
nChan
;
i
++
)
{
cmsUInt32Number
index
=
DoSwap
?
(
nChan
-
i
-
1
)
:
i
;
v
=
wOut
[
index
]
*
65535
.
0
;
if
(
Reverse
)
v
=
65535
.
0
-
v
;
vv
=
_cmsQuickSaturateWord
(
v
);
if
(
Planar
)
((
cmsUInt16Number
*
)
output
)[(
i
+
start
)
*
Stride
]
=
vv
;
else
((
cmsUInt16Number
*
)
output
)[
i
+
start
]
=
vv
;
}
if
(
Extra
==
0
&&
SwapFirst
)
{
memmove
(
swap1
+
1
,
swap1
,
(
nChan
-
1
)
*
sizeof
(
cmsUInt16Number
));
*
swap1
=
vv
;
}
if
(
T_PLANAR
(
info
->
OutputFormat
))
return
output
+
sizeof
(
cmsUInt16Number
);
else
return
output
+
(
nChan
+
Extra
)
*
sizeof
(
cmsUInt16Number
);
}
static
cmsUInt8Number
*
PackFloatsFromFloat
(
_cmsTRANSFORM
*
info
,
cmsFloat32Number
wOut
[],
cmsUInt8Number
*
output
,
...
...
@@ -3114,6 +3216,77 @@ cmsUInt8Number* PackLabDoubleFromFloat(_cmsTRANSFORM* Info,
}
static
cmsUInt8Number
*
PackEncodedBytesLabV2FromFloat
(
_cmsTRANSFORM
*
Info
,
cmsFloat32Number
wOut
[],
cmsUInt8Number
*
output
,
cmsUInt32Number
Stride
)
{
cmsCIELab
Lab
;
cmsUInt16Number
wlab
[
3
];
Lab
.
L
=
(
cmsFloat64Number
)(
wOut
[
0
]
*
100
.
0
);
Lab
.
a
=
(
cmsFloat64Number
)(
wOut
[
1
]
*
255
.
0
-
128
.
0
);
Lab
.
b
=
(
cmsFloat64Number
)(
wOut
[
2
]
*
255
.
0
-
128
.
0
);
cmsFloat2LabEncoded
(
wlab
,
&
Lab
);
if
(
T_PLANAR
(
Info
->
OutputFormat
))
{
Stride
/=
PixelSize
(
Info
->
OutputFormat
);
output
[
0
]
=
wlab
[
0
]
>>
8
;
output
[
Stride
]
=
wlab
[
1
]
>>
8
;
output
[
Stride
*
2
]
=
wlab
[
2
]
>>
8
;
return
output
+
1
;
}
else
{
output
[
0
]
=
wlab
[
0
]
>>
8
;
output
[
1
]
=
wlab
[
1
]
>>
8
;
output
[
2
]
=
wlab
[
2
]
>>
8
;
return
output
+
(
3
+
T_EXTRA
(
Info
->
OutputFormat
));
}
}
static
cmsUInt8Number
*
PackEncodedWordsLabV2FromFloat
(
_cmsTRANSFORM
*
Info
,
cmsFloat32Number
wOut
[],
cmsUInt8Number
*
output
,
cmsUInt32Number
Stride
)
{
cmsCIELab
Lab
;
cmsUInt16Number
wlab
[
3
];
Lab
.
L
=
(
cmsFloat64Number
)(
wOut
[
0
]
*
100
.
0
);
Lab
.
a
=
(
cmsFloat64Number
)(
wOut
[
1
]
*
255
.
0
-
128
.
0
);
Lab
.
b
=
(
cmsFloat64Number
)(
wOut
[
2
]
*
255
.
0
-
128
.
0
);
cmsFloat2LabEncodedV2
(
wlab
,
&
Lab
);
if
(
T_PLANAR
(
Info
->
OutputFormat
))
{
Stride
/=
PixelSize
(
Info
->
OutputFormat
);
((
cmsUInt16Number
*
)
output
)[
0
]
=
wlab
[
0
];
((
cmsUInt16Number
*
)
output
)[
Stride
]
=
wlab
[
1
];
((
cmsUInt16Number
*
)
output
)[
Stride
*
2
]
=
wlab
[
2
];
return
output
+
sizeof
(
cmsUInt16Number
);
}
else
{
((
cmsUInt16Number
*
)
output
)[
0
]
=
wlab
[
0
];
((
cmsUInt16Number
*
)
output
)[
1
]
=
wlab
[
1
];
((
cmsUInt16Number
*
)
output
)[
2
]
=
wlab
[
2
];
return
output
+
(
3
+
T_EXTRA
(
Info
->
OutputFormat
))
*
sizeof
(
cmsUInt16Number
);
}
}
// From 0..1 range to 0..MAX_ENCODEABLE_XYZ
static
cmsUInt8Number
*
PackXYZFloatFromFloat
(
_cmsTRANSFORM
*
Info
,
...
...
@@ -3647,10 +3820,20 @@ static const cmsFormattersFloat OutputFormattersFloat[] = {
{
TYPE_Lab_DBL
,
ANYPLANAR
|
ANYEXTRA
,
PackLabDoubleFromFloat
},
{
TYPE_XYZ_DBL
,
ANYPLANAR
|
ANYEXTRA
,
PackXYZDoubleFromFloat
},
{
TYPE_LabV2_8
,
ANYPLANAR
|
ANYEXTRA
,
PackEncodedBytesLabV2FromFloat
},
{
TYPE_LabV2_16
,
ANYPLANAR
|
ANYEXTRA
,
PackEncodedWordsLabV2FromFloat
},
{
FLOAT_SH
(
1
)
|
BYTES_SH
(
4
),
ANYPLANAR
|
ANYFLAVOR
|
ANYSWAPFIRST
|
ANYSWAP
|
ANYEXTRA
|
ANYCHANNELS
|
ANYSPACE
,
PackFloatsFromFloat
},
{
FLOAT_SH
(
1
)
|
BYTES_SH
(
0
),
ANYPLANAR
|
ANYFLAVOR
|
ANYSWAPFIRST
|
ANYSWAP
|
ANYEXTRA
|
ANYCHANNELS
|
ANYSPACE
,
PackDoublesFromFloat
},
{
BYTES_SH
(
2
),
ANYPLANAR
|
ANYFLAVOR
|
ANYSWAPFIRST
|
ANYSWAP
|
ANYEXTRA
|
ANYCHANNELS
|
ANYSPACE
,
PackWordsFromFloat
},
{
BYTES_SH
(
1
),
ANYPLANAR
|
ANYFLAVOR
|
ANYSWAPFIRST
|
ANYSWAP
|
ANYEXTRA
|
ANYCHANNELS
|
ANYSPACE
,
PackBytesFromFloat
},
#ifndef CMS_NO_HALF_SUPPORT
{
FLOAT_SH
(
1
)
|
BYTES_SH
(
2
),
ANYFLAVOR
|
ANYSWAPFIRST
|
ANYSWAP
|
ANYEXTRA
|
ANYCHANNELS
|
ANYSPACE
,
PackHalfFromFloat
},
...
...
@@ -3861,7 +4044,7 @@ cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsU
cmsColorSpaceSignature
ColorSpace
=
cmsGetPCS
(
hProfile
);
cmsUInt32Number
ColorSpaceBits
=
(
cmsUInt32Number
)
_cmsLCMScolorSpace
(
ColorSpace
);
cms
UInt32Number
nOutputChans
=
cmsChannelsOf
(
ColorSpace
);
cms
Int32Number
nOutputChans
=
cmsChannelsOfColorSpace
(
ColorSpace
);
cmsUInt32Number
Float
=
lIsFloat
?
1U
:
0
;
// Unsupported color space?
...
...
@@ -3870,4 +4053,3 @@ cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsU
// Create a fake formatter for result
return
FLOAT_SH
(
Float
)
|
COLORSPACE_SH
(
ColorSpaceBits
)
|
BYTES_SH
(
nBytes
)
|
CHANNELS_SH
(
nOutputChans
);
}
libs/lcms2/src/cmsplugin.c
View file @
b15d0120
...
...
@@ -364,12 +364,7 @@ cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ)
// from Fixed point 8.8 to double
cmsFloat64Number
CMSEXPORT
_cms8Fixed8toDouble
(
cmsUInt16Number
fixed8
)
{
cmsUInt8Number
msb
,
lsb
;
lsb
=
(
cmsUInt8Number
)
(
fixed8
&
0xff
);
msb
=
(
cmsUInt8Number
)
(((
cmsUInt16Number
)
fixed8
>>
8
)
&
0xff
);
return
(
cmsFloat64Number
)
((
cmsFloat64Number
)
msb
+
((
cmsFloat64Number
)
lsb
/
256
.
0
));
return
fixed8
/
256
.
0
;
}
cmsUInt16Number
CMSEXPORT
_cmsDoubleTo8Fixed8
(
cmsFloat64Number
val
)
...
...
@@ -381,19 +376,7 @@ cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val)
// from Fixed point 15.16 to double
cmsFloat64Number
CMSEXPORT
_cms15Fixed16toDouble
(
cmsS15Fixed16Number
fix32
)
{
cmsFloat64Number
floater
,
sign
,
mid
;
int
Whole
,
FracPart
;
sign
=
(
fix32
<
0
?
-
1
:
1
);
fix32
=
abs
(
fix32
);
Whole
=
(
cmsUInt16Number
)(
fix32
>>
16
)
&
0xffff
;
FracPart
=
(
cmsUInt16Number
)(
fix32
&
0xffff
);
mid
=
(
cmsFloat64Number
)
FracPart
/
65536
.
0
;
floater
=
(
cmsFloat64Number
)
Whole
+
mid
;
return
sign
*
floater
;
return
fix32
/
65536
.
0
;
}
// from double to Fixed point 15.16
...
...
libs/lcms2/src/cmssamp.c
View file @
b15d0120
...
...
@@ -123,7 +123,7 @@ cmsBool BlackPointAsDarkerColorant(cmsHPROFILE hInput,
// Convert black to Lab
cmsDoTransform
(
xform
,
Black
,
&
Lab
,
1
);
// Force it to be neutral, check for inconsistences
// Force it to be neutral, check for inconsistenc
i
es
Lab
.
a
=
Lab
.
b
=
0
;
if
(
Lab
.
L
>
50
||
Lab
.
L
<
0
)
Lab
.
L
=
0
;
...
...
libs/lcms2/src/cmstypes.c
View file @
b15d0120
This diff is collapsed.
Click to expand it.
libs/lcms2/src/cmsvirt.c
View file @
b15d0120
...
...
@@ -406,10 +406,9 @@ cmsHPROFILE CMSEXPORT cmsCreateInkLimitingDeviceLinkTHR(cmsContext ContextID,
if
(
Limit
<
0
.
0
||
Limit
>
400
)
{
cmsSignalError
(
ContextID
,
cmsERROR_RANGE
,
"InkLimiting: Limit should be between
0
..400"
);
if
(
Limit
<
0
)
Limit
=
0
;
cmsSignalError
(
ContextID
,
cmsERROR_RANGE
,
"InkLimiting: Limit should be between
1
..400"
);
if
(
Limit
<
1
)
Limit
=
1
;
if
(
Limit
>
400
)
Limit
=
400
;
}
hICC
=
cmsCreateProfilePlaceholder
(
ContextID
);
...
...
@@ -672,6 +671,127 @@ cmsHPROFILE CMSEXPORT cmsCreate_sRGBProfile(void)
return
cmsCreate_sRGBProfileTHR
(
NULL
);
}
/**
* Oklab colorspace profile (experimental)
*
* This virtual profile cannot be saved as an ICC file
*/
cmsHPROFILE
cmsCreate_OkLabProfile
(
cmsContext
ctx
)
{
cmsStage
*
XYZPCS
=
_cmsStageNormalizeFromXyzFloat
(
ctx
);
cmsStage
*
PCSXYZ
=
_cmsStageNormalizeToXyzFloat
(
ctx
);
const
double
M_D65_D50
[]
=
{
1
.
047
886
,
0
.
022
919
,
-
0
.
050216
,
0
.
02
9582
,
0
.
990484
,
-
0
.
01707
9
,
-
0
.
00
9252
,
0
.
015073
,
0
.
751678
};
const
double
M_D50_D65
[]
=
{
0
.
955512609517083
,
-
0
.
0230732141
84645
,
0
.
06330
8961782107
,
-
0
.
02
8324949364887
,
1
.
00
9942432477107
,
0
.
021054
814890112
,
0
.
01232
8875695483
,
-
0
.
020535
835374141
,
1
.
330713916450354
};
cmsStage
*
D65toD50
=
cmsStageAllocMatrix
(
ctx
,
3
,
3
,
M_D65_D50
,
NULL
);
cmsStage
*
D50toD65
=
cmsStageAllocMatrix
(
ctx
,
3
,
3
,
M_D50_D65
,
NULL
);
const
double
M_D65_LMS
[]
=
{
0
.
8189330101
,
0
.
3618667424
,
-
0
.
1288597137
,
0
.
032
9845436
,
0
.
9293118715
,
0
.
03614563
87
,
0
.
04
82003018
,
0
.
2643662691
,
0
.
6338517070
};
const
double
M_LMS_D65
[]
=
{
1
.
227013851103521
,
-
0
.
557799980651822
,
0
.
281256148966468
,
-
0
.
0405
80178423281
,
1
.
112256869616830
,
-
0
.
07167667
8665601
,
-
0
.
0763
81284505707
,
-
0
.
421481978418013
,
1
.
586163220440795
};
cmsStage
*
D65toLMS
=
cmsStageAllocMatrix
(
ctx
,
3
,
3
,
M_D65_LMS
,
NULL
);
cmsStage
*
LMStoD65
=
cmsStageAllocMatrix
(
ctx
,
3
,
3
,
M_LMS_D65
,
NULL
);
cmsToneCurve
*
CubeRoot
=
cmsBuildGamma
(
ctx
,
1
.
0
/
3
.
0
);
cmsToneCurve
*
Cube
=
cmsBuildGamma
(
ctx
,
3
.
0
);
cmsToneCurve
*
Roots
[
3
]
=
{
CubeRoot
,
CubeRoot
,
CubeRoot
};
cmsToneCurve
*
Cubes
[
3
]
=
{
Cube
,
Cube
,
Cube
};
cmsStage
*
NonLinearityFw
=
cmsStageAllocToneCurves
(
ctx
,
3
,
Roots
);
cmsStage
*
NonLinearityRv
=
cmsStageAllocToneCurves
(
ctx
,
3
,
Cubes
);
const
double
M_LMSprime_OkLab
[]
=
{
0
.
2104542553
,
0
.
7936177850
,
-
0
.
004072046
8
,
1
.
9779984951
,
-
2
.
4285922050
,
0
.
4505937099
,
0
.
025
9040371
,
0
.
7827717662
,
-
0
.
8086757660
};
const
double
M_OkLab_LMSprime
[]
=
{
0
.
999999998450520
,
0
.
396337792173768
,
0
.
215803758060759
,
1
.
00000000
8881761
,
-
0
.
105561342323656
,
-
0
.
063
854174771706
,
1
.
000000054672411
,
-
0
.
089484182094966
,
-
1
.
291485537864092
};
cmsStage
*
LMSprime_OkLab
=
cmsStageAllocMatrix
(
ctx
,
3
,
3
,
M_LMSprime_OkLab
,
NULL
);
cmsStage
*
OkLab_LMSprime
=
cmsStageAllocMatrix
(
ctx
,
3
,
3
,
M_OkLab_LMSprime
,
NULL
);
cmsPipeline
*
AToB
=
cmsPipelineAlloc
(
ctx
,
3
,
3
);
cmsPipeline
*
BToA
=
cmsPipelineAlloc
(
ctx
,
3
,
3
);
cmsHPROFILE
hProfile
=
cmsCreateProfilePlaceholder
(
ctx
);
cmsSetProfileVersion
(
hProfile
,
4
.
4
);
cmsSetDeviceClass
(
hProfile
,
cmsSigColorSpaceClass
);
cmsSetColorSpace
(
hProfile
,
cmsSig3colorData
);
cmsSetPCS
(
hProfile
,
cmsSigXYZData
);
cmsSetHeaderRenderingIntent
(
hProfile
,
INTENT_RELATIVE_COLORIMETRIC
);
/**
* Conversion PCS (XYZ/D50) to OkLab
*/
if
(
!
cmsPipelineInsertStage
(
BToA
,
cmsAT_END
,
PCSXYZ
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
BToA
,
cmsAT_END
,
D50toD65
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
BToA
,
cmsAT_END
,
D65toLMS
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
BToA
,
cmsAT_END
,
NonLinearityFw
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
BToA
,
cmsAT_END
,
LMSprime_OkLab
))
goto
error
;
if
(
!
cmsWriteTag
(
hProfile
,
cmsSigBToA0Tag
,
BToA
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
AToB
,
cmsAT_END
,
OkLab_LMSprime
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
AToB
,
cmsAT_END
,
NonLinearityRv
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
AToB
,
cmsAT_END
,
LMStoD65
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
AToB
,
cmsAT_END
,
D65toD50
))
goto
error
;
if
(
!
cmsPipelineInsertStage
(
AToB
,
cmsAT_END
,
XYZPCS
))
goto
error
;
if
(
!
cmsWriteTag
(
hProfile
,
cmsSigAToB0Tag
,
AToB
))
goto
error
;
cmsPipelineFree
(
BToA
);
cmsPipelineFree
(
AToB
);
cmsFreeToneCurve
(
CubeRoot
);
cmsFreeToneCurve
(
Cube
);
return
hProfile
;
error:
cmsPipelineFree
(
BToA
);
cmsPipelineFree
(
AToB
);
cmsFreeToneCurve
(
CubeRoot
);
cmsFreeToneCurve
(
Cube
);
cmsCloseProfile
(
hProfile
);
return
NULL
;
}
typedef
struct
{
...
...
@@ -1031,7 +1151,7 @@ cmsBool CheckOne(const cmsAllowedLUT* Tab, const cmsPipeline* Lut)
for
(
n
=
0
,
mpe
=
Lut
->
Elements
;
mpe
!=
NULL
;
mpe
=
mpe
->
Next
,
n
++
)
{
if
(
n
>
Tab
->
nTypes
)
return
FALSE
;
if
(
n
>
=
Tab
->
nTypes
)
return
FALSE
;
if
(
cmsStageType
(
mpe
)
!=
Tab
->
MpeTypes
[
n
])
return
FALSE
;
}
...
...
@@ -1062,9 +1182,9 @@ const cmsAllowedLUT* FindCombination(const cmsPipeline* Lut, cmsBool IsV4, cmsTa
cmsHPROFILE
CMSEXPORT
cmsTransform2DeviceLink
(
cmsHTRANSFORM
hTransform
,
cmsFloat64Number
Version
,
cmsUInt32Number
dwFlags
)
{
cmsHPROFILE
hProfile
=
NULL
;
cmsUInt32Number
FrmIn
,
FrmOut
;
cmsInt32Number
ChansIn
,
ChansOut
;
int
ColorSpaceBitsIn
,
ColorSpaceBitsOut
;
cmsUInt32Number
FrmIn
,
FrmOut
;
cmsInt32Number
ChansIn
,
ChansOut
;
int
ColorSpaceBitsIn
,
ColorSpaceBitsOut
;
_cmsTRANSFORM
*
xform
=
(
_cmsTRANSFORM
*
)
hTransform
;
cmsPipeline
*
LUT
=
NULL
;
cmsStage
*
mpe
;
...
...
@@ -1075,6 +1195,9 @@ cmsHPROFILE CMSEXPORT cmsTransform2DeviceLink(cmsHTRANSFORM hTransform, cmsFloat
_cmsAssert
(
hTransform
!=
NULL
);
// Check if the pipeline holding is valid
if
(
xform
->
Lut
==
NULL
)
return
NULL
;
// Get the first mpe to check for named color
mpe
=
cmsPipelineGetPtrToFirstStage
(
xform
->
Lut
);
...
...
libs/lcms2/src/cmsxform.c
View file @
b15d0120
...
...
@@ -914,7 +914,7 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
}
// Check whatever this is a true floating point transform
if
(
_cmsFormatterIsFloat
(
*
OutputFormat
))
{
if
(
_cmsFormatterIsFloat
(
*
InputFormat
)
||
_cmsFormatterIsFloat
(
*
OutputFormat
))
{
// Get formatter function always return a valid union, but the contents of this union may be NULL.
p
->
FromInputFloat
=
_cmsGetFormatter
(
ContextID
,
*
InputFormat
,
cmsFormatterInput
,
CMS_PACK_FLAGS_FLOAT
).
FmtFloat
;
...
...
@@ -989,6 +989,19 @@ _cmsTRANSFORM* AllocEmptyTransform(cmsContext ContextID, cmsPipeline* lut,
}
}
/**
* Check consistency for alpha channel copy
*/
if
(
*
dwFlags
&
cmsFLAGS_COPY_ALPHA
)
{
if
(
T_EXTRA
(
*
InputFormat
)
!=
T_EXTRA
(
*
OutputFormat
))
{
cmsSignalError
(
ContextID
,
cmsERROR_NOT_SUITABLE
,
"Mismatched alpha channels"
);
cmsDeleteTransform
(
p
);
return
NULL
;
}
}
p
->
InputFormat
=
*
InputFormat
;
p
->
OutputFormat
=
*
OutputFormat
;
p
->
dwOriginalFlags
=
*
dwFlags
;
...
...
libs/lcms2/src/lcms2_internal.h
View file @
b15d0120
...
...
@@ -260,6 +260,7 @@ typedef CRITICAL_SECTION _cmsMutex;
#ifdef _MSC_VER
# if (_MSC_VER >= 1800)
# pragma warning(disable : 26135)
# pragma warning(disable : 4127)
# endif
#endif
...
...
@@ -517,7 +518,7 @@ struct _cmsContext_struct {
struct
_cmsContext_struct
*
Next
;
// Points to next context in the new style
_cmsSubAllocator
*
MemPool
;
// The memory pool that stores context data
void
*
chunks
[
MemoryClientMax
];
// array of pointers to client chunks. Memory itself is h
old in the suballocator.
void
*
chunks
[
MemoryClientMax
];
// array of pointers to client chunks. Memory itself is h
eld in the suballocator.
// If NULL, then it reverts to global Context0
_cmsMemPluginChunkType
DefaultMemoryManager
;
// The allocators used for creating the context itself. Cannot be overridden
...
...
@@ -811,6 +812,9 @@ typedef struct _cms_iccprofile_struct {
// Creation time
struct
tm
Created
;
// Color management module identification
cmsUInt32Number
CMM
;
// Only most important items found in ICC profiles
cmsUInt32Number
Version
;
cmsProfileClassSignature
DeviceClass
;
...
...
@@ -818,6 +822,7 @@ typedef struct _cms_iccprofile_struct {
cmsColorSpaceSignature
PCS
;
cmsUInt32Number
RenderingIntent
;
cmsPlatformSignature
platform
;
cmsUInt32Number
flags
;
cmsUInt32Number
manufacturer
,
model
;
cmsUInt64Number
attributes
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment