lcms2_plugin.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. //---------------------------------------------------------------------------------
  2. //
  3. // Little Color Management System
  4. // Copyright (c) 1998-2011 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. #ifndef _lcms_plugin_H
  31. // Deal with Microsoft's attempt at deprecating C standard runtime functions
  32. #ifdef _MSC_VER
  33. # if (_MSC_VER >= 1400)
  34. # ifndef _CRT_SECURE_NO_DEPRECATE
  35. # define _CRT_SECURE_NO_DEPRECATE
  36. # endif
  37. # ifndef _CRT_SECURE_NO_WARNINGS
  38. # define _CRT_SECURE_NO_WARNINGS
  39. # endif
  40. # endif
  41. #endif
  42. #ifndef _lcms2_H
  43. #include "lcms2.h"
  44. #endif
  45. // We need some standard C functions.
  46. #include <stdlib.h>
  47. #include <math.h>
  48. #include <stdarg.h>
  49. #include <memory.h>
  50. #include <string.h>
  51. #ifndef CMS_USE_CPP_API
  52. # ifdef __cplusplus
  53. extern "C" {
  54. # endif
  55. #endif
  56. // Vector & Matrix operations -----------------------------------------------------------------------
  57. // Axis of the matrix/array. No specific meaning at all.
  58. #define VX 0
  59. #define VY 1
  60. #define VZ 2
  61. // Vectors
  62. typedef struct {
  63. cmsFloat64Number n[3];
  64. } cmsVEC3;
  65. // 3x3 Matrix
  66. typedef struct {
  67. cmsVEC3 v[3];
  68. } cmsMAT3;
  69. CMSAPI void CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
  70. CMSAPI void CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b);
  71. CMSAPI void CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v);
  72. CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v);
  73. CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3length(const cmsVEC3* a);
  74. CMSAPI cmsFloat64Number CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b);
  75. CMSAPI void CMSEXPORT _cmsMAT3identity(cmsMAT3* a);
  76. CMSAPI cmsBool CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a);
  77. CMSAPI void CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b);
  78. CMSAPI cmsBool CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b);
  79. CMSAPI cmsBool CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b);
  80. CMSAPI void CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
  81. // Error logging -------------------------------------------------------------------------------------
  82. CMSAPI void CMSEXPORT cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
  83. // Memory management ----------------------------------------------------------------------------------
  84. CMSAPI void* CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size);
  85. CMSAPI void* CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size);
  86. CMSAPI void* CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
  87. CMSAPI void* CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
  88. CMSAPI void CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr);
  89. CMSAPI void* CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size);
  90. // I/O handler ----------------------------------------------------------------------------------
  91. struct _cms_io_handler {
  92. void* stream; // Associated stream, which is implemented differently depending on media.
  93. cmsContext ContextID;
  94. cmsUInt32Number UsedSpace;
  95. cmsUInt32Number ReportedSize;
  96. char PhysicalFile[cmsMAX_PATH];
  97. cmsUInt32Number (* Read)(struct _cms_io_handler* iohandler, void *Buffer,
  98. cmsUInt32Number size,
  99. cmsUInt32Number count);
  100. cmsBool (* Seek)(struct _cms_io_handler* iohandler, cmsUInt32Number offset);
  101. cmsBool (* Close)(struct _cms_io_handler* iohandler);
  102. cmsUInt32Number (* Tell)(struct _cms_io_handler* iohandler);
  103. cmsBool (* Write)(struct _cms_io_handler* iohandler, cmsUInt32Number size,
  104. const void* Buffer);
  105. };
  106. // Endianess adjust functions
  107. CMSAPI cmsUInt16Number CMSEXPORT _cmsAdjustEndianess16(cmsUInt16Number Word);
  108. CMSAPI cmsUInt32Number CMSEXPORT _cmsAdjustEndianess32(cmsUInt32Number Value);
  109. CMSAPI void CMSEXPORT _cmsAdjustEndianess64(cmsUInt64Number* Result, cmsUInt64Number* QWord);
  110. // Helper IO functions
  111. CMSAPI cmsBool CMSEXPORT _cmsReadUInt8Number(cmsIOHANDLER* io, cmsUInt8Number* n);
  112. CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Number(cmsIOHANDLER* io, cmsUInt16Number* n);
  113. CMSAPI cmsBool CMSEXPORT _cmsReadUInt32Number(cmsIOHANDLER* io, cmsUInt32Number* n);
  114. CMSAPI cmsBool CMSEXPORT _cmsReadFloat32Number(cmsIOHANDLER* io, cmsFloat32Number* n);
  115. CMSAPI cmsBool CMSEXPORT _cmsReadUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
  116. CMSAPI cmsBool CMSEXPORT _cmsRead15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number* n);
  117. CMSAPI cmsBool CMSEXPORT _cmsReadXYZNumber(cmsIOHANDLER* io, cmsCIEXYZ* XYZ);
  118. CMSAPI cmsBool CMSEXPORT _cmsReadUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, cmsUInt16Number* Array);
  119. CMSAPI cmsBool CMSEXPORT _cmsWriteUInt8Number(cmsIOHANDLER* io, cmsUInt8Number n);
  120. CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Number(cmsIOHANDLER* io, cmsUInt16Number n);
  121. CMSAPI cmsBool CMSEXPORT _cmsWriteUInt32Number(cmsIOHANDLER* io, cmsUInt32Number n);
  122. CMSAPI cmsBool CMSEXPORT _cmsWriteFloat32Number(cmsIOHANDLER* io, cmsFloat32Number n);
  123. CMSAPI cmsBool CMSEXPORT _cmsWriteUInt64Number(cmsIOHANDLER* io, cmsUInt64Number* n);
  124. CMSAPI cmsBool CMSEXPORT _cmsWrite15Fixed16Number(cmsIOHANDLER* io, cmsFloat64Number n);
  125. CMSAPI cmsBool CMSEXPORT _cmsWriteXYZNumber(cmsIOHANDLER* io, const cmsCIEXYZ* XYZ);
  126. CMSAPI cmsBool CMSEXPORT _cmsWriteUInt16Array(cmsIOHANDLER* io, cmsUInt32Number n, const cmsUInt16Number* Array);
  127. // ICC base tag
  128. typedef struct {
  129. cmsTagTypeSignature sig;
  130. cmsInt8Number reserved[4];
  131. } _cmsTagBase;
  132. // Type base helper functions
  133. CMSAPI cmsTagTypeSignature CMSEXPORT _cmsReadTypeBase(cmsIOHANDLER* io);
  134. CMSAPI cmsBool CMSEXPORT _cmsWriteTypeBase(cmsIOHANDLER* io, cmsTagTypeSignature sig);
  135. // Alignment functions
  136. CMSAPI cmsBool CMSEXPORT _cmsReadAlignment(cmsIOHANDLER* io);
  137. CMSAPI cmsBool CMSEXPORT _cmsWriteAlignment(cmsIOHANDLER* io);
  138. // To deal with text streams. 2K at most
  139. CMSAPI cmsBool CMSEXPORT _cmsIOPrintf(cmsIOHANDLER* io, const char* frm, ...);
  140. // Fixed point helper functions
  141. CMSAPI cmsFloat64Number CMSEXPORT _cms8Fixed8toDouble(cmsUInt16Number fixed8);
  142. CMSAPI cmsUInt16Number CMSEXPORT _cmsDoubleTo8Fixed8(cmsFloat64Number val);
  143. CMSAPI cmsFloat64Number CMSEXPORT _cms15Fixed16toDouble(cmsS15Fixed16Number fix32);
  144. CMSAPI cmsS15Fixed16Number CMSEXPORT _cmsDoubleTo15Fixed16(cmsFloat64Number v);
  145. // Date/time helper functions
  146. CMSAPI void CMSEXPORT _cmsEncodeDateTimeNumber(cmsDateTimeNumber *Dest, const struct tm *Source);
  147. CMSAPI void CMSEXPORT _cmsDecodeDateTimeNumber(const cmsDateTimeNumber *Source, struct tm *Dest);
  148. //----------------------------------------------------------------------------------------------------------
  149. // Shared callbacks for user data
  150. typedef void (* _cmsFreeUserDataFn)(cmsContext ContextID, void* Data);
  151. typedef void* (* _cmsDupUserDataFn)(cmsContext ContextID, const void* Data);
  152. //----------------------------------------------------------------------------------------------------------
  153. // Plug-in foundation
  154. #define cmsPluginMagicNumber 0x61637070 // 'acpp'
  155. #define cmsPluginMemHandlerSig 0x6D656D48 // 'memH'
  156. #define cmsPluginInterpolationSig 0x696E7048 // 'inpH'
  157. #define cmsPluginParametricCurveSig 0x70617248 // 'parH'
  158. #define cmsPluginFormattersSig 0x66726D48 // 'frmH
  159. #define cmsPluginTagTypeSig 0x74797048 // 'typH'
  160. #define cmsPluginTagSig 0x74616748 // 'tagH'
  161. #define cmsPluginRenderingIntentSig 0x696E7448 // 'intH'
  162. #define cmsPluginMultiProcessElementSig 0x6D706548 // 'mpeH'
  163. #define cmsPluginOptimizationSig 0x6F707448 // 'optH'
  164. #define cmsPluginTransformSig 0x7A666D48 // 'xfmH'
  165. typedef struct _cmsPluginBaseStruct {
  166. cmsUInt32Number Magic; // 'acpp' signature
  167. cmsUInt32Number ExpectedVersion; // Expected version of LittleCMS
  168. cmsUInt32Number Type; // Type of plug-in
  169. struct _cmsPluginBaseStruct* Next; // For multiple plugin definition. NULL for end of list.
  170. } cmsPluginBase;
  171. // Maximum number of types in a plugin array
  172. #define MAX_TYPES_IN_LCMS_PLUGIN 20
  173. //----------------------------------------------------------------------------------------------------------
  174. // Memory handler. Each new plug-in type replaces current behaviour
  175. typedef struct {
  176. cmsPluginBase base;
  177. // Required
  178. void * (* MallocPtr)(cmsContext ContextID, cmsUInt32Number size);
  179. void (* FreePtr)(cmsContext ContextID, void *Ptr);
  180. void * (* ReallocPtr)(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
  181. // Optional
  182. void * (* MallocZeroPtr)(cmsContext ContextID, cmsUInt32Number size);
  183. void * (* CallocPtr)(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
  184. void * (* DupPtr)(cmsContext ContextID, const void* Org, cmsUInt32Number size);
  185. } cmsPluginMemHandler;
  186. // ------------------------------------------------------------------------------------------------------------------
  187. // Interpolation. 16 bits and floating point versions.
  188. struct _cms_interp_struc;
  189. // Interpolation callbacks
  190. // 16 bits forward interpolation. This function performs precision-limited linear interpolation
  191. // and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
  192. // choose to implement any other interpolation algorithm.
  193. typedef void (* _cmsInterpFn16)(register const cmsUInt16Number Input[],
  194. register cmsUInt16Number Output[],
  195. register const struct _cms_interp_struc* p);
  196. // Floating point forward interpolation. Full precision interpolation using floats. This is not a
  197. // time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
  198. // choose to implement any other interpolation algorithm.
  199. typedef void (* _cmsInterpFnFloat)(cmsFloat32Number const Input[],
  200. cmsFloat32Number Output[],
  201. const struct _cms_interp_struc* p);
  202. // This type holds a pointer to an interpolator that can be either 16 bits or float
  203. typedef union {
  204. _cmsInterpFn16 Lerp16; // Forward interpolation in 16 bits
  205. _cmsInterpFnFloat LerpFloat; // Forward interpolation in floating point
  206. } cmsInterpFunction;
  207. // Flags for interpolator selection
  208. #define CMS_LERP_FLAGS_16BITS 0x0000 // The default
  209. #define CMS_LERP_FLAGS_FLOAT 0x0001 // Requires different implementation
  210. #define CMS_LERP_FLAGS_TRILINEAR 0x0100 // Hint only
  211. #define MAX_INPUT_DIMENSIONS 8
  212. typedef struct _cms_interp_struc { // Used on all interpolations. Supplied by lcms2 when calling the interpolation function
  213. cmsContext ContextID; // The calling thread
  214. cmsUInt32Number dwFlags; // Keep original flags
  215. cmsUInt32Number nInputs; // != 1 only in 3D interpolation
  216. cmsUInt32Number nOutputs; // != 1 only in 3D interpolation
  217. cmsUInt32Number nSamples[MAX_INPUT_DIMENSIONS]; // Valid on all kinds of tables
  218. cmsUInt32Number Domain[MAX_INPUT_DIMENSIONS]; // Domain = nSamples - 1
  219. cmsUInt32Number opta[MAX_INPUT_DIMENSIONS]; // Optimization for 3D CLUT. This is the number of nodes premultiplied for each
  220. // dimension. For example, in 7 nodes, 7, 7^2 , 7^3, 7^4, etc. On non-regular
  221. // Samplings may vary according of the number of nodes for each dimension.
  222. const void *Table; // Points to the actual interpolation table
  223. cmsInterpFunction Interpolation; // Points to the function to do the interpolation
  224. } cmsInterpParams;
  225. // Interpolators factory
  226. typedef cmsInterpFunction (* cmsInterpFnFactory)(cmsUInt32Number nInputChannels, cmsUInt32Number nOutputChannels, cmsUInt32Number dwFlags);
  227. // The plug-in
  228. typedef struct {
  229. cmsPluginBase base;
  230. // Points to a user-supplied function which implements the factory
  231. cmsInterpFnFactory InterpolatorsFactory;
  232. } cmsPluginInterpolation;
  233. //----------------------------------------------------------------------------------------------------------
  234. // Parametric curves. A negative type means same function but analytically inverted. Max. number of params is 10
  235. // Evaluator callback for user-suplied parametric curves. May implement more than one type
  236. typedef cmsFloat64Number (* cmsParametricCurveEvaluator)(cmsInt32Number Type, const cmsFloat64Number Params[10], cmsFloat64Number R);
  237. // Plug-in may implement an arbitrary number of parametric curves
  238. typedef struct {
  239. cmsPluginBase base;
  240. cmsUInt32Number nFunctions; // Number of supported functions
  241. cmsUInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN]; // The identification types
  242. cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN]; // Number of parameters for each function
  243. cmsParametricCurveEvaluator Evaluator; // The evaluator
  244. } cmsPluginParametricCurves;
  245. //----------------------------------------------------------------------------------------------------------
  246. // Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with
  247. // cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across
  248. // Formatter16 callback
  249. struct _cmstransform_struct;
  250. typedef cmsUInt8Number* (* cmsFormatter16)(register struct _cmstransform_struct* CMMcargo,
  251. register cmsUInt16Number Values[],
  252. register cmsUInt8Number* Buffer,
  253. register cmsUInt32Number Stride);
  254. typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
  255. cmsFloat32Number Values[],
  256. cmsUInt8Number* Buffer,
  257. cmsUInt32Number Stride);
  258. // This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number
  259. typedef union {
  260. cmsFormatter16 Fmt16;
  261. cmsFormatterFloat FmtFloat;
  262. } cmsFormatter;
  263. #define CMS_PACK_FLAGS_16BITS 0x0000
  264. #define CMS_PACK_FLAGS_FLOAT 0x0001
  265. typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection;
  266. typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type, // Specific type, i.e. TYPE_RGB_8
  267. cmsFormatterDirection Dir,
  268. cmsUInt32Number dwFlags); // precision
  269. // Plug-in may implement an arbitrary number of formatters
  270. typedef struct {
  271. cmsPluginBase base;
  272. cmsFormatterFactory FormattersFactory;
  273. } cmsPluginFormatters;
  274. //----------------------------------------------------------------------------------------------------------
  275. // Tag type handler. Each type is free to return anything it wants, and it is up to the caller to
  276. // know in advance what is the type contained in the tag.
  277. typedef struct _cms_typehandler_struct {
  278. cmsTagTypeSignature Signature; // The signature of the type
  279. // Allocates and reads items
  280. void * (* ReadPtr)(struct _cms_typehandler_struct* self,
  281. cmsIOHANDLER* io,
  282. cmsUInt32Number* nItems,
  283. cmsUInt32Number SizeOfTag);
  284. // Writes n Items
  285. cmsBool (* WritePtr)(struct _cms_typehandler_struct* self,
  286. cmsIOHANDLER* io,
  287. void* Ptr,
  288. cmsUInt32Number nItems);
  289. // Duplicate an item or array of items
  290. void* (* DupPtr)(struct _cms_typehandler_struct* self,
  291. const void *Ptr,
  292. cmsUInt32Number n);
  293. // Free all resources
  294. void (* FreePtr)(struct _cms_typehandler_struct* self,
  295. void *Ptr);
  296. // Additional parameters used by the calling thread
  297. cmsContext ContextID;
  298. cmsUInt32Number ICCVersion;
  299. } cmsTagTypeHandler;
  300. // Each plug-in implements a single type
  301. typedef struct {
  302. cmsPluginBase base;
  303. cmsTagTypeHandler Handler;
  304. } cmsPluginTagType;
  305. //----------------------------------------------------------------------------------------------------------
  306. // This is the tag plugin, which identifies tags. For writing, a pointer to function is provided.
  307. // This function should return the desired type for this tag, given the version of profile
  308. // and the data being serialized.
  309. typedef struct {
  310. cmsUInt32Number ElemCount; // If this tag needs an array, how many elements should keep
  311. // For reading.
  312. cmsUInt32Number nSupportedTypes; // In how many types this tag can come (MAX_TYPES_IN_LCMS_PLUGIN maximum)
  313. cmsTagTypeSignature SupportedTypes[MAX_TYPES_IN_LCMS_PLUGIN];
  314. // For writting
  315. cmsTagTypeSignature (* DecideType)(cmsFloat64Number ICCVersion, const void *Data);
  316. } cmsTagDescriptor;
  317. // Plug-in implements a single tag
  318. typedef struct {
  319. cmsPluginBase base;
  320. cmsTagSignature Signature;
  321. cmsTagDescriptor Descriptor;
  322. } cmsPluginTag;
  323. //----------------------------------------------------------------------------------------------------------
  324. // Custom intents. This function should join all profiles specified in the array in
  325. // a single LUT. Any custom intent in the chain redirects to custom function. If more than
  326. // one custom intent is found, the one located first is invoked. Usually users should use only one
  327. // custom intent, so mixing custom intents in same multiprofile transform is not supported.
  328. typedef cmsPipeline* (* cmsIntentFn)( cmsContext ContextID,
  329. cmsUInt32Number nProfiles,
  330. cmsUInt32Number Intents[],
  331. cmsHPROFILE hProfiles[],
  332. cmsBool BPC[],
  333. cmsFloat64Number AdaptationStates[],
  334. cmsUInt32Number dwFlags);
  335. // Each plug-in defines a single intent number.
  336. typedef struct {
  337. cmsPluginBase base;
  338. cmsUInt32Number Intent;
  339. cmsIntentFn Link;
  340. char Description[256];
  341. } cmsPluginRenderingIntent;
  342. // The default ICC intents (perceptual, saturation, rel.col and abs.col)
  343. CMSAPI cmsPipeline* CMSEXPORT _cmsDefaultICCintents(cmsContext ContextID,
  344. cmsUInt32Number nProfiles,
  345. cmsUInt32Number Intents[],
  346. cmsHPROFILE hProfiles[],
  347. cmsBool BPC[],
  348. cmsFloat64Number AdaptationStates[],
  349. cmsUInt32Number dwFlags);
  350. //----------------------------------------------------------------------------------------------------------
  351. // Pipelines, Multi Process Elements.
  352. typedef void (* _cmsStageEvalFn) (const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage* mpe);
  353. typedef void*(* _cmsStageDupElemFn) (cmsStage* mpe);
  354. typedef void (* _cmsStageFreeElemFn) (cmsStage* mpe);
  355. // This function allocates a generic MPE
  356. CMSAPI cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID,
  357. cmsStageSignature Type,
  358. cmsUInt32Number InputChannels,
  359. cmsUInt32Number OutputChannels,
  360. _cmsStageEvalFn EvalPtr, // Points to fn that evaluates the element (always in floating point)
  361. _cmsStageDupElemFn DupElemPtr, // Points to a fn that duplicates the stage
  362. _cmsStageFreeElemFn FreePtr, // Points to a fn that sets the element free
  363. void* Data); // A generic pointer to whatever memory needed by the element
  364. typedef struct {
  365. cmsPluginBase base;
  366. cmsTagTypeHandler Handler;
  367. } cmsPluginMultiProcessElement;
  368. // Data kept in "Element" member of cmsStage
  369. // Curves
  370. typedef struct {
  371. cmsUInt32Number nCurves;
  372. cmsToneCurve** TheCurves;
  373. } _cmsStageToneCurvesData;
  374. // Matrix
  375. typedef struct {
  376. cmsFloat64Number* Double; // floating point for the matrix
  377. cmsFloat64Number* Offset; // The offset
  378. } _cmsStageMatrixData;
  379. // CLUT
  380. typedef struct {
  381. union { // Can have only one of both representations at same time
  382. cmsUInt16Number* T; // Points to the table 16 bits table
  383. cmsFloat32Number* TFloat; // Points to the cmsFloat32Number table
  384. } Tab;
  385. cmsInterpParams* Params;
  386. cmsUInt32Number nEntries;
  387. cmsBool HasFloatValues;
  388. } _cmsStageCLutData;
  389. //----------------------------------------------------------------------------------------------------------
  390. // Optimization. Using this plug-in, additional optimization strategies may be implemented.
  391. // The function should return TRUE if any optimization is done on the LUT, this terminates
  392. // the optimization search. Or FALSE if it is unable to optimize and want to give a chance
  393. // to the rest of optimizers.
  394. typedef void (* _cmsOPTeval16Fn)(register const cmsUInt16Number In[],
  395. register cmsUInt16Number Out[],
  396. register const void* Data);
  397. typedef cmsBool (* _cmsOPToptimizeFn)(cmsPipeline** Lut,
  398. cmsUInt32Number Intent,
  399. cmsUInt32Number* InputFormat,
  400. cmsUInt32Number* OutputFormat,
  401. cmsUInt32Number* dwFlags);
  402. // This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
  403. // duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
  404. CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
  405. _cmsOPTeval16Fn Eval16,
  406. void* PrivateData,
  407. _cmsFreeUserDataFn FreePrivateDataFn,
  408. _cmsDupUserDataFn DupPrivateDataFn);
  409. typedef struct {
  410. cmsPluginBase base;
  411. // Optimize entry point
  412. _cmsOPToptimizeFn OptimizePtr;
  413. } cmsPluginOptimization;
  414. //----------------------------------------------------------------------------------------------------------
  415. // Full xform
  416. typedef void (* _cmsTransformFn)(struct _cmstransform_struct *CMMcargo,
  417. const void* InputBuffer,
  418. void* OutputBuffer,
  419. cmsUInt32Number Size,
  420. cmsUInt32Number Stride);
  421. typedef cmsBool (* _cmsTransformFactory)(_cmsTransformFn* xform,
  422. void** UserData,
  423. _cmsFreeUserDataFn* FreePrivateDataFn,
  424. cmsPipeline** Lut,
  425. cmsUInt32Number* InputFormat,
  426. cmsUInt32Number* OutputFormat,
  427. cmsUInt32Number* dwFlags);
  428. // Retrieve user data as specified by the factory
  429. CMSAPI void CMSEXPORT _cmsSetTransformUserData(struct _cmstransform_struct *CMMcargo, void* ptr, _cmsFreeUserDataFn FreePrivateDataFn);
  430. CMSAPI void * CMSEXPORT _cmsGetTransformUserData(struct _cmstransform_struct *CMMcargo);
  431. // Retrieve formatters
  432. CMSAPI void CMSEXPORT _cmsGetTransformFormatters16 (struct _cmstransform_struct *CMMcargo, cmsFormatter16* FromInput, cmsFormatter16* ToOutput);
  433. CMSAPI void CMSEXPORT _cmsGetTransformFormattersFloat(struct _cmstransform_struct *CMMcargo, cmsFormatterFloat* FromInput, cmsFormatterFloat* ToOutput);
  434. typedef struct {
  435. cmsPluginBase base;
  436. // Transform entry point
  437. _cmsTransformFactory Factory;
  438. } cmsPluginTransform;
  439. #ifndef CMS_USE_CPP_API
  440. # ifdef __cplusplus
  441. }
  442. # endif
  443. #endif
  444. #define _lcms_plugin_H
  445. #endif