OLD | NEW |
(Empty) | |
| 1 diff --git a/src/iccread.c b/src/iccread.c |
| 2 index 36b7011..2454924 100644 |
| 3 --- a/src/iccread.c |
| 4 +++ b/src/iccread.c |
| 5 @@ -297,6 +297,11 @@ qcms_bool qcms_profile_is_bogus(qcms_profile *profile) |
| 6 sum[1] = rY + gY + bY; |
| 7 sum[2] = rZ + gZ + bZ; |
| 8 |
| 9 +#if defined (_MSC_VER) |
| 10 +#pragma warning(push) |
| 11 +/* Disable double to float truncation warning 4305 */ |
| 12 +#pragma warning(disable:4305) |
| 13 +#endif |
| 14 // Build our target vector (see mozilla bug 460629) |
| 15 target[0] = 0.96420; |
| 16 target[1] = 1.00000; |
| 17 @@ -310,6 +315,10 @@ qcms_bool qcms_profile_is_bogus(qcms_profile *profile) |
| 18 tolerance[1] = 0.02; |
| 19 tolerance[2] = 0.04; |
| 20 |
| 21 +#if defined (_MSC_VER) |
| 22 +/* Restore warnings */ |
| 23 +#pragma warning(pop) |
| 24 +#endif |
| 25 // Compare with our tolerance |
| 26 for (i = 0; i < 3; ++i) { |
| 27 if (!(((sum[i] - tolerance[i]) <= target[i]) && |
| 28 diff --git a/src/qcms.h b/src/qcms.h |
| 29 index 7d83623..1e3e125 100644 |
| 30 --- a/src/qcms.h |
| 31 +++ b/src/qcms.h |
| 32 @@ -102,6 +102,12 @@ typedef enum { |
| 33 QCMS_DATA_GRAYA_8 |
| 34 } qcms_data_type; |
| 35 |
| 36 +/* Format of the output data for qcms_transform_data_type() */ |
| 37 +typedef enum { |
| 38 + QCMS_OUTPUT_RGBX, |
| 39 + QCMS_OUTPUT_BGRX |
| 40 +} qcms_output_type; |
| 41 + |
| 42 /* the names for the following two types are sort of ugly */ |
| 43 typedef struct |
| 44 { |
| 45 @@ -146,6 +152,7 @@ qcms_transform* qcms_transform_create( |
| 46 void qcms_transform_release(qcms_transform *); |
| 47 |
| 48 void qcms_transform_data(qcms_transform *transform, void *src, void *dest, size
_t length); |
| 49 +void qcms_transform_data_type(qcms_transform *transform, void *src, void *dest,
size_t length, qcms_output_type type); |
| 50 |
| 51 void qcms_enable_iccv4(); |
| 52 |
| 53 diff --git a/src/qcmsint.h b/src/qcmsint.h |
| 54 index 53a3420..63905de 100644 |
| 55 --- a/src/qcmsint.h |
| 56 +++ b/src/qcmsint.h |
| 57 @@ -45,6 +45,11 @@ struct precache_output |
| 58 #define ALIGN __attribute__(( aligned (16) )) |
| 59 #endif |
| 60 |
| 61 +typedef struct _qcms_format_type { |
| 62 + int r; |
| 63 + int b; |
| 64 +} qcms_format_type; |
| 65 + |
| 66 struct _qcms_transform { |
| 67 float ALIGN matrix[3][4]; |
| 68 float *input_gamma_table_r; |
| 69 @@ -88,7 +93,7 @@ struct _qcms_transform { |
| 70 struct precache_output *output_table_g; |
| 71 struct precache_output *output_table_b; |
| 72 |
| 73 - void (*transform_fn)(struct _qcms_transform *transform, unsigned char *s
rc, unsigned char *dest, size_t length); |
| 74 + void (*transform_fn)(struct _qcms_transform *transform, unsigned char *s
rc, unsigned char *dest, size_t length, struct _qcms_format_type output_format); |
| 75 }; |
| 76 |
| 77 struct matrix { |
| 78 @@ -280,18 +285,22 @@ qcms_bool set_rgb_colorants(qcms_profile *profile, qcms_CI
E_xyY white_point, qcm |
| 79 void qcms_transform_data_rgb_out_lut_sse2(qcms_transform *transform, |
| 80 unsigned char *src, |
| 81 unsigned char *dest, |
| 82 - size_t length); |
| 83 + size_t length, |
| 84 + qcms_format_type output_format); |
| 85 void qcms_transform_data_rgba_out_lut_sse2(qcms_transform *transform, |
| 86 unsigned char *src, |
| 87 unsigned char *dest, |
| 88 - size_t length); |
| 89 + size_t length, |
| 90 + qcms_format_type output_format); |
| 91 void qcms_transform_data_rgb_out_lut_sse1(qcms_transform *transform, |
| 92 unsigned char *src, |
| 93 unsigned char *dest, |
| 94 - size_t length); |
| 95 + size_t length, |
| 96 + qcms_format_type output_format); |
| 97 void qcms_transform_data_rgba_out_lut_sse1(qcms_transform *transform, |
| 98 unsigned char *src, |
| 99 unsigned char *dest, |
| 100 - size_t length); |
| 101 + size_t length, |
| 102 + qcms_format_type output_format); |
| 103 |
| 104 extern qcms_bool qcms_supports_iccv4; |
| 105 diff --git a/src/qcmstypes.h b/src/qcmstypes.h |
| 106 index 56d8de3..9a9b197 100644 |
| 107 --- a/src/qcmstypes.h |
| 108 +++ b/src/qcmstypes.h |
| 109 @@ -87,7 +87,12 @@ typedef unsigned __int64 uint64_t; |
| 110 #ifdef _WIN64 |
| 111 typedef unsigned __int64 uintptr_t; |
| 112 #else |
| 113 +#pragma warning(push) |
| 114 +/* Disable benign redefinition of type warning 4142 */ |
| 115 +#pragma warning(disable:4142) |
| 116 typedef unsigned long uintptr_t; |
| 117 +/* Restore warnings */ |
| 118 +#pragma warning(pop) |
| 119 #endif |
| 120 |
| 121 #elif defined (_AIX) |
| 122 diff --git a/src/transform-sse1.c b/src/transform-sse1.c |
| 123 index 2f34db5..aaee1bf 100644 |
| 124 --- a/src/transform-sse1.c |
| 125 +++ b/src/transform-sse1.c |
| 126 @@ -34,7 +34,8 @@ static const ALIGN float clampMaxValueX4[4] = |
| 127 void qcms_transform_data_rgb_out_lut_sse1(qcms_transform *transform, |
| 128 unsigned char *src, |
| 129 unsigned char *dest, |
| 130 - size_t length) |
| 131 + size_t length, |
| 132 + qcms_format_type output_format) |
| 133 { |
| 134 unsigned int i; |
| 135 float (*mat)[4] = transform->matrix; |
| 136 @@ -70,6 +71,8 @@ void qcms_transform_data_rgb_out_lut_sse1(qcms_transform *tran
sform, |
| 137 |
| 138 /* working variables */ |
| 139 __m128 vec_r, vec_g, vec_b, result; |
| 140 + const int r_out = output_format.r; |
| 141 + const int b_out = output_format.b; |
| 142 |
| 143 /* CYA */ |
| 144 if (!length) |
| 145 @@ -116,9 +119,9 @@ void qcms_transform_data_rgb_out_lut_sse1(qcms_transform *tr
ansform, |
| 146 src += 3; |
| 147 |
| 148 /* use calc'd indices to output RGB values */ |
| 149 - dest[0] = otdata_r[output[0]]; |
| 150 - dest[1] = otdata_g[output[1]]; |
| 151 - dest[2] = otdata_b[output[2]]; |
| 152 + dest[r_out] = otdata_r[output[0]]; |
| 153 + dest[1] = otdata_g[output[1]]; |
| 154 + dest[b_out] = otdata_b[output[2]]; |
| 155 dest += 3; |
| 156 } |
| 157 |
| 158 @@ -141,9 +144,9 @@ void qcms_transform_data_rgb_out_lut_sse1(qcms_transform *tr
ansform, |
| 159 result = _mm_movehl_ps(result, result); |
| 160 *((__m64 *)&output[2]) = _mm_cvtps_pi32(result); |
| 161 |
| 162 - dest[0] = otdata_r[output[0]]; |
| 163 - dest[1] = otdata_g[output[1]]; |
| 164 - dest[2] = otdata_b[output[2]]; |
| 165 + dest[r_out] = otdata_r[output[0]]; |
| 166 + dest[1] = otdata_g[output[1]]; |
| 167 + dest[b_out] = otdata_b[output[2]]; |
| 168 |
| 169 _mm_empty(); |
| 170 } |
| 171 @@ -151,7 +154,8 @@ void qcms_transform_data_rgb_out_lut_sse1(qcms_transform *tr
ansform, |
| 172 void qcms_transform_data_rgba_out_lut_sse1(qcms_transform *transform, |
| 173 unsigned char *src, |
| 174 unsigned char *dest, |
| 175 - size_t length) |
| 176 + size_t length, |
| 177 + qcms_format_type output_format) |
| 178 { |
| 179 unsigned int i; |
| 180 float (*mat)[4] = transform->matrix; |
| 181 @@ -187,6 +191,8 @@ void qcms_transform_data_rgba_out_lut_sse1(qcms_transform *t
ransform, |
| 182 |
| 183 /* working variables */ |
| 184 __m128 vec_r, vec_g, vec_b, result; |
| 185 + const int r_out = output_format.r; |
| 186 + const int b_out = output_format.b; |
| 187 unsigned char alpha; |
| 188 |
| 189 /* CYA */ |
| 190 @@ -239,9 +245,9 @@ void qcms_transform_data_rgba_out_lut_sse1(qcms_transform *t
ransform, |
| 191 src += 4; |
| 192 |
| 193 /* use calc'd indices to output RGB values */ |
| 194 - dest[0] = otdata_r[output[0]]; |
| 195 - dest[1] = otdata_g[output[1]]; |
| 196 - dest[2] = otdata_b[output[2]]; |
| 197 + dest[r_out] = otdata_r[output[0]]; |
| 198 + dest[1] = otdata_g[output[1]]; |
| 199 + dest[b_out] = otdata_b[output[2]]; |
| 200 dest += 4; |
| 201 } |
| 202 |
| 203 @@ -266,9 +272,9 @@ void qcms_transform_data_rgba_out_lut_sse1(qcms_transform *t
ransform, |
| 204 result = _mm_movehl_ps(result, result); |
| 205 *((__m64 *)&output[2]) = _mm_cvtps_pi32(result); |
| 206 |
| 207 - dest[0] = otdata_r[output[0]]; |
| 208 - dest[1] = otdata_g[output[1]]; |
| 209 - dest[2] = otdata_b[output[2]]; |
| 210 + dest[r_out] = otdata_r[output[0]]; |
| 211 + dest[1] = otdata_g[output[1]]; |
| 212 + dest[b_out] = otdata_b[output[2]]; |
| 213 |
| 214 _mm_empty(); |
| 215 } |
| 216 diff --git a/src/transform-sse2.c b/src/transform-sse2.c |
| 217 index 6a5faf9..fa7f2d1 100644 |
| 218 --- a/src/transform-sse2.c |
| 219 +++ b/src/transform-sse2.c |
| 220 @@ -34,7 +34,8 @@ static const ALIGN float clampMaxValueX4[4] = |
| 221 void qcms_transform_data_rgb_out_lut_sse2(qcms_transform *transform, |
| 222 unsigned char *src, |
| 223 unsigned char *dest, |
| 224 - size_t length) |
| 225 + size_t length, |
| 226 + qcms_format_type output_format) |
| 227 { |
| 228 unsigned int i; |
| 229 float (*mat)[4] = transform->matrix; |
| 230 @@ -70,6 +71,8 @@ void qcms_transform_data_rgb_out_lut_sse2(qcms_transform *tran
sform, |
| 231 |
| 232 /* working variables */ |
| 233 __m128 vec_r, vec_g, vec_b, result; |
| 234 + const int r_out = output_format.r; |
| 235 + const int b_out = output_format.b; |
| 236 |
| 237 /* CYA */ |
| 238 if (!length) |
| 239 @@ -114,9 +117,9 @@ void qcms_transform_data_rgb_out_lut_sse2(qcms_transform *tr
ansform, |
| 240 src += 3; |
| 241 |
| 242 /* use calc'd indices to output RGB values */ |
| 243 - dest[0] = otdata_r[output[0]]; |
| 244 - dest[1] = otdata_g[output[1]]; |
| 245 - dest[2] = otdata_b[output[2]]; |
| 246 + dest[r_out] = otdata_r[output[0]]; |
| 247 + dest[1] = otdata_g[output[1]]; |
| 248 + dest[b_out] = otdata_b[output[2]]; |
| 249 dest += 3; |
| 250 } |
| 251 |
| 252 @@ -137,15 +140,16 @@ void qcms_transform_data_rgb_out_lut_sse2(qcms_transform *
transform, |
| 253 |
| 254 _mm_store_si128((__m128i*)output, _mm_cvtps_epi32(result)); |
| 255 |
| 256 - dest[0] = otdata_r[output[0]]; |
| 257 - dest[1] = otdata_g[output[1]]; |
| 258 - dest[2] = otdata_b[output[2]]; |
| 259 + dest[r_out] = otdata_r[output[0]]; |
| 260 + dest[1] = otdata_g[output[1]]; |
| 261 + dest[b_out] = otdata_b[output[2]]; |
| 262 } |
| 263 |
| 264 void qcms_transform_data_rgba_out_lut_sse2(qcms_transform *transform, |
| 265 unsigned char *src, |
| 266 unsigned char *dest, |
| 267 - size_t length) |
| 268 + size_t length, |
| 269 + qcms_format_type output_format) |
| 270 { |
| 271 unsigned int i; |
| 272 float (*mat)[4] = transform->matrix; |
| 273 @@ -181,6 +185,8 @@ void qcms_transform_data_rgba_out_lut_sse2(qcms_transform *t
ransform, |
| 274 |
| 275 /* working variables */ |
| 276 __m128 vec_r, vec_g, vec_b, result; |
| 277 + const int r_out = output_format.r; |
| 278 + const int b_out = output_format.b; |
| 279 unsigned char alpha; |
| 280 |
| 281 /* CYA */ |
| 282 @@ -231,9 +237,9 @@ void qcms_transform_data_rgba_out_lut_sse2(qcms_transform *t
ransform, |
| 283 src += 4; |
| 284 |
| 285 /* use calc'd indices to output RGB values */ |
| 286 - dest[0] = otdata_r[output[0]]; |
| 287 - dest[1] = otdata_g[output[1]]; |
| 288 - dest[2] = otdata_b[output[2]]; |
| 289 + dest[r_out] = otdata_r[output[0]]; |
| 290 + dest[1] = otdata_g[output[1]]; |
| 291 + dest[b_out] = otdata_b[output[2]]; |
| 292 dest += 4; |
| 293 } |
| 294 |
| 295 @@ -256,7 +262,7 @@ void qcms_transform_data_rgba_out_lut_sse2(qcms_transform *t
ransform, |
| 296 |
| 297 _mm_store_si128((__m128i*)output, _mm_cvtps_epi32(result)); |
| 298 |
| 299 - dest[0] = otdata_r[output[0]]; |
| 300 - dest[1] = otdata_g[output[1]]; |
| 301 - dest[2] = otdata_b[output[2]]; |
| 302 + dest[r_out] = otdata_r[output[0]]; |
| 303 + dest[1] = otdata_g[output[1]]; |
| 304 + dest[b_out] = otdata_b[output[2]]; |
| 305 } |
| 306 diff --git a/src/transform.c b/src/transform.c |
| 307 index 9a6562b..ae3f628 100644 |
| 308 --- a/src/transform.c |
| 309 +++ b/src/transform.c |
| 310 @@ -181,11 +181,20 @@ compute_chromatic_adaption(struct CIE_XYZ source_white_poi
nt, |
| 311 static struct matrix |
| 312 adaption_matrix(struct CIE_XYZ source_illumination, struct CIE_XYZ target_illum
ination) |
| 313 { |
| 314 +#if defined (_MSC_VER) |
| 315 +#pragma warning(push) |
| 316 +/* Disable double to float truncation warning 4305 */ |
| 317 +#pragma warning(disable:4305) |
| 318 +#endif |
| 319 struct matrix lam_rigg = {{ // Bradford matrix |
| 320 { 0.8951, 0.2664, -0.1614 }, |
| 321 { -0.7502, 1.7135, 0.0367 }, |
| 322 { 0.0389, -0.0685, 1.0296 } |
| 323 }}; |
| 324 +#if defined (_MSC_VER) |
| 325 +/* Restore warnings */ |
| 326 +#pragma warning(pop) |
| 327 +#endif |
| 328 return compute_chromatic_adaption(source_illumination, target_illuminati
on, lam_rigg); |
| 329 } |
| 330 |
| 331 @@ -230,8 +239,11 @@ qcms_bool set_rgb_colorants(qcms_profile *profile, qcms_CIE
_xyY white_point, qcm |
| 332 } |
| 333 |
| 334 #if 0 |
| 335 -static void qcms_transform_data_rgb_out_pow(qcms_transform *transform, unsigned
char *src, unsigned char *dest, size_t length) |
| 336 +static void qcms_transform_data_rgb_out_pow(qcms_transform *transform, unsigned
char *src, unsigned char *dest, size_t length, qcms_format_type output_format) |
| 337 { |
| 338 + const int r_out = output_format.r; |
| 339 + const int b_out = output_format.b; |
| 340 + |
| 341 int i; |
| 342 float (*mat)[4] = transform->matrix; |
| 343 for (i=0; i<length; i++) { |
| 344 @@ -251,15 +263,19 @@ static void qcms_transform_data_rgb_out_pow(qcms_transform
*transform, unsigned |
| 345 float out_device_g = pow(out_linear_g, transform->out_gamma_g); |
| 346 float out_device_b = pow(out_linear_b, transform->out_gamma_b); |
| 347 |
| 348 - *dest++ = clamp_u8(255*out_device_r); |
| 349 - *dest++ = clamp_u8(255*out_device_g); |
| 350 - *dest++ = clamp_u8(255*out_device_b); |
| 351 + dest[r_out] = clamp_u8(out_device_r*255); |
| 352 + dest[1] = clamp_u8(out_device_g*255); |
| 353 + dest[b_out] = clamp_u8(out_device_b*255); |
| 354 + dest += 3; |
| 355 } |
| 356 } |
| 357 #endif |
| 358 |
| 359 -static void qcms_transform_data_gray_out_lut(qcms_transform *transform, unsigne
d char *src, unsigned char *dest, size_t length) |
| 360 +static void qcms_transform_data_gray_out_lut(qcms_transform *transform, unsigne
d char *src, unsigned char *dest, size_t length, qcms_format_type output_format) |
| 361 { |
| 362 + const int r_out = output_format.r; |
| 363 + const int b_out = output_format.b; |
| 364 + |
| 365 unsigned int i; |
| 366 for (i = 0; i < length; i++) { |
| 367 float out_device_r, out_device_g, out_device_b; |
| 368 @@ -267,13 +283,14 @@ static void qcms_transform_data_gray_out_lut(qcms_transfor
m *transform, unsigned |
| 369 |
| 370 float linear = transform->input_gamma_table_gray[device]; |
| 371 |
| 372 - out_device_r = lut_interp_linear(linear, transform->output_gamm
a_lut_r, transform->output_gamma_lut_r_length); |
| 373 + out_device_r = lut_interp_linear(linear, transform->output_gamma
_lut_r, transform->output_gamma_lut_r_length); |
| 374 out_device_g = lut_interp_linear(linear, transform->output_gamma
_lut_g, transform->output_gamma_lut_g_length); |
| 375 out_device_b = lut_interp_linear(linear, transform->output_gamma
_lut_b, transform->output_gamma_lut_b_length); |
| 376 |
| 377 - *dest++ = clamp_u8(out_device_r*255); |
| 378 - *dest++ = clamp_u8(out_device_g*255); |
| 379 - *dest++ = clamp_u8(out_device_b*255); |
| 380 + dest[r_out] = clamp_u8(out_device_r*255); |
| 381 + dest[1] = clamp_u8(out_device_g*255); |
| 382 + dest[b_out] = clamp_u8(out_device_b*255); |
| 383 + dest += 3; |
| 384 } |
| 385 } |
| 386 |
| 387 @@ -283,8 +300,11 @@ static void qcms_transform_data_gray_out_lut(qcms_transform
*transform, unsigned |
| 388 See: ftp://ftp.alvyray.com/Acrobat/17_Nonln.pdf |
| 389 */ |
| 390 |
| 391 -static void qcms_transform_data_graya_out_lut(qcms_transform *transform, unsign
ed char *src, unsigned char *dest, size_t length) |
| 392 +static void qcms_transform_data_graya_out_lut(qcms_transform *transform, unsign
ed char *src, unsigned char *dest, size_t length, qcms_format_type output_format
) |
| 393 { |
| 394 + const int r_out = output_format.r; |
| 395 + const int b_out = output_format.b; |
| 396 + |
| 397 unsigned int i; |
| 398 for (i = 0; i < length; i++) { |
| 399 float out_device_r, out_device_g, out_device_b; |
| 400 @@ -293,20 +313,24 @@ static void qcms_transform_data_graya_out_lut(qcms_transfo
rm *transform, unsigne |
| 401 |
| 402 float linear = transform->input_gamma_table_gray[device]; |
| 403 |
| 404 - out_device_r = lut_interp_linear(linear, transform->output_gamm
a_lut_r, transform->output_gamma_lut_r_length); |
| 405 + out_device_r = lut_interp_linear(linear, transform->output_gamma
_lut_r, transform->output_gamma_lut_r_length); |
| 406 out_device_g = lut_interp_linear(linear, transform->output_gamma
_lut_g, transform->output_gamma_lut_g_length); |
| 407 out_device_b = lut_interp_linear(linear, transform->output_gamma
_lut_b, transform->output_gamma_lut_b_length); |
| 408 |
| 409 - *dest++ = clamp_u8(out_device_r*255); |
| 410 - *dest++ = clamp_u8(out_device_g*255); |
| 411 - *dest++ = clamp_u8(out_device_b*255); |
| 412 - *dest++ = alpha; |
| 413 + dest[r_out] = clamp_u8(out_device_r*255); |
| 414 + dest[1] = clamp_u8(out_device_g*255); |
| 415 + dest[b_out] = clamp_u8(out_device_b*255); |
| 416 + dest[3] = alpha; |
| 417 + dest += 4; |
| 418 } |
| 419 } |
| 420 |
| 421 |
| 422 -static void qcms_transform_data_gray_out_precache(qcms_transform *transform, un
signed char *src, unsigned char *dest, size_t length) |
| 423 +static void qcms_transform_data_gray_out_precache(qcms_transform *transform, un
signed char *src, unsigned char *dest, size_t length, qcms_format_type output_fo
rmat) |
| 424 { |
| 425 + const int r_out = output_format.r; |
| 426 + const int b_out = output_format.b; |
| 427 + |
| 428 unsigned int i; |
| 429 for (i = 0; i < length; i++) { |
| 430 unsigned char device = *src++; |
| 431 @@ -317,14 +341,19 @@ static void qcms_transform_data_gray_out_precache(qcms_tra
nsform *transform, uns |
| 432 /* we could round here... */ |
| 433 gray = linear * PRECACHE_OUTPUT_MAX; |
| 434 |
| 435 - *dest++ = transform->output_table_r->data[gray]; |
| 436 - *dest++ = transform->output_table_g->data[gray]; |
| 437 - *dest++ = transform->output_table_b->data[gray]; |
| 438 + dest[r_out] = transform->output_table_r->data[gray]; |
| 439 + dest[1] = transform->output_table_g->data[gray]; |
| 440 + dest[b_out] = transform->output_table_b->data[gray]; |
| 441 + dest += 3; |
| 442 } |
| 443 } |
| 444 |
| 445 -static void qcms_transform_data_graya_out_precache(qcms_transform *transform, u
nsigned char *src, unsigned char *dest, size_t length) |
| 446 + |
| 447 +static void qcms_transform_data_graya_out_precache(qcms_transform *transform, u
nsigned char *src, unsigned char *dest, size_t length, qcms_format_type output_f
ormat) |
| 448 { |
| 449 + const int r_out = output_format.r; |
| 450 + const int b_out = output_format.b; |
| 451 + |
| 452 unsigned int i; |
| 453 for (i = 0; i < length; i++) { |
| 454 unsigned char device = *src++; |
| 455 @@ -336,15 +365,19 @@ static void qcms_transform_data_graya_out_precache(qcms_tr
ansform *transform, un |
| 456 /* we could round here... */ |
| 457 gray = linear * PRECACHE_OUTPUT_MAX; |
| 458 |
| 459 - *dest++ = transform->output_table_r->data[gray]; |
| 460 - *dest++ = transform->output_table_g->data[gray]; |
| 461 - *dest++ = transform->output_table_b->data[gray]; |
| 462 - *dest++ = alpha; |
| 463 + dest[r_out] = transform->output_table_r->data[gray]; |
| 464 + dest[1] = transform->output_table_g->data[gray]; |
| 465 + dest[b_out] = transform->output_table_b->data[gray]; |
| 466 + dest[3] = alpha; |
| 467 + dest += 4; |
| 468 } |
| 469 } |
| 470 |
| 471 -static void qcms_transform_data_rgb_out_lut_precache(qcms_transform *transform,
unsigned char *src, unsigned char *dest, size_t length) |
| 472 +static void qcms_transform_data_rgb_out_lut_precache(qcms_transform *transform,
unsigned char *src, unsigned char *dest, size_t length, qcms_format_type output
_format) |
| 473 { |
| 474 + const int r_out = output_format.r; |
| 475 + const int b_out = output_format.b; |
| 476 + |
| 477 unsigned int i; |
| 478 float (*mat)[4] = transform->matrix; |
| 479 for (i = 0; i < length; i++) { |
| 480 @@ -370,14 +403,18 @@ static void qcms_transform_data_rgb_out_lut_precache(qcms_
transform *transform, |
| 481 g = out_linear_g * PRECACHE_OUTPUT_MAX; |
| 482 b = out_linear_b * PRECACHE_OUTPUT_MAX; |
| 483 |
| 484 - *dest++ = transform->output_table_r->data[r]; |
| 485 - *dest++ = transform->output_table_g->data[g]; |
| 486 - *dest++ = transform->output_table_b->data[b]; |
| 487 + dest[r_out] = transform->output_table_r->data[r]; |
| 488 + dest[1] = transform->output_table_g->data[g]; |
| 489 + dest[b_out] = transform->output_table_b->data[b]; |
| 490 + dest += 3; |
| 491 } |
| 492 } |
| 493 |
| 494 -static void qcms_transform_data_rgba_out_lut_precache(qcms_transform *transform
, unsigned char *src, unsigned char *dest, size_t length) |
| 495 +static void qcms_transform_data_rgba_out_lut_precache(qcms_transform *transform
, unsigned char *src, unsigned char *dest, size_t length, qcms_format_type outpu
t_format) |
| 496 { |
| 497 + const int r_out = output_format.r; |
| 498 + const int b_out = output_format.b; |
| 499 + |
| 500 unsigned int i; |
| 501 float (*mat)[4] = transform->matrix; |
| 502 for (i = 0; i < length; i++) { |
| 503 @@ -404,16 +441,21 @@ static void qcms_transform_data_rgba_out_lut_precache(qcms
_transform *transform, |
| 504 g = out_linear_g * PRECACHE_OUTPUT_MAX; |
| 505 b = out_linear_b * PRECACHE_OUTPUT_MAX; |
| 506 |
| 507 - *dest++ = transform->output_table_r->data[r]; |
| 508 - *dest++ = transform->output_table_g->data[g]; |
| 509 - *dest++ = transform->output_table_b->data[b]; |
| 510 - *dest++ = alpha; |
| 511 + dest[r_out] = transform->output_table_r->data[r]; |
| 512 + dest[1] = transform->output_table_g->data[g]; |
| 513 + dest[b_out] = transform->output_table_b->data[b]; |
| 514 + dest[3] = alpha; |
| 515 + dest += 4; |
| 516 } |
| 517 } |
| 518 |
| 519 // Not used |
| 520 /* |
| 521 -static void qcms_transform_data_clut(qcms_transform *transform, unsigned char *
src, unsigned char *dest, size_t length) { |
| 522 +static void qcms_transform_data_clut(qcms_transform *transform, unsigned char *
src, unsigned char *dest, size_t length, qcms_format_type output_format) |
| 523 +{ |
| 524 + const int r_out = output_format.r; |
| 525 + const int b_out = output_format.b; |
| 526 + |
| 527 unsigned int i; |
| 528 int xy_len = 1; |
| 529 int x_len = transform->grid_size; |
| 530 @@ -462,15 +504,20 @@ static void qcms_transform_data_clut(qcms_transform *trans
form, unsigned char *s |
| 531 float b_y2 = lerp(b_x3, b_x4, y_d); |
| 532 float clut_b = lerp(b_y1, b_y2, z_d); |
| 533 |
| 534 - *dest++ = clamp_u8(clut_r*255.0f); |
| 535 - *dest++ = clamp_u8(clut_g*255.0f); |
| 536 - *dest++ = clamp_u8(clut_b*255.0f); |
| 537 - } |
| 538 + dest[r_out] = clamp_u8(clut_r*255.0f); |
| 539 + dest[1] = clamp_u8(clut_g*255.0f); |
| 540 + dest[b_out] = clamp_u8(clut_b*255.0f); |
| 541 + dest += 3; |
| 542 + } |
| 543 } |
| 544 */ |
| 545 |
| 546 // Using lcms' tetra interpolation algorithm. |
| 547 -static void qcms_transform_data_tetra_clut_rgba(qcms_transform *transform, unsi
gned char *src, unsigned char *dest, size_t length) { |
| 548 +static void qcms_transform_data_tetra_clut_rgba(qcms_transform *transform, unsi
gned char *src, unsigned char *dest, size_t length, qcms_format_type output_form
at) |
| 549 +{ |
| 550 + const int r_out = output_format.r; |
| 551 + const int b_out = output_format.b; |
| 552 + |
| 553 unsigned int i; |
| 554 int xy_len = 1; |
| 555 int x_len = transform->grid_size; |
| 556 @@ -577,15 +624,20 @@ static void qcms_transform_data_tetra_clut_rgba(qcms_trans
form *transform, unsig |
| 557 clut_g = c0_g + c1_g*rx + c2_g*ry + c3_g*rz; |
| 558 clut_b = c0_b + c1_b*rx + c2_b*ry + c3_b*rz; |
| 559 |
| 560 - *dest++ = clamp_u8(clut_r*255.0f); |
| 561 - *dest++ = clamp_u8(clut_g*255.0f); |
| 562 - *dest++ = clamp_u8(clut_b*255.0f); |
| 563 - *dest++ = in_a; |
| 564 - } |
| 565 + dest[r_out] = clamp_u8(clut_r*255.0f); |
| 566 + dest[1] = clamp_u8(clut_g*255.0f); |
| 567 + dest[b_out] = clamp_u8(clut_b*255.0f); |
| 568 + dest[3] = in_a; |
| 569 + dest += 4; |
| 570 + } |
| 571 } |
| 572 |
| 573 // Using lcms' tetra interpolation code. |
| 574 -static void qcms_transform_data_tetra_clut(qcms_transform *transform, unsigned
char *src, unsigned char *dest, size_t length) { |
| 575 +static void qcms_transform_data_tetra_clut(qcms_transform *transform, unsigned
char *src, unsigned char *dest, size_t length, qcms_format_type output_format) |
| 576 +{ |
| 577 + const int r_out = output_format.r; |
| 578 + const int b_out = output_format.b; |
| 579 + |
| 580 unsigned int i; |
| 581 int xy_len = 1; |
| 582 int x_len = transform->grid_size; |
| 583 @@ -691,14 +743,18 @@ static void qcms_transform_data_tetra_clut(qcms_transform
*transform, unsigned c |
| 584 clut_g = c0_g + c1_g*rx + c2_g*ry + c3_g*rz; |
| 585 clut_b = c0_b + c1_b*rx + c2_b*ry + c3_b*rz; |
| 586 |
| 587 - *dest++ = clamp_u8(clut_r*255.0f); |
| 588 - *dest++ = clamp_u8(clut_g*255.0f); |
| 589 - *dest++ = clamp_u8(clut_b*255.0f); |
| 590 - } |
| 591 + dest[r_out] = clamp_u8(clut_r*255.0f); |
| 592 + dest[1] = clamp_u8(clut_g*255.0f); |
| 593 + dest[b_out] = clamp_u8(clut_b*255.0f); |
| 594 + dest += 3; |
| 595 + } |
| 596 } |
| 597 |
| 598 -static void qcms_transform_data_rgb_out_lut(qcms_transform *transform, unsigned
char *src, unsigned char *dest, size_t length) |
| 599 +static void qcms_transform_data_rgb_out_lut(qcms_transform *transform, unsigned
char *src, unsigned char *dest, size_t length, qcms_format_type output_format) |
| 600 { |
| 601 + const int r_out = output_format.r; |
| 602 + const int b_out = output_format.b; |
| 603 + |
| 604 unsigned int i; |
| 605 float (*mat)[4] = transform->matrix; |
| 606 for (i = 0; i < length; i++) { |
| 607 @@ -726,14 +782,18 @@ static void qcms_transform_data_rgb_out_lut(qcms_transform
*transform, unsigned |
| 608 out_device_b = lut_interp_linear(out_linear_b, |
| 609 transform->output_gamma_lut_b, transform->output
_gamma_lut_b_length); |
| 610 |
| 611 - *dest++ = clamp_u8(out_device_r*255); |
| 612 - *dest++ = clamp_u8(out_device_g*255); |
| 613 - *dest++ = clamp_u8(out_device_b*255); |
| 614 + dest[r_out] = clamp_u8(out_device_r*255); |
| 615 + dest[1] = clamp_u8(out_device_g*255); |
| 616 + dest[b_out] = clamp_u8(out_device_b*255); |
| 617 + dest += 3; |
| 618 } |
| 619 } |
| 620 |
| 621 -static void qcms_transform_data_rgba_out_lut(qcms_transform *transform, unsigne
d char *src, unsigned char *dest, size_t length) |
| 622 +static void qcms_transform_data_rgba_out_lut(qcms_transform *transform, unsigne
d char *src, unsigned char *dest, size_t length, qcms_format_type output_format) |
| 623 { |
| 624 + const int r_out = output_format.r; |
| 625 + const int b_out = output_format.b; |
| 626 + |
| 627 unsigned int i; |
| 628 float (*mat)[4] = transform->matrix; |
| 629 for (i = 0; i < length; i++) { |
| 630 @@ -762,16 +822,20 @@ static void qcms_transform_data_rgba_out_lut(qcms_transfor
m *transform, unsigned |
| 631 out_device_b = lut_interp_linear(out_linear_b, |
| 632 transform->output_gamma_lut_b, transform->output
_gamma_lut_b_length); |
| 633 |
| 634 - *dest++ = clamp_u8(out_device_r*255); |
| 635 - *dest++ = clamp_u8(out_device_g*255); |
| 636 - *dest++ = clamp_u8(out_device_b*255); |
| 637 - *dest++ = alpha; |
| 638 + dest[r_out] = clamp_u8(out_device_r*255); |
| 639 + dest[1] = clamp_u8(out_device_g*255); |
| 640 + dest[b_out] = clamp_u8(out_device_b*255); |
| 641 + dest[3] = alpha; |
| 642 + dest += 4; |
| 643 } |
| 644 } |
| 645 |
| 646 #if 0 |
| 647 -static void qcms_transform_data_rgb_out_linear(qcms_transform *transform, unsig
ned char *src, unsigned char *dest, size_t length) |
| 648 +static void qcms_transform_data_rgb_out_linear(qcms_transform *transform, unsig
ned char *src, unsigned char *dest, size_t length, qcms_format_type output_forma
t) |
| 649 { |
| 650 + const int r_out = output_format.r; |
| 651 + const int b_out = output_format.b; |
| 652 + |
| 653 int i; |
| 654 float (*mat)[4] = transform->matrix; |
| 655 for (i = 0; i < length; i++) { |
| 656 @@ -787,9 +851,10 @@ static void qcms_transform_data_rgb_out_linear(qcms_transfo
rm *transform, unsign |
| 657 float out_linear_g = mat[0][1]*linear_r + mat[1][1]*linear_g + m
at[2][1]*linear_b; |
| 658 float out_linear_b = mat[0][2]*linear_r + mat[1][2]*linear_g + m
at[2][2]*linear_b; |
| 659 |
| 660 - *dest++ = clamp_u8(out_linear_r*255); |
| 661 - *dest++ = clamp_u8(out_linear_g*255); |
| 662 - *dest++ = clamp_u8(out_linear_b*255); |
| 663 + dest[r_out] = clamp_u8(out_linear_r*255); |
| 664 + dest[1] = clamp_u8(out_linear_g*255); |
| 665 + dest[b_out] = clamp_u8(out_linear_b*255); |
| 666 + dest += 3; |
| 667 } |
| 668 } |
| 669 #endif |
| 670 @@ -1262,7 +1327,17 @@ __attribute__((__force_align_arg_pointer__)) |
| 671 #endif |
| 672 void qcms_transform_data(qcms_transform *transform, void *src, void *dest, size
_t length) |
| 673 { |
| 674 - transform->transform_fn(transform, src, dest, length); |
| 675 + static const struct _qcms_format_type output_rgbx = { 0, 2 }; |
| 676 + |
| 677 + transform->transform_fn(transform, src, dest, length, output_rgbx); |
| 678 +} |
| 679 + |
| 680 +void qcms_transform_data_type(qcms_transform *transform, void *src, void *dest,
size_t length, qcms_output_type type) |
| 681 +{ |
| 682 + static const struct _qcms_format_type output_rgbx = { 0, 2 }; |
| 683 + static const struct _qcms_format_type output_bgrx = { 2, 0 }; |
| 684 + |
| 685 + transform->transform_fn(transform, src, dest, length, type == QCMS_OUTPU
T_BGRX ? output_bgrx : output_rgbx); |
| 686 } |
| 687 |
| 688 qcms_bool qcms_supports_iccv4; |
OLD | NEW |