~ubuntu-branches/ubuntu/natty/digikam/natty

« back to all changes in this revision

Viewing changes to libs/3rdparty/lprof/lcmsprf.h

  • Committer: Bazaar Package Importer
  • Author(s): Luka Renko
  • Date: 2009-11-12 18:02:13 UTC
  • mfrom: (1.2.24 upstream) (3.2.7 sid)
  • Revision ID: james.westby@ubuntu.com-20091112180213-8p63z8taug49ji3t
Tags: 2:1.0.0~beta6-1ubuntu1
* Merge with Debian, remaining changes:
  - Export .pot name and copy to plugins in debian/rules
  - Remove liblqr-1-0-dev from build-deps, not in main

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
 
38
38
#ifndef __cmsprf_H
39
39
 
 
40
// liblcms includes.
 
41
 
40
42
#include <lcms.h>
41
43
 
42
 
#include <ctype.h>
43
 
#include <limits.h>
44
 
#include <stdarg.h>
 
44
// C++ includes.
 
45
 
 
46
#include <cctype>
 
47
#include <climits>
 
48
#include <cstdarg>
 
49
 
 
50
// C Ansi includes.
 
51
 
45
52
#include <sys/stat.h>
46
53
 
47
54
#ifdef __cplusplus
48
 
extern "C" {
 
55
extern "C"
 
56
{
49
57
#endif
50
58
 
51
59
#ifdef NON_WINDOWS
58
66
#define max(a,b) ((a) > (b)?(a):(b))
59
67
#endif
60
68
 
 
69
// See B.K.O #148930: compile with lcms v.1.17
 
70
#if (LCMS_VERSION > 116)
 
71
typedef LCMSBOOL BOOL;
 
72
#endif
 
73
 
61
74
 
62
75
/* Matrix operations - arbitrary size ----------------------------------------------------- */
63
76
 
64
 
typedef struct {
 
77
typedef struct
 
78
{
65
79
 
66
80
    int       Cols, Rows;
67
81
    double**  Values;
68
82
 
69
 
    } MATN,FAR* LPMATN;
70
 
 
71
 
// See B.K.O #148930: compile with lcms v.1.17
72
 
#if (LCMS_VERSION > 116)
73
 
typedef LCMSBOOL BOOL;
74
 
#endif
 
83
} MATN,FAR* LPMATN;
75
84
 
76
85
LPMATN      cdecl MATNalloc(int Rows, int Cols);
77
86
void        cdecl MATNfree (LPMATN mat);
107
116
int         cdecl cmsxIT8EnumProperties(LCMSHANDLE cmsxIT8, char ***PropertyNames);
108
117
int         cdecl cmsxIT8EnumDataFormat(LCMSHANDLE cmsxIT8, char ***SampleNames);
109
118
BOOL        cdecl cmsxIT8SetDataFormat(LCMSHANDLE cmsxIT8, int n, const char *Sample);
110
 
 
111
119
BOOL        cdecl cmsxIT8GetDataSetByPos(LCMSHANDLE IT8, int col, int row, char* Val, int ValBufferLen);
112
 
 
113
 
BOOL        cdecl cmsxIT8GetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch,
114
 
                        const char* cSample,
115
 
                        char* Val, int ValBuffLen);
116
 
 
 
120
BOOL        cdecl cmsxIT8GetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, char* Val, int ValBuffLen);
117
121
BOOL        cdecl cmsxIT8GetDataSetDbl(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, double* v);
118
 
 
119
 
BOOL        cdecl cmsxIT8SetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch,
120
 
                        const char* cSample,
121
 
                        char *Val);
122
 
 
 
122
BOOL        cdecl cmsxIT8SetDataSet(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, char *Val);
123
123
BOOL        cdecl cmsxIT8SetDataSetDbl(LCMSHANDLE cmsxIT8, const char* cPatch, const char* cSample, double Val);
124
 
 
125
124
const char *cdecl cmsxIT8GenericPatchName(int nPatch, char* buffer);
126
125
 
127
126
 
128
 
 
129
127
/* Patch collections (measurement lists) -------------------------------------------------- */
130
128
 
131
129
#define PATCH_HAS_Lab         0x00000001
136
134
#define PATCH_HAS_HEXACRM     0x00000020
137
135
#define PATCH_HAS_STD_Lab     0x00010000
138
136
#define PATCH_HAS_STD_XYZ     0x00020000
139
 
#define PATCH_HAS_XYZ_PROOF   0x00100000  
 
137
#define PATCH_HAS_XYZ_PROOF   0x00100000
140
138
#define PATCH_HAS_MEAN_DE     0x01000000
141
139
#define PATCH_HAS_STD_DE      0x02000000
142
140
#define PATCH_HAS_CHISQ       0x04000000
143
141
 
144
142
 
145
 
#define MAXPATCHNAMELEN     20
 
143
#define MAXPATCHNAMELEN       20
 
144
 
146
145
/* A patch in memory */
147
146
 
148
 
typedef struct {
 
147
typedef struct
 
148
            {
149
149
 
150
150
                DWORD        dwFlags;   /* Is quite possible to have colorant in only */
151
151
                                        /* some patches of sheet, so mark each entry with */
156
156
                cmsCIELab Lab;          /* The tristimulus values of target */
157
157
                cmsCIEXYZ XYZ;
158
158
 
159
 
                                cmsCIEXYZ XYZProof;             /* The absolute XYZ value returned by profile */
160
 
                                                                                /* (gamut constrained to device) */
 
159
                cmsCIEXYZ XYZProof;     /* The absolute XYZ value returned by profile */
 
160
                                        /* (gamut constrained to device) */
161
161
 
162
162
                union {                 /* The possible colorants. Only one space is */
163
163
                                        /* allowed...obviously only one set of */
167
167
                        double CMYK[4];
168
168
                        double Hexa[MAXCHANNELS];
169
169
 
170
 
                        } Colorant;             
 
170
                        } Colorant;
171
171
 
172
172
                double dEStd;               /* Standard deviation  */
173
173
                double ChiSq;               /* Chi-square parameter (mean of STD of colorants) */
184
184
 
185
185
/* This struct holds whole Patches collection */
186
186
 
187
 
typedef struct _measurement {
 
187
typedef struct _measurement
 
188
           {
188
189
 
189
190
           int          nPatches;
190
191
           LPPATCH      Patches;
196
197
void         cdecl cmsxPCollFreeMeasurements(LPMEASUREMENT m);
197
198
SETOFPATCHES cdecl cmsxPCollBuildSet(LPMEASUREMENT m, BOOL lDefault);
198
199
 
199
 
BOOL         cdecl cmsxPCollBuildMeasurement(LPMEASUREMENT m, 
200
 
                                             const char *ReferenceSheet,
201
 
                                             const char *MeasurementSheet,
202
 
                                             DWORD dwNeededSamplesType);
 
200
BOOL         cdecl cmsxPCollBuildMeasurement(LPMEASUREMENT m, const char *ReferenceSheet,
 
201
                                             const char *MeasurementSheet, DWORD dwNeededSamplesType);
203
202
 
204
203
int          cdecl cmsxPCollCountSet(LPMEASUREMENT m, SETOFPATCHES Set);
205
204
BOOL         cdecl cmsxPCollValidatePatches(LPMEASUREMENT m, DWORD dwFlags);
214
213
                                        double r, double g, double b,
215
214
                                        LPcmsCIEXYZ XYZ, LPcmsCIELab Lab);
216
215
 
217
 
void         cdecl cmsxPCollLinearizePatches(LPMEASUREMENT m, SETOFPATCHES Valids,
218
 
                                             LPGAMMATABLE Gamma[3]);
 
216
void         cdecl cmsxPCollLinearizePatches(LPMEASUREMENT m, SETOFPATCHES Valids, LPGAMMATABLE Gamma[3]);
219
217
 
220
218
/* Extraction utilities */
221
219
 
241
239
 
242
240
/* Find important values */
243
241
 
244
 
LPPATCH          cdecl cmsxPCollFindWhite(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
245
 
LPPATCH          cdecl cmsxPCollFindBlack(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
246
 
LPPATCH          cdecl cmsxPCollFindPrimary(LPMEASUREMENT m, SETOFPATCHES Valids, int Channel, double* Distance);
 
242
LPPATCH      cdecl cmsxPCollFindWhite(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
 
243
LPPATCH      cdecl cmsxPCollFindBlack(LPMEASUREMENT m, SETOFPATCHES Valids, double* Distance);
 
244
LPPATCH      cdecl cmsxPCollFindPrimary(LPMEASUREMENT m, SETOFPATCHES Valids, int Channel, double* Distance);
247
245
 
248
246
/* Multiple linear regression stuff ---------------------------------------- */
249
247
 
250
248
 
251
249
/* A measurement of error */
252
250
 
253
 
typedef struct {
 
251
typedef struct
 
252
    {
254
253
 
255
254
        double SSE;             /* The error sum of squares */
256
255
        double MSE;             /* The error mean sum of squares */
281
280
                                       LPMATN tfm, LPcmsCIEXYZ XYZ);
282
281
 
283
282
BOOL cdecl cmsxRegressionInterpolatorRGB(LPMEASUREMENT m,
284
 
                                       int ColorSpace,                            
 
283
                                       int ColorSpace,
285
284
                                       int    RegressionTerms,
286
285
                                       BOOL   lUseLocalPatches,
287
286
                                       int    MinPatchesToCollect,
289
288
                                       void* Res);
290
289
 
291
290
 
292
 
 
293
291
/* Levenberg-Marquardt ---------------------------------------------------------------------- */
294
292
 
295
293
LCMSHANDLE cdecl cmsxLevenbergMarquardtInit(LPSAMPLEDCURVE x, LPSAMPLEDCURVE y, double sig,
296
 
                                                                double a[],
297
 
                                                                int ma,  
298
 
                                                                void (*funcs)(double, double[], double*, double[], int)
299
 
                                                                );
 
294
                                            double a[], int ma,
 
295
                                            void (*funcs)(double, double[], double*, double[], int));
300
296
 
301
297
double    cdecl cmsxLevenbergMarquardtAlamda(LCMSHANDLE hMRQ);
302
298
double    cdecl cmsxLevenbergMarquardtChiSq(LCMSHANDLE hMRQ);
307
303
/* Convex hull geometric routines ------------------------------------------------------------ */
308
304
 
309
305
LCMSHANDLE cdecl cmsxHullInit(void);
310
 
void       cdecl cmsxHullDone(LCMSHANDLE hHull);
311
 
BOOL       cdecl cmsxHullAddPoint(LCMSHANDLE hHull, int x, int y, int z);
312
 
BOOL       cdecl cmsxHullComputeHull(LCMSHANDLE hHull);
313
 
char       cdecl cmsxHullCheckpoint(LCMSHANDLE hHull, int x, int y, int z);
 
306
void       cdecl cmsxHullDone(LCMSHANDLE hHull);
 
307
BOOL       cdecl cmsxHullAddPoint(LCMSHANDLE hHull, int x, int y, int z);
 
308
BOOL       cdecl cmsxHullComputeHull(LCMSHANDLE hHull);
 
309
char       cdecl cmsxHullCheckpoint(LCMSHANDLE hHull, int x, int y, int z);
314
310
BOOL       cdecl cmsxHullDumpVRML(LCMSHANDLE hHull, const char* fname);
315
311
 
316
312
 
317
313
/* Linearization ---------------------------------------------------------------------------- */
318
314
 
319
315
 
320
 
#define MEDIUM_REFLECTIVE_D50   0       /* Used for scanner targets */
321
 
#define MEDIUM_TRANSMISSIVE             1       /* Used for monitors & projectors */
322
 
           
323
 
void cdecl cmsxComputeLinearizationTables(LPMEASUREMENT m, 
324
 
                                    int ColorSpace, 
325
 
                                    LPGAMMATABLE Lin[3],
326
 
                                                                        int nResultingPoints,
327
 
                                                                        int Medium);                                    
328
 
                     
329
 
         
330
 
void             cdecl cmsxCompleteLabOfPatches(LPMEASUREMENT m, SETOFPATCHES Valids, int Medium);
 
316
#define MEDIUM_REFLECTIVE_D50    0    /* Used for scanner targets */
 
317
#define MEDIUM_TRANSMISSIVE      1    /* Used for monitors & projectors */
 
318
 
 
319
void cdecl cmsxComputeLinearizationTables(LPMEASUREMENT m, int ColorSpace, 
 
320
                                    LPGAMMATABLE Lin[3], int nResultingPoints, int Medium);
 
321
 
 
322
void         cdecl cmsxCompleteLabOfPatches(LPMEASUREMENT m, SETOFPATCHES Valids, int Medium);
331
323
LPGAMMATABLE cdecl cmsxEstimateGamma(LPSAMPLEDCURVE X, LPSAMPLEDCURVE Y, int nResultingPoints);
332
 
                                            
 
324
 
333
325
void cdecl cmsxApplyLinearizationTable(double In[3], LPGAMMATABLE Gamma[3], double Out[3]);
334
326
void cdecl cmsxApplyLinearizationGamma(WORD In[3], LPGAMMATABLE Gamma[3], WORD Out[3]);
335
327
 
342
334
/* Matrix shaper profiler API ------------------------------------------------------------- */
343
335
 
344
336
 
345
 
BOOL cdecl cmsxComputeMatrixShaper(const char* ReferenceSheet,                              
 
337
BOOL cdecl cmsxComputeMatrixShaper(const char* ReferenceSheet,
346
338
                                   const char* MeasurementSheet,
347
 
                                                                   int Medium,
 
339
                                   int Medium,
348
340
                                   LPGAMMATABLE TransferCurves[3],
349
341
                                   LPcmsCIEXYZ WhitePoint,
350
342
                                   LPcmsCIEXYZ BlackPoint,
358
350
typedef int (* cmsxGAUGER)(const char *Label, int nMin, int nMax, int Pos);
359
351
typedef int (* cmsxPRINTF)(const char *Frm, ...);
360
352
 
361
 
typedef struct {
 
353
typedef struct
 
354
    {
362
355
 
363
356
           /* Files */
364
357
           char ReferenceSheet[MAX_PATH];
381
374
           cmsCIExyYTRIPLE Primaries;       /* The primaries */
382
375
           LPGAMMATABLE Gamma[3];           /* Gamma curves */
383
376
 
384
 
                   /* Profile */ 
385
 
                   cmsHPROFILE hProfile;            /* handle to profile */
 
377
           /* Profile */
 
378
           cmsHPROFILE hProfile;            /* handle to profile */
386
379
 
387
380
           icProfileClassSignature DeviceClass;
388
381
           icColorSpaceSignature   ColorSpace;
389
382
 
390
383
           int PCSType;                    /* PT_XYZ or PT_Lab */
391
384
           int CLUTPoints;                 /* Final CLUT resolution */
392
 
                   int ProfileVerbosityLevel;      /* 0=minimum, 1=additional, 2=Verbose, 3=Any suitable */
393
 
 
394
 
           
395
 
                   /* Measurement */    
 
385
           int ProfileVerbosityLevel;       /* 0=minimum, 1=additional, 2=Verbose, 3=Any suitable */
 
386
 
 
387
 
 
388
           /* Measurement */
396
389
           MEASUREMENT m;                /* Contains list of available patches */
397
 
                   int Medium;
398
 
 
399
 
 
400
 
                   /* RGB Gamut hull */
401
 
                   LCMSHANDLE hRGBHull;   /* Contains bobbin of valid RGB values */
402
 
 
403
 
                   /* CIECAM97s */
404
 
                   BOOL lUseCIECAM97s;   /* Use CIECAM97s for chromatic adaptation? */
405
 
 
406
 
                   cmsViewingConditions device;     /* Viewing condition of source */
 
390
           int Medium;
 
391
 
 
392
 
 
393
           /* RGB Gamut hull */
 
394
           LCMSHANDLE hRGBHull;   /* Contains bobbin of valid RGB values */
 
395
 
 
396
           /* CIECAM97s */
 
397
           BOOL lUseCIECAM97s;   /* Use CIECAM97s for chromatic adaptation? */
 
398
 
 
399
           cmsViewingConditions device;     /* Viewing condition of source */
407
400
           cmsViewingConditions PCS;        /* Viewing condition of PCS */
408
401
 
409
402
           LCMSHANDLE hDevice;              /* CIECAM97s models used for adaptation */
410
403
           LCMSHANDLE hPCS;                 /* and viewing conditions */
411
 
           
412
404
 
413
405
    } PROFILERCOMMONDATA,FAR* LPPROFILERCOMMONDATA;
414
 
 
 
406
 
415
407
 
416
408
/* Shared routines */
417
409
 
427
419
 
428
420
/* Monitor profiler API ------------------------------------------------------------------- */
429
421
 
430
 
typedef struct {
 
422
typedef struct
 
423
           {
431
424
 
432
425
           PROFILERCOMMONDATA hdr;
433
 
                                                
434
 
                     
 
426
 
435
427
           LPGAMMATABLE         Prelinearization[3];    /* Canonic gamma */
436
428
           LPGAMMATABLE         ReverseTables[3];       /* Reverse (direct) gamma */
437
429
           LPGAMMATABLE         PreLab[3];
438
430
           LPGAMMATABLE         PreLabRev[3];
439
 
         
440
431
 
441
432
           MAT3                 PrimariesMatrix;
442
433
           MAT3                 PrimariesMatrixRev; 
443
 
         
444
434
 
445
435
           } MONITORPROFILERDATA,FAR* LPMONITORPROFILERDATA;
446
436
 
453
443
/* Scanner profiler API ------------------------------------------------------------------- */
454
444
 
455
445
 
456
 
typedef struct {
 
446
typedef struct
 
447
           {
457
448
 
458
449
           PROFILERCOMMONDATA hdr;
459
 
                                                                                   
460
 
           LPGAMMATABLE Prelinearization[3];        
461
 
                             
462
 
                   LPMATN HiTerms;      /* Regression matrix of many terms */
463
 
                   LPMATN LoTerms;      /* Low order regression matrix used for extrapolation */
464
 
                   
465
 
                   BOOL   lLocalConvergenceExtrapolation;
466
 
                                                                  
 
450
 
 
451
           LPGAMMATABLE Prelinearization[3];
 
452
 
 
453
           LPMATN HiTerms;      /* Regression matrix of many terms */
 
454
           LPMATN LoTerms;      /* Low order regression matrix used for extrapolation */
 
455
 
 
456
           BOOL   lLocalConvergenceExtrapolation;
 
457
 
467
458
 
468
459
           } SCANNERPROFILERDATA,FAR* LPSCANNERPROFILERDATA;
469
460
 
470
461
 
471
 
 
472
 
 
473
462
BOOL   cdecl cmsxScannerProfilerInit(LPSCANNERPROFILERDATA sys);                                       
474
463
BOOL   cdecl cmsxScannerProfilerDo(LPSCANNERPROFILERDATA sys);
475
464