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