13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 // This file is available under and governed by the GNU General Public
26 // License version 2 only, as published by the Free Software Foundation.
27 // However, the following notice accompanied the original version of this
28 // file:
29 //
30 //---------------------------------------------------------------------------------
31 //
32 // Little Color Management System
33 // Copyright (c) 1998-2010 Marti Maria Saguer
34 //
35 // Permission is hereby granted, free of charge, to any person obtaining
36 // a copy of this software and associated documentation files (the "Software"),
37 // to deal in the Software without restriction, including without limitation
38 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
39 // and/or sell copies of the Software, and to permit persons to whom the Software
40 // is furnished to do so, subject to the following conditions:
41 //
42 // The above copyright notice and this permission notice shall be included in
43 // all copies or substantial portions of the Software.
44 //
45 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
47 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
49 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
50 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
51 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52 //
53 //---------------------------------------------------------------------------------
93 } cmsFormatters16;
94
95 typedef struct {
96 cmsUInt32Number Type;
97 cmsUInt32Number Mask;
98 cmsFormatterFloat Frm;
99
100 } cmsFormattersFloat;
101
102
103 #define ANYSPACE COLORSPACE_SH(31)
104 #define ANYCHANNELS CHANNELS_SH(15)
105 #define ANYEXTRA EXTRA_SH(7)
106 #define ANYPLANAR PLANAR_SH(1)
107 #define ANYENDIAN ENDIAN16_SH(1)
108 #define ANYSWAP DOSWAP_SH(1)
109 #define ANYSWAPFIRST SWAPFIRST_SH(1)
110 #define ANYFLAVOR FLAVOR_SH(1)
111
112
113 // Supress waning about info never being used
114
115 #ifdef _MSC_VER
116 #pragma warning(disable : 4100)
117 #endif
118
119 // Unpacking routines (16 bits) ----------------------------------------------------------------------------------------
120
121
122 // Does almost everything but is slow
123 static
124 cmsUInt8Number* UnrollChunkyBytes(register _cmsTRANSFORM* info,
125 register cmsUInt16Number wIn[],
126 register cmsUInt8Number* accum,
127 register cmsUInt32Number Stride)
128 {
129 int nChan = T_CHANNELS(info -> InputFormat);
130 int DoSwap = T_DOSWAP(info ->InputFormat);
131 int Reverse = T_FLAVOR(info ->InputFormat);
132 int SwapFirst = T_SWAPFIRST(info -> InputFormat);
133 int Extra = T_EXTRA(info -> InputFormat);
3171 ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackFloatsFromFloat },
3172 { FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|
3173 ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackDoublesFromFloat },
3174 #ifndef CMS_NO_HALF_SUPPORT
3175 { FLOAT_SH(1)|BYTES_SH(2),
3176 ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackHalfFromFloat },
3177 #endif
3178
3179
3180
3181 };
3182
3183
3184 // Bit fields set to one in the mask are not compared
3185 static
3186 cmsFormatter _cmsGetStockOutputFormatter(cmsUInt32Number dwInput, cmsUInt32Number dwFlags)
3187 {
3188 cmsUInt32Number i;
3189 cmsFormatter fr;
3190
3191
3192 switch (dwFlags)
3193 {
3194
3195 case CMS_PACK_FLAGS_16BITS: {
3196
3197 for (i=0; i < sizeof(OutputFormatters16) / sizeof(cmsFormatters16); i++) {
3198 cmsFormatters16* f = OutputFormatters16 + i;
3199
3200 if ((dwInput & ~f ->Mask) == f ->Type) {
3201 fr.Fmt16 = f ->Frm;
3202 return fr;
3203 }
3204 }
3205 }
3206 break;
3207
3208 case CMS_PACK_FLAGS_FLOAT: {
3209
3210 for (i=0; i < sizeof(OutputFormattersFloat) / sizeof(cmsFormattersFloat); i++) {
|
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 */
24
25 // This file is available under and governed by the GNU General Public
26 // License version 2 only, as published by the Free Software Foundation.
27 // However, the following notice accompanied the original version of this
28 // file:
29 //
30 //---------------------------------------------------------------------------------
31 //
32 // Little Color Management System
33 // Copyright (c) 1998-2016 Marti Maria Saguer
34 //
35 // Permission is hereby granted, free of charge, to any person obtaining
36 // a copy of this software and associated documentation files (the "Software"),
37 // to deal in the Software without restriction, including without limitation
38 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
39 // and/or sell copies of the Software, and to permit persons to whom the Software
40 // is furnished to do so, subject to the following conditions:
41 //
42 // The above copyright notice and this permission notice shall be included in
43 // all copies or substantial portions of the Software.
44 //
45 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
46 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
47 // THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
48 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
49 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
50 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
51 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52 //
53 //---------------------------------------------------------------------------------
93 } cmsFormatters16;
94
95 typedef struct {
96 cmsUInt32Number Type;
97 cmsUInt32Number Mask;
98 cmsFormatterFloat Frm;
99
100 } cmsFormattersFloat;
101
102
103 #define ANYSPACE COLORSPACE_SH(31)
104 #define ANYCHANNELS CHANNELS_SH(15)
105 #define ANYEXTRA EXTRA_SH(7)
106 #define ANYPLANAR PLANAR_SH(1)
107 #define ANYENDIAN ENDIAN16_SH(1)
108 #define ANYSWAP DOSWAP_SH(1)
109 #define ANYSWAPFIRST SWAPFIRST_SH(1)
110 #define ANYFLAVOR FLAVOR_SH(1)
111
112
113 // Suppress waning about info never being used
114
115 #ifdef _MSC_VER
116 #pragma warning(disable : 4100)
117 #endif
118
119 // Unpacking routines (16 bits) ----------------------------------------------------------------------------------------
120
121
122 // Does almost everything but is slow
123 static
124 cmsUInt8Number* UnrollChunkyBytes(register _cmsTRANSFORM* info,
125 register cmsUInt16Number wIn[],
126 register cmsUInt8Number* accum,
127 register cmsUInt32Number Stride)
128 {
129 int nChan = T_CHANNELS(info -> InputFormat);
130 int DoSwap = T_DOSWAP(info ->InputFormat);
131 int Reverse = T_FLAVOR(info ->InputFormat);
132 int SwapFirst = T_SWAPFIRST(info -> InputFormat);
133 int Extra = T_EXTRA(info -> InputFormat);
3171 ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackFloatsFromFloat },
3172 { FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|
3173 ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackDoublesFromFloat },
3174 #ifndef CMS_NO_HALF_SUPPORT
3175 { FLOAT_SH(1)|BYTES_SH(2),
3176 ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackHalfFromFloat },
3177 #endif
3178
3179
3180
3181 };
3182
3183
3184 // Bit fields set to one in the mask are not compared
3185 static
3186 cmsFormatter _cmsGetStockOutputFormatter(cmsUInt32Number dwInput, cmsUInt32Number dwFlags)
3187 {
3188 cmsUInt32Number i;
3189 cmsFormatter fr;
3190
3191 // Optimization is only a hint
3192 dwInput &= ~OPTIMIZED_SH(1);
3193
3194 switch (dwFlags)
3195 {
3196
3197 case CMS_PACK_FLAGS_16BITS: {
3198
3199 for (i=0; i < sizeof(OutputFormatters16) / sizeof(cmsFormatters16); i++) {
3200 cmsFormatters16* f = OutputFormatters16 + i;
3201
3202 if ((dwInput & ~f ->Mask) == f ->Type) {
3203 fr.Fmt16 = f ->Frm;
3204 return fr;
3205 }
3206 }
3207 }
3208 break;
3209
3210 case CMS_PACK_FLAGS_FLOAT: {
3211
3212 for (i=0; i < sizeof(OutputFormattersFloat) / sizeof(cmsFormattersFloat); i++) {
|