Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

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