Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-27 09:55:30

0001 //---------------------------------------------------------------------------------
0002 //
0003 //  Little Color Management System
0004 //  Copyright (c) 1998-2023 Marti Maria Saguer
0005 //
0006 // Permission is hereby granted, free of charge, to any person obtaining
0007 // a copy of this software and associated documentation files (the "Software"),
0008 // to deal in the Software without restriction, including without limitation
0009 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
0010 // and/or sell copies of the Software, and to permit persons to whom the Software
0011 // is furnished to do so, subject to the following conditions:
0012 //
0013 // The above copyright notice and this permission notice shall be included in
0014 // all copies or substantial portions of the Software.
0015 //
0016 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0017 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
0018 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0019 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
0020 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
0021 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
0022 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
0023 //
0024 //---------------------------------------------------------------------------------
0025 //
0026 // This is the plug-in header file. Normal LittleCMS clients should not use it.
0027 // It is provided for plug-in writers that may want to access the support
0028 // functions to do low level operations. All plug-in related structures
0029 // are defined here. Including this file forces to include the standard API too.
0030 
0031 #ifndef _lcms_plugin_H
0032 
0033 // Deal with Microsoft's attempt at deprecating C standard runtime functions
0034 #ifdef _MSC_VER
0035 #    if (_MSC_VER >= 1400)
0036 #      ifndef _CRT_SECURE_NO_DEPRECATE
0037 #        define _CRT_SECURE_NO_DEPRECATE
0038 #      endif
0039 #      ifndef _CRT_SECURE_NO_WARNINGS
0040 #        define _CRT_SECURE_NO_WARNINGS
0041 #      endif
0042 #    endif
0043 #endif
0044 
0045 #ifndef _lcms2_H
0046 #include "lcms2.h"
0047 #endif
0048 
0049 // We need some standard C functions.
0050 #include <stdlib.h>
0051 #include <math.h>
0052 #include <stdarg.h>
0053 #include <memory.h>
0054 #include <string.h>
0055 
0056 
0057 #ifndef CMS_USE_CPP_API
0058 #   ifdef __cplusplus
0059 extern "C" {
0060 #   endif
0061 #endif
0062 
0063 // Vector & Matrix operations -----------------------------------------------------------------------
0064 
0065 // Axis of the matrix/array. No specific meaning at all.
0066 #define VX      0
0067 #define VY      1
0068 #define VZ      2
0069 
0070 // Vectors
0071 typedef struct {
0072     cmsFloat64Number n[3];
0073 
0074     } cmsVEC3;
0075 
0076 // 3x3 Matrix
0077 typedef struct {
0078     cmsVEC3 v[3];
0079 
0080     } cmsMAT3;
0081 
0082 CMSAPI void               CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
0083 CMSAPI void               CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b);
0084 CMSAPI void               CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v);
0085 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v);
0086 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3length(const cmsVEC3* a);
0087 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b);
0088 
0089 CMSAPI void               CMSEXPORT _cmsMAT3identity(cmsMAT3* a);
0090 CMSAPI cmsBool            CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a);
0091 CMSAPI void               CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b);
0092 CMSAPI cmsBool            CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b);
0093 CMSAPI cmsBool            CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b);
0094 CMSAPI void               CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
0095 
0096 
0097 // MD5 low level  -------------------------------------------------------------------------------------
0098 
0099 CMSAPI cmsHANDLE          CMSEXPORT cmsMD5alloc(cmsContext ContextID);
0100 CMSAPI void               CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len);
0101 CMSAPI void               CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle);
0102 
0103 // Error logging  -------------------------------------------------------------------------------------
0104 
0105 CMSAPI void               CMSEXPORT  cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
0106 
0107 // Memory management ----------------------------------------------------------------------------------
0108 
0109 CMSAPI void*              CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size);
0110 CMSAPI void*              CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size);
0111 CMSAPI void*              CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
0112 CMSAPI void*              CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
0113 CMSAPI void               CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr);
0114 CMSAPI void*              CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size);
0115 
0116 // I/O handler ----------------------------------------------------------------------------------
0117 
0118 struct _cms_io_handler {
0119 
0120     void* stream;   // Associated stream, which is implemented differently depending on media.
0121 
0122     cmsContext        ContextID;
0123     cmsUInt32Number   UsedSpace;
0124     cmsUInt32Number   ReportedSize;
0125     char              PhysicalFile[cmsMAX_PATH];
0126 
0127     cmsUInt32Number   (* Read)(struct _cms_io_handler* iohandler, void *Buffer,
0128                                                                   cmsUInt32Number size,
0129                                                                   cmsUInt32Number count);
0130     cmsBool           (* Seek)(struct _cms_io_handler* iohandler, cmsUInt32Number offset);
0131     cmsBool           (* Close)(struct _cms_io_handler* iohandler);
0132     cmsUInt32Number   (* Tell)(struct _cms_io_handler* iohandler);
0133     cmsBool           (* Write)(struct _cms_io_handler* iohandler, cmsUInt32Number size,
0134                                                                    const void* Buffer);
0135 };
0136 
0137 // Endianness adjust functions
0138 CMSAPI cmsUInt16Number   CMSEXPORT  _cmsAdjustEndianess16(cmsUInt16Number Word);
0139 CMSAPI cmsUInt32Number   CMSEXPORT  _cmsAdjustEndianess32(cmsUInt32Number Value);
0140 CMSAPI void              CMSEXPORT  _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
0141 
0142 // Helper IO functions
0143 CMSAPI cmsBool           CMSEXPORT  _cmsReadUInt8Number(cmsIOHANDLER* io,  cmsUInt8Number* n);
0144 CMSAPI cmsBool           CMSEXPORT  _cmsReadUInt16Number(cmsIOHANDLER* io, cmsUInt16Number* n);
0145 CMSAPI cmsBool           CMSEXPORT  _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n);
0146 CMSAPI cmsBool           CMSEXPORT  _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n);
0147 CMSAPI cmsBool           CMSEXPORT  _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
0148 CMSAPI cmsBool           CMSEXPORT  _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n);
0149 CMSAPI cmsBool           CMSEXPORT  _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ);
0150 CMSAPI cmsBool           CMSEXPORT  _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array);
0151 
0152 CMSAPI cmsBool           CMSEXPORT  _cmsWriteUInt8Number(cmsIOHANDLER* io, cmsUInt8Number n);
0153 CMSAPI cmsBool           CMSEXPORT  _cmsWriteUInt16Number(cmsIOHANDLER* io, cmsUInt16Number n);
0154 CMSAPI cmsBool           CMSEXPORT  _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n);
0155 CMSAPI cmsBool           CMSEXPORT  _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n);
0156 CMSAPI cmsBool           CMSEXPORT  _cmsWriteUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
0157 CMSAPI cmsBool           CMSEXPORT  _cmsWrite15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number n);
0158 CMSAPI cmsBool           CMSEXPORT  _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ);
0159 CMSAPI cmsBool           CMSEXPORT  _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array);
0160 
0161 // ICC base tag
0162 typedef struct {
0163     cmsTagTypeSignature  sig;
0164     cmsInt8Number        reserved[4];
0165 
0166 } _cmsTagBase;
0167 
0168 // Type base helper functions
0169 CMSAPI cmsTagTypeSignature  CMSEXPORT _cmsReadTypeBase(cmsIOHANDLER* io);
0170 CMSAPI cmsBool              CMSEXPORT _cmsWriteTypeBase(cmsIOHANDLER* io, cmsTagTypeSignature sig);
0171 
0172 // Alignment functions
0173 CMSAPI cmsBool             CMSEXPORT _cmsReadAlignment(cmsIOHANDLER* io);
0174 CMSAPI cmsBool             CMSEXPORT _cmsWriteAlignment(cmsIOHANDLER* io);
0175 
0176 // To deal with text streams. 2K at most
0177 CMSAPI cmsBool             CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...);
0178 
0179 // Fixed point helper functions
0180 CMSAPI cmsFloat64Number    CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8);
0181 CMSAPI cmsUInt16Number     CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val);
0182 
0183 CMSAPI cmsFloat64Number    CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32);
0184 CMSAPI cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v);
0185 
0186 // Date/time helper functions
0187 CMSAPI void                CMSEXPORT _cmsEncodeDateTimeNumber(cmsDateTimeNumber *Dest, const struct tm *Source);
0188 CMSAPI void                CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest);
0189 
0190 //----------------------------------------------------------------------------------------------------------
0191 
0192 // Shared callbacks for user data
0193 typedef void     (* _cmsFreeUserDataFn)(cmsContext ContextID, void* Data);
0194 typedef void*    (* _cmsDupUserDataFn)(cmsContext ContextID, const void* Data);
0195 
0196 //----------------------------------------------------------------------------------------------------------
0197 
0198 // Plug-in foundation
0199 #define cmsPluginMagicNumber                 0x61637070     // 'acpp'
0200 
0201 #define cmsPluginMemHandlerSig               0x6D656D48     // 'memH'
0202 #define cmsPluginInterpolationSig            0x696E7048     // 'inpH'
0203 #define cmsPluginParametricCurveSig          0x70617248     // 'parH'
0204 #define cmsPluginFormattersSig               0x66726D48     // 'frmH
0205 #define cmsPluginTagTypeSig                  0x74797048     // 'typH'
0206 #define cmsPluginTagSig                      0x74616748     // 'tagH'
0207 #define cmsPluginRenderingIntentSig          0x696E7448     // 'intH'
0208 #define cmsPluginMultiProcessElementSig      0x6D706548     // 'mpeH'
0209 #define cmsPluginOptimizationSig             0x6F707448     // 'optH'
0210 #define cmsPluginTransformSig                0x7A666D48     // 'xfmH'
0211 #define cmsPluginMutexSig                    0x6D747A48     // 'mtxH'
0212 #define cmsPluginParalellizationSig          0x70726C48     // 'prlH
0213 
0214 typedef struct _cmsPluginBaseStruct {
0215 
0216         cmsUInt32Number                Magic;               // 'acpp' signature
0217         cmsUInt32Number                ExpectedVersion;     // Expected version of LittleCMS
0218         cmsUInt32Number                Type;                // Type of plug-in
0219         struct _cmsPluginBaseStruct*   Next;                // For multiple plugin definition. NULL for end of list.
0220 
0221 } cmsPluginBase;
0222 
0223 // Maximum number of types in a plugin array
0224 #define MAX_TYPES_IN_LCMS_PLUGIN    20
0225 
0226 //----------------------------------------------------------------------------------------------------------
0227 
0228 // Memory handler. Each new plug-in type replaces current behaviour
0229 
0230 typedef void* (* _cmsMallocFnPtrType)(cmsContext ContextID, cmsUInt32Number size); 
0231 typedef void  (* _cmsFreeFnPtrType)(cmsContext ContextID, void *Ptr);
0232 typedef void* (* _cmsReallocFnPtrType)(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
0233 
0234 typedef void* (* _cmsMalloZerocFnPtrType)(cmsContext ContextID, cmsUInt32Number size); 
0235 typedef void* (* _cmsCallocFnPtrType)(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
0236 typedef void* (* _cmsDupFnPtrType)(cmsContext ContextID, const void* Org, cmsUInt32Number size);
0237 
0238 typedef struct {
0239 
0240         cmsPluginBase base;
0241 
0242         // Required
0243         _cmsMallocFnPtrType  MallocPtr;
0244         _cmsFreeFnPtrType    FreePtr;
0245         _cmsReallocFnPtrType ReallocPtr;
0246 
0247         // Optional
0248        _cmsMalloZerocFnPtrType MallocZeroPtr;
0249        _cmsCallocFnPtrType     CallocPtr;
0250        _cmsDupFnPtrType        DupPtr;
0251 
0252 } cmsPluginMemHandler;
0253 
0254 
0255 // ------------------------------------------------------------------------------------------------------------------
0256 
0257 // Interpolation. 16 bits and floating point versions.
0258 struct _cms_interp_struc;
0259 
0260 // Interpolation callbacks
0261 
0262 // 16 bits forward interpolation. This function performs precision-limited linear interpolation
0263 // and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
0264 // choose to implement any other interpolation algorithm.
0265 typedef void (* _cmsInterpFn16)(CMSREGISTER const cmsUInt16Number Input[],
0266                                 CMSREGISTER cmsUInt16Number Output[],
0267                                 CMSREGISTER const struct _cms_interp_struc* p);
0268 
0269 // Floating point forward interpolation. Full precision interpolation using floats. This is not a
0270 // time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
0271 // choose to implement any other interpolation algorithm.
0272 typedef void (* _cmsInterpFnFloat)(cmsFloat32Number const Input[],
0273                                    cmsFloat32Number Output[],
0274                                    const struct _cms_interp_struc* p);
0275 
0276 
0277 
0278 // This type holds a pointer to an interpolator that can be either 16 bits or float
0279 typedef union {
0280     _cmsInterpFn16       Lerp16;            // Forward interpolation in 16 bits
0281     _cmsInterpFnFloat    LerpFloat;         // Forward interpolation in floating point
0282 } cmsInterpFunction;
0283 
0284 // Flags for interpolator selection
0285 #define CMS_LERP_FLAGS_16BITS             0x0000        // The default
0286 #define CMS_LERP_FLAGS_FLOAT              0x0001        // Requires different implementation
0287 #define CMS_LERP_FLAGS_TRILINEAR          0x0100        // Hint only
0288 
0289 
0290 #define MAX_INPUT_DIMENSIONS 15
0291 
0292 typedef struct _cms_interp_struc {  // Used on all interpolations. Supplied by lcms2 when calling the interpolation function
0293 
0294     cmsContext ContextID;     // The calling thread
0295 
0296     cmsUInt32Number dwFlags;  // Keep original flags
0297     cmsUInt32Number nInputs;  // != 1 only in 3D interpolation
0298     cmsUInt32Number nOutputs; // != 1 only in 3D interpolation
0299 
0300     cmsUInt32Number nSamples[MAX_INPUT_DIMENSIONS];  // Valid on all kinds of tables
0301     cmsUInt32Number Domain[MAX_INPUT_DIMENSIONS];    // Domain = nSamples - 1
0302 
0303     cmsUInt32Number opta[MAX_INPUT_DIMENSIONS];     // Optimization for 3D CLUT. This is the number of nodes premultiplied for each
0304                                                     // dimension. For example, in 7 nodes, 7, 7^2 , 7^3, 7^4, etc. On non-regular
0305                                                     // Samplings may vary according of the number of nodes for each dimension.
0306 
0307     const void *Table;                // Points to the actual interpolation table
0308     cmsInterpFunction Interpolation;  // Points to the function to do the interpolation
0309 
0310  } cmsInterpParams;
0311 
0312 // Interpolators factory
0313 typedef cmsInterpFunction (* cmsInterpFnFactory)(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
0314 
0315 // The plug-in
0316 typedef struct {
0317     cmsPluginBase base;
0318 
0319     // Points to a user-supplied function which implements the factory
0320     cmsInterpFnFactory InterpolatorsFactory;
0321 
0322 } cmsPluginInterpolation;
0323 
0324 //----------------------------------------------------------------------------------------------------------
0325 
0326 // Parametric curves. A negative type means same function but analytically inverted. Max. number of params is 10
0327 
0328 // Evaluator callback for user-supplied parametric curves. May implement more than one type
0329 typedef  cmsFloat64Number (* cmsParametricCurveEvaluator)(cmsInt32Number Type, const cmsFloat64Number Params[10], cmsFloat64Number R);
0330 
0331 // Plug-in may implement an arbitrary number of parametric curves
0332 typedef struct {
0333     cmsPluginBase base;
0334 
0335     cmsUInt32Number nFunctions;                                     // Number of supported functions
0336     cmsUInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN];        // The identification types
0337     cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN];       // Number of parameters for each function
0338 
0339     cmsParametricCurveEvaluator    Evaluator;                       // The evaluator
0340 
0341 } cmsPluginParametricCurves;
0342 //----------------------------------------------------------------------------------------------------------
0343 
0344 // Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with
0345 // cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across
0346 // Formatter16 callback
0347 
0348 struct _cmstransform_struct;
0349 
0350 typedef cmsUInt8Number* (* cmsFormatter16)(CMSREGISTER struct _cmstransform_struct* CMMcargo,
0351                                            CMSREGISTER cmsUInt16Number Values[],
0352                                            CMSREGISTER cmsUInt8Number* Buffer,
0353                                            CMSREGISTER cmsUInt32Number Stride);
0354 
0355 typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
0356                                               cmsFloat32Number Values[],
0357                                               cmsUInt8Number*  Buffer,
0358                                               cmsUInt32Number  Stride);
0359 
0360 // This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number
0361 typedef union {
0362     cmsFormatter16    Fmt16;
0363     cmsFormatterFloat FmtFloat;
0364 
0365 } cmsFormatter;
0366 
0367 #define CMS_PACK_FLAGS_16BITS       0x0000
0368 #define CMS_PACK_FLAGS_FLOAT        0x0001
0369 
0370 typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection;
0371 
0372 typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type,           // Specific type, i.e. TYPE_RGB_8
0373                                              cmsFormatterDirection Dir,
0374                                              cmsUInt32Number dwFlags);      // precision
0375 
0376 // Plug-in may implement an arbitrary number of formatters
0377 typedef struct {
0378     cmsPluginBase          base;
0379     cmsFormatterFactory    FormattersFactory;
0380 
0381 } cmsPluginFormatters;
0382 
0383 //----------------------------------------------------------------------------------------------------------
0384 
0385 // Tag type handler. Each type is free to return anything it wants, and it is up to the caller to
0386 // know in advance what is the type contained in the tag.
0387 typedef struct _cms_typehandler_struct {
0388 
0389         cmsTagTypeSignature Signature;     // The signature of the type
0390 
0391         // Allocates and reads items
0392         void *   (* ReadPtr)(struct _cms_typehandler_struct* self,
0393                              cmsIOHANDLER*      io,
0394                              cmsUInt32Number*   nItems,
0395                              cmsUInt32Number    SizeOfTag);
0396 
0397         // Writes n Items
0398         cmsBool  (* WritePtr)(struct _cms_typehandler_struct* self,
0399                               cmsIOHANDLER*     io,
0400                               void*             Ptr,
0401                               cmsUInt32Number   nItems);
0402 
0403         // Duplicate an item or array of items
0404         void*   (* DupPtr)(struct _cms_typehandler_struct* self,
0405                            const void *Ptr,
0406                            cmsUInt32Number n);
0407 
0408         // Free all resources
0409         void    (* FreePtr)(struct _cms_typehandler_struct* self,
0410                             void *Ptr);
0411 
0412         // Additional parameters used by the calling thread
0413         cmsContext       ContextID;
0414         cmsUInt32Number  ICCVersion;
0415 
0416 } cmsTagTypeHandler;
0417 
0418 // Each plug-in implements a single type
0419 typedef struct {
0420         cmsPluginBase      base;
0421         cmsTagTypeHandler  Handler;
0422 
0423 } cmsPluginTagType;
0424 
0425 //----------------------------------------------------------------------------------------------------------
0426 
0427 // This is the tag plugin, which identifies tags. For writing, a pointer to function is provided.
0428 // This function should return the desired type for this tag, given the version of profile
0429 // and the data being serialized.
0430 typedef struct {
0431 
0432     cmsUInt32Number     ElemCount;          // If this tag needs an array, how many elements should keep
0433 
0434     // For reading.
0435     cmsUInt32Number     nSupportedTypes;    // In how many types this tag can come (MAX_TYPES_IN_LCMS_PLUGIN maximum)
0436     cmsTagTypeSignature SupportedTypes[MAX_TYPES_IN_LCMS_PLUGIN];
0437 
0438     // For writing
0439     cmsTagTypeSignature (* DecideType)(cmsFloat64Number ICCVersion, const void *Data);
0440 
0441 } cmsTagDescriptor;
0442 
0443 // Plug-in implements a single tag
0444 typedef struct {
0445     cmsPluginBase    base;
0446 
0447     cmsTagSignature  Signature;
0448     cmsTagDescriptor Descriptor;
0449 
0450 } cmsPluginTag;
0451 
0452 //----------------------------------------------------------------------------------------------------------
0453 
0454 // Custom intents. This function should join all profiles specified in the array in
0455 // a single LUT. Any custom intent in the chain redirects to custom function. If more than
0456 // one custom intent is found, the one located first is invoked. Usually users should use only one
0457 // custom intent, so mixing custom intents in same multiprofile transform is not supported.
0458 
0459 typedef cmsPipeline* (* cmsIntentFn)( cmsContext       ContextID,
0460                                       cmsUInt32Number  nProfiles,
0461                                       cmsUInt32Number  Intents[],
0462                                       cmsHPROFILE      hProfiles[],
0463                                       cmsBool          BPC[],
0464                                       cmsFloat64Number AdaptationStates[],
0465                                       cmsUInt32Number  dwFlags);
0466 
0467 
0468 // Each plug-in defines a single intent number.
0469 typedef struct {
0470     cmsPluginBase     base;
0471     cmsUInt32Number   Intent;
0472     cmsIntentFn       Link;
0473     char              Description[256];
0474 
0475 } cmsPluginRenderingIntent;
0476 
0477 
0478 // The default ICC intents (perceptual, saturation, rel.col and abs.col)
0479 CMSAPI cmsPipeline*  CMSEXPORT _cmsDefaultICCintents(cmsContext       ContextID,
0480                                                      cmsUInt32Number  nProfiles,
0481                                                      cmsUInt32Number  Intents[],
0482                                                      cmsHPROFILE      hProfiles[],
0483                                                      cmsBool          BPC[],
0484                                                      cmsFloat64Number AdaptationStates[],
0485                                                      cmsUInt32Number  dwFlags);
0486 
0487 
0488 //----------------------------------------------------------------------------------------------------------
0489 
0490 // Pipelines, Multi Process Elements.
0491 
0492 typedef void (* _cmsStageEvalFn)     (const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage* mpe);
0493 typedef void*(* _cmsStageDupElemFn)  (cmsStage* mpe);
0494 typedef void (* _cmsStageFreeElemFn) (cmsStage* mpe);
0495 
0496 
0497 // This function allocates a generic MPE
0498 CMSAPI cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID,
0499                                 cmsStageSignature     Type,
0500                                 cmsUInt32Number       InputChannels,
0501                                 cmsUInt32Number       OutputChannels,
0502                                 _cmsStageEvalFn       EvalPtr,            // Points to fn that evaluates the element (always in floating point)
0503                                 _cmsStageDupElemFn    DupElemPtr,         // Points to a fn that duplicates the stage
0504                                 _cmsStageFreeElemFn   FreePtr,            // Points to a fn that sets the element free
0505                                 void*                 Data);              // A generic pointer to whatever memory needed by the element
0506 typedef struct {
0507       cmsPluginBase     base;
0508       cmsTagTypeHandler Handler;
0509 
0510 }  cmsPluginMultiProcessElement;
0511 
0512 
0513 // Data kept in "Element" member of cmsStage
0514 
0515 // Curves
0516 typedef struct {
0517     cmsUInt32Number nCurves;
0518     cmsToneCurve**  TheCurves;
0519 
0520 } _cmsStageToneCurvesData;
0521 
0522 // Matrix
0523 typedef struct {
0524     cmsFloat64Number*  Double;          // floating point for the matrix
0525     cmsFloat64Number*  Offset;          // The offset
0526 
0527 } _cmsStageMatrixData;
0528 
0529 // CLUT
0530 typedef struct {
0531 
0532     union {                       // Can have only one of both representations at same time
0533         cmsUInt16Number*  T;      // Points to the table 16 bits table
0534         cmsFloat32Number* TFloat; // Points to the cmsFloat32Number table
0535 
0536     } Tab;
0537 
0538     cmsInterpParams* Params;
0539     cmsUInt32Number  nEntries;
0540     cmsBool          HasFloatValues;
0541 
0542 } _cmsStageCLutData;
0543 
0544 
0545 //----------------------------------------------------------------------------------------------------------
0546 // Optimization. Using this plug-in, additional optimization strategies may be implemented.
0547 // The function should return TRUE if any optimization is done on the LUT, this terminates
0548 // the optimization  search. Or FALSE if it is unable to optimize and want to give a chance
0549 // to the rest of optimizers.
0550 
0551 typedef cmsBool  (* _cmsOPToptimizeFn)(cmsPipeline** Lut,
0552                                        cmsUInt32Number  Intent,
0553                                        cmsUInt32Number* InputFormat,
0554                                        cmsUInt32Number* OutputFormat,
0555                                        cmsUInt32Number* dwFlags);
0556 
0557 // Pipeline Evaluator (in 16 bits)
0558 typedef void (* _cmsPipelineEval16Fn)(CMSREGISTER const cmsUInt16Number In[],
0559                                      CMSREGISTER cmsUInt16Number Out[],
0560                                      const void* Data);
0561 
0562 // Pipeline Evaluator (in floating point)
0563 typedef void (* _cmsPipelineEvalFloatFn)(const cmsFloat32Number In[],
0564                                          cmsFloat32Number Out[],
0565                                          const void* Data);
0566 
0567 
0568 // This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
0569 // duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
0570 
0571 CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
0572                                                _cmsPipelineEval16Fn Eval16,
0573                                                void* PrivateData,
0574                                                _cmsFreeUserDataFn FreePrivateDataFn,
0575                                                _cmsDupUserDataFn DupPrivateDataFn);
0576 
0577 typedef struct {
0578       cmsPluginBase     base;
0579 
0580       // Optimize entry point
0581       _cmsOPToptimizeFn  OptimizePtr;
0582 
0583 }  cmsPluginOptimization;
0584 
0585 //----------------------------------------------------------------------------------------------------------
0586 // Full xform
0587 
0588 typedef struct {
0589        cmsUInt32Number BytesPerLineIn;
0590        cmsUInt32Number BytesPerLineOut;
0591        cmsUInt32Number BytesPerPlaneIn;
0592        cmsUInt32Number BytesPerPlaneOut;
0593 
0594 } cmsStride;
0595 
0596 typedef void     (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo,   // Legacy function, handles just ONE scanline.
0597                                      const void* InputBuffer,
0598                                      void* OutputBuffer,
0599                                      cmsUInt32Number Size,
0600                                      cmsUInt32Number Stride);                 // Stride in bytes to the next plane in planar formats
0601 
0602 
0603 typedef void     (*_cmsTransform2Fn)(struct _cmstransform_struct *CMMcargo,
0604                                      const void* InputBuffer,
0605                                      void* OutputBuffer,
0606                                      cmsUInt32Number PixelsPerLine,
0607                                      cmsUInt32Number LineCount,      
0608                                      const cmsStride* Stride); 
0609 
0610 typedef cmsBool  (* _cmsTransformFactory)(_cmsTransformFn* xform,
0611                                          void** UserData,
0612                                          _cmsFreeUserDataFn* FreePrivateDataFn,
0613                                          cmsPipeline** Lut,
0614                                          cmsUInt32Number* InputFormat,
0615                                          cmsUInt32Number* OutputFormat,
0616                                          cmsUInt32Number* dwFlags);
0617 
0618 typedef cmsBool  (* _cmsTransform2Factory)(_cmsTransform2Fn* xform,
0619                                          void** UserData,
0620                                          _cmsFreeUserDataFn* FreePrivateDataFn,
0621                                          cmsPipeline** Lut,
0622                                          cmsUInt32Number* InputFormat,
0623                                          cmsUInt32Number* OutputFormat,
0624                                          cmsUInt32Number* dwFlags);
0625 
0626 
0627 // Retrieve user data as specified by the factory
0628 CMSAPI void   CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn);
0629 CMSAPI void * CMSEXPORT _cmsGetTransformUserData(struct _cmstransform_struct *CMMcargo);
0630 
0631 
0632 // Retrieve formatters
0633 CMSAPI void   CMSEXPORT _cmsGetTransformFormatters16   (struct _cmstransform_struct *CMMcargo, cmsFormatter16* FromInput, cmsFormatter16* ToOutput);
0634 CMSAPI void   CMSEXPORT _cmsGetTransformFormattersFloat(struct _cmstransform_struct *CMMcargo, cmsFormatterFloat* FromInput, cmsFormatterFloat* ToOutput);
0635 
0636 // Retrieve original flags
0637 CMSAPI cmsUInt32Number CMSEXPORT _cmsGetTransformFlags(struct _cmstransform_struct* CMMcargo);
0638 
0639 typedef struct {
0640       cmsPluginBase     base;
0641 
0642       // Transform entry point
0643       union {
0644              _cmsTransformFactory        legacy_xform;
0645              _cmsTransform2Factory       xform;
0646       } factories;
0647 
0648 }  cmsPluginTransform;
0649 
0650 //----------------------------------------------------------------------------------------------------------
0651 // Mutex
0652 
0653 typedef void*    (* _cmsCreateMutexFnPtrType)(cmsContext ContextID);
0654 typedef void     (* _cmsDestroyMutexFnPtrType)(cmsContext ContextID, void* mtx);
0655 typedef cmsBool  (* _cmsLockMutexFnPtrType)(cmsContext ContextID, void* mtx);
0656 typedef void     (* _cmsUnlockMutexFnPtrType)(cmsContext ContextID, void* mtx);
0657 
0658 typedef struct {
0659       cmsPluginBase     base;
0660 
0661      _cmsCreateMutexFnPtrType  CreateMutexPtr;
0662      _cmsDestroyMutexFnPtrType DestroyMutexPtr;
0663      _cmsLockMutexFnPtrType    LockMutexPtr;
0664      _cmsUnlockMutexFnPtrType  UnlockMutexPtr;
0665 
0666 }  cmsPluginMutex;
0667 
0668 CMSAPI void*   CMSEXPORT _cmsCreateMutex(cmsContext ContextID);
0669 CMSAPI void    CMSEXPORT _cmsDestroyMutex(cmsContext ContextID, void* mtx);
0670 CMSAPI cmsBool CMSEXPORT _cmsLockMutex(cmsContext ContextID, void* mtx);
0671 CMSAPI void    CMSEXPORT _cmsUnlockMutex(cmsContext ContextID, void* mtx);
0672 
0673 //----------------------------------------------------------------------------------------------------------
0674 // Parallelization 
0675 
0676 CMSAPI _cmsTransform2Fn CMSEXPORT _cmsGetTransformWorker(struct _cmstransform_struct* CMMcargo);
0677 CMSAPI cmsInt32Number   CMSEXPORT _cmsGetTransformMaxWorkers(struct _cmstransform_struct* CMMcargo);
0678 CMSAPI cmsUInt32Number  CMSEXPORT _cmsGetTransformWorkerFlags(struct _cmstransform_struct* CMMcargo);
0679 
0680 // Let's plug-in to guess the best number of workers
0681 #define CMS_GUESS_MAX_WORKERS -1
0682 
0683 typedef struct {
0684     cmsPluginBase       base;
0685 
0686     cmsInt32Number      MaxWorkers;       // Number of starts to do as maximum
0687     cmsUInt32Number     WorkerFlags;      // Reserved
0688     _cmsTransform2Fn    SchedulerFn;      // callback to setup functions     
0689 
0690 }  cmsPluginParalellization;
0691 
0692 
0693 #ifndef CMS_USE_CPP_API
0694 #   ifdef __cplusplus
0695     }
0696 #   endif
0697 #endif
0698 
0699 #define _lcms_plugin_H
0700 #endif