~ubuntu-branches/ubuntu/trusty/argyll/trusty-proposed

« back to all changes in this revision

Viewing changes to xicc/xsep.c

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2014-02-12 00:35:39 UTC
  • mfrom: (13.1.24 sid)
  • Revision ID: package-import@ubuntu.com-20140212003539-24tautzlitsiz61w
Tags: 1.5.1-5ubuntu1
* Merge from Debian unstable. (LP: #1275572) Remaining changes:
  - debian/control:
    + Build-depend on libtiff-dev rather than libtiff4-dev.
  - debian/control, debian/patches/06_fix_udev_rule.patch:
    + Fix udev rules to actually work; ENV{ACL_MANAGE} has
      stopped working ages ago, and with logind it's now the
      "uaccess" tag. Dropping also consolekit from Recommends.
  - debian/patches/drop-usb-db.patch:
    + Use hwdb builtin, instead of the obsolete usb-db
      in the udev rules.
* debian/patches/05_ftbfs-underlinkage.diff:
  - Dropped change, no needed anymore.
* Refresh the patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/* 
3
 
 * International Color Consortium color transform expanded support
4
 
 *
5
 
 * Author:  Graeme W. Gill
6
 
 * Date:    1/5/01
7
 
 * Version: 1.00
8
 
 *
9
 
 * Copyright 2000 Graeme W. Gill
10
 
 * All rights reserved.
11
 
 * This material is licenced under the GNU AFFERO GENERAL PUBLIC LICENSE Version 3 :-
12
 
 * see the License.txt file for licencing details.
13
 
 *
14
 
 */
15
 
 
16
 
/*
17
 
 * This class handles the creation of an optimised color separation.
18
 
 * This is a middle layer that has a repertoire of ink separation
19
 
 * rules that can be applied to suite the particular colorspace and
20
 
 * wishes of the user. 
21
 
 *
22
 
 * !!! Under Development - not finished yet !!!
23
 
 */
24
 
 
25
 
#include "numlib.h"
26
 
#include "rspl_imp.h"
27
 
#include "xicc.h"
28
 
#include "xsep.h"
29
 
 
30
 
/* Return the separation given the pseudo-device values */
31
 
/* (Assumes that we have loaded or computed the separation into a */
32
 
/*  separation object) */
33
 
static void xsep_lookup(
34
 
xsep *p,
35
 
double out[MXDO],       /* Actual device output (ie. CMYKOG) */
36
 
double in[MXDI]         /* Pseudo device CMYx input */
37
 
) {
38
 
        co tc;
39
 
        int i;
40
 
 
41
 
        for (i = 0; i < p->pdi; i++)
42
 
                tc.p[i] = in[i];
43
 
 
44
 
        p->sep->interp(p->sep, &tc); 
45
 
 
46
 
        for (i = 0; i < p->ddi; i++)
47
 
                out[i] = tc.v[i];
48
 
}
49
 
 
50
 
static void xsep_del(
51
 
xsep *p
52
 
) {
53
 
 
54
 
        if (p->sep != NULL)
55
 
                p->sep->del(p->sep);
56
 
                
57
 
        free(p);
58
 
}
59
 
 
60
 
 
61
 
#ifdef NEVER    /* Not used yet */
62
 
 
63
 
/* The optimisation function passed to opt_rspl */
64
 
/* Returns value is the "error" for this point. */
65
 
static double optfunc(
66
 
void *fdata,
67
 
double *inout,  /* Pointers to fdi+pdi+adi values for the grid point being optimised. */
68
 
                                /* corresponding to  */
69
 
double *surav,  /* Pointers to fdi+pdi values which are the average of the */
70
 
                                /* neighbors of this grid point. Pointer will NULL if this */
71
 
                                /* is a surface grid point. */
72
 
int first,              /* Flag, NZ if this is the first optimisation of this point. */
73
 
double cw               /* The (grid resolution) curvature weighting factor */
74
 
) {
75
 
        xsep *p = (xsep *)fdata;
76
 
 
77
 
        /* If first time at this grid resolution, compute needed locus extreme values */
78
 
        /* and place them in the additional values allocation */
79
 
        if (first) {
80
 
        }
81
 
 
82
 
        if (surav == NULL) {    /* Must be a surface point */
83
 
                /* Optimise to maximise distance along vector direction */
84
 
                /* together with device value smoothness, inking rule */
85
 
                /* targets and ink limit. */
86
 
 
87
 
                /* Compute surface smoothness value */
88
 
 
89
 
        } else {                                /* Must be an interior point */
90
 
                /* Compute Lab target as mean of surrounding targets, */
91
 
                /* and optimise towards it, together with device value */
92
 
                /* smoothness, inking rule targets and ink limit. */
93
 
 
94
 
                /* Compute interior smoothness value */
95
 
        }
96
 
 
97
 
        return 0.0;
98
 
}
99
 
 
100
 
#endif /* NEVER */
101
 
 
102
 
 
103
 
/* default target vectors (Labx) for CMYx input */
104
 
static double def_tvect[16][4] = {
105
 
        { 100.0,   0.0,    0.0,  100.0 },               /* 0 0 0 0 */
106
 
        {  50.0, -60.0, -100.0,  100.0 },               /* C 0 0 0 */
107
 
        {  50.0, 100.0,    0.0,  100.0 },               /* 0 M 0 0 */
108
 
        {  25.0,  60.0, -100.0,  100.0 },               /* C M 0 0 */
109
 
        {  90.0,   0.0,  100.0,  100.0 },               /* 0 0 Y 0 */
110
 
        {  50.0,-100.0,   60.0,  100.0 },               /* C 0 Y 0 */
111
 
        {  50.0, 100.0,  100.0,  100.0 },               /* 0 M Y 0 */
112
 
        {   0.0,   0.0,    0.0,  100.0 },               /* C M Y 0 */
113
 
        { 100.0,   0.0,    0.0,    0.0 },               /* 0 0 0 x */
114
 
        {  50.0, -60.0, -100.0,    0.0 },               /* C 0 0 x */
115
 
        {  50.0, 100.0,    0.0,    0.0 },               /* 0 M 0 x */
116
 
        {  25.0,  60.0, -100.0,    0.0 },               /* C M 0 x */
117
 
        {  90.0,   0.0,  100.0,    0.0 },               /* 0 0 Y x */
118
 
        {  50.0,-100.0,   60.0,    0.0 },               /* C 0 Y x */
119
 
        {  50.0, 100.0,  100.0,    0.0 },               /* 0 M Y x */
120
 
        {   0.0,   0.0,    0.0,    0.0 }                /* C M Y x */
121
 
};
122
 
 
123
 
/* Create the optimised separation - return NULL on error */
124
 
/* We assume that we want to create a separation from pseudo-device */
125
 
/* channels CMY' to the real device channels. There may also be auxiliary */
126
 
/* channels that come after CMY' and Lab. The schident[] is used to align */
127
 
/* the pseudo chanels with their real counterparts. If there are no */
128
 
/* counterparts, then xsep will use a default. The schident[3] is assumed */
129
 
/* to be the chanel to use for the black (C+M+Y) chanel as an alternative */
130
 
/* to the C+M+Y direction. */
131
 
xsep *new_xsep(
132
 
int pdi,                        /* pseudo device CMY'/CMYK', and target Lab/LabL (PCS) dimensions */
133
 
int ddi,                        /* Device Dimensions/Channels */
134
 
int (*dev2lab) (void *d2lcntx, double *out, double *in),        /* Device to Lab callback */
135
 
void *d2lcntx,          /* dev2lab callback context */
136
 
double (*dev2ink) (void *d2icntx, double *out, double *in),     /* Device to ink callback */
137
 
                                        /* Return 2 or 3 totals: Total ink, CMY sup. group, K sup. */
138
 
void *d2icntx,          /* dev2ink callback context */
139
 
double totlimit,        /* Value not to be exceeded by dev2ink() Total ink, 0.0 .. N.0 */
140
 
double smoothness,      /* Device value smoothness, nominally 1.0 */
141
 
int schident[3],        /* Standard channel ident for psudo CMY' chanels. */
142
 
                                        /* -1 = no mapping else index of corresponding device channel. */
143
 
icxScat cat[MXDO]       /* Device channel control and function category */
144
 
){
145
 
        xsep *p;                /* this */
146
 
        rspl *sep;              /* Mapping we will create */
147
 
        int i, j;
148
 
//      double **vdata; /* pdi^2 array of function, target and additional values to init */
149
 
        double *vdatap[16];
150
 
 
151
 
        /* Sanity check */
152
 
        if (pdi != 3 && pdi != 4) {
153
 
                return NULL;
154
 
        }
155
 
 
156
 
        if (ddi < 1 || ddi > MXDO) {
157
 
                return NULL;
158
 
        }
159
 
 
160
 
        if ((p = (xsep *) calloc(1,sizeof(xsep))) == NULL)
161
 
                return NULL;
162
 
 
163
 
        p->lookup      = xsep_lookup;
164
 
        p->del         = xsep_del;
165
 
 
166
 
        /* We need to setup the initial CMYx' colorant target vectors */
167
 
        /* This will be from the device counterparts (ie. like CMYK), */
168
 
        /* or using a default set of directions. */
169
 
        
170
 
        for (i = 0; i < pdi; i++) {
171
 
                if (schident[i] < 0)
172
 
                        break;                          /* Not all defined */
173
 
                for (j = 0; j < i; j++)
174
 
                        if (schident[j] == schident[i])
175
 
                                break;                  /* Two are the same */
176
 
                if (j < i)
177
 
                        break;
178
 
        }
179
 
        if (i < pdi) {                          /* Fall back on default */
180
 
                for (i = 0; i < (1 << pdi); i++) {
181
 
                        vdatap[i] = def_tvect[i];       // ~~~99
182
 
                }
183
 
        } else {
184
 
        }
185
 
 
186
 
        /* !!! Stuff goes here !!! */
187
 
        /* This will rely on the opt_rspl method of the rspl class */
188
 
 
189
 
        /* Create the rspl that maps CMYx -> Device values */
190
 
        if ((sep = new_rspl(RSPL_NOFLAGS, pdi, ddi)) == NULL) {
191
 
                free(p);
192
 
                return NULL;
193
 
        }
194
 
 
195
 
#ifdef NEVER
196
 
        /* Set values by multi-grid optimisation using the provided function. */
197
 
        /* The input values to the rspl are typically the CMY' or CMYx' color space. */
198
 
        /* The output values are the device values */
199
 
        /* The target values are typically Lab or Labx (vector dir on surface) */
200
 
        /* The additional value are typically the device auxiliary chanel locus limits, */
201
 
        /* computed on the first call at a given grid resolution. */
202
 
        /* The func needs to compute the smoothness value, and weight it */
203
 
        /* by the curvature value. */
204
 
        int sep->opt_rspl(
205
 
                sep,                    /* this */
206
 
                int flags,              /* Combination of flags */
207
 
                int pdi,                /* Dimensionality of target data (typically Lab or Labx) */
208
 
                int adi,                /* Additional grid point data allowance */
209
 
                double **vdata, /* pdi^2 array of function, target and additional values to init */
210
 
                                                /* array corners with. */
211
 
                double (*func)(void *fdata, double *inout, double *surav, int first, double cw),
212
 
                                                /* Optimisation function */
213
 
                void *fdata,    /* Opaque data needed by function */
214
 
                datai glow,             /* Grid low scale - NULL = default 0.0 */
215
 
                datai ghigh,    /* Grid high scale - NULL = default 1.0 */
216
 
                int gres,               /* Spline grid resolution */
217
 
                datao vlow,             /* Data value low normalize, NULL = default 0.0 */
218
 
                datao vhigh             /* Data value high normalize - NULL = default 1.0 */
219
 
        );
220
 
#endif /* NEVER */
221
 
 
222
 
        return p;
223
 
}
224
 
 
225
 
 
226
 
 
227
 
 
228
 
 
229
 
 
230
 
 
231
 
 
232
 
 
233
 
 
234
 
 
235
 
 
236
 
 
237
 
 
238
 
 
239
 
 
240
 
 
241
 
 
242
 
 
243
 
 
244
 
 
245
 
 
246