author | chegar |
Sun, 17 Aug 2014 15:54:13 +0100 | |
changeset 25859 | 3317bb8137f4 |
parent 23906 | jdk/src/share/native/sun/java2d/cmm/lcms/cmslut.c@8f7f9cb6fe11 |
child 30491 | ea1c291ee28f |
permissions | -rw-r--r-- |
2 | 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 |
|
5506 | 6 |
* published by the Free Software Foundation. Oracle designates this |
2 | 7 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 8 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 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 |
// |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
30 |
//--------------------------------------------------------------------------------- |
2 | 31 |
// |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
32 |
// Little Color Management System |
14300 | 33 |
// Copyright (c) 1998-2012 Marti Maria Saguer |
2 | 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 |
// |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
53 |
//--------------------------------------------------------------------------------- |
2 | 54 |
// |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
55 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
56 |
#include "lcms2_internal.h" |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
57 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
58 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
59 |
// Allocates an empty multi profile element |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
60 |
cmsStage* CMSEXPORT _cmsStageAllocPlaceholder(cmsContext ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
61 |
cmsStageSignature Type, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
62 |
cmsUInt32Number InputChannels, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
63 |
cmsUInt32Number OutputChannels, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
64 |
_cmsStageEvalFn EvalPtr, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
65 |
_cmsStageDupElemFn DupElemPtr, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
66 |
_cmsStageFreeElemFn FreePtr, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
67 |
void* Data) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
68 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
69 |
cmsStage* ph = (cmsStage*) _cmsMallocZero(ContextID, sizeof(cmsStage)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
70 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
71 |
if (ph == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
72 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
73 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
74 |
ph ->ContextID = ContextID; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
75 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
76 |
ph ->Type = Type; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
77 |
ph ->Implements = Type; // By default, no clue on what is implementing |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
78 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
79 |
ph ->InputChannels = InputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
80 |
ph ->OutputChannels = OutputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
81 |
ph ->EvalPtr = EvalPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
82 |
ph ->DupElemPtr = DupElemPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
83 |
ph ->FreePtr = FreePtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
84 |
ph ->Data = Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
85 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
86 |
return ph; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
87 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
88 |
|
2 | 89 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
90 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
91 |
void EvaluateIdentity(const cmsFloat32Number In[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
92 |
cmsFloat32Number Out[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
93 |
const cmsStage *mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
94 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
95 |
memmove(Out, In, mpe ->InputChannels * sizeof(cmsFloat32Number)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
96 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
97 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
98 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
99 |
cmsStage* CMSEXPORT cmsStageAllocIdentity(cmsContext ContextID, cmsUInt32Number nChannels) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
100 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
101 |
return _cmsStageAllocPlaceholder(ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
102 |
cmsSigIdentityElemType, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
103 |
nChannels, nChannels, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
104 |
EvaluateIdentity, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
105 |
NULL, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
106 |
NULL, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
107 |
NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
108 |
} |
2 | 109 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
110 |
// Conversion functions. From floating point to 16 bits |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
111 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
112 |
void FromFloatTo16(const cmsFloat32Number In[], cmsUInt16Number Out[], cmsUInt32Number n) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
113 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
114 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
115 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
116 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
117 |
Out[i] = _cmsQuickSaturateWord(In[i] * 65535.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
118 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
119 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
120 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
121 |
// From 16 bits to floating point |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
122 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
123 |
void From16ToFloat(const cmsUInt16Number In[], cmsFloat32Number Out[], cmsUInt32Number n) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
124 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
125 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
126 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
127 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
128 |
Out[i] = (cmsFloat32Number) In[i] / 65535.0F; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
129 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
130 |
} |
2 | 131 |
|
132 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
133 |
// This function is quite useful to analyze the structure of a LUT and retrieve the MPE elements |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
134 |
// that conform the LUT. It should be called with the LUT, the number of expected elements and |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
135 |
// then a list of expected types followed with a list of cmsFloat64Number pointers to MPE elements. If |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
136 |
// the function founds a match with current pipeline, it fills the pointers and returns TRUE |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
137 |
// if not, returns FALSE without touching anything. Setting pointers to NULL does bypass |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
138 |
// the storage process. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
139 |
cmsBool CMSEXPORT cmsPipelineCheckAndRetreiveStages(const cmsPipeline* Lut, cmsUInt32Number n, ...) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
140 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
141 |
va_list args; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
142 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
143 |
cmsStage* mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
144 |
cmsStageSignature Type; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
145 |
void** ElemPtr; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
146 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
147 |
// Make sure same number of elements |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
148 |
if (cmsPipelineStageCount(Lut) != n) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
149 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
150 |
va_start(args, n); |
2 | 151 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
152 |
// Iterate across asked types |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
153 |
mpe = Lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
154 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
155 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
156 |
// Get asked type |
14300 | 157 |
Type = (cmsStageSignature)va_arg(args, cmsStageSignature); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
158 |
if (mpe ->Type != Type) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
159 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
160 |
va_end(args); // Mismatch. We are done. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
161 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
162 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
163 |
mpe = mpe ->Next; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
164 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
165 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
166 |
// Found a combination, fill pointers if not NULL |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
167 |
mpe = Lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
168 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
169 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
170 |
ElemPtr = va_arg(args, void**); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
171 |
if (ElemPtr != NULL) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
172 |
*ElemPtr = mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
173 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
174 |
mpe = mpe ->Next; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
175 |
} |
2 | 176 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
177 |
va_end(args); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
178 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
179 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
180 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
181 |
// Below there are implementations for several types of elements. Each type may be implemented by a |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
182 |
// evaluation function, a duplication function, a function to free resources and a constructor. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
183 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
184 |
// ************************************************************************************************* |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
185 |
// Type cmsSigCurveSetElemType (curves) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
186 |
// ************************************************************************************************* |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
187 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
188 |
cmsToneCurve** _cmsStageGetPtrToCurveSet(const cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
189 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
190 |
_cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
191 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
192 |
return Data ->TheCurves; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
193 |
} |
2 | 194 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
195 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
196 |
void EvaluateCurves(const cmsFloat32Number In[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
197 |
cmsFloat32Number Out[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
198 |
const cmsStage *mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
199 |
{ |
14300 | 200 |
_cmsStageToneCurvesData* Data; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
201 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
202 |
|
14300 | 203 |
_cmsAssert(mpe != NULL); |
204 |
||
205 |
Data = (_cmsStageToneCurvesData*) mpe ->Data; |
|
206 |
if (Data == NULL) return; |
|
207 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
208 |
if (Data ->TheCurves == NULL) return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
209 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
210 |
for (i=0; i < Data ->nCurves; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
211 |
Out[i] = cmsEvalToneCurveFloat(Data ->TheCurves[i], In[i]); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
212 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
213 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
214 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
215 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
216 |
void CurveSetElemTypeFree(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
217 |
{ |
14300 | 218 |
_cmsStageToneCurvesData* Data; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
219 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
220 |
|
14300 | 221 |
_cmsAssert(mpe != NULL); |
222 |
||
223 |
Data = (_cmsStageToneCurvesData*) mpe ->Data; |
|
224 |
if (Data == NULL) return; |
|
225 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
226 |
if (Data ->TheCurves != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
227 |
for (i=0; i < Data ->nCurves; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
228 |
if (Data ->TheCurves[i] != NULL) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
229 |
cmsFreeToneCurve(Data ->TheCurves[i]); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
230 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
231 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
232 |
_cmsFree(mpe ->ContextID, Data ->TheCurves); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
233 |
_cmsFree(mpe ->ContextID, Data); |
2 | 234 |
} |
235 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
236 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
237 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
238 |
void* CurveSetDup(cmsStage* mpe) |
2 | 239 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
240 |
_cmsStageToneCurvesData* Data = (_cmsStageToneCurvesData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
241 |
_cmsStageToneCurvesData* NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
242 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
243 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
244 |
NewElem = (_cmsStageToneCurvesData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageToneCurvesData)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
245 |
if (NewElem == NULL) return NULL; |
2 | 246 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
247 |
NewElem ->nCurves = Data ->nCurves; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
248 |
NewElem ->TheCurves = (cmsToneCurve**) _cmsCalloc(mpe ->ContextID, NewElem ->nCurves, sizeof(cmsToneCurve*)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
249 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
250 |
if (NewElem ->TheCurves == NULL) goto Error; |
2 | 251 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
252 |
for (i=0; i < NewElem ->nCurves; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
253 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
254 |
// Duplicate each curve. It may fail. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
255 |
NewElem ->TheCurves[i] = cmsDupToneCurve(Data ->TheCurves[i]); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
256 |
if (NewElem ->TheCurves[i] == NULL) goto Error; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
257 |
|
2 | 258 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
259 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
260 |
return (void*) NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
261 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
262 |
Error: |
2 | 263 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
264 |
if (NewElem ->TheCurves != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
265 |
for (i=0; i < NewElem ->nCurves; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
266 |
if (NewElem ->TheCurves[i]) |
23906 | 267 |
cmsFreeToneCurve(NewElem ->TheCurves[i]); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
268 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
269 |
} |
23906 | 270 |
_cmsFree(mpe ->ContextID, NewElem ->TheCurves); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
271 |
_cmsFree(mpe ->ContextID, NewElem); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
272 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
273 |
} |
2 | 274 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
275 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
276 |
// Curves == NULL forces identity curves |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
277 |
cmsStage* CMSEXPORT cmsStageAllocToneCurves(cmsContext ContextID, cmsUInt32Number nChannels, cmsToneCurve* const Curves[]) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
278 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
279 |
cmsUInt32Number i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
280 |
_cmsStageToneCurvesData* NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
281 |
cmsStage* NewMPE; |
2 | 282 |
|
283 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
284 |
NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCurveSetElemType, nChannels, nChannels, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
285 |
EvaluateCurves, CurveSetDup, CurveSetElemTypeFree, NULL ); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
286 |
if (NewMPE == NULL) return NULL; |
2 | 287 |
|
14300 | 288 |
NewElem = (_cmsStageToneCurvesData*) _cmsMallocZero(ContextID, sizeof(_cmsStageToneCurvesData)); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
289 |
if (NewElem == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
290 |
cmsStageFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
291 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
292 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
293 |
|
14300 | 294 |
NewMPE ->Data = (void*) NewElem; |
295 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
296 |
NewElem ->nCurves = nChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
297 |
NewElem ->TheCurves = (cmsToneCurve**) _cmsCalloc(ContextID, nChannels, sizeof(cmsToneCurve*)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
298 |
if (NewElem ->TheCurves == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
299 |
cmsStageFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
300 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
301 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
302 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
303 |
for (i=0; i < nChannels; i++) { |
2 | 304 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
305 |
if (Curves == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
306 |
NewElem ->TheCurves[i] = cmsBuildGamma(ContextID, 1.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
307 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
308 |
else { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
309 |
NewElem ->TheCurves[i] = cmsDupToneCurve(Curves[i]); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
310 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
311 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
312 |
if (NewElem ->TheCurves[i] == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
313 |
cmsStageFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
314 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
315 |
} |
14300 | 316 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
317 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
318 |
|
14300 | 319 |
return NewMPE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
320 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
321 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
322 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
323 |
// Create a bunch of identity curves |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
324 |
cmsStage* _cmsStageAllocIdentityCurves(cmsContext ContextID, int nChannels) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
325 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
326 |
cmsStage* mpe = cmsStageAllocToneCurves(ContextID, nChannels, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
327 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
328 |
if (mpe == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
329 |
mpe ->Implements = cmsSigIdentityElemType; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
330 |
return mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
331 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
332 |
|
2 | 333 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
334 |
// ************************************************************************************************* |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
335 |
// Type cmsSigMatrixElemType (Matrices) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
336 |
// ************************************************************************************************* |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
337 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
338 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
339 |
// Special care should be taken here because precision loss. A temporary cmsFloat64Number buffer is being used |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
340 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
341 |
void EvaluateMatrix(const cmsFloat32Number In[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
342 |
cmsFloat32Number Out[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
343 |
const cmsStage *mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
344 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
345 |
cmsUInt32Number i, j; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
346 |
_cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
347 |
cmsFloat64Number Tmp; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
348 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
349 |
// Input is already in 0..1.0 notation |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
350 |
for (i=0; i < mpe ->OutputChannels; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
351 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
352 |
Tmp = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
353 |
for (j=0; j < mpe->InputChannels; j++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
354 |
Tmp += In[j] * Data->Double[i*mpe->InputChannels + j]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
355 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
356 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
357 |
if (Data ->Offset != NULL) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
358 |
Tmp += Data->Offset[i]; |
2 | 359 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
360 |
Out[i] = (cmsFloat32Number) Tmp; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
361 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
362 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
363 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
364 |
// Output in 0..1.0 domain |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
365 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
366 |
|
2 | 367 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
368 |
// Duplicate a yet-existing matrix element |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
369 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
370 |
void* MatrixElemDup(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
371 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
372 |
_cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
373 |
_cmsStageMatrixData* NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
374 |
cmsUInt32Number sz; |
2 | 375 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
376 |
NewElem = (_cmsStageMatrixData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageMatrixData)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
377 |
if (NewElem == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
378 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
379 |
sz = mpe ->InputChannels * mpe ->OutputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
380 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
381 |
NewElem ->Double = (cmsFloat64Number*) _cmsDupMem(mpe ->ContextID, Data ->Double, sz * sizeof(cmsFloat64Number)) ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
382 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
383 |
if (Data ->Offset) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
384 |
NewElem ->Offset = (cmsFloat64Number*) _cmsDupMem(mpe ->ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
385 |
Data ->Offset, mpe -> OutputChannels * sizeof(cmsFloat64Number)) ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
386 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
387 |
return (void*) NewElem; |
2 | 388 |
} |
389 |
||
390 |
||
391 |
static |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
392 |
void MatrixElemTypeFree(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
393 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
394 |
_cmsStageMatrixData* Data = (_cmsStageMatrixData*) mpe ->Data; |
23906 | 395 |
if (Data == NULL) |
396 |
return; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
397 |
if (Data ->Double) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
398 |
_cmsFree(mpe ->ContextID, Data ->Double); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
399 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
400 |
if (Data ->Offset) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
401 |
_cmsFree(mpe ->ContextID, Data ->Offset); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
402 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
403 |
_cmsFree(mpe ->ContextID, mpe ->Data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
404 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
405 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
406 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
407 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
408 |
cmsStage* CMSEXPORT cmsStageAllocMatrix(cmsContext ContextID, cmsUInt32Number Rows, cmsUInt32Number Cols, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
409 |
const cmsFloat64Number* Matrix, const cmsFloat64Number* Offset) |
2 | 410 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
411 |
cmsUInt32Number i, n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
412 |
_cmsStageMatrixData* NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
413 |
cmsStage* NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
414 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
415 |
n = Rows * Cols; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
416 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
417 |
// Check for overflow |
14300 | 418 |
if (n == 0) return NULL; |
419 |
if (n >= UINT_MAX / Cols) return NULL; |
|
420 |
if (n >= UINT_MAX / Rows) return NULL; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
421 |
if (n < Rows || n < Cols) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
422 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
423 |
NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigMatrixElemType, Cols, Rows, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
424 |
EvaluateMatrix, MatrixElemDup, MatrixElemTypeFree, NULL ); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
425 |
if (NewMPE == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
426 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
427 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
428 |
NewElem = (_cmsStageMatrixData*) _cmsMallocZero(ContextID, sizeof(_cmsStageMatrixData)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
429 |
if (NewElem == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
430 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
431 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
432 |
NewElem ->Double = (cmsFloat64Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat64Number)); |
2 | 433 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
434 |
if (NewElem->Double == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
435 |
MatrixElemTypeFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
436 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
437 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
438 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
439 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
440 |
NewElem ->Double[i] = Matrix[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
441 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
442 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
443 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
444 |
if (Offset != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
445 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
446 |
NewElem ->Offset = (cmsFloat64Number*) _cmsCalloc(ContextID, Cols, sizeof(cmsFloat64Number)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
447 |
if (NewElem->Offset == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
448 |
MatrixElemTypeFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
449 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
450 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
451 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
452 |
for (i=0; i < Cols; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
453 |
NewElem ->Offset[i] = Offset[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
454 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
455 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
456 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
457 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
458 |
NewMPE ->Data = (void*) NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
459 |
return NewMPE; |
2 | 460 |
} |
461 |
||
462 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
463 |
// ************************************************************************************************* |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
464 |
// Type cmsSigCLutElemType |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
465 |
// ************************************************************************************************* |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
466 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
467 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
468 |
// Evaluate in true floating point |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
469 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
470 |
void EvaluateCLUTfloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe) |
2 | 471 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
472 |
_cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
473 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
474 |
Data -> Params ->Interpolation.LerpFloat(In, Out, Data->Params); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
475 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
476 |
|
2 | 477 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
478 |
// Convert to 16 bits, evaluate, and back to floating point |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
479 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
480 |
void EvaluateCLUTfloatIn16(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
481 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
482 |
_cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
483 |
cmsUInt16Number In16[MAX_STAGE_CHANNELS], Out16[MAX_STAGE_CHANNELS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
484 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
485 |
_cmsAssert(mpe ->InputChannels <= MAX_STAGE_CHANNELS); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
486 |
_cmsAssert(mpe ->OutputChannels <= MAX_STAGE_CHANNELS); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
487 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
488 |
FromFloatTo16(In, In16, mpe ->InputChannels); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
489 |
Data -> Params ->Interpolation.Lerp16(In16, Out16, Data->Params); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
490 |
From16ToFloat(Out16, Out, mpe ->OutputChannels); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
491 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
492 |
|
2 | 493 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
494 |
// Given an hypercube of b dimensions, with Dims[] number of nodes by dimension, calculate the total amount of nodes |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
495 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
496 |
cmsUInt32Number CubeSize(const cmsUInt32Number Dims[], cmsUInt32Number b) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
497 |
{ |
14300 | 498 |
cmsUInt32Number rv, dim; |
499 |
||
500 |
_cmsAssert(Dims != NULL); |
|
501 |
||
502 |
for (rv = 1; b > 0; b--) { |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
503 |
|
14300 | 504 |
dim = Dims[b-1]; |
505 |
if (dim == 0) return 0; // Error |
|
506 |
||
507 |
rv *= dim; |
|
508 |
||
509 |
// Check for overflow |
|
510 |
if (rv > UINT_MAX / dim) return 0; |
|
511 |
} |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
512 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
513 |
return rv; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
514 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
515 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
516 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
517 |
void* CLUTElemDup(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
518 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
519 |
_cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
520 |
_cmsStageCLutData* NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
521 |
|
2 | 522 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
523 |
NewElem = (_cmsStageCLutData*) _cmsMallocZero(mpe ->ContextID, sizeof(_cmsStageCLutData)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
524 |
if (NewElem == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
525 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
526 |
NewElem ->nEntries = Data ->nEntries; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
527 |
NewElem ->HasFloatValues = Data ->HasFloatValues; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
528 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
529 |
if (Data ->Tab.T) { |
2 | 530 |
|
23906 | 531 |
if (Data ->HasFloatValues) { |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
532 |
NewElem ->Tab.TFloat = (cmsFloat32Number*) _cmsDupMem(mpe ->ContextID, Data ->Tab.TFloat, Data ->nEntries * sizeof (cmsFloat32Number)); |
23906 | 533 |
if (NewElem ->Tab.TFloat == NULL) |
534 |
goto Error; |
|
535 |
} else { |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
536 |
NewElem ->Tab.T = (cmsUInt16Number*) _cmsDupMem(mpe ->ContextID, Data ->Tab.T, Data ->nEntries * sizeof (cmsUInt16Number)); |
23906 | 537 |
if (NewElem ->Tab.TFloat == NULL) |
538 |
goto Error; |
|
539 |
} |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
540 |
} |
2 | 541 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
542 |
NewElem ->Params = _cmsComputeInterpParamsEx(mpe ->ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
543 |
Data ->Params ->nSamples, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
544 |
Data ->Params ->nInputs, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
545 |
Data ->Params ->nOutputs, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
546 |
NewElem ->Tab.T, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
547 |
Data ->Params ->dwFlags); |
23906 | 548 |
if (NewElem->Params != NULL) |
549 |
return (void*) NewElem; |
|
550 |
Error: |
|
551 |
if (NewElem->Tab.T) |
|
552 |
// This works for both types |
|
553 |
_cmsFree(mpe ->ContextID, NewElem -> Tab.T); |
|
554 |
_cmsFree(mpe ->ContextID, NewElem); |
|
555 |
return NULL; |
|
2 | 556 |
} |
557 |
||
558 |
||
559 |
static |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
560 |
void CLutElemTypeFree(cmsStage* mpe) |
2 | 561 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
562 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
563 |
_cmsStageCLutData* Data = (_cmsStageCLutData*) mpe ->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
564 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
565 |
// Already empty |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
566 |
if (Data == NULL) return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
567 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
568 |
// This works for both types |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
569 |
if (Data -> Tab.T) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
570 |
_cmsFree(mpe ->ContextID, Data -> Tab.T); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
571 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
572 |
_cmsFreeInterpParams(Data ->Params); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
573 |
_cmsFree(mpe ->ContextID, mpe ->Data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
574 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
575 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
576 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
577 |
// Allocates a 16-bit multidimensional CLUT. This is evaluated at 16-bit precision. Table may have different |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
578 |
// granularity on each dimension. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
579 |
cmsStage* CMSEXPORT cmsStageAllocCLut16bitGranular(cmsContext ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
580 |
const cmsUInt32Number clutPoints[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
581 |
cmsUInt32Number inputChan, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
582 |
cmsUInt32Number outputChan, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
583 |
const cmsUInt16Number* Table) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
584 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
585 |
cmsUInt32Number i, n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
586 |
_cmsStageCLutData* NewElem; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
587 |
cmsStage* NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
588 |
|
14300 | 589 |
_cmsAssert(clutPoints != NULL); |
590 |
||
591 |
if (inputChan > MAX_INPUT_DIMENSIONS) { |
|
592 |
cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", inputChan, MAX_INPUT_DIMENSIONS); |
|
593 |
return NULL; |
|
594 |
} |
|
595 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
596 |
NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCLutElemType, inputChan, outputChan, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
597 |
EvaluateCLUTfloatIn16, CLUTElemDup, CLutElemTypeFree, NULL ); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
598 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
599 |
if (NewMPE == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
600 |
|
14300 | 601 |
NewElem = (_cmsStageCLutData*) _cmsMallocZero(ContextID, sizeof(_cmsStageCLutData)); |
602 |
if (NewElem == NULL) { |
|
603 |
cmsStageFree(NewMPE); |
|
604 |
return NULL; |
|
605 |
} |
|
606 |
||
607 |
NewMPE ->Data = (void*) NewElem; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
608 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
609 |
NewElem -> nEntries = n = outputChan * CubeSize(clutPoints, inputChan); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
610 |
NewElem -> HasFloatValues = FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
611 |
|
14300 | 612 |
if (n == 0) { |
613 |
cmsStageFree(NewMPE); |
|
614 |
return NULL; |
|
615 |
} |
|
616 |
||
617 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
618 |
NewElem ->Tab.T = (cmsUInt16Number*) _cmsCalloc(ContextID, n, sizeof(cmsUInt16Number)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
619 |
if (NewElem ->Tab.T == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
620 |
cmsStageFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
621 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
622 |
} |
2 | 623 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
624 |
if (Table != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
625 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
626 |
NewElem ->Tab.T[i] = Table[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
627 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
628 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
629 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
630 |
NewElem ->Params = _cmsComputeInterpParamsEx(ContextID, clutPoints, inputChan, outputChan, NewElem ->Tab.T, CMS_LERP_FLAGS_16BITS); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
631 |
if (NewElem ->Params == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
632 |
cmsStageFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
633 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
634 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
635 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
636 |
return NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
637 |
} |
2 | 638 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
639 |
cmsStage* CMSEXPORT cmsStageAllocCLut16bit(cmsContext ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
640 |
cmsUInt32Number nGridPoints, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
641 |
cmsUInt32Number inputChan, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
642 |
cmsUInt32Number outputChan, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
643 |
const cmsUInt16Number* Table) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
644 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
645 |
cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
646 |
int i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
647 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
648 |
// Our resulting LUT would be same gridpoints on all dimensions |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
649 |
for (i=0; i < MAX_INPUT_DIMENSIONS; i++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
650 |
Dimensions[i] = nGridPoints; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
651 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
652 |
return cmsStageAllocCLut16bitGranular(ContextID, Dimensions, inputChan, outputChan, Table); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
653 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
654 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
655 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
656 |
cmsStage* CMSEXPORT cmsStageAllocCLutFloat(cmsContext ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
657 |
cmsUInt32Number nGridPoints, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
658 |
cmsUInt32Number inputChan, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
659 |
cmsUInt32Number outputChan, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
660 |
const cmsFloat32Number* Table) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
661 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
662 |
cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
663 |
int i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
664 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
665 |
// Our resulting LUT would be same gridpoints on all dimensions |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
666 |
for (i=0; i < MAX_INPUT_DIMENSIONS; i++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
667 |
Dimensions[i] = nGridPoints; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
668 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
669 |
return cmsStageAllocCLutFloatGranular(ContextID, Dimensions, inputChan, outputChan, Table); |
2 | 670 |
} |
671 |
||
672 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
673 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
674 |
cmsStage* CMSEXPORT cmsStageAllocCLutFloatGranular(cmsContext ContextID, const cmsUInt32Number clutPoints[], cmsUInt32Number inputChan, cmsUInt32Number outputChan, const cmsFloat32Number* Table) |
2394 | 675 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
676 |
cmsUInt32Number i, n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
677 |
_cmsStageCLutData* NewElem; |
14300 | 678 |
cmsStage* NewMPE; |
679 |
||
680 |
_cmsAssert(clutPoints != NULL); |
|
681 |
||
682 |
if (inputChan > MAX_INPUT_DIMENSIONS) { |
|
683 |
cmsSignalError(ContextID, cmsERROR_RANGE, "Too many input channels (%d channels, max=%d)", inputChan, MAX_INPUT_DIMENSIONS); |
|
684 |
return NULL; |
|
685 |
} |
|
686 |
||
687 |
NewMPE = _cmsStageAllocPlaceholder(ContextID, cmsSigCLutElemType, inputChan, outputChan, |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
688 |
EvaluateCLUTfloat, CLUTElemDup, CLutElemTypeFree, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
689 |
if (NewMPE == NULL) return NULL; |
2394 | 690 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
691 |
|
14300 | 692 |
NewElem = (_cmsStageCLutData*) _cmsMallocZero(ContextID, sizeof(_cmsStageCLutData)); |
693 |
if (NewElem == NULL) { |
|
694 |
cmsStageFree(NewMPE); |
|
695 |
return NULL; |
|
696 |
} |
|
697 |
||
698 |
NewMPE ->Data = (void*) NewElem; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
699 |
|
14300 | 700 |
// There is a potential integer overflow on conputing n and nEntries. |
701 |
NewElem -> nEntries = n = outputChan * CubeSize(clutPoints, inputChan); |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
702 |
NewElem -> HasFloatValues = TRUE; |
2394 | 703 |
|
14300 | 704 |
if (n == 0) { |
705 |
cmsStageFree(NewMPE); |
|
706 |
return NULL; |
|
707 |
} |
|
708 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
709 |
NewElem ->Tab.TFloat = (cmsFloat32Number*) _cmsCalloc(ContextID, n, sizeof(cmsFloat32Number)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
710 |
if (NewElem ->Tab.TFloat == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
711 |
cmsStageFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
712 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
713 |
} |
2394 | 714 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
715 |
if (Table != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
716 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
717 |
NewElem ->Tab.TFloat[i] = Table[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
718 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
719 |
} |
2394 | 720 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
721 |
NewElem ->Params = _cmsComputeInterpParamsEx(ContextID, clutPoints, inputChan, outputChan, NewElem ->Tab.TFloat, CMS_LERP_FLAGS_FLOAT); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
722 |
if (NewElem ->Params == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
723 |
cmsStageFree(NewMPE); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
724 |
return NULL; |
2394 | 725 |
} |
726 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
727 |
return NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
728 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
729 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
730 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
731 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
732 |
int IdentitySampler(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register void * Cargo) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
733 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
734 |
int nChan = *(int*) Cargo; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
735 |
int i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
736 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
737 |
for (i=0; i < nChan; i++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
738 |
Out[i] = In[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
739 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
740 |
return 1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
741 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
742 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
743 |
// Creates an MPE that just copies input to output |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
744 |
cmsStage* _cmsStageAllocIdentityCLut(cmsContext ContextID, int nChan) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
745 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
746 |
cmsUInt32Number Dimensions[MAX_INPUT_DIMENSIONS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
747 |
cmsStage* mpe ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
748 |
int i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
749 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
750 |
for (i=0; i < MAX_INPUT_DIMENSIONS; i++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
751 |
Dimensions[i] = 2; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
752 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
753 |
mpe = cmsStageAllocCLut16bitGranular(ContextID, Dimensions, nChan, nChan, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
754 |
if (mpe == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
755 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
756 |
if (!cmsStageSampleCLut16bit(mpe, IdentitySampler, &nChan, 0)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
757 |
cmsStageFree(mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
758 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
759 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
760 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
761 |
mpe ->Implements = cmsSigIdentityElemType; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
762 |
return mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
763 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
764 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
765 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
766 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
767 |
// Quantize a value 0 <= i < MaxSamples to 0..0xffff |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
768 |
cmsUInt16Number _cmsQuantizeVal(cmsFloat64Number i, int MaxSamples) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
769 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
770 |
cmsFloat64Number x; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
771 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
772 |
x = ((cmsFloat64Number) i * 65535.) / (cmsFloat64Number) (MaxSamples - 1); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
773 |
return _cmsQuickSaturateWord(x); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
774 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
775 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
776 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
777 |
// This routine does a sweep on whole input space, and calls its callback |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
778 |
// function on knots. returns TRUE if all ok, FALSE otherwise. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
779 |
cmsBool CMSEXPORT cmsStageSampleCLut16bit(cmsStage* mpe, cmsSAMPLER16 Sampler, void * Cargo, cmsUInt32Number dwFlags) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
780 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
781 |
int i, t, nTotalPoints, index, rest; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
782 |
int nInputs, nOutputs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
783 |
cmsUInt32Number* nSamples; |
23906 | 784 |
cmsUInt16Number In[MAX_INPUT_DIMENSIONS+1], Out[MAX_STAGE_CHANNELS]; |
14300 | 785 |
_cmsStageCLutData* clut; |
786 |
||
787 |
if (mpe == NULL) return FALSE; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
788 |
|
14300 | 789 |
clut = (_cmsStageCLutData*) mpe->Data; |
790 |
||
791 |
if (clut == NULL) return FALSE; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
792 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
793 |
nSamples = clut->Params ->nSamples; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
794 |
nInputs = clut->Params ->nInputs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
795 |
nOutputs = clut->Params ->nOutputs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
796 |
|
23906 | 797 |
if (nInputs <= 0) return FALSE; |
798 |
if (nOutputs <= 0) return FALSE; |
|
799 |
if (nInputs > MAX_INPUT_DIMENSIONS) return FALSE; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
800 |
if (nOutputs >= MAX_STAGE_CHANNELS) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
801 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
802 |
nTotalPoints = CubeSize(nSamples, nInputs); |
14300 | 803 |
if (nTotalPoints == 0) return FALSE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
804 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
805 |
index = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
806 |
for (i = 0; i < nTotalPoints; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
807 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
808 |
rest = i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
809 |
for (t = nInputs-1; t >=0; --t) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
810 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
811 |
cmsUInt32Number Colorant = rest % nSamples[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
812 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
813 |
rest /= nSamples[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
814 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
815 |
In[t] = _cmsQuantizeVal(Colorant, nSamples[t]); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
816 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
817 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
818 |
if (clut ->Tab.T != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
819 |
for (t=0; t < nOutputs; t++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
820 |
Out[t] = clut->Tab.T[index + t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
821 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
822 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
823 |
if (!Sampler(In, Out, Cargo)) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
824 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
825 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
826 |
if (!(dwFlags & SAMPLER_INSPECT)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
827 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
828 |
if (clut ->Tab.T != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
829 |
for (t=0; t < nOutputs; t++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
830 |
clut->Tab.T[index + t] = Out[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
831 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
832 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
833 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
834 |
index += nOutputs; |
2394 | 835 |
} |
836 |
||
837 |
return TRUE; |
|
838 |
} |
|
839 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
840 |
// Same as anterior, but for floting point |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
841 |
cmsBool CMSEXPORT cmsStageSampleCLutFloat(cmsStage* mpe, cmsSAMPLERFLOAT Sampler, void * Cargo, cmsUInt32Number dwFlags) |
2 | 842 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
843 |
int i, t, nTotalPoints, index, rest; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
844 |
int nInputs, nOutputs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
845 |
cmsUInt32Number* nSamples; |
23906 | 846 |
cmsFloat32Number In[MAX_INPUT_DIMENSIONS+1], Out[MAX_STAGE_CHANNELS]; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
847 |
_cmsStageCLutData* clut = (_cmsStageCLutData*) mpe->Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
848 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
849 |
nSamples = clut->Params ->nSamples; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
850 |
nInputs = clut->Params ->nInputs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
851 |
nOutputs = clut->Params ->nOutputs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
852 |
|
23906 | 853 |
if (nInputs <= 0) return FALSE; |
854 |
if (nOutputs <= 0) return FALSE; |
|
855 |
if (nInputs > MAX_INPUT_DIMENSIONS) return FALSE; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
856 |
if (nOutputs >= MAX_STAGE_CHANNELS) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
857 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
858 |
nTotalPoints = CubeSize(nSamples, nInputs); |
14300 | 859 |
if (nTotalPoints == 0) return FALSE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
860 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
861 |
index = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
862 |
for (i = 0; i < nTotalPoints; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
863 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
864 |
rest = i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
865 |
for (t = nInputs-1; t >=0; --t) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
866 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
867 |
cmsUInt32Number Colorant = rest % nSamples[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
868 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
869 |
rest /= nSamples[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
870 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
871 |
In[t] = (cmsFloat32Number) (_cmsQuantizeVal(Colorant, nSamples[t]) / 65535.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
872 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
873 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
874 |
if (clut ->Tab.TFloat != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
875 |
for (t=0; t < nOutputs; t++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
876 |
Out[t] = clut->Tab.TFloat[index + t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
877 |
} |
2 | 878 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
879 |
if (!Sampler(In, Out, Cargo)) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
880 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
881 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
882 |
if (!(dwFlags & SAMPLER_INSPECT)) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
883 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
884 |
if (clut ->Tab.TFloat != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
885 |
for (t=0; t < nOutputs; t++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
886 |
clut->Tab.TFloat[index + t] = Out[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
887 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
888 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
889 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
890 |
index += nOutputs; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
891 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
892 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
893 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
894 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
895 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
896 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
897 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
898 |
// This routine does a sweep on whole input space, and calls its callback |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
899 |
// function on knots. returns TRUE if all ok, FALSE otherwise. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
900 |
cmsBool CMSEXPORT cmsSliceSpace16(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
901 |
cmsSAMPLER16 Sampler, void * Cargo) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
902 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
903 |
int i, t, nTotalPoints, rest; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
904 |
cmsUInt16Number In[cmsMAXCHANNELS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
905 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
906 |
if (nInputs >= cmsMAXCHANNELS) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
907 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
908 |
nTotalPoints = CubeSize(clutPoints, nInputs); |
14300 | 909 |
if (nTotalPoints == 0) return FALSE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
910 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
911 |
for (i = 0; i < nTotalPoints; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
912 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
913 |
rest = i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
914 |
for (t = nInputs-1; t >=0; --t) { |
2 | 915 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
916 |
cmsUInt32Number Colorant = rest % clutPoints[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
917 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
918 |
rest /= clutPoints[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
919 |
In[t] = _cmsQuantizeVal(Colorant, clutPoints[t]); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
920 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
921 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
922 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
923 |
if (!Sampler(In, NULL, Cargo)) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
924 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
925 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
926 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
927 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
928 |
} |
2 | 929 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
930 |
cmsInt32Number CMSEXPORT cmsSliceSpaceFloat(cmsUInt32Number nInputs, const cmsUInt32Number clutPoints[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
931 |
cmsSAMPLERFLOAT Sampler, void * Cargo) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
932 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
933 |
int i, t, nTotalPoints, rest; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
934 |
cmsFloat32Number In[cmsMAXCHANNELS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
935 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
936 |
if (nInputs >= cmsMAXCHANNELS) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
937 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
938 |
nTotalPoints = CubeSize(clutPoints, nInputs); |
14300 | 939 |
if (nTotalPoints == 0) return FALSE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
940 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
941 |
for (i = 0; i < nTotalPoints; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
942 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
943 |
rest = i; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
944 |
for (t = nInputs-1; t >=0; --t) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
945 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
946 |
cmsUInt32Number Colorant = rest % clutPoints[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
947 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
948 |
rest /= clutPoints[t]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
949 |
In[t] = (cmsFloat32Number) (_cmsQuantizeVal(Colorant, clutPoints[t]) / 65535.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
950 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
951 |
} |
2 | 952 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
953 |
if (!Sampler(In, NULL, Cargo)) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
954 |
return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
955 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
956 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
957 |
return TRUE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
958 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
959 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
960 |
// ******************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
961 |
// Type cmsSigLab2XYZElemType |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
962 |
// ******************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
963 |
|
2394 | 964 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
965 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
966 |
void EvaluateLab2XYZ(const cmsFloat32Number In[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
967 |
cmsFloat32Number Out[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
968 |
const cmsStage *mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
969 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
970 |
cmsCIELab Lab; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
971 |
cmsCIEXYZ XYZ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
972 |
const cmsFloat64Number XYZadj = MAX_ENCODEABLE_XYZ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
973 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
974 |
// V4 rules |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
975 |
Lab.L = In[0] * 100.0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
976 |
Lab.a = In[1] * 255.0 - 128.0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
977 |
Lab.b = In[2] * 255.0 - 128.0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
978 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
979 |
cmsLab2XYZ(NULL, &XYZ, &Lab); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
980 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
981 |
// From XYZ, range 0..19997 to 0..1.0, note that 1.99997 comes from 0xffff |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
982 |
// encoded as 1.15 fixed point, so 1 + (32767.0 / 32768.0) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
983 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
984 |
Out[0] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.X / XYZadj); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
985 |
Out[1] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.Y / XYZadj); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
986 |
Out[2] = (cmsFloat32Number) ((cmsFloat64Number) XYZ.Z / XYZadj); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
987 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
988 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
989 |
cmsUNUSED_PARAMETER(mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
990 |
} |
2 | 991 |
|
992 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
993 |
// No dup or free routines needed, as the structure has no pointers in it. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
994 |
cmsStage* _cmsStageAllocLab2XYZ(cmsContext ContextID) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
995 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
996 |
return _cmsStageAllocPlaceholder(ContextID, cmsSigLab2XYZElemType, 3, 3, EvaluateLab2XYZ, NULL, NULL, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
997 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
998 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
999 |
// ******************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1000 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1001 |
// v2 L=100 is supposed to be placed on 0xFF00. There is no reasonable |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1002 |
// number of gridpoints that would make exact match. However, a prelinearization |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1003 |
// of 258 entries, would map 0xFF00 exactly on entry 257, and this is good to avoid scum dot. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1004 |
// Almost all what we need but unfortunately, the rest of entries should be scaled by |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1005 |
// (255*257/256) and this is not exact. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1006 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1007 |
cmsStage* _cmsStageAllocLabV2ToV4curves(cmsContext ContextID) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1008 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1009 |
cmsStage* mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1010 |
cmsToneCurve* LabTable[3]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1011 |
int i, j; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1012 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1013 |
LabTable[0] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1014 |
LabTable[1] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1015 |
LabTable[2] = cmsBuildTabulatedToneCurve16(ContextID, 258, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1016 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1017 |
for (j=0; j < 3; j++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1018 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1019 |
if (LabTable[j] == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1020 |
cmsFreeToneCurveTriple(LabTable); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1021 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1022 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1023 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1024 |
// We need to map * (0xffff / 0xff00), thats same as (257 / 256) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1025 |
// So we can use 258-entry tables to do the trick (i / 257) * (255 * 257) * (257 / 256); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1026 |
for (i=0; i < 257; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1027 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1028 |
LabTable[j]->Table16[i] = (cmsUInt16Number) ((i * 0xffff + 0x80) >> 8); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1029 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1030 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1031 |
LabTable[j] ->Table16[257] = 0xffff; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1032 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1033 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1034 |
mpe = cmsStageAllocToneCurves(ContextID, 3, LabTable); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1035 |
cmsFreeToneCurveTriple(LabTable); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1036 |
|
23906 | 1037 |
if (mpe == NULL) return NULL; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1038 |
mpe ->Implements = cmsSigLabV2toV4; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1039 |
return mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1040 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1041 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1042 |
// ******************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1043 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1044 |
// Matrix-based conversion, which is more accurate, but slower and cannot properly be saved in devicelink profiles |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1045 |
cmsStage* _cmsStageAllocLabV2ToV4(cmsContext ContextID) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1046 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1047 |
static const cmsFloat64Number V2ToV4[] = { 65535.0/65280.0, 0, 0, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1048 |
0, 65535.0/65280.0, 0, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1049 |
0, 0, 65535.0/65280.0 |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1050 |
}; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1051 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1052 |
cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, V2ToV4, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1053 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1054 |
if (mpe == NULL) return mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1055 |
mpe ->Implements = cmsSigLabV2toV4; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1056 |
return mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1057 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1058 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1059 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1060 |
// Reverse direction |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1061 |
cmsStage* _cmsStageAllocLabV4ToV2(cmsContext ContextID) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1062 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1063 |
static const cmsFloat64Number V4ToV2[] = { 65280.0/65535.0, 0, 0, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1064 |
0, 65280.0/65535.0, 0, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1065 |
0, 0, 65280.0/65535.0 |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1066 |
}; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1067 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1068 |
cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, V4ToV2, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1069 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1070 |
if (mpe == NULL) return mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1071 |
mpe ->Implements = cmsSigLabV4toV2; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1072 |
return mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1073 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1074 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1075 |
|
14300 | 1076 |
// To Lab to float. Note that the MPE gives numbers in normal Lab range |
1077 |
// and we need 0..1.0 range for the formatters |
|
1078 |
// L* : 0...100 => 0...1.0 (L* / 100) |
|
1079 |
// ab* : -128..+127 to 0..1 ((ab* + 128) / 255) |
|
1080 |
||
1081 |
cmsStage* _cmsStageNormalizeFromLabFloat(cmsContext ContextID) |
|
1082 |
{ |
|
1083 |
static const cmsFloat64Number a1[] = { |
|
1084 |
1.0/100.0, 0, 0, |
|
1085 |
0, 1.0/255.0, 0, |
|
1086 |
0, 0, 1.0/255.0 |
|
1087 |
}; |
|
1088 |
||
1089 |
static const cmsFloat64Number o1[] = { |
|
1090 |
0, |
|
1091 |
128.0/255.0, |
|
1092 |
128.0/255.0 |
|
1093 |
}; |
|
1094 |
||
1095 |
cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, o1); |
|
1096 |
||
1097 |
if (mpe == NULL) return mpe; |
|
1098 |
mpe ->Implements = cmsSigLab2FloatPCS; |
|
1099 |
return mpe; |
|
1100 |
} |
|
1101 |
||
1102 |
// Fom XYZ to floating point PCS |
|
1103 |
cmsStage* _cmsStageNormalizeFromXyzFloat(cmsContext ContextID) |
|
1104 |
{ |
|
1105 |
#define n (32768.0/65535.0) |
|
1106 |
static const cmsFloat64Number a1[] = { |
|
1107 |
n, 0, 0, |
|
1108 |
0, n, 0, |
|
1109 |
0, 0, n |
|
1110 |
}; |
|
1111 |
#undef n |
|
1112 |
||
1113 |
cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL); |
|
1114 |
||
1115 |
if (mpe == NULL) return mpe; |
|
1116 |
mpe ->Implements = cmsSigXYZ2FloatPCS; |
|
1117 |
return mpe; |
|
1118 |
} |
|
1119 |
||
1120 |
cmsStage* _cmsStageNormalizeToLabFloat(cmsContext ContextID) |
|
1121 |
{ |
|
1122 |
static const cmsFloat64Number a1[] = { |
|
1123 |
100.0, 0, 0, |
|
1124 |
0, 255.0, 0, |
|
1125 |
0, 0, 255.0 |
|
1126 |
}; |
|
1127 |
||
1128 |
static const cmsFloat64Number o1[] = { |
|
1129 |
0, |
|
1130 |
-128.0, |
|
1131 |
-128.0 |
|
1132 |
}; |
|
1133 |
||
1134 |
cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, o1); |
|
1135 |
if (mpe == NULL) return mpe; |
|
1136 |
mpe ->Implements = cmsSigFloatPCS2Lab; |
|
1137 |
return mpe; |
|
1138 |
} |
|
1139 |
||
1140 |
cmsStage* _cmsStageNormalizeToXyzFloat(cmsContext ContextID) |
|
1141 |
{ |
|
1142 |
#define n (65535.0/32768.0) |
|
1143 |
||
1144 |
static const cmsFloat64Number a1[] = { |
|
1145 |
n, 0, 0, |
|
1146 |
0, n, 0, |
|
1147 |
0, 0, n |
|
1148 |
}; |
|
1149 |
#undef n |
|
1150 |
||
1151 |
cmsStage *mpe = cmsStageAllocMatrix(ContextID, 3, 3, a1, NULL); |
|
1152 |
if (mpe == NULL) return mpe; |
|
1153 |
mpe ->Implements = cmsSigFloatPCS2XYZ; |
|
1154 |
return mpe; |
|
1155 |
} |
|
1156 |
||
1157 |
||
1158 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1159 |
// ******************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1160 |
// Type cmsSigXYZ2LabElemType |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1161 |
// ******************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1162 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1163 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1164 |
void EvaluateXYZ2Lab(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsStage *mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1165 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1166 |
cmsCIELab Lab; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1167 |
cmsCIEXYZ XYZ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1168 |
const cmsFloat64Number XYZadj = MAX_ENCODEABLE_XYZ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1169 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1170 |
// From 0..1.0 to XYZ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1171 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1172 |
XYZ.X = In[0] * XYZadj; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1173 |
XYZ.Y = In[1] * XYZadj; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1174 |
XYZ.Z = In[2] * XYZadj; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1175 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1176 |
cmsXYZ2Lab(NULL, &Lab, &XYZ); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1177 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1178 |
// From V4 Lab to 0..1.0 |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1179 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1180 |
Out[0] = (cmsFloat32Number) (Lab.L / 100.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1181 |
Out[1] = (cmsFloat32Number) ((Lab.a + 128.0) / 255.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1182 |
Out[2] = (cmsFloat32Number) ((Lab.b + 128.0) / 255.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1183 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1184 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1185 |
cmsUNUSED_PARAMETER(mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1186 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1187 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1188 |
cmsStage* _cmsStageAllocXYZ2Lab(cmsContext ContextID) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1189 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1190 |
return _cmsStageAllocPlaceholder(ContextID, cmsSigXYZ2LabElemType, 3, 3, EvaluateXYZ2Lab, NULL, NULL, NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1191 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1192 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1193 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1194 |
// ******************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1195 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1196 |
// For v4, S-Shaped curves are placed in a/b axis to increase resolution near gray |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1197 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1198 |
cmsStage* _cmsStageAllocLabPrelin(cmsContext ContextID) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1199 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1200 |
cmsToneCurve* LabTable[3]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1201 |
cmsFloat64Number Params[1] = {2.4} ; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1202 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1203 |
LabTable[0] = cmsBuildGamma(ContextID, 1.0); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1204 |
LabTable[1] = cmsBuildParametricToneCurve(ContextID, 108, Params); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1205 |
LabTable[2] = cmsBuildParametricToneCurve(ContextID, 108, Params); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1206 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1207 |
return cmsStageAllocToneCurves(ContextID, 3, LabTable); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1208 |
} |
2 | 1209 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1210 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1211 |
// Free a single MPE |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1212 |
void CMSEXPORT cmsStageFree(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1213 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1214 |
if (mpe ->FreePtr) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1215 |
mpe ->FreePtr(mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1216 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1217 |
_cmsFree(mpe ->ContextID, mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1218 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1219 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1220 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1221 |
cmsUInt32Number CMSEXPORT cmsStageInputChannels(const cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1222 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1223 |
return mpe ->InputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1224 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1225 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1226 |
cmsUInt32Number CMSEXPORT cmsStageOutputChannels(const cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1227 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1228 |
return mpe ->OutputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1229 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1230 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1231 |
cmsStageSignature CMSEXPORT cmsStageType(const cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1232 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1233 |
return mpe -> Type; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1234 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1235 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1236 |
void* CMSEXPORT cmsStageData(const cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1237 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1238 |
return mpe -> Data; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1239 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1240 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1241 |
cmsStage* CMSEXPORT cmsStageNext(const cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1242 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1243 |
return mpe -> Next; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1244 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1245 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1246 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1247 |
// Duplicates an MPE |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1248 |
cmsStage* CMSEXPORT cmsStageDup(cmsStage* mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1249 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1250 |
cmsStage* NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1251 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1252 |
if (mpe == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1253 |
NewMPE = _cmsStageAllocPlaceholder(mpe ->ContextID, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1254 |
mpe ->Type, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1255 |
mpe ->InputChannels, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1256 |
mpe ->OutputChannels, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1257 |
mpe ->EvalPtr, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1258 |
mpe ->DupElemPtr, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1259 |
mpe ->FreePtr, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1260 |
NULL); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1261 |
if (NewMPE == NULL) return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1262 |
|
23906 | 1263 |
NewMPE ->Implements = mpe ->Implements; |
1264 |
||
1265 |
if (mpe ->DupElemPtr) { |
|
1266 |
||
1267 |
NewMPE ->Data = mpe ->DupElemPtr(mpe); |
|
1268 |
||
1269 |
if (NewMPE->Data == NULL) { |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1270 |
|
23906 | 1271 |
cmsStageFree(NewMPE); |
1272 |
return NULL; |
|
1273 |
} |
|
1274 |
||
1275 |
} else { |
|
1276 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1277 |
NewMPE ->Data = NULL; |
23906 | 1278 |
} |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1279 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1280 |
return NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1281 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1282 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1283 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1284 |
// *********************************************************************************************************** |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1285 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1286 |
// This function sets up the channel count |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1287 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1288 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1289 |
void BlessLUT(cmsPipeline* lut) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1290 |
{ |
23906 | 1291 |
// We can set the input/ouput channels only if we have elements. |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1292 |
if (lut ->Elements != NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1293 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1294 |
cmsStage *First, *Last; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1295 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1296 |
First = cmsPipelineGetPtrToFirstStage(lut); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1297 |
Last = cmsPipelineGetPtrToLastStage(lut); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1298 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1299 |
if (First != NULL)lut ->InputChannels = First ->InputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1300 |
if (Last != NULL) lut ->OutputChannels = Last ->OutputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1301 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1302 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1303 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1304 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1305 |
// Default to evaluate the LUT on 16 bit-basis. Precision is retained. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1306 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1307 |
void _LUTeval16(register const cmsUInt16Number In[], register cmsUInt16Number Out[], register const void* D) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1308 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1309 |
cmsPipeline* lut = (cmsPipeline*) D; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1310 |
cmsStage *mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1311 |
cmsFloat32Number Storage[2][MAX_STAGE_CHANNELS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1312 |
int Phase = 0, NextPhase; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1313 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1314 |
From16ToFloat(In, &Storage[Phase][0], lut ->InputChannels); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1315 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1316 |
for (mpe = lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1317 |
mpe != NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1318 |
mpe = mpe ->Next) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1319 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1320 |
NextPhase = Phase ^ 1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1321 |
mpe ->EvalPtr(&Storage[Phase][0], &Storage[NextPhase][0], mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1322 |
Phase = NextPhase; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1323 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1324 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1325 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1326 |
FromFloatTo16(&Storage[Phase][0], Out, lut ->OutputChannels); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1327 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1328 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1329 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1330 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1331 |
// Does evaluate the LUT on cmsFloat32Number-basis. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1332 |
static |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1333 |
void _LUTevalFloat(register const cmsFloat32Number In[], register cmsFloat32Number Out[], const void* D) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1334 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1335 |
cmsPipeline* lut = (cmsPipeline*) D; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1336 |
cmsStage *mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1337 |
cmsFloat32Number Storage[2][MAX_STAGE_CHANNELS]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1338 |
int Phase = 0, NextPhase; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1339 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1340 |
memmove(&Storage[Phase][0], In, lut ->InputChannels * sizeof(cmsFloat32Number)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1341 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1342 |
for (mpe = lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1343 |
mpe != NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1344 |
mpe = mpe ->Next) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1345 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1346 |
NextPhase = Phase ^ 1; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1347 |
mpe ->EvalPtr(&Storage[Phase][0], &Storage[NextPhase][0], mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1348 |
Phase = NextPhase; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1349 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1350 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1351 |
memmove(Out, &Storage[Phase][0], lut ->OutputChannels * sizeof(cmsFloat32Number)); |
2 | 1352 |
} |
1353 |
||
1354 |
||
1355 |
||
1356 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1357 |
// LUT Creation & Destruction |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1358 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1359 |
cmsPipeline* CMSEXPORT cmsPipelineAlloc(cmsContext ContextID, cmsUInt32Number InputChannels, cmsUInt32Number OutputChannels) |
2 | 1360 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1361 |
cmsPipeline* NewLUT; |
2 | 1362 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1363 |
if (InputChannels >= cmsMAXCHANNELS || |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1364 |
OutputChannels >= cmsMAXCHANNELS) return NULL; |
2 | 1365 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1366 |
NewLUT = (cmsPipeline*) _cmsMallocZero(ContextID, sizeof(cmsPipeline)); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1367 |
if (NewLUT == NULL) return NULL; |
2 | 1368 |
|
1369 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1370 |
NewLUT -> InputChannels = InputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1371 |
NewLUT -> OutputChannels = OutputChannels; |
2 | 1372 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1373 |
NewLUT ->Eval16Fn = _LUTeval16; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1374 |
NewLUT ->EvalFloatFn = _LUTevalFloat; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1375 |
NewLUT ->DupDataFn = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1376 |
NewLUT ->FreeDataFn = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1377 |
NewLUT ->Data = NewLUT; |
14300 | 1378 |
NewLUT ->ContextID = ContextID; |
2394 | 1379 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1380 |
BlessLUT(NewLUT); |
2 | 1381 |
|
1382 |
return NewLUT; |
|
1383 |
} |
|
1384 |
||
14300 | 1385 |
cmsContext CMSEXPORT cmsGetPipelineContextID(const cmsPipeline* lut) |
1386 |
{ |
|
1387 |
_cmsAssert(lut != NULL); |
|
1388 |
return lut ->ContextID; |
|
1389 |
} |
|
2 | 1390 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1391 |
cmsUInt32Number CMSEXPORT cmsPipelineInputChannels(const cmsPipeline* lut) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1392 |
{ |
14300 | 1393 |
_cmsAssert(lut != NULL); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1394 |
return lut ->InputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1395 |
} |
2 | 1396 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1397 |
cmsUInt32Number CMSEXPORT cmsPipelineOutputChannels(const cmsPipeline* lut) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1398 |
{ |
14300 | 1399 |
_cmsAssert(lut != NULL); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1400 |
return lut ->OutputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1401 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1402 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1403 |
// Free a profile elements LUT |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1404 |
void CMSEXPORT cmsPipelineFree(cmsPipeline* lut) |
2 | 1405 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1406 |
cmsStage *mpe, *Next; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1407 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1408 |
if (lut == NULL) return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1409 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1410 |
for (mpe = lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1411 |
mpe != NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1412 |
mpe = Next) { |
2 | 1413 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1414 |
Next = mpe ->Next; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1415 |
cmsStageFree(mpe); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1416 |
} |
2 | 1417 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1418 |
if (lut ->FreeDataFn) lut ->FreeDataFn(lut ->ContextID, lut ->Data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1419 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1420 |
_cmsFree(lut ->ContextID, lut); |
2 | 1421 |
} |
1422 |
||
1423 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1424 |
// Default to evaluate the LUT on 16 bit-basis. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1425 |
void CMSEXPORT cmsPipelineEval16(const cmsUInt16Number In[], cmsUInt16Number Out[], const cmsPipeline* lut) |
2 | 1426 |
{ |
14300 | 1427 |
_cmsAssert(lut != NULL); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1428 |
lut ->Eval16Fn(In, Out, lut->Data); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1429 |
} |
2 | 1430 |
|
1431 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1432 |
// Does evaluate the LUT on cmsFloat32Number-basis. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1433 |
void CMSEXPORT cmsPipelineEvalFloat(const cmsFloat32Number In[], cmsFloat32Number Out[], const cmsPipeline* lut) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1434 |
{ |
14300 | 1435 |
_cmsAssert(lut != NULL); |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1436 |
lut ->EvalFloatFn(In, Out, lut); |
2 | 1437 |
} |
1438 |
||
1439 |
||
1440 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1441 |
// Duplicates a LUT |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1442 |
cmsPipeline* CMSEXPORT cmsPipelineDup(const cmsPipeline* lut) |
2 | 1443 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1444 |
cmsPipeline* NewLUT; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1445 |
cmsStage *NewMPE, *Anterior = NULL, *mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1446 |
cmsBool First = TRUE; |
2 | 1447 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1448 |
if (lut == NULL) return NULL; |
2 | 1449 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1450 |
NewLUT = cmsPipelineAlloc(lut ->ContextID, lut ->InputChannels, lut ->OutputChannels); |
18210 | 1451 |
if (NewLUT == NULL) return NULL; |
1452 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1453 |
for (mpe = lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1454 |
mpe != NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1455 |
mpe = mpe ->Next) { |
2 | 1456 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1457 |
NewMPE = cmsStageDup(mpe); |
2 | 1458 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1459 |
if (NewMPE == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1460 |
cmsPipelineFree(NewLUT); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1461 |
return NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1462 |
} |
2 | 1463 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1464 |
if (First) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1465 |
NewLUT ->Elements = NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1466 |
First = FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1467 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1468 |
else { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1469 |
Anterior ->Next = NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1470 |
} |
2 | 1471 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1472 |
Anterior = NewMPE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1473 |
} |
2 | 1474 |
|
14300 | 1475 |
NewLUT ->Eval16Fn = lut ->Eval16Fn; |
1476 |
NewLUT ->EvalFloatFn = lut ->EvalFloatFn; |
|
1477 |
NewLUT ->DupDataFn = lut ->DupDataFn; |
|
1478 |
NewLUT ->FreeDataFn = lut ->FreeDataFn; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1479 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1480 |
if (NewLUT ->DupDataFn != NULL) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1481 |
NewLUT ->Data = NewLUT ->DupDataFn(lut ->ContextID, lut->Data); |
2 | 1482 |
|
1483 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1484 |
NewLUT ->SaveAs8Bits = lut ->SaveAs8Bits; |
2 | 1485 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1486 |
BlessLUT(NewLUT); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1487 |
return NewLUT; |
2 | 1488 |
} |
1489 |
||
1490 |
||
23906 | 1491 |
int CMSEXPORT cmsPipelineInsertStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage* mpe) |
2 | 1492 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1493 |
cmsStage* Anterior = NULL, *pt; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1494 |
|
23906 | 1495 |
if (lut == NULL || mpe == NULL) |
1496 |
return FALSE; |
|
14300 | 1497 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1498 |
switch (loc) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1499 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1500 |
case cmsAT_BEGIN: |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1501 |
mpe ->Next = lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1502 |
lut ->Elements = mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1503 |
break; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1504 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1505 |
case cmsAT_END: |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1506 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1507 |
if (lut ->Elements == NULL) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1508 |
lut ->Elements = mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1509 |
else { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1510 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1511 |
for (pt = lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1512 |
pt != NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1513 |
pt = pt -> Next) Anterior = pt; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1514 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1515 |
Anterior ->Next = mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1516 |
mpe ->Next = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1517 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1518 |
break; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1519 |
default:; |
23906 | 1520 |
return FALSE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1521 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1522 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1523 |
BlessLUT(lut); |
23906 | 1524 |
return TRUE; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1525 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1526 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1527 |
// Unlink an element and return the pointer to it |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1528 |
void CMSEXPORT cmsPipelineUnlinkStage(cmsPipeline* lut, cmsStageLoc loc, cmsStage** mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1529 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1530 |
cmsStage *Anterior, *pt, *Last; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1531 |
cmsStage *Unlinked = NULL; |
2 | 1532 |
|
1533 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1534 |
// If empty LUT, there is nothing to remove |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1535 |
if (lut ->Elements == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1536 |
if (mpe) *mpe = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1537 |
return; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1538 |
} |
2 | 1539 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1540 |
// On depending on the strategy... |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1541 |
switch (loc) { |
2 | 1542 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1543 |
case cmsAT_BEGIN: |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1544 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1545 |
cmsStage* elem = lut ->Elements; |
2 | 1546 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1547 |
lut ->Elements = elem -> Next; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1548 |
elem ->Next = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1549 |
Unlinked = elem; |
2 | 1550 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1551 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1552 |
break; |
2 | 1553 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1554 |
case cmsAT_END: |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1555 |
Anterior = Last = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1556 |
for (pt = lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1557 |
pt != NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1558 |
pt = pt -> Next) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1559 |
Anterior = Last; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1560 |
Last = pt; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1561 |
} |
2 | 1562 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1563 |
Unlinked = Last; // Next already points to NULL |
2 | 1564 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1565 |
// Truncate the chain |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1566 |
if (Anterior) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1567 |
Anterior ->Next = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1568 |
else |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1569 |
lut ->Elements = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1570 |
break; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1571 |
default:; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1572 |
} |
2 | 1573 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1574 |
if (mpe) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1575 |
*mpe = Unlinked; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1576 |
else |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1577 |
cmsStageFree(Unlinked); |
2 | 1578 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1579 |
BlessLUT(lut); |
2 | 1580 |
} |
1581 |
||
1582 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1583 |
// Concatenate two LUT into a new single one |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1584 |
cmsBool CMSEXPORT cmsPipelineCat(cmsPipeline* l1, const cmsPipeline* l2) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1585 |
{ |
23906 | 1586 |
cmsStage* mpe; |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1587 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1588 |
// If both LUTS does not have elements, we need to inherit |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1589 |
// the number of channels |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1590 |
if (l1 ->Elements == NULL && l2 ->Elements == NULL) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1591 |
l1 ->InputChannels = l2 ->InputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1592 |
l1 ->OutputChannels = l2 ->OutputChannels; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1593 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1594 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1595 |
// Cat second |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1596 |
for (mpe = l2 ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1597 |
mpe != NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1598 |
mpe = mpe ->Next) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1599 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1600 |
// We have to dup each element |
23906 | 1601 |
if (!cmsPipelineInsertStage(l1, cmsAT_END, cmsStageDup(mpe))) |
1602 |
return FALSE; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1603 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1604 |
|
23906 | 1605 |
BlessLUT(l1); |
1606 |
return TRUE; |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1607 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1608 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1609 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1610 |
cmsBool CMSEXPORT cmsPipelineSetSaveAs8bitsFlag(cmsPipeline* lut, cmsBool On) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1611 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1612 |
cmsBool Anterior = lut ->SaveAs8Bits; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1613 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1614 |
lut ->SaveAs8Bits = On; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1615 |
return Anterior; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1616 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1617 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1618 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1619 |
cmsStage* CMSEXPORT cmsPipelineGetPtrToFirstStage(const cmsPipeline* lut) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1620 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1621 |
return lut ->Elements; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1622 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1623 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1624 |
cmsStage* CMSEXPORT cmsPipelineGetPtrToLastStage(const cmsPipeline* lut) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1625 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1626 |
cmsStage *mpe, *Anterior = NULL; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1627 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1628 |
for (mpe = lut ->Elements; mpe != NULL; mpe = mpe ->Next) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1629 |
Anterior = mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1630 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1631 |
return Anterior; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1632 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1633 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1634 |
cmsUInt32Number CMSEXPORT cmsPipelineStageCount(const cmsPipeline* lut) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1635 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1636 |
cmsStage *mpe; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1637 |
cmsUInt32Number n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1638 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1639 |
for (n=0, mpe = lut ->Elements; mpe != NULL; mpe = mpe ->Next) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1640 |
n++; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1641 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1642 |
return n; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1643 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1644 |
|
14300 | 1645 |
// This function may be used to set the optional evaluator and a block of private data. If private data is being used, an optional |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1646 |
// duplicator and free functions should also be specified in order to duplicate the LUT construct. Use NULL to inhibit such functionality. |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1647 |
void CMSEXPORT _cmsPipelineSetOptimizationParameters(cmsPipeline* Lut, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1648 |
_cmsOPTeval16Fn Eval16, |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1649 |
void* PrivateData, |
14300 | 1650 |
_cmsFreeUserDataFn FreePrivateDataFn, |
1651 |
_cmsDupUserDataFn DupPrivateDataFn) |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1652 |
{ |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1653 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1654 |
Lut ->Eval16Fn = Eval16; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1655 |
Lut ->DupDataFn = DupPrivateDataFn; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1656 |
Lut ->FreeDataFn = FreePrivateDataFn; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1657 |
Lut ->Data = PrivateData; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1658 |
} |
2 | 1659 |
|
1660 |
||
1661 |
// ----------------------------------------------------------- Reverse interpolation |
|
1662 |
// Here's how it goes. The derivative Df(x) of the function f is the linear |
|
1663 |
// transformation that best approximates f near the point x. It can be represented |
|
1664 |
// by a matrix A whose entries are the partial derivatives of the components of f |
|
1665 |
// with respect to all the coordinates. This is know as the Jacobian |
|
1666 |
// |
|
1667 |
// The best linear approximation to f is given by the matrix equation: |
|
1668 |
// |
|
1669 |
// y-y0 = A (x-x0) |
|
1670 |
// |
|
1671 |
// So, if x0 is a good "guess" for the zero of f, then solving for the zero of this |
|
1672 |
// linear approximation will give a "better guess" for the zero of f. Thus let y=0, |
|
1673 |
// and since y0=f(x0) one can solve the above equation for x. This leads to the |
|
1674 |
// Newton's method formula: |
|
1675 |
// |
|
1676 |
// xn+1 = xn - A-1 f(xn) |
|
1677 |
// |
|
1678 |
// where xn+1 denotes the (n+1)-st guess, obtained from the n-th guess xn in the |
|
1679 |
// fashion described above. Iterating this will give better and better approximations |
|
1680 |
// if you have a "good enough" initial guess. |
|
1681 |
||
1682 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1683 |
#define JACOBIAN_EPSILON 0.001f |
2 | 1684 |
#define INVERSION_MAX_ITERATIONS 30 |
1685 |
||
1686 |
// Increment with reflexion on boundary |
|
1687 |
static |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1688 |
void IncDelta(cmsFloat32Number *Val) |
2 | 1689 |
{ |
1690 |
if (*Val < (1.0 - JACOBIAN_EPSILON)) |
|
1691 |
||
1692 |
*Val += JACOBIAN_EPSILON; |
|
1693 |
||
1694 |
else |
|
1695 |
*Val -= JACOBIAN_EPSILON; |
|
1696 |
||
1697 |
} |
|
1698 |
||
1699 |
||
1700 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1701 |
// Euclidean distance between two vectors of n elements each one |
2 | 1702 |
static |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1703 |
cmsFloat32Number EuclideanDistance(cmsFloat32Number a[], cmsFloat32Number b[], int n) |
2 | 1704 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1705 |
cmsFloat32Number sum = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1706 |
int i; |
2 | 1707 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1708 |
for (i=0; i < n; i++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1709 |
cmsFloat32Number dif = b[i] - a[i]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1710 |
sum += dif * dif; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1711 |
} |
2 | 1712 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1713 |
return sqrtf(sum); |
2 | 1714 |
} |
1715 |
||
1716 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1717 |
// Evaluate a LUT in reverse direction. It only searches on 3->3 LUT. Uses Newton method |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1718 |
// |
2 | 1719 |
// x1 <- x - [J(x)]^-1 * f(x) |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1720 |
// |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1721 |
// lut: The LUT on where to do the search |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1722 |
// Target: LabK, 3 values of Lab plus destination K which is fixed |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1723 |
// Result: The obtained CMYK |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1724 |
// Hint: Location where begin the search |
2 | 1725 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1726 |
cmsBool CMSEXPORT cmsPipelineEvalReverseFloat(cmsFloat32Number Target[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1727 |
cmsFloat32Number Result[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1728 |
cmsFloat32Number Hint[], |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1729 |
const cmsPipeline* lut) |
2 | 1730 |
{ |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1731 |
cmsUInt32Number i, j; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1732 |
cmsFloat64Number error, LastError = 1E20; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1733 |
cmsFloat32Number fx[4], x[4], xd[4], fxd[4]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1734 |
cmsVEC3 tmp, tmp2; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1735 |
cmsMAT3 Jacobian; |
2 | 1736 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1737 |
// Only 3->3 and 4->3 are supported |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1738 |
if (lut ->InputChannels != 3 && lut ->InputChannels != 4) return FALSE; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1739 |
if (lut ->OutputChannels != 3) return FALSE; |
2 | 1740 |
|
1741 |
// Take the hint as starting point if specified |
|
1742 |
if (Hint == NULL) { |
|
1743 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1744 |
// Begin at any point, we choose 1/3 of CMY axis |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1745 |
x[0] = x[1] = x[2] = 0.3f; |
2 | 1746 |
} |
1747 |
else { |
|
1748 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1749 |
// Only copy 3 channels from hint... |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1750 |
for (j=0; j < 3; j++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1751 |
x[j] = Hint[j]; |
2 | 1752 |
} |
1753 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1754 |
// If Lut is 4-dimensions, then grab target[3], which is fixed |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1755 |
if (lut ->InputChannels == 4) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1756 |
x[3] = Target[3]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1757 |
} |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1758 |
else x[3] = 0; // To keep lint happy |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1759 |
|
2 | 1760 |
|
1761 |
// Iterate |
|
1762 |
for (i = 0; i < INVERSION_MAX_ITERATIONS; i++) { |
|
1763 |
||
1764 |
// Get beginning fx |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1765 |
cmsPipelineEvalFloat(x, fx, lut); |
2 | 1766 |
|
1767 |
// Compute error |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1768 |
error = EuclideanDistance(fx, Target, 3); |
2 | 1769 |
|
1770 |
// If not convergent, return last safe value |
|
1771 |
if (error >= LastError) |
|
1772 |
break; |
|
1773 |
||
1774 |
// Keep latest values |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1775 |
LastError = error; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1776 |
for (j=0; j < lut ->InputChannels; j++) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1777 |
Result[j] = x[j]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1778 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1779 |
// Found an exact match? |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1780 |
if (error <= 0) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1781 |
break; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1782 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1783 |
// Obtain slope (the Jacobian) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1784 |
for (j = 0; j < 3; j++) { |
2 | 1785 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1786 |
xd[0] = x[0]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1787 |
xd[1] = x[1]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1788 |
xd[2] = x[2]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1789 |
xd[3] = x[3]; // Keep fixed channel |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1790 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1791 |
IncDelta(&xd[j]); |
2 | 1792 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1793 |
cmsPipelineEvalFloat(xd, fxd, lut); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1794 |
|
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1795 |
Jacobian.v[0].n[j] = ((fxd[0] - fx[0]) / JACOBIAN_EPSILON); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1796 |
Jacobian.v[1].n[j] = ((fxd[1] - fx[1]) / JACOBIAN_EPSILON); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1797 |
Jacobian.v[2].n[j] = ((fxd[2] - fx[2]) / JACOBIAN_EPSILON); |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1798 |
} |
2 | 1799 |
|
2394 | 1800 |
// Solve system |
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1801 |
tmp2.n[0] = fx[0] - Target[0]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1802 |
tmp2.n[1] = fx[1] - Target[1]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1803 |
tmp2.n[2] = fx[2] - Target[2]; |
2 | 1804 |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1805 |
if (!_cmsMAT3solve(&tmp, &Jacobian, &tmp2)) |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1806 |
return FALSE; |
2 | 1807 |
|
1808 |
// Move our guess |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1809 |
x[0] -= (cmsFloat32Number) tmp.n[0]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1810 |
x[1] -= (cmsFloat32Number) tmp.n[1]; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1811 |
x[2] -= (cmsFloat32Number) tmp.n[2]; |
2 | 1812 |
|
1813 |
// Some clipping.... |
|
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1814 |
for (j=0; j < 3; j++) { |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1815 |
if (x[j] < 0) x[j] = 0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1816 |
else |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1817 |
if (x[j] > 1.0) x[j] = 1.0; |
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1818 |
} |
2 | 1819 |
} |
1820 |
||
6482
0f6a4442b29e
6523398: OSS CMM: Need to implement writing ICC profile tags in new lcms library
bae
parents:
5506
diff
changeset
|
1821 |
return TRUE; |
2 | 1822 |
} |
2394 | 1823 |
|
14300 | 1824 |