annotate CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/include/lcms2_plugin.h @ 69:33d812a61356

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 17:55:14 -0400
parents
children
rev   line source
jpayne@69 1 //---------------------------------------------------------------------------------
jpayne@69 2 //
jpayne@69 3 // Little Color Management System
jpayne@69 4 // Copyright (c) 1998-2023 Marti Maria Saguer
jpayne@69 5 //
jpayne@69 6 // Permission is hereby granted, free of charge, to any person obtaining
jpayne@69 7 // a copy of this software and associated documentation files (the "Software"),
jpayne@69 8 // to deal in the Software without restriction, including without limitation
jpayne@69 9 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
jpayne@69 10 // and/or sell copies of the Software, and to permit persons to whom the Software
jpayne@69 11 // is furnished to do so, subject to the following conditions:
jpayne@69 12 //
jpayne@69 13 // The above copyright notice and this permission notice shall be included in
jpayne@69 14 // all copies or substantial portions of the Software.
jpayne@69 15 //
jpayne@69 16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
jpayne@69 17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
jpayne@69 18 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
jpayne@69 19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
jpayne@69 20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
jpayne@69 21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
jpayne@69 22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jpayne@69 23 //
jpayne@69 24 //---------------------------------------------------------------------------------
jpayne@69 25 //
jpayne@69 26 // This is the plug-in header file. Normal LittleCMS clients should not use it.
jpayne@69 27 // It is provided for plug-in writers that may want to access the support
jpayne@69 28 // functions to do low level operations. All plug-in related structures
jpayne@69 29 // are defined here. Including this file forces to include the standard API too.
jpayne@69 30
jpayne@69 31 #ifndef _lcms_plugin_H
jpayne@69 32
jpayne@69 33 // Deal with Microsoft's attempt at deprecating C standard runtime functions
jpayne@69 34 #ifdef _MSC_VER
jpayne@69 35 # if (_MSC_VER >= 1400)
jpayne@69 36 # ifndef _CRT_SECURE_NO_DEPRECATE
jpayne@69 37 # define _CRT_SECURE_NO_DEPRECATE
jpayne@69 38 # endif
jpayne@69 39 # ifndef _CRT_SECURE_NO_WARNINGS
jpayne@69 40 # define _CRT_SECURE_NO_WARNINGS
jpayne@69 41 # endif
jpayne@69 42 # endif
jpayne@69 43 #endif
jpayne@69 44
jpayne@69 45 #ifndef _lcms2_H
jpayne@69 46 #include "lcms2.h"
jpayne@69 47 #endif
jpayne@69 48
jpayne@69 49 // We need some standard C functions.
jpayne@69 50 #include <stdlib.h>
jpayne@69 51 #include <math.h>
jpayne@69 52 #include <stdarg.h>
jpayne@69 53 #include <memory.h>
jpayne@69 54 #include <string.h>
jpayne@69 55
jpayne@69 56
jpayne@69 57 #ifndef CMS_USE_CPP_API
jpayne@69 58 # ifdef __cplusplus
jpayne@69 59 extern "C" {
jpayne@69 60 # endif
jpayne@69 61 #endif
jpayne@69 62
jpayne@69 63 // Vector & Matrix operations -----------------------------------------------------------------------
jpayne@69 64
jpayne@69 65 // Axis of the matrix/array. No specific meaning at all.
jpayne@69 66 #define VX 0
jpayne@69 67 #define VY 1
jpayne@69 68 #define VZ 2
jpayne@69 69
jpayne@69 70 // Vectors
jpayne@69 71 typedef struct {
jpayne@69 72 cmsFloat64Number n[3];
jpayne@69 73
jpayne@69 74 } cmsVEC3;
jpayne@69 75
jpayne@69 76 // 3x3 Matrix
jpayne@69 77 typedef struct {
jpayne@69 78 cmsVEC3 v[3];
jpayne@69 79
jpayne@69 80 } cmsMAT3;
jpayne@69 81
jpayne@69 82 CMSAPI void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
jpayne@69 83 CMSAPI void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b);
jpayne@69 84 CMSAPI void CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v);
jpayne@69 85 CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v);
jpayne@69 86 CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3length(const cmsVEC3* a);
jpayne@69 87 CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b);
jpayne@69 88
jpayne@69 89 CMSAPI void CMSEXPORT _cmsMAT3identity(cmsMAT3* a);
jpayne@69 90 CMSAPI cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a);
jpayne@69 91 CMSAPI void CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b);
jpayne@69 92 CMSAPI cmsBool CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b);
jpayne@69 93 CMSAPI cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b);
jpayne@69 94 CMSAPI void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
jpayne@69 95
jpayne@69 96
jpayne@69 97 // MD5 low level -------------------------------------------------------------------------------------
jpayne@69 98
jpayne@69 99 CMSAPI cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID);
jpayne@69 100 CMSAPI void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len);
jpayne@69 101 CMSAPI void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle);
jpayne@69 102
jpayne@69 103 // Error logging -------------------------------------------------------------------------------------
jpayne@69 104
jpayne@69 105 CMSAPI void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
jpayne@69 106
jpayne@69 107 // Memory management ----------------------------------------------------------------------------------
jpayne@69 108
jpayne@69 109 CMSAPI void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size);
jpayne@69 110 CMSAPI void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size);
jpayne@69 111 CMSAPI void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
jpayne@69 112 CMSAPI void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
jpayne@69 113 CMSAPI void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr);
jpayne@69 114 CMSAPI void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size);
jpayne@69 115
jpayne@69 116 // I/O handler ----------------------------------------------------------------------------------
jpayne@69 117
jpayne@69 118 struct _cms_io_handler {
jpayne@69 119
jpayne@69 120 void* stream; // Associated stream, which is implemented differently depending on media.
jpayne@69 121
jpayne@69 122 cmsContext ContextID;
jpayne@69 123 cmsUInt32Number UsedSpace;
jpayne@69 124 cmsUInt32Number ReportedSize;
jpayne@69 125 char PhysicalFile[cmsMAX_PATH];
jpayne@69 126
jpayne@69 127 cmsUInt32Number (* Read)(struct _cms_io_handler* iohandler, void *Buffer,
jpayne@69 128 cmsUInt32Number size,
jpayne@69 129 cmsUInt32Number count);
jpayne@69 130 cmsBool (* Seek)(struct _cms_io_handler* iohandler, cmsUInt32Number offset);
jpayne@69 131 cmsBool (* Close)(struct _cms_io_handler* iohandler);
jpayne@69 132 cmsUInt32Number (* Tell)(struct _cms_io_handler* iohandler);
jpayne@69 133 cmsBool (* Write)(struct _cms_io_handler* iohandler, cmsUInt32Number size,
jpayne@69 134 const void* Buffer);
jpayne@69 135 };
jpayne@69 136
jpayne@69 137 // Endianness adjust functions
jpayne@69 138 CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
jpayne@69 139 CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
jpayne@69 140 CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
jpayne@69 141
jpayne@69 142 // Helper IO functions
jpayne@69 143 CMSAPI cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n);
jpayne@69 144 CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Number(cmsIOHANDLER* io, cmsUInt16Number* n);
jpayne@69 145 CMSAPI cmsBool CMSEXPORT _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n);
jpayne@69 146 CMSAPI cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n);
jpayne@69 147 CMSAPI cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
jpayne@69 148 CMSAPI cmsBool CMSEXPORT _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n);
jpayne@69 149 CMSAPI cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ);
jpayne@69 150 CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array);
jpayne@69 151
jpayne@69 152 CMSAPI cmsBool CMSEXPORT _cmsWriteUInt8Number(cmsIOHANDLER* io, cmsUInt8Number n);
jpayne@69 153 CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Number(cmsIOHANDLER* io, cmsUInt16Number n);
jpayne@69 154 CMSAPI cmsBool CMSEXPORT _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n);
jpayne@69 155 CMSAPI cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n);
jpayne@69 156 CMSAPI cmsBool CMSEXPORT _cmsWriteUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
jpayne@69 157 CMSAPI cmsBool CMSEXPORT _cmsWrite15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number n);
jpayne@69 158 CMSAPI cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ);
jpayne@69 159 CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array);
jpayne@69 160
jpayne@69 161 // ICC base tag
jpayne@69 162 typedef struct {
jpayne@69 163 cmsTagTypeSignature sig;
jpayne@69 164 cmsInt8Number reserved[4];
jpayne@69 165
jpayne@69 166 } _cmsTagBase;
jpayne@69 167
jpayne@69 168 // Type base helper functions
jpayne@69 169 CMSAPI cmsTagTypeSignature CMSEXPORT _cmsReadTypeBase(cmsIOHANDLER* io);
jpayne@69 170 CMSAPI cmsBool CMSEXPORT _cmsWriteTypeBase(cmsIOHANDLER* io, cmsTagTypeSignature sig);
jpayne@69 171
jpayne@69 172 // Alignment functions
jpayne@69 173 CMSAPI cmsBool CMSEXPORT _cmsReadAlignment(cmsIOHANDLER* io);
jpayne@69 174 CMSAPI cmsBool CMSEXPORT _cmsWriteAlignment(cmsIOHANDLER* io);
jpayne@69 175
jpayne@69 176 // To deal with text streams. 2K at most
jpayne@69 177 CMSAPI cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...);
jpayne@69 178
jpayne@69 179 // Fixed point helper functions
jpayne@69 180 CMSAPI cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8);
jpayne@69 181 CMSAPI cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val);
jpayne@69 182
jpayne@69 183 CMSAPI cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32);
jpayne@69 184 CMSAPI cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v);
jpayne@69 185
jpayne@69 186 // Date/time helper functions
jpayne@69 187 CMSAPI void CMSEXPORT _cmsEncodeDateTimeNumber(cmsDateTimeNumber *Dest, const struct tm *Source);
jpayne@69 188 CMSAPI void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest);
jpayne@69 189
jpayne@69 190 //----------------------------------------------------------------------------------------------------------
jpayne@69 191
jpayne@69 192 // Shared callbacks for user data
jpayne@69 193 typedef void (* _cmsFreeUserDataFn)(cmsContext ContextID, void* Data);
jpayne@69 194 typedef void* (* _cmsDupUserDataFn)(cmsContext ContextID, const void* Data);
jpayne@69 195
jpayne@69 196 //----------------------------------------------------------------------------------------------------------
jpayne@69 197
jpayne@69 198 // Plug-in foundation
jpayne@69 199 #define cmsPluginMagicNumber 0x61637070 // 'acpp'
jpayne@69 200
jpayne@69 201 #define cmsPluginMemHandlerSig 0x6D656D48 // 'memH'
jpayne@69 202 #define cmsPluginInterpolationSig 0x696E7048 // 'inpH'
jpayne@69 203 #define cmsPluginParametricCurveSig 0x70617248 // 'parH'
jpayne@69 204 #define cmsPluginFormattersSig 0x66726D48 // 'frmH
jpayne@69 205 #define cmsPluginTagTypeSig 0x74797048 // 'typH'
jpayne@69 206 #define cmsPluginTagSig 0x74616748 // 'tagH'
jpayne@69 207 #define cmsPluginRenderingIntentSig 0x696E7448 // 'intH'
jpayne@69 208 #define cmsPluginMultiProcessElementSig 0x6D706548 // 'mpeH'
jpayne@69 209 #define cmsPluginOptimizationSig 0x6F707448 // 'optH'
jpayne@69 210 #define cmsPluginTransformSig 0x7A666D48 // 'xfmH'
jpayne@69 211 #define cmsPluginMutexSig 0x6D747A48 // 'mtxH'
jpayne@69 212 #define cmsPluginParalellizationSig 0x70726C48 // 'prlH
jpayne@69 213
jpayne@69 214 typedef struct _cmsPluginBaseStruct {
jpayne@69 215
jpayne@69 216 cmsUInt32Number Magic; // 'acpp' signature
jpayne@69 217 cmsUInt32Number ExpectedVersion; // Expected version of LittleCMS
jpayne@69 218 cmsUInt32Number Type; // Type of plug-in
jpayne@69 219 struct _cmsPluginBaseStruct* Next; // For multiple plugin definition. NULL for end of list.
jpayne@69 220
jpayne@69 221 } cmsPluginBase;
jpayne@69 222
jpayne@69 223 // Maximum number of types in a plugin array
jpayne@69 224 #define MAX_TYPES_IN_LCMS_PLUGIN 20
jpayne@69 225
jpayne@69 226 //----------------------------------------------------------------------------------------------------------
jpayne@69 227
jpayne@69 228 // Memory handler. Each new plug-in type replaces current behaviour
jpayne@69 229
jpayne@69 230 typedef void* (* _cmsMallocFnPtrType)(cmsContext ContextID, cmsUInt32Number size);
jpayne@69 231 typedef void (* _cmsFreeFnPtrType)(cmsContext ContextID, void *Ptr);
jpayne@69 232 typedef void* (* _cmsReallocFnPtrType)(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
jpayne@69 233
jpayne@69 234 typedef void* (* _cmsMalloZerocFnPtrType)(cmsContext ContextID, cmsUInt32Number size);
jpayne@69 235 typedef void* (* _cmsCallocFnPtrType)(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
jpayne@69 236 typedef void* (* _cmsDupFnPtrType)(cmsContext ContextID, const void* Org, cmsUInt32Number size);
jpayne@69 237
jpayne@69 238 typedef struct {
jpayne@69 239
jpayne@69 240 cmsPluginBase base;
jpayne@69 241
jpayne@69 242 // Required
jpayne@69 243 _cmsMallocFnPtrType MallocPtr;
jpayne@69 244 _cmsFreeFnPtrType FreePtr;
jpayne@69 245 _cmsReallocFnPtrType ReallocPtr;
jpayne@69 246
jpayne@69 247 // Optional
jpayne@69 248 _cmsMalloZerocFnPtrType MallocZeroPtr;
jpayne@69 249 _cmsCallocFnPtrType CallocPtr;
jpayne@69 250 _cmsDupFnPtrType DupPtr;
jpayne@69 251
jpayne@69 252 } cmsPluginMemHandler;
jpayne@69 253
jpayne@69 254
jpayne@69 255 // ------------------------------------------------------------------------------------------------------------------
jpayne@69 256
jpayne@69 257 // Interpolation. 16 bits and floating point versions.
jpayne@69 258 struct _cms_interp_struc;
jpayne@69 259
jpayne@69 260 // Interpolation callbacks
jpayne@69 261
jpayne@69 262 // 16 bits forward interpolation. This function performs precision-limited linear interpolation
jpayne@69 263 // and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
jpayne@69 264 // choose to implement any other interpolation algorithm.
jpayne@69 265 typedef void (* _cmsInterpFn16)(CMSREGISTER const cmsUInt16Number Input[],
jpayne@69 266 CMSREGISTER cmsUInt16Number Output[],
jpayne@69 267 CMSREGISTER const struct _cms_interp_struc* p);
jpayne@69 268
jpayne@69 269 // Floating point forward interpolation. Full precision interpolation using floats. This is not a
jpayne@69 270 // time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
jpayne@69 271 // choose to implement any other interpolation algorithm.
jpayne@69 272 typedef void (* _cmsInterpFnFloat)(cmsFloat32Number const Input[],
jpayne@69 273 cmsFloat32Number Output[],
jpayne@69 274 const struct _cms_interp_struc* p);
jpayne@69 275
jpayne@69 276
jpayne@69 277
jpayne@69 278 // This type holds a pointer to an interpolator that can be either 16 bits or float
jpayne@69 279 typedef union {
jpayne@69 280 _cmsInterpFn16 Lerp16; // Forward interpolation in 16 bits
jpayne@69 281 _cmsInterpFnFloat LerpFloat; // Forward interpolation in floating point
jpayne@69 282 } cmsInterpFunction;
jpayne@69 283
jpayne@69 284 // Flags for interpolator selection
jpayne@69 285 #define CMS_LERP_FLAGS_16BITS 0x0000 // The default
jpayne@69 286 #define CMS_LERP_FLAGS_FLOAT 0x0001 // Requires different implementation
jpayne@69 287 #define CMS_LERP_FLAGS_TRILINEAR 0x0100 // Hint only
jpayne@69 288
jpayne@69 289
jpayne@69 290 #define MAX_INPUT_DIMENSIONS 15
jpayne@69 291
jpayne@69 292 typedef struct _cms_interp_struc { // Used on all interpolations. Supplied by lcms2 when calling the interpolation function
jpayne@69 293
jpayne@69 294 cmsContext ContextID; // The calling thread
jpayne@69 295
jpayne@69 296 cmsUInt32Number dwFlags; // Keep original flags
jpayne@69 297 cmsUInt32Number nInputs; // != 1 only in 3D interpolation
jpayne@69 298 cmsUInt32Number nOutputs; // != 1 only in 3D interpolation
jpayne@69 299
jpayne@69 300 cmsUInt32Number nSamples[MAX_INPUT_DIMENSIONS]; // Valid on all kinds of tables
jpayne@69 301 cmsUInt32Number Domain[MAX_INPUT_DIMENSIONS]; // Domain = nSamples - 1
jpayne@69 302
jpayne@69 303 cmsUInt32Number opta[MAX_INPUT_DIMENSIONS]; // Optimization for 3D CLUT. This is the number of nodes premultiplied for each
jpayne@69 304 // dimension. For example, in 7 nodes, 7, 7^2 , 7^3, 7^4, etc. On non-regular
jpayne@69 305 // Samplings may vary according of the number of nodes for each dimension.
jpayne@69 306
jpayne@69 307 const void *Table; // Points to the actual interpolation table
jpayne@69 308 cmsInterpFunction Interpolation; // Points to the function to do the interpolation
jpayne@69 309
jpayne@69 310 } cmsInterpParams;
jpayne@69 311
jpayne@69 312 // Interpolators factory
jpayne@69 313 typedef cmsInterpFunction (* cmsInterpFnFactory)(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
jpayne@69 314
jpayne@69 315 // The plug-in
jpayne@69 316 typedef struct {
jpayne@69 317 cmsPluginBase base;
jpayne@69 318
jpayne@69 319 // Points to a user-supplied function which implements the factory
jpayne@69 320 cmsInterpFnFactory InterpolatorsFactory;
jpayne@69 321
jpayne@69 322 } cmsPluginInterpolation;
jpayne@69 323
jpayne@69 324 //----------------------------------------------------------------------------------------------------------
jpayne@69 325
jpayne@69 326 // Parametric curves. A negative type means same function but analytically inverted. Max. number of params is 10
jpayne@69 327
jpayne@69 328 // Evaluator callback for user-supplied parametric curves. May implement more than one type
jpayne@69 329 typedef cmsFloat64Number (* cmsParametricCurveEvaluator)(cmsInt32Number Type, const cmsFloat64Number Params[10], cmsFloat64Number R);
jpayne@69 330
jpayne@69 331 // Plug-in may implement an arbitrary number of parametric curves
jpayne@69 332 typedef struct {
jpayne@69 333 cmsPluginBase base;
jpayne@69 334
jpayne@69 335 cmsUInt32Number nFunctions; // Number of supported functions
jpayne@69 336 cmsUInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN]; // The identification types
jpayne@69 337 cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN]; // Number of parameters for each function
jpayne@69 338
jpayne@69 339 cmsParametricCurveEvaluator Evaluator; // The evaluator
jpayne@69 340
jpayne@69 341 } cmsPluginParametricCurves;
jpayne@69 342 //----------------------------------------------------------------------------------------------------------
jpayne@69 343
jpayne@69 344 // Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with
jpayne@69 345 // cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across
jpayne@69 346 // Formatter16 callback
jpayne@69 347
jpayne@69 348 struct _cmstransform_struct;
jpayne@69 349
jpayne@69 350 typedef cmsUInt8Number* (* cmsFormatter16)(CMSREGISTER struct _cmstransform_struct* CMMcargo,
jpayne@69 351 CMSREGISTER cmsUInt16Number Values[],
jpayne@69 352 CMSREGISTER cmsUInt8Number* Buffer,
jpayne@69 353 CMSREGISTER cmsUInt32Number Stride);
jpayne@69 354
jpayne@69 355 typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
jpayne@69 356 cmsFloat32Number Values[],
jpayne@69 357 cmsUInt8Number* Buffer,
jpayne@69 358 cmsUInt32Number Stride);
jpayne@69 359
jpayne@69 360 // This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number
jpayne@69 361 typedef union {
jpayne@69 362 cmsFormatter16 Fmt16;
jpayne@69 363 cmsFormatterFloat FmtFloat;
jpayne@69 364
jpayne@69 365 } cmsFormatter;
jpayne@69 366
jpayne@69 367 #define CMS_PACK_FLAGS_16BITS 0x0000
jpayne@69 368 #define CMS_PACK_FLAGS_FLOAT 0x0001
jpayne@69 369
jpayne@69 370 typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection;
jpayne@69 371
jpayne@69 372 typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8
jpayne@69 373 cmsFormatterDirection Dir,
jpayne@69 374 cmsUInt32Number dwFlags); // precision
jpayne@69 375
jpayne@69 376 // Plug-in may implement an arbitrary number of formatters
jpayne@69 377 typedef struct {
jpayne@69 378 cmsPluginBase base;
jpayne@69 379 cmsFormatterFactory FormattersFactory;
jpayne@69 380
jpayne@69 381 } cmsPluginFormatters;
jpayne@69 382
jpayne@69 383 //----------------------------------------------------------------------------------------------------------
jpayne@69 384
jpayne@69 385 // Tag type handler. Each type is free to return anything it wants, and it is up to the caller to
jpayne@69 386 // know in advance what is the type contained in the tag.
jpayne@69 387 typedef struct _cms_typehandler_struct {
jpayne@69 388
jpayne@69 389 cmsTagTypeSignature Signature; // The signature of the type
jpayne@69 390
jpayne@69 391 // Allocates and reads items
jpayne@69 392 void * (* ReadPtr)(struct _cms_typehandler_struct* self,
jpayne@69 393 cmsIOHANDLER* io,
jpayne@69 394 cmsUInt32Number* nItems,
jpayne@69 395 cmsUInt32Number SizeOfTag);
jpayne@69 396
jpayne@69 397 // Writes n Items
jpayne@69 398 cmsBool (* WritePtr)(struct _cms_typehandler_struct* self,
jpayne@69 399 cmsIOHANDLER* io,
jpayne@69 400 void* Ptr,
jpayne@69 401 cmsUInt32Number nItems);
jpayne@69 402
jpayne@69 403 // Duplicate an item or array of items
jpayne@69 404 void* (* DupPtr)(struct _cms_typehandler_struct* self,
jpayne@69 405 const void *Ptr,
jpayne@69 406 cmsUInt32Number n);
jpayne@69 407
jpayne@69 408 // Free all resources
jpayne@69 409 void (* FreePtr)(struct _cms_typehandler_struct* self,
jpayne@69 410 void *Ptr);
jpayne@69 411
jpayne@69 412 // Additional parameters used by the calling thread
jpayne@69 413 cmsContext ContextID;
jpayne@69 414 cmsUInt32Number ICCVersion;
jpayne@69 415
jpayne@69 416 } cmsTagTypeHandler;
jpayne@69 417
jpayne@69 418 // Each plug-in implements a single type
jpayne@69 419 typedef struct {
jpayne@69 420 cmsPluginBase base;
jpayne@69 421 cmsTagTypeHandler Handler;
jpayne@69 422
jpayne@69 423 } cmsPluginTagType;
jpayne@69 424
jpayne@69 425 //----------------------------------------------------------------------------------------------------------
jpayne@69 426
jpayne@69 427 // This is the tag plugin, which identifies tags. For writing, a pointer to function is provided.
jpayne@69 428 // This function should return the desired type for this tag, given the version of profile
jpayne@69 429 // and the data being serialized.
jpayne@69 430 typedef struct {
jpayne@69 431
jpayne@69 432 cmsUInt32Number ElemCount; // If this tag needs an array, how many elements should keep
jpayne@69 433
jpayne@69 434 // For reading.
jpayne@69 435 cmsUInt32Number nSupportedTypes; // In how many types this tag can come (MAX_TYPES_IN_LCMS_PLUGIN maximum)
jpayne@69 436 cmsTagTypeSignature SupportedTypes[MAX_TYPES_IN_LCMS_PLUGIN];
jpayne@69 437
jpayne@69 438 // For writing
jpayne@69 439 cmsTagTypeSignature (* DecideType)(cmsFloat64Number ICCVersion, const void *Data);
jpayne@69 440
jpayne@69 441 } cmsTagDescriptor;
jpayne@69 442
jpayne@69 443 // Plug-in implements a single tag
jpayne@69 444 typedef struct {
jpayne@69 445 cmsPluginBase base;
jpayne@69 446
jpayne@69 447 cmsTagSignature Signature;
jpayne@69 448 cmsTagDescriptor Descriptor;
jpayne@69 449
jpayne@69 450 } cmsPluginTag;
jpayne@69 451
jpayne@69 452 //----------------------------------------------------------------------------------------------------------
jpayne@69 453
jpayne@69 454 // Custom intents. This function should join all profiles specified in the array in
jpayne@69 455 // a single LUT. Any custom intent in the chain redirects to custom function. If more than
jpayne@69 456 // one custom intent is found, the one located first is invoked. Usually users should use only one
jpayne@69 457 // custom intent, so mixing custom intents in same multiprofile transform is not supported.
jpayne@69 458
jpayne@69 459 typedef cmsPipeline* (* cmsIntentFn)( cmsContext ContextID,
jpayne@69 460 cmsUInt32Number nProfiles,
jpayne@69 461 cmsUInt32Number Intents[],
jpayne@69 462 cmsHPROFILE hProfiles[],
jpayne@69 463 cmsBool BPC[],
jpayne@69 464 cmsFloat64Number AdaptationStates[],
jpayne@69 465 cmsUInt32Number dwFlags);
jpayne@69 466
jpayne@69 467
jpayne@69 468 // Each plug-in defines a single intent number.
jpayne@69 469 typedef struct {
jpayne@69 470 cmsPluginBase base;
jpayne@69 471 cmsUInt32Number Intent;
jpayne@69 472 cmsIntentFn Link;
jpayne@69 473 char Description[256];
jpayne@69 474
jpayne@69 475 } cmsPluginRenderingIntent;
jpayne@69 476
jpayne@69 477
jpayne@69 478 // The default ICC intents (perceptual, saturation, rel.col and abs.col)
jpayne@69 479 CMSAPI cmsPipeline* CMSEXPORT _cmsDefaultICCintents(cmsContext ContextID,
jpayne@69 480 cmsUInt32Number nProfiles,
jpayne@69 481 cmsUInt32Number Intents[],
jpayne@69 482 cmsHPROFILE hProfiles[],
jpayne@69 483 cmsBool BPC[],
jpayne@69 484 cmsFloat64Number AdaptationStates[],
jpayne@69 485 cmsUInt32Number dwFlags);
jpayne@69 486
jpayne@69 487
jpayne@69 488 //----------------------------------------------------------------------------------------------------------
jpayne@69 489
jpayne@69 490 // Pipelines, Multi Process Elements.
jpayne@69 491
jpayne@69 492 typedef void (* _cmsStageEvalFn) (const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage* mpe);
jpayne@69 493 typedef void*(* _cmsStageDupElemFn) (cmsStage* mpe);
jpayne@69 494 typedef void (* _cmsStageFreeElemFn) (cmsStage* mpe);
jpayne@69 495
jpayne@69 496
jpayne@69 497 // This function allocates a generic MPE
jpayne@69 498 CMSAPI cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID,
jpayne@69 499 cmsStageSignature Type,
jpayne@69 500 cmsUInt32Number InputChannels,
jpayne@69 501 cmsUInt32Number OutputChannels,
jpayne@69 502 _cmsStageEvalFn EvalPtr, // Points to fn that evaluates the element (always in floating point)
jpayne@69 503 _cmsStageDupElemFn DupElemPtr, // Points to a fn that duplicates the stage
jpayne@69 504 _cmsStageFreeElemFn FreePtr, // Points to a fn that sets the element free
jpayne@69 505 void* Data); // A generic pointer to whatever memory needed by the element
jpayne@69 506 typedef struct {
jpayne@69 507 cmsPluginBase base;
jpayne@69 508 cmsTagTypeHandler Handler;
jpayne@69 509
jpayne@69 510 } cmsPluginMultiProcessElement;
jpayne@69 511
jpayne@69 512
jpayne@69 513 // Data kept in "Element" member of cmsStage
jpayne@69 514
jpayne@69 515 // Curves
jpayne@69 516 typedef struct {
jpayne@69 517 cmsUInt32Number nCurves;
jpayne@69 518 cmsToneCurve** TheCurves;
jpayne@69 519
jpayne@69 520 } _cmsStageToneCurvesData;
jpayne@69 521
jpayne@69 522 // Matrix
jpayne@69 523 typedef struct {
jpayne@69 524 cmsFloat64Number* Double; // floating point for the matrix
jpayne@69 525 cmsFloat64Number* Offset; // The offset
jpayne@69 526
jpayne@69 527 } _cmsStageMatrixData;
jpayne@69 528
jpayne@69 529 // CLUT
jpayne@69 530 typedef struct {
jpayne@69 531
jpayne@69 532 union { // Can have only one of both representations at same time
jpayne@69 533 cmsUInt16Number* T; // Points to the table 16 bits table
jpayne@69 534 cmsFloat32Number* TFloat; // Points to the cmsFloat32Number table
jpayne@69 535
jpayne@69 536 } Tab;
jpayne@69 537
jpayne@69 538 cmsInterpParams* Params;
jpayne@69 539 cmsUInt32Number nEntries;
jpayne@69 540 cmsBool HasFloatValues;
jpayne@69 541
jpayne@69 542 } _cmsStageCLutData;
jpayne@69 543
jpayne@69 544
jpayne@69 545 //----------------------------------------------------------------------------------------------------------
jpayne@69 546 // Optimization. Using this plug-in, additional optimization strategies may be implemented.
jpayne@69 547 // The function should return TRUE if any optimization is done on the LUT, this terminates
jpayne@69 548 // the optimization search. Or FALSE if it is unable to optimize and want to give a chance
jpayne@69 549 // to the rest of optimizers.
jpayne@69 550
jpayne@69 551 typedef cmsBool (* _cmsOPToptimizeFn)(cmsPipeline** Lut,
jpayne@69 552 cmsUInt32Number Intent,
jpayne@69 553 cmsUInt32Number* InputFormat,
jpayne@69 554 cmsUInt32Number* OutputFormat,
jpayne@69 555 cmsUInt32Number* dwFlags);
jpayne@69 556
jpayne@69 557 // Pipeline Evaluator (in 16 bits)
jpayne@69 558 typedef void (* _cmsPipelineEval16Fn)(CMSREGISTER const cmsUInt16Number In[],
jpayne@69 559 CMSREGISTER cmsUInt16Number Out[],
jpayne@69 560 const void* Data);
jpayne@69 561
jpayne@69 562 // Pipeline Evaluator (in floating point)
jpayne@69 563 typedef void (* _cmsPipelineEvalFloatFn)(const cmsFloat32Number In[],
jpayne@69 564 cmsFloat32Number Out[],
jpayne@69 565 const void* Data);
jpayne@69 566
jpayne@69 567
jpayne@69 568 // This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
jpayne@69 569 // duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
jpayne@69 570
jpayne@69 571 CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
jpayne@69 572 _cmsPipelineEval16Fn Eval16,
jpayne@69 573 void* PrivateData,
jpayne@69 574 _cmsFreeUserDataFn FreePrivateDataFn,
jpayne@69 575 _cmsDupUserDataFn DupPrivateDataFn);
jpayne@69 576
jpayne@69 577 typedef struct {
jpayne@69 578 cmsPluginBase base;
jpayne@69 579
jpayne@69 580 // Optimize entry point
jpayne@69 581 _cmsOPToptimizeFn OptimizePtr;
jpayne@69 582
jpayne@69 583 } cmsPluginOptimization;
jpayne@69 584
jpayne@69 585 //----------------------------------------------------------------------------------------------------------
jpayne@69 586 // Full xform
jpayne@69 587
jpayne@69 588 typedef struct {
jpayne@69 589 cmsUInt32Number BytesPerLineIn;
jpayne@69 590 cmsUInt32Number BytesPerLineOut;
jpayne@69 591 cmsUInt32Number BytesPerPlaneIn;
jpayne@69 592 cmsUInt32Number BytesPerPlaneOut;
jpayne@69 593
jpayne@69 594 } cmsStride;
jpayne@69 595
jpayne@69 596 typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo, // Legacy function, handles just ONE scanline.
jpayne@69 597 const void* InputBuffer,
jpayne@69 598 void* OutputBuffer,
jpayne@69 599 cmsUInt32Number Size,
jpayne@69 600 cmsUInt32Number Stride); // Stride in bytes to the next plane in planar formats
jpayne@69 601
jpayne@69 602
jpayne@69 603 typedef void (*_cmsTransform2Fn)(struct _cmstransform_struct *CMMcargo,
jpayne@69 604 const void* InputBuffer,
jpayne@69 605 void* OutputBuffer,
jpayne@69 606 cmsUInt32Number PixelsPerLine,
jpayne@69 607 cmsUInt32Number LineCount,
jpayne@69 608 const cmsStride* Stride);
jpayne@69 609
jpayne@69 610 typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform,
jpayne@69 611 void** UserData,
jpayne@69 612 _cmsFreeUserDataFn* FreePrivateDataFn,
jpayne@69 613 cmsPipeline** Lut,
jpayne@69 614 cmsUInt32Number* InputFormat,
jpayne@69 615 cmsUInt32Number* OutputFormat,
jpayne@69 616 cmsUInt32Number* dwFlags);
jpayne@69 617
jpayne@69 618 typedef cmsBool (* _cmsTransform2Factory)(_cmsTransform2Fn* xform,
jpayne@69 619 void** UserData,
jpayne@69 620 _cmsFreeUserDataFn* FreePrivateDataFn,
jpayne@69 621 cmsPipeline** Lut,
jpayne@69 622 cmsUInt32Number* InputFormat,
jpayne@69 623 cmsUInt32Number* OutputFormat,
jpayne@69 624 cmsUInt32Number* dwFlags);
jpayne@69 625
jpayne@69 626
jpayne@69 627 // Retrieve user data as specified by the factory
jpayne@69 628 CMSAPI void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn);
jpayne@69 629 CMSAPI void * CMSEXPORT _cmsGetTransformUserData(struct _cmstransform_struct *CMMcargo);
jpayne@69 630
jpayne@69 631
jpayne@69 632 // Retrieve formatters
jpayne@69 633 CMSAPI void CMSEXPORT _cmsGetTransformFormatters16 (struct _cmstransform_struct *CMMcargo, cmsFormatter16* FromInput, cmsFormatter16* ToOutput);
jpayne@69 634 CMSAPI void CMSEXPORT _cmsGetTransformFormattersFloat(struct _cmstransform_struct *CMMcargo, cmsFormatterFloat* FromInput, cmsFormatterFloat* ToOutput);
jpayne@69 635
jpayne@69 636 // Retrieve original flags
jpayne@69 637 CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformFlags(struct _cmstransform_struct* CMMcargo);
jpayne@69 638
jpayne@69 639 typedef struct {
jpayne@69 640 cmsPluginBase base;
jpayne@69 641
jpayne@69 642 // Transform entry point
jpayne@69 643 union {
jpayne@69 644 _cmsTransformFactory legacy_xform;
jpayne@69 645 _cmsTransform2Factory xform;
jpayne@69 646 } factories;
jpayne@69 647
jpayne@69 648 } cmsPluginTransform;
jpayne@69 649
jpayne@69 650 //----------------------------------------------------------------------------------------------------------
jpayne@69 651 // Mutex
jpayne@69 652
jpayne@69 653 typedef void* (* _cmsCreateMutexFnPtrType)(cmsContext ContextID);
jpayne@69 654 typedef void (* _cmsDestroyMutexFnPtrType)(cmsContext ContextID, void* mtx);
jpayne@69 655 typedef cmsBool (* _cmsLockMutexFnPtrType)(cmsContext ContextID, void* mtx);
jpayne@69 656 typedef void (* _cmsUnlockMutexFnPtrType)(cmsContext ContextID, void* mtx);
jpayne@69 657
jpayne@69 658 typedef struct {
jpayne@69 659 cmsPluginBase base;
jpayne@69 660
jpayne@69 661 _cmsCreateMutexFnPtrType CreateMutexPtr;
jpayne@69 662 _cmsDestroyMutexFnPtrType DestroyMutexPtr;
jpayne@69 663 _cmsLockMutexFnPtrType LockMutexPtr;
jpayne@69 664 _cmsUnlockMutexFnPtrType UnlockMutexPtr;
jpayne@69 665
jpayne@69 666 } cmsPluginMutex;
jpayne@69 667
jpayne@69 668 CMSAPI void* CMSEXPORT _cmsCreateMutex(cmsContext ContextID);
jpayne@69 669 CMSAPI void CMSEXPORT _cmsDestroyMutex(cmsContext ContextID, void* mtx);
jpayne@69 670 CMSAPI cmsBool CMSEXPORT _cmsLockMutex(cmsContext ContextID, void* mtx);
jpayne@69 671 CMSAPI void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx);
jpayne@69 672
jpayne@69 673 //----------------------------------------------------------------------------------------------------------
jpayne@69 674 // Parallelization
jpayne@69 675
jpayne@69 676 CMSAPI _cmsTransform2Fn CMSEXPORT _cmsGetTransformWorker(struct _cmstransform_struct* CMMcargo);
jpayne@69 677 CMSAPI cmsInt32Number CMSEXPORT _cmsGetTransformMaxWorkers(struct _cmstransform_struct* CMMcargo);
jpayne@69 678 CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformWorkerFlags(struct _cmstransform_struct* CMMcargo);
jpayne@69 679
jpayne@69 680 // Let's plug-in to guess the best number of workers
jpayne@69 681 #define CMS_GUESS_MAX_WORKERS -1
jpayne@69 682
jpayne@69 683 typedef struct {
jpayne@69 684 cmsPluginBase base;
jpayne@69 685
jpayne@69 686 cmsInt32Number MaxWorkers; // Number of starts to do as maximum
jpayne@69 687 cmsUInt32Number WorkerFlags; // Reserved
jpayne@69 688 _cmsTransform2Fn SchedulerFn; // callback to setup functions
jpayne@69 689
jpayne@69 690 } cmsPluginParalellization;
jpayne@69 691
jpayne@69 692
jpayne@69 693 #ifndef CMS_USE_CPP_API
jpayne@69 694 # ifdef __cplusplus
jpayne@69 695 }
jpayne@69 696 # endif
jpayne@69 697 #endif
jpayne@69 698
jpayne@69 699 #define _lcms_plugin_H
jpayne@69 700 #endif