jpayne@69: //--------------------------------------------------------------------------------- jpayne@69: // jpayne@69: // Little Color Management System jpayne@69: // Copyright (c) 1998-2023 Marti Maria Saguer jpayne@69: // jpayne@69: // Permission is hereby granted, free of charge, to any person obtaining jpayne@69: // a copy of this software and associated documentation files (the "Software"), jpayne@69: // to deal in the Software without restriction, including without limitation jpayne@69: // the rights to use, copy, modify, merge, publish, distribute, sublicense, jpayne@69: // and/or sell copies of the Software, and to permit persons to whom the Software jpayne@69: // is furnished to do so, subject to the following conditions: jpayne@69: // jpayne@69: // The above copyright notice and this permission notice shall be included in jpayne@69: // all copies or substantial portions of the Software. jpayne@69: // jpayne@69: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, jpayne@69: // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO jpayne@69: // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND jpayne@69: // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE jpayne@69: // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION jpayne@69: // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION jpayne@69: // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jpayne@69: // jpayne@69: //--------------------------------------------------------------------------------- jpayne@69: // jpayne@69: // This is the plug-in header file. Normal LittleCMS clients should not use it. jpayne@69: // It is provided for plug-in writers that may want to access the support jpayne@69: // functions to do low level operations. All plug-in related structures jpayne@69: // are defined here. Including this file forces to include the standard API too. jpayne@69: jpayne@69: #ifndef _lcms_plugin_H jpayne@69: jpayne@69: // Deal with Microsoft's attempt at deprecating C standard runtime functions jpayne@69: #ifdef _MSC_VER jpayne@69: # if (_MSC_VER >= 1400) jpayne@69: # ifndef _CRT_SECURE_NO_DEPRECATE jpayne@69: # define _CRT_SECURE_NO_DEPRECATE jpayne@69: # endif jpayne@69: # ifndef _CRT_SECURE_NO_WARNINGS jpayne@69: # define _CRT_SECURE_NO_WARNINGS jpayne@69: # endif jpayne@69: # endif jpayne@69: #endif jpayne@69: jpayne@69: #ifndef _lcms2_H jpayne@69: #include "lcms2.h" jpayne@69: #endif jpayne@69: jpayne@69: // We need some standard C functions. jpayne@69: #include jpayne@69: #include jpayne@69: #include jpayne@69: #include jpayne@69: #include jpayne@69: jpayne@69: jpayne@69: #ifndef CMS_USE_CPP_API jpayne@69: # ifdef __cplusplus jpayne@69: extern "C" { jpayne@69: # endif jpayne@69: #endif jpayne@69: jpayne@69: // Vector & Matrix operations ----------------------------------------------------------------------- jpayne@69: jpayne@69: // Axis of the matrix/array. No specific meaning at all. jpayne@69: #define VX 0 jpayne@69: #define VY 1 jpayne@69: #define VZ 2 jpayne@69: jpayne@69: // Vectors jpayne@69: typedef struct { jpayne@69: cmsFloat64Number n[3]; jpayne@69: jpayne@69: } cmsVEC3; jpayne@69: jpayne@69: // 3x3 Matrix jpayne@69: typedef struct { jpayne@69: cmsVEC3 v[3]; jpayne@69: jpayne@69: } cmsMAT3; jpayne@69: jpayne@69: CMSAPI void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z); jpayne@69: CMSAPI void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b); jpayne@69: CMSAPI void CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v); jpayne@69: CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v); jpayne@69: CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3length(const cmsVEC3* a); jpayne@69: CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b); jpayne@69: jpayne@69: CMSAPI void CMSEXPORT _cmsMAT3identity(cmsMAT3* a); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a); jpayne@69: CMSAPI void CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b); jpayne@69: CMSAPI void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v); jpayne@69: jpayne@69: jpayne@69: // MD5 low level ------------------------------------------------------------------------------------- jpayne@69: jpayne@69: CMSAPI cmsHANDLE CMSEXPORT cmsMD5alloc(cmsContext ContextID); jpayne@69: CMSAPI void CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len); jpayne@69: CMSAPI void CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle); jpayne@69: jpayne@69: // Error logging ------------------------------------------------------------------------------------- jpayne@69: jpayne@69: CMSAPI void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...); jpayne@69: jpayne@69: // Memory management ---------------------------------------------------------------------------------- jpayne@69: jpayne@69: CMSAPI void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size); jpayne@69: CMSAPI void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size); jpayne@69: CMSAPI void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size); jpayne@69: CMSAPI void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize); jpayne@69: CMSAPI void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr); jpayne@69: CMSAPI void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size); jpayne@69: jpayne@69: // I/O handler ---------------------------------------------------------------------------------- jpayne@69: jpayne@69: struct _cms_io_handler { jpayne@69: jpayne@69: void* stream; // Associated stream, which is implemented differently depending on media. jpayne@69: jpayne@69: cmsContext ContextID; jpayne@69: cmsUInt32Number UsedSpace; jpayne@69: cmsUInt32Number ReportedSize; jpayne@69: char PhysicalFile[cmsMAX_PATH]; jpayne@69: jpayne@69: cmsUInt32Number (* Read)(struct _cms_io_handler* iohandler, void *Buffer, jpayne@69: cmsUInt32Number size, jpayne@69: cmsUInt32Number count); jpayne@69: cmsBool (* Seek)(struct _cms_io_handler* iohandler, cmsUInt32Number offset); jpayne@69: cmsBool (* Close)(struct _cms_io_handler* iohandler); jpayne@69: cmsUInt32Number (* Tell)(struct _cms_io_handler* iohandler); jpayne@69: cmsBool (* Write)(struct _cms_io_handler* iohandler, cmsUInt32Number size, jpayne@69: const void* Buffer); jpayne@69: }; jpayne@69: jpayne@69: // Endianness adjust functions jpayne@69: CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word); jpayne@69: CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value); jpayne@69: CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord); jpayne@69: jpayne@69: // Helper IO functions jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Number(cmsIOHANDLER* io, cmsUInt16Number* n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array); jpayne@69: jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteUInt8Number(cmsIOHANDLER* io, cmsUInt8Number n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Number(cmsIOHANDLER* io, cmsUInt16Number n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWrite15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number n); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array); jpayne@69: jpayne@69: // ICC base tag jpayne@69: typedef struct { jpayne@69: cmsTagTypeSignature sig; jpayne@69: cmsInt8Number reserved[4]; jpayne@69: jpayne@69: } _cmsTagBase; jpayne@69: jpayne@69: // Type base helper functions jpayne@69: CMSAPI cmsTagTypeSignature CMSEXPORT _cmsReadTypeBase(cmsIOHANDLER* io); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteTypeBase(cmsIOHANDLER* io, cmsTagTypeSignature sig); jpayne@69: jpayne@69: // Alignment functions jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsReadAlignment(cmsIOHANDLER* io); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsWriteAlignment(cmsIOHANDLER* io); jpayne@69: jpayne@69: // To deal with text streams. 2K at most jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...); jpayne@69: jpayne@69: // Fixed point helper functions jpayne@69: CMSAPI cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8); jpayne@69: CMSAPI cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val); jpayne@69: jpayne@69: CMSAPI cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32); jpayne@69: CMSAPI cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v); jpayne@69: jpayne@69: // Date/time helper functions jpayne@69: CMSAPI void CMSEXPORT _cmsEncodeDateTimeNumber(cmsDateTimeNumber *Dest, const struct tm *Source); jpayne@69: CMSAPI void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest); jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Shared callbacks for user data jpayne@69: typedef void (* _cmsFreeUserDataFn)(cmsContext ContextID, void* Data); jpayne@69: typedef void* (* _cmsDupUserDataFn)(cmsContext ContextID, const void* Data); jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Plug-in foundation jpayne@69: #define cmsPluginMagicNumber 0x61637070 // 'acpp' jpayne@69: jpayne@69: #define cmsPluginMemHandlerSig 0x6D656D48 // 'memH' jpayne@69: #define cmsPluginInterpolationSig 0x696E7048 // 'inpH' jpayne@69: #define cmsPluginParametricCurveSig 0x70617248 // 'parH' jpayne@69: #define cmsPluginFormattersSig 0x66726D48 // 'frmH jpayne@69: #define cmsPluginTagTypeSig 0x74797048 // 'typH' jpayne@69: #define cmsPluginTagSig 0x74616748 // 'tagH' jpayne@69: #define cmsPluginRenderingIntentSig 0x696E7448 // 'intH' jpayne@69: #define cmsPluginMultiProcessElementSig 0x6D706548 // 'mpeH' jpayne@69: #define cmsPluginOptimizationSig 0x6F707448 // 'optH' jpayne@69: #define cmsPluginTransformSig 0x7A666D48 // 'xfmH' jpayne@69: #define cmsPluginMutexSig 0x6D747A48 // 'mtxH' jpayne@69: #define cmsPluginParalellizationSig 0x70726C48 // 'prlH jpayne@69: jpayne@69: typedef struct _cmsPluginBaseStruct { jpayne@69: jpayne@69: cmsUInt32Number Magic; // 'acpp' signature jpayne@69: cmsUInt32Number ExpectedVersion; // Expected version of LittleCMS jpayne@69: cmsUInt32Number Type; // Type of plug-in jpayne@69: struct _cmsPluginBaseStruct* Next; // For multiple plugin definition. NULL for end of list. jpayne@69: jpayne@69: } cmsPluginBase; jpayne@69: jpayne@69: // Maximum number of types in a plugin array jpayne@69: #define MAX_TYPES_IN_LCMS_PLUGIN 20 jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Memory handler. Each new plug-in type replaces current behaviour jpayne@69: jpayne@69: typedef void* (* _cmsMallocFnPtrType)(cmsContext ContextID, cmsUInt32Number size); jpayne@69: typedef void (* _cmsFreeFnPtrType)(cmsContext ContextID, void *Ptr); jpayne@69: typedef void* (* _cmsReallocFnPtrType)(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize); jpayne@69: jpayne@69: typedef void* (* _cmsMalloZerocFnPtrType)(cmsContext ContextID, cmsUInt32Number size); jpayne@69: typedef void* (* _cmsCallocFnPtrType)(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size); jpayne@69: typedef void* (* _cmsDupFnPtrType)(cmsContext ContextID, const void* Org, cmsUInt32Number size); jpayne@69: jpayne@69: typedef struct { jpayne@69: jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: // Required jpayne@69: _cmsMallocFnPtrType MallocPtr; jpayne@69: _cmsFreeFnPtrType FreePtr; jpayne@69: _cmsReallocFnPtrType ReallocPtr; jpayne@69: jpayne@69: // Optional jpayne@69: _cmsMalloZerocFnPtrType MallocZeroPtr; jpayne@69: _cmsCallocFnPtrType CallocPtr; jpayne@69: _cmsDupFnPtrType DupPtr; jpayne@69: jpayne@69: } cmsPluginMemHandler; jpayne@69: jpayne@69: jpayne@69: // ------------------------------------------------------------------------------------------------------------------ jpayne@69: jpayne@69: // Interpolation. 16 bits and floating point versions. jpayne@69: struct _cms_interp_struc; jpayne@69: jpayne@69: // Interpolation callbacks jpayne@69: jpayne@69: // 16 bits forward interpolation. This function performs precision-limited linear interpolation jpayne@69: // and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may jpayne@69: // choose to implement any other interpolation algorithm. jpayne@69: typedef void (* _cmsInterpFn16)(CMSREGISTER const cmsUInt16Number Input[], jpayne@69: CMSREGISTER cmsUInt16Number Output[], jpayne@69: CMSREGISTER const struct _cms_interp_struc* p); jpayne@69: jpayne@69: // Floating point forward interpolation. Full precision interpolation using floats. This is not a jpayne@69: // time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may jpayne@69: // choose to implement any other interpolation algorithm. jpayne@69: typedef void (* _cmsInterpFnFloat)(cmsFloat32Number const Input[], jpayne@69: cmsFloat32Number Output[], jpayne@69: const struct _cms_interp_struc* p); jpayne@69: jpayne@69: jpayne@69: jpayne@69: // This type holds a pointer to an interpolator that can be either 16 bits or float jpayne@69: typedef union { jpayne@69: _cmsInterpFn16 Lerp16; // Forward interpolation in 16 bits jpayne@69: _cmsInterpFnFloat LerpFloat; // Forward interpolation in floating point jpayne@69: } cmsInterpFunction; jpayne@69: jpayne@69: // Flags for interpolator selection jpayne@69: #define CMS_LERP_FLAGS_16BITS 0x0000 // The default jpayne@69: #define CMS_LERP_FLAGS_FLOAT 0x0001 // Requires different implementation jpayne@69: #define CMS_LERP_FLAGS_TRILINEAR 0x0100 // Hint only jpayne@69: jpayne@69: jpayne@69: #define MAX_INPUT_DIMENSIONS 15 jpayne@69: jpayne@69: typedef struct _cms_interp_struc { // Used on all interpolations. Supplied by lcms2 when calling the interpolation function jpayne@69: jpayne@69: cmsContext ContextID; // The calling thread jpayne@69: jpayne@69: cmsUInt32Number dwFlags; // Keep original flags jpayne@69: cmsUInt32Number nInputs; // != 1 only in 3D interpolation jpayne@69: cmsUInt32Number nOutputs; // != 1 only in 3D interpolation jpayne@69: jpayne@69: cmsUInt32Number nSamples[MAX_INPUT_DIMENSIONS]; // Valid on all kinds of tables jpayne@69: cmsUInt32Number Domain[MAX_INPUT_DIMENSIONS]; // Domain = nSamples - 1 jpayne@69: jpayne@69: cmsUInt32Number opta[MAX_INPUT_DIMENSIONS]; // Optimization for 3D CLUT. This is the number of nodes premultiplied for each jpayne@69: // dimension. For example, in 7 nodes, 7, 7^2 , 7^3, 7^4, etc. On non-regular jpayne@69: // Samplings may vary according of the number of nodes for each dimension. jpayne@69: jpayne@69: const void *Table; // Points to the actual interpolation table jpayne@69: cmsInterpFunction Interpolation; // Points to the function to do the interpolation jpayne@69: jpayne@69: } cmsInterpParams; jpayne@69: jpayne@69: // Interpolators factory jpayne@69: typedef cmsInterpFunction (* cmsInterpFnFactory)(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags); jpayne@69: jpayne@69: // The plug-in jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: // Points to a user-supplied function which implements the factory jpayne@69: cmsInterpFnFactory InterpolatorsFactory; jpayne@69: jpayne@69: } cmsPluginInterpolation; jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Parametric curves. A negative type means same function but analytically inverted. Max. number of params is 10 jpayne@69: jpayne@69: // Evaluator callback for user-supplied parametric curves. May implement more than one type jpayne@69: typedef cmsFloat64Number (* cmsParametricCurveEvaluator)(cmsInt32Number Type, const cmsFloat64Number Params[10], cmsFloat64Number R); jpayne@69: jpayne@69: // Plug-in may implement an arbitrary number of parametric curves jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: cmsUInt32Number nFunctions; // Number of supported functions jpayne@69: cmsUInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN]; // The identification types jpayne@69: cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN]; // Number of parameters for each function jpayne@69: jpayne@69: cmsParametricCurveEvaluator Evaluator; // The evaluator jpayne@69: jpayne@69: } cmsPluginParametricCurves; jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with jpayne@69: // cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across jpayne@69: // Formatter16 callback jpayne@69: jpayne@69: struct _cmstransform_struct; jpayne@69: jpayne@69: typedef cmsUInt8Number* (* cmsFormatter16)(CMSREGISTER struct _cmstransform_struct* CMMcargo, jpayne@69: CMSREGISTER cmsUInt16Number Values[], jpayne@69: CMSREGISTER cmsUInt8Number* Buffer, jpayne@69: CMSREGISTER cmsUInt32Number Stride); jpayne@69: jpayne@69: typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo, jpayne@69: cmsFloat32Number Values[], jpayne@69: cmsUInt8Number* Buffer, jpayne@69: cmsUInt32Number Stride); jpayne@69: jpayne@69: // This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number jpayne@69: typedef union { jpayne@69: cmsFormatter16 Fmt16; jpayne@69: cmsFormatterFloat FmtFloat; jpayne@69: jpayne@69: } cmsFormatter; jpayne@69: jpayne@69: #define CMS_PACK_FLAGS_16BITS 0x0000 jpayne@69: #define CMS_PACK_FLAGS_FLOAT 0x0001 jpayne@69: jpayne@69: typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection; jpayne@69: jpayne@69: typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8 jpayne@69: cmsFormatterDirection Dir, jpayne@69: cmsUInt32Number dwFlags); // precision jpayne@69: jpayne@69: // Plug-in may implement an arbitrary number of formatters jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: cmsFormatterFactory FormattersFactory; jpayne@69: jpayne@69: } cmsPluginFormatters; jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Tag type handler. Each type is free to return anything it wants, and it is up to the caller to jpayne@69: // know in advance what is the type contained in the tag. jpayne@69: typedef struct _cms_typehandler_struct { jpayne@69: jpayne@69: cmsTagTypeSignature Signature; // The signature of the type jpayne@69: jpayne@69: // Allocates and reads items jpayne@69: void * (* ReadPtr)(struct _cms_typehandler_struct* self, jpayne@69: cmsIOHANDLER* io, jpayne@69: cmsUInt32Number* nItems, jpayne@69: cmsUInt32Number SizeOfTag); jpayne@69: jpayne@69: // Writes n Items jpayne@69: cmsBool (* WritePtr)(struct _cms_typehandler_struct* self, jpayne@69: cmsIOHANDLER* io, jpayne@69: void* Ptr, jpayne@69: cmsUInt32Number nItems); jpayne@69: jpayne@69: // Duplicate an item or array of items jpayne@69: void* (* DupPtr)(struct _cms_typehandler_struct* self, jpayne@69: const void *Ptr, jpayne@69: cmsUInt32Number n); jpayne@69: jpayne@69: // Free all resources jpayne@69: void (* FreePtr)(struct _cms_typehandler_struct* self, jpayne@69: void *Ptr); jpayne@69: jpayne@69: // Additional parameters used by the calling thread jpayne@69: cmsContext ContextID; jpayne@69: cmsUInt32Number ICCVersion; jpayne@69: jpayne@69: } cmsTagTypeHandler; jpayne@69: jpayne@69: // Each plug-in implements a single type jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: cmsTagTypeHandler Handler; jpayne@69: jpayne@69: } cmsPluginTagType; jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // This is the tag plugin, which identifies tags. For writing, a pointer to function is provided. jpayne@69: // This function should return the desired type for this tag, given the version of profile jpayne@69: // and the data being serialized. jpayne@69: typedef struct { jpayne@69: jpayne@69: cmsUInt32Number ElemCount; // If this tag needs an array, how many elements should keep jpayne@69: jpayne@69: // For reading. jpayne@69: cmsUInt32Number nSupportedTypes; // In how many types this tag can come (MAX_TYPES_IN_LCMS_PLUGIN maximum) jpayne@69: cmsTagTypeSignature SupportedTypes[MAX_TYPES_IN_LCMS_PLUGIN]; jpayne@69: jpayne@69: // For writing jpayne@69: cmsTagTypeSignature (* DecideType)(cmsFloat64Number ICCVersion, const void *Data); jpayne@69: jpayne@69: } cmsTagDescriptor; jpayne@69: jpayne@69: // Plug-in implements a single tag jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: cmsTagSignature Signature; jpayne@69: cmsTagDescriptor Descriptor; jpayne@69: jpayne@69: } cmsPluginTag; jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Custom intents. This function should join all profiles specified in the array in jpayne@69: // a single LUT. Any custom intent in the chain redirects to custom function. If more than jpayne@69: // one custom intent is found, the one located first is invoked. Usually users should use only one jpayne@69: // custom intent, so mixing custom intents in same multiprofile transform is not supported. jpayne@69: jpayne@69: typedef cmsPipeline* (* cmsIntentFn)( cmsContext ContextID, jpayne@69: cmsUInt32Number nProfiles, jpayne@69: cmsUInt32Number Intents[], jpayne@69: cmsHPROFILE hProfiles[], jpayne@69: cmsBool BPC[], jpayne@69: cmsFloat64Number AdaptationStates[], jpayne@69: cmsUInt32Number dwFlags); jpayne@69: jpayne@69: jpayne@69: // Each plug-in defines a single intent number. jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: cmsUInt32Number Intent; jpayne@69: cmsIntentFn Link; jpayne@69: char Description[256]; jpayne@69: jpayne@69: } cmsPluginRenderingIntent; jpayne@69: jpayne@69: jpayne@69: // The default ICC intents (perceptual, saturation, rel.col and abs.col) jpayne@69: CMSAPI cmsPipeline* CMSEXPORT _cmsDefaultICCintents(cmsContext ContextID, jpayne@69: cmsUInt32Number nProfiles, jpayne@69: cmsUInt32Number Intents[], jpayne@69: cmsHPROFILE hProfiles[], jpayne@69: cmsBool BPC[], jpayne@69: cmsFloat64Number AdaptationStates[], jpayne@69: cmsUInt32Number dwFlags); jpayne@69: jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: jpayne@69: // Pipelines, Multi Process Elements. jpayne@69: jpayne@69: typedef void (* _cmsStageEvalFn) (const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage* mpe); jpayne@69: typedef void*(* _cmsStageDupElemFn) (cmsStage* mpe); jpayne@69: typedef void (* _cmsStageFreeElemFn) (cmsStage* mpe); jpayne@69: jpayne@69: jpayne@69: // This function allocates a generic MPE jpayne@69: CMSAPI cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID, jpayne@69: cmsStageSignature Type, jpayne@69: cmsUInt32Number InputChannels, jpayne@69: cmsUInt32Number OutputChannels, jpayne@69: _cmsStageEvalFn EvalPtr, // Points to fn that evaluates the element (always in floating point) jpayne@69: _cmsStageDupElemFn DupElemPtr, // Points to a fn that duplicates the stage jpayne@69: _cmsStageFreeElemFn FreePtr, // Points to a fn that sets the element free jpayne@69: void* Data); // A generic pointer to whatever memory needed by the element jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: cmsTagTypeHandler Handler; jpayne@69: jpayne@69: } cmsPluginMultiProcessElement; jpayne@69: jpayne@69: jpayne@69: // Data kept in "Element" member of cmsStage jpayne@69: jpayne@69: // Curves jpayne@69: typedef struct { jpayne@69: cmsUInt32Number nCurves; jpayne@69: cmsToneCurve** TheCurves; jpayne@69: jpayne@69: } _cmsStageToneCurvesData; jpayne@69: jpayne@69: // Matrix jpayne@69: typedef struct { jpayne@69: cmsFloat64Number* Double; // floating point for the matrix jpayne@69: cmsFloat64Number* Offset; // The offset jpayne@69: jpayne@69: } _cmsStageMatrixData; jpayne@69: jpayne@69: // CLUT jpayne@69: typedef struct { jpayne@69: jpayne@69: union { // Can have only one of both representations at same time jpayne@69: cmsUInt16Number* T; // Points to the table 16 bits table jpayne@69: cmsFloat32Number* TFloat; // Points to the cmsFloat32Number table jpayne@69: jpayne@69: } Tab; jpayne@69: jpayne@69: cmsInterpParams* Params; jpayne@69: cmsUInt32Number nEntries; jpayne@69: cmsBool HasFloatValues; jpayne@69: jpayne@69: } _cmsStageCLutData; jpayne@69: jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: // Optimization. Using this plug-in, additional optimization strategies may be implemented. jpayne@69: // The function should return TRUE if any optimization is done on the LUT, this terminates jpayne@69: // the optimization search. Or FALSE if it is unable to optimize and want to give a chance jpayne@69: // to the rest of optimizers. jpayne@69: jpayne@69: typedef cmsBool (* _cmsOPToptimizeFn)(cmsPipeline** Lut, jpayne@69: cmsUInt32Number Intent, jpayne@69: cmsUInt32Number* InputFormat, jpayne@69: cmsUInt32Number* OutputFormat, jpayne@69: cmsUInt32Number* dwFlags); jpayne@69: jpayne@69: // Pipeline Evaluator (in 16 bits) jpayne@69: typedef void (* _cmsPipelineEval16Fn)(CMSREGISTER const cmsUInt16Number In[], jpayne@69: CMSREGISTER cmsUInt16Number Out[], jpayne@69: const void* Data); jpayne@69: jpayne@69: // Pipeline Evaluator (in floating point) jpayne@69: typedef void (* _cmsPipelineEvalFloatFn)(const cmsFloat32Number In[], jpayne@69: cmsFloat32Number Out[], jpayne@69: const void* Data); jpayne@69: jpayne@69: jpayne@69: // 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: // duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality. jpayne@69: jpayne@69: CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut, jpayne@69: _cmsPipelineEval16Fn Eval16, jpayne@69: void* PrivateData, jpayne@69: _cmsFreeUserDataFn FreePrivateDataFn, jpayne@69: _cmsDupUserDataFn DupPrivateDataFn); jpayne@69: jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: // Optimize entry point jpayne@69: _cmsOPToptimizeFn OptimizePtr; jpayne@69: jpayne@69: } cmsPluginOptimization; jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: // Full xform jpayne@69: jpayne@69: typedef struct { jpayne@69: cmsUInt32Number BytesPerLineIn; jpayne@69: cmsUInt32Number BytesPerLineOut; jpayne@69: cmsUInt32Number BytesPerPlaneIn; jpayne@69: cmsUInt32Number BytesPerPlaneOut; jpayne@69: jpayne@69: } cmsStride; jpayne@69: jpayne@69: typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo, // Legacy function, handles just ONE scanline. jpayne@69: const void* InputBuffer, jpayne@69: void* OutputBuffer, jpayne@69: cmsUInt32Number Size, jpayne@69: cmsUInt32Number Stride); // Stride in bytes to the next plane in planar formats jpayne@69: jpayne@69: jpayne@69: typedef void (*_cmsTransform2Fn)(struct _cmstransform_struct *CMMcargo, jpayne@69: const void* InputBuffer, jpayne@69: void* OutputBuffer, jpayne@69: cmsUInt32Number PixelsPerLine, jpayne@69: cmsUInt32Number LineCount, jpayne@69: const cmsStride* Stride); jpayne@69: jpayne@69: typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform, jpayne@69: void** UserData, jpayne@69: _cmsFreeUserDataFn* FreePrivateDataFn, jpayne@69: cmsPipeline** Lut, jpayne@69: cmsUInt32Number* InputFormat, jpayne@69: cmsUInt32Number* OutputFormat, jpayne@69: cmsUInt32Number* dwFlags); jpayne@69: jpayne@69: typedef cmsBool (* _cmsTransform2Factory)(_cmsTransform2Fn* xform, jpayne@69: void** UserData, jpayne@69: _cmsFreeUserDataFn* FreePrivateDataFn, jpayne@69: cmsPipeline** Lut, jpayne@69: cmsUInt32Number* InputFormat, jpayne@69: cmsUInt32Number* OutputFormat, jpayne@69: cmsUInt32Number* dwFlags); jpayne@69: jpayne@69: jpayne@69: // Retrieve user data as specified by the factory jpayne@69: CMSAPI void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn); jpayne@69: CMSAPI void * CMSEXPORT _cmsGetTransformUserData(struct _cmstransform_struct *CMMcargo); jpayne@69: jpayne@69: jpayne@69: // Retrieve formatters jpayne@69: CMSAPI void CMSEXPORT _cmsGetTransformFormatters16 (struct _cmstransform_struct *CMMcargo, cmsFormatter16* FromInput, cmsFormatter16* ToOutput); jpayne@69: CMSAPI void CMSEXPORT _cmsGetTransformFormattersFloat(struct _cmstransform_struct *CMMcargo, cmsFormatterFloat* FromInput, cmsFormatterFloat* ToOutput); jpayne@69: jpayne@69: // Retrieve original flags jpayne@69: CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformFlags(struct _cmstransform_struct* CMMcargo); jpayne@69: jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: // Transform entry point jpayne@69: union { jpayne@69: _cmsTransformFactory legacy_xform; jpayne@69: _cmsTransform2Factory xform; jpayne@69: } factories; jpayne@69: jpayne@69: } cmsPluginTransform; jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: // Mutex jpayne@69: jpayne@69: typedef void* (* _cmsCreateMutexFnPtrType)(cmsContext ContextID); jpayne@69: typedef void (* _cmsDestroyMutexFnPtrType)(cmsContext ContextID, void* mtx); jpayne@69: typedef cmsBool (* _cmsLockMutexFnPtrType)(cmsContext ContextID, void* mtx); jpayne@69: typedef void (* _cmsUnlockMutexFnPtrType)(cmsContext ContextID, void* mtx); jpayne@69: jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: _cmsCreateMutexFnPtrType CreateMutexPtr; jpayne@69: _cmsDestroyMutexFnPtrType DestroyMutexPtr; jpayne@69: _cmsLockMutexFnPtrType LockMutexPtr; jpayne@69: _cmsUnlockMutexFnPtrType UnlockMutexPtr; jpayne@69: jpayne@69: } cmsPluginMutex; jpayne@69: jpayne@69: CMSAPI void* CMSEXPORT _cmsCreateMutex(cmsContext ContextID); jpayne@69: CMSAPI void CMSEXPORT _cmsDestroyMutex(cmsContext ContextID, void* mtx); jpayne@69: CMSAPI cmsBool CMSEXPORT _cmsLockMutex(cmsContext ContextID, void* mtx); jpayne@69: CMSAPI void CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx); jpayne@69: jpayne@69: //---------------------------------------------------------------------------------------------------------- jpayne@69: // Parallelization jpayne@69: jpayne@69: CMSAPI _cmsTransform2Fn CMSEXPORT _cmsGetTransformWorker(struct _cmstransform_struct* CMMcargo); jpayne@69: CMSAPI cmsInt32Number CMSEXPORT _cmsGetTransformMaxWorkers(struct _cmstransform_struct* CMMcargo); jpayne@69: CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformWorkerFlags(struct _cmstransform_struct* CMMcargo); jpayne@69: jpayne@69: // Let's plug-in to guess the best number of workers jpayne@69: #define CMS_GUESS_MAX_WORKERS -1 jpayne@69: jpayne@69: typedef struct { jpayne@69: cmsPluginBase base; jpayne@69: jpayne@69: cmsInt32Number MaxWorkers; // Number of starts to do as maximum jpayne@69: cmsUInt32Number WorkerFlags; // Reserved jpayne@69: _cmsTransform2Fn SchedulerFn; // callback to setup functions jpayne@69: jpayne@69: } cmsPluginParalellization; jpayne@69: jpayne@69: jpayne@69: #ifndef CMS_USE_CPP_API jpayne@69: # ifdef __cplusplus jpayne@69: } jpayne@69: # endif jpayne@69: #endif jpayne@69: jpayne@69: #define _lcms_plugin_H jpayne@69: #endif