comparison mupdf-source/thirdparty/lcms2/include/lcms2mt_plugin.h @ 2:b50eed0cc0ef upstream

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