< prev index next >

src/java.desktop/share/native/liblcms/lcms2_plugin.h

Print this page




  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-2017 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 //---------------------------------------------------------------------------------


 106 typedef struct {
 107     cmsVEC3 v[3];
 108 
 109     } cmsMAT3;
 110 
 111 CMSAPI void               CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
 112 CMSAPI void               CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b);
 113 CMSAPI void               CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v);
 114 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v);
 115 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3length(const cmsVEC3* a);
 116 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b);
 117 
 118 CMSAPI void               CMSEXPORT _cmsMAT3identity(cmsMAT3* a);
 119 CMSAPI cmsBool            CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a);
 120 CMSAPI void               CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b);
 121 CMSAPI cmsBool            CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b);
 122 CMSAPI cmsBool            CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b);
 123 CMSAPI void               CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
 124 
 125 






 126 // Error logging  -------------------------------------------------------------------------------------
 127 
 128 CMSAPI void               CMSEXPORT  cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
 129 
 130 // Memory management ----------------------------------------------------------------------------------
 131 
 132 CMSAPI void*              CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size);
 133 CMSAPI void*              CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size);
 134 CMSAPI void*              CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
 135 CMSAPI void*              CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
 136 CMSAPI void               CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr);
 137 CMSAPI void*              CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size);
 138 
 139 // I/O handler ----------------------------------------------------------------------------------
 140 
 141 struct _cms_io_handler {
 142 
 143     void* stream;   // Associated stream, which is implemented differently depending on media.
 144 
 145     cmsContext        ContextID;


 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.
 280 struct _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.
 287 typedef 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.
 294 typedef 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
 301 typedef 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


 352 
 353 // Plug-in may implement an arbitrary number of parametric curves
 354 typedef 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 
 370 struct _cmstransform_struct;
 371 
 372 typedef cmsUInt8Number* (* cmsFormatter16)(register struct _cmstransform_struct* CMMcargo,
 373                                            register cmsUInt16Number Values[],
 374                                            register cmsUInt8Number* Buffer,
 375                                            register cmsUInt32Number Stride);
 376 
 377 typedef 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
 383 typedef 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 
 392 typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection;
 393 
 394 typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type,           // Specific type, i.e. TYPE_RGB_8
 395                                              cmsFormatterDirection Dir,


 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 
 573 typedef void     (* _cmsOPTeval16Fn)(register const cmsUInt16Number In[],
 574                                      register cmsUInt16Number Out[],
 575                                      register const void* Data);
 576 
 577 
 578 typedef 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 
 587 CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
 588                                                _cmsOPTeval16Fn Eval16,
 589                                                void* PrivateData,
 590                                                _cmsFreeUserDataFn FreePrivateDataFn,
 591                                                _cmsDupUserDataFn DupPrivateDataFn);
 592 
 593 typedef struct {
 594       cmsPluginBase     base;
 595 




  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-2020 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 //---------------------------------------------------------------------------------


 106 typedef struct {
 107     cmsVEC3 v[3];
 108 
 109     } cmsMAT3;
 110 
 111 CMSAPI void               CMSEXPORT _cmsVEC3init(cmsVEC3* r, cmsFloat64Number x, cmsFloat64Number y, cmsFloat64Number z);
 112 CMSAPI void               CMSEXPORT _cmsVEC3minus(cmsVEC3* r, const cmsVEC3* a, const cmsVEC3* b);
 113 CMSAPI void               CMSEXPORT _cmsVEC3cross(cmsVEC3* r, const cmsVEC3* u, const cmsVEC3* v);
 114 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3dot(const cmsVEC3* u, const cmsVEC3* v);
 115 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3length(const cmsVEC3* a);
 116 CMSAPI cmsFloat64Number   CMSEXPORT _cmsVEC3distance(const cmsVEC3* a, const cmsVEC3* b);
 117 
 118 CMSAPI void               CMSEXPORT _cmsMAT3identity(cmsMAT3* a);
 119 CMSAPI cmsBool            CMSEXPORT _cmsMAT3isIdentity(const cmsMAT3* a);
 120 CMSAPI void               CMSEXPORT _cmsMAT3per(cmsMAT3* r, const cmsMAT3* a, const cmsMAT3* b);
 121 CMSAPI cmsBool            CMSEXPORT _cmsMAT3inverse(const cmsMAT3* a, cmsMAT3* b);
 122 CMSAPI cmsBool            CMSEXPORT _cmsMAT3solve(cmsVEC3* x, cmsMAT3* a, cmsVEC3* b);
 123 CMSAPI void               CMSEXPORT _cmsMAT3eval(cmsVEC3* r, const cmsMAT3* a, const cmsVEC3* v);
 124 
 125 
 126 // MD5 low level  -------------------------------------------------------------------------------------
 127 
 128 CMSAPI cmsHANDLE          CMSEXPORT cmsMD5alloc(cmsContext ContextID);
 129 CMSAPI void               CMSEXPORT cmsMD5add(cmsHANDLE Handle, const cmsUInt8Number* buf, cmsUInt32Number len);
 130 CMSAPI void               CMSEXPORT cmsMD5finish(cmsProfileID* ProfileID, cmsHANDLE Handle);
 131 
 132 // Error logging  -------------------------------------------------------------------------------------
 133 
 134 CMSAPI void               CMSEXPORT  cmsSignalError(cmsContext ContextID, cmsUInt32Number ErrorCode, const char *ErrorText, ...);
 135 
 136 // Memory management ----------------------------------------------------------------------------------
 137 
 138 CMSAPI void*              CMSEXPORT _cmsMalloc(cmsContext ContextID, cmsUInt32Number size);
 139 CMSAPI void*              CMSEXPORT _cmsMallocZero(cmsContext ContextID, cmsUInt32Number size);
 140 CMSAPI void*              CMSEXPORT _cmsCalloc(cmsContext ContextID, cmsUInt32Number num, cmsUInt32Number size);
 141 CMSAPI void*              CMSEXPORT _cmsRealloc(cmsContext ContextID, void* Ptr, cmsUInt32Number NewSize);
 142 CMSAPI void               CMSEXPORT _cmsFree(cmsContext ContextID, void* Ptr);
 143 CMSAPI void*              CMSEXPORT _cmsDupMem(cmsContext ContextID, const void* Org, cmsUInt32Number size);
 144 
 145 // I/O handler ----------------------------------------------------------------------------------
 146 
 147 struct _cms_io_handler {
 148 
 149     void* stream;   // Associated stream, which is implemented differently depending on media.
 150 
 151     cmsContext        ContextID;


 273         _cmsReallocFnPtrType ReallocPtr;
 274 
 275         // Optional
 276        _cmsMalloZerocFnPtrType MallocZeroPtr;
 277        _cmsCallocFnPtrType     CallocPtr;
 278        _cmsDupFnPtrType        DupPtr;
 279 
 280 } cmsPluginMemHandler;
 281 
 282 
 283 // ------------------------------------------------------------------------------------------------------------------
 284 
 285 // Interpolation. 16 bits and floating point versions.
 286 struct _cms_interp_struc;
 287 
 288 // Interpolation callbacks
 289 
 290 // 16 bits forward interpolation. This function performs precision-limited linear interpolation
 291 // and is supposed to be quite fast. Implementation may be tetrahedral or trilinear, and plug-ins may
 292 // choose to implement any other interpolation algorithm.
 293 typedef void (* _cmsInterpFn16)(CMSREGISTER const cmsUInt16Number Input[],
 294                                 CMSREGISTER cmsUInt16Number Output[],
 295                                 CMSREGISTER const struct _cms_interp_struc* p);
 296 
 297 // Floating point forward interpolation. Full precision interpolation using floats. This is not a
 298 // time critical function. Implementation may be tetrahedral or trilinear, and plug-ins may
 299 // choose to implement any other interpolation algorithm.
 300 typedef void (* _cmsInterpFnFloat)(cmsFloat32Number const Input[],
 301                                    cmsFloat32Number Output[],
 302                                    const struct _cms_interp_struc* p);
 303 
 304 
 305 
 306 // This type holds a pointer to an interpolator that can be either 16 bits or float
 307 typedef union {
 308     _cmsInterpFn16       Lerp16;            // Forward interpolation in 16 bits
 309     _cmsInterpFnFloat    LerpFloat;         // Forward interpolation in floating point
 310 } cmsInterpFunction;
 311 
 312 // Flags for interpolator selection
 313 #define CMS_LERP_FLAGS_16BITS             0x0000        // The default
 314 #define CMS_LERP_FLAGS_FLOAT              0x0001        // Requires different implementation
 315 #define CMS_LERP_FLAGS_TRILINEAR          0x0100        // Hint only


 358 
 359 // Plug-in may implement an arbitrary number of parametric curves
 360 typedef struct {
 361     cmsPluginBase base;
 362 
 363     cmsUInt32Number nFunctions;                                     // Number of supported functions
 364     cmsUInt32Number FunctionTypes[MAX_TYPES_IN_LCMS_PLUGIN];        // The identification types
 365     cmsUInt32Number ParameterCount[MAX_TYPES_IN_LCMS_PLUGIN];       // Number of parameters for each function
 366 
 367     cmsParametricCurveEvaluator    Evaluator;                       // The evaluator
 368 
 369 } cmsPluginParametricCurves;
 370 //----------------------------------------------------------------------------------------------------------
 371 
 372 // Formatters. This plug-in adds new handlers, replacing them if they already exist. Formatters dealing with
 373 // cmsFloat32Number (bps = 4) or double (bps = 0) types are requested via FormatterFloat callback. Others come across
 374 // Formatter16 callback
 375 
 376 struct _cmstransform_struct;
 377 
 378 typedef cmsUInt8Number* (* cmsFormatter16)(CMSREGISTER struct _cmstransform_struct* CMMcargo,
 379                                            CMSREGISTER cmsUInt16Number Values[],
 380                                            CMSREGISTER cmsUInt8Number* Buffer,
 381                                            CMSREGISTER cmsUInt32Number Stride);
 382 
 383 typedef cmsUInt8Number* (* cmsFormatterFloat)(struct _cmstransform_struct* CMMcargo,
 384                                               cmsFloat32Number Values[],
 385                                               cmsUInt8Number*  Buffer,
 386                                               cmsUInt32Number  Stride);
 387 
 388 // This type holds a pointer to a formatter that can be either 16 bits or cmsFloat32Number
 389 typedef union {
 390     cmsFormatter16    Fmt16;
 391     cmsFormatterFloat FmtFloat;
 392 
 393 } cmsFormatter;
 394 
 395 #define CMS_PACK_FLAGS_16BITS       0x0000
 396 #define CMS_PACK_FLAGS_FLOAT        0x0001
 397 
 398 typedef enum { cmsFormatterInput=0, cmsFormatterOutput=1 } cmsFormatterDirection;
 399 
 400 typedef cmsFormatter (* cmsFormatterFactory)(cmsUInt32Number Type,           // Specific type, i.e. TYPE_RGB_8
 401                                              cmsFormatterDirection Dir,


 559 
 560     union {                       // Can have only one of both representations at same time
 561         cmsUInt16Number*  T;      // Points to the table 16 bits table
 562         cmsFloat32Number* TFloat; // Points to the cmsFloat32Number table
 563 
 564     } Tab;
 565 
 566     cmsInterpParams* Params;
 567     cmsUInt32Number  nEntries;
 568     cmsBool          HasFloatValues;
 569 
 570 } _cmsStageCLutData;
 571 
 572 
 573 //----------------------------------------------------------------------------------------------------------
 574 // Optimization. Using this plug-in, additional optimization strategies may be implemented.
 575 // The function should return TRUE if any optimization is done on the LUT, this terminates
 576 // the optimization  search. Or FALSE if it is unable to optimize and want to give a chance
 577 // to the rest of optimizers.
 578 
 579 typedef void     (* _cmsOPTeval16Fn)(CMSREGISTER const cmsUInt16Number In[],
 580                                      CMSREGISTER cmsUInt16Number Out[],
 581                                      CMSREGISTER const void* Data);
 582 
 583 
 584 typedef cmsBool  (* _cmsOPToptimizeFn)(cmsPipeline** Lut,
 585                                        cmsUInt32Number  Intent,
 586                                        cmsUInt32Number* InputFormat,
 587                                        cmsUInt32Number* OutputFormat,
 588                                        cmsUInt32Number* dwFlags);
 589 
 590 // This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional
 591 // duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality.
 592 
 593 CMSAPI void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut,
 594                                                _cmsOPTeval16Fn Eval16,
 595                                                void* PrivateData,
 596                                                _cmsFreeUserDataFn FreePrivateDataFn,
 597                                                _cmsDupUserDataFn DupPrivateDataFn);
 598 
 599 typedef struct {
 600       cmsPluginBase     base;
 601 


< prev index next >