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