56
#include "lcms2_internal.h"
67
#define CHANGE_ENDIAN(w) (cmsUInt16Number) ((cmsUInt16Number) ((w)<<8)|((w)>>8))
70
#define REVERSE_FLAVOR_8(x) ((cmsUInt8Number) (0xff-(x)))
71
#define REVERSE_FLAVOR_16(x) ((cmsUInt16Number)(0xffff-(x)))
74
cmsINLINE cmsUInt16Number FomLabV2ToLabV4(cmsUInt16Number x)
76
int a = (x << 8 | x) >> 8;
77
if ( a > 0xffff) return 0xffff;
78
return (cmsUInt16Number) a;
82
cmsINLINE cmsUInt16Number FomLabV4ToLabV2(cmsUInt16Number x)
84
return (cmsUInt16Number) (((x << 8) + 0x80) / 257);
98
cmsFormatterFloat Frm;
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
#define ANYPREMUL PREMUL_SH(1)
117
#pragma warning(disable : 4100)
125
cmsUInt8Number* UnrollChunkyBytes(CMSREGISTER _cmsTRANSFORM* info,
126
CMSREGISTER cmsUInt16Number wIn[],
127
CMSREGISTER cmsUInt8Number* accum,
128
CMSREGISTER cmsUInt32Number Stride)
130
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
131
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
132
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
133
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
134
cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
135
cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
137
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
140
cmsUInt32Number alpha_factor = 1;
145
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[0]));
152
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[nChan]));
155
for (i=0; i < nChan; i++) {
157
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
159
v = FROM_8_TO_16(*accum);
160
v = Reverse ? REVERSE_FLAVOR_16(v) : v;
162
if (Premul && alpha_factor > 0)
164
v = ((cmsUInt32Number)((cmsUInt32Number)v << 16) / alpha_factor);
165
if (v > 0xffff) v = 0xffff;
168
wIn[index] = (cmsUInt16Number) v;
176
if (Extra == 0 && SwapFirst) {
177
cmsUInt16Number tmp = wIn[0];
179
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
185
cmsUNUSED_PARAMETER(info);
186
cmsUNUSED_PARAMETER(Stride);
193
cmsUInt8Number* UnrollPlanarBytes(CMSREGISTER _cmsTRANSFORM* info,
194
CMSREGISTER cmsUInt16Number wIn[],
195
CMSREGISTER cmsUInt8Number* accum,
196
CMSREGISTER cmsUInt32Number Stride)
198
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
199
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
200
cmsUInt32Number SwapFirst = T_SWAPFIRST(info ->InputFormat);
201
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
203
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
204
cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
205
cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
206
cmsUInt8Number* Init = accum;
207
cmsUInt32Number alpha_factor = 1;
212
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[0]));
215
accum += Extra * Stride;
220
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(accum[(nChan) * Stride]));
223
for (i=0; i < nChan; i++) {
225
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
226
cmsUInt32Number v = FROM_8_TO_16(*accum);
228
v = Reverse ? REVERSE_FLAVOR_16(v) : v;
230
if (Premul && alpha_factor > 0)
232
v = ((cmsUInt32Number)((cmsUInt32Number)v << 16) / alpha_factor);
233
if (v > 0xffff) v = 0xffff;
236
wIn[index] = (cmsUInt16Number) v;
246
cmsUInt8Number* Unroll4Bytes(CMSREGISTER _cmsTRANSFORM* info,
247
CMSREGISTER cmsUInt16Number wIn[],
248
CMSREGISTER cmsUInt8Number* accum,
249
CMSREGISTER cmsUInt32Number Stride)
251
wIn[0] = FROM_8_TO_16(*accum); accum++;
252
wIn[1] = FROM_8_TO_16(*accum); accum++;
253
wIn[2] = FROM_8_TO_16(*accum); accum++;
254
wIn[3] = FROM_8_TO_16(*accum); accum++;
258
cmsUNUSED_PARAMETER(info);
259
cmsUNUSED_PARAMETER(Stride);
263
cmsUInt8Number* Unroll4BytesReverse(CMSREGISTER _cmsTRANSFORM* info,
264
CMSREGISTER cmsUInt16Number wIn[],
265
CMSREGISTER cmsUInt8Number* accum,
266
CMSREGISTER cmsUInt32Number Stride)
268
wIn[0] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++;
269
wIn[1] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++;
270
wIn[2] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++;
271
wIn[3] = FROM_8_TO_16(REVERSE_FLAVOR_8(*accum)); accum++;
275
cmsUNUSED_PARAMETER(info);
276
cmsUNUSED_PARAMETER(Stride);
280
cmsUInt8Number* Unroll4BytesSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
281
CMSREGISTER cmsUInt16Number wIn[],
282
CMSREGISTER cmsUInt8Number* accum,
283
CMSREGISTER cmsUInt32Number Stride)
285
wIn[3] = FROM_8_TO_16(*accum); accum++;
286
wIn[0] = FROM_8_TO_16(*accum); accum++;
287
wIn[1] = FROM_8_TO_16(*accum); accum++;
288
wIn[2] = FROM_8_TO_16(*accum); accum++;
292
cmsUNUSED_PARAMETER(info);
293
cmsUNUSED_PARAMETER(Stride);
298
cmsUInt8Number* Unroll4BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
299
CMSREGISTER cmsUInt16Number wIn[],
300
CMSREGISTER cmsUInt8Number* accum,
301
CMSREGISTER cmsUInt32Number Stride)
303
wIn[3] = FROM_8_TO_16(*accum); accum++;
304
wIn[2] = FROM_8_TO_16(*accum); accum++;
305
wIn[1] = FROM_8_TO_16(*accum); accum++;
306
wIn[0] = FROM_8_TO_16(*accum); accum++;
310
cmsUNUSED_PARAMETER(info);
311
cmsUNUSED_PARAMETER(Stride);
315
cmsUInt8Number* Unroll4BytesSwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
316
CMSREGISTER cmsUInt16Number wIn[],
317
CMSREGISTER cmsUInt8Number* accum,
318
CMSREGISTER cmsUInt32Number Stride)
320
wIn[2] = FROM_8_TO_16(*accum); accum++;
321
wIn[1] = FROM_8_TO_16(*accum); accum++;
322
wIn[0] = FROM_8_TO_16(*accum); accum++;
323
wIn[3] = FROM_8_TO_16(*accum); accum++;
327
cmsUNUSED_PARAMETER(info);
328
cmsUNUSED_PARAMETER(Stride);
332
cmsUInt8Number* Unroll3Bytes(CMSREGISTER _cmsTRANSFORM* info,
333
CMSREGISTER cmsUInt16Number wIn[],
334
CMSREGISTER cmsUInt8Number* accum,
335
CMSREGISTER cmsUInt32Number Stride)
337
wIn[0] = FROM_8_TO_16(*accum); accum++;
338
wIn[1] = FROM_8_TO_16(*accum); accum++;
339
wIn[2] = FROM_8_TO_16(*accum); accum++;
343
cmsUNUSED_PARAMETER(info);
344
cmsUNUSED_PARAMETER(Stride);
348
cmsUInt8Number* Unroll3BytesSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
349
CMSREGISTER cmsUInt16Number wIn[],
350
CMSREGISTER cmsUInt8Number* accum,
351
CMSREGISTER cmsUInt32Number Stride)
354
wIn[2] = FROM_8_TO_16(*accum); accum++;
355
wIn[1] = FROM_8_TO_16(*accum); accum++;
356
wIn[0] = FROM_8_TO_16(*accum); accum++;
360
cmsUNUSED_PARAMETER(info);
361
cmsUNUSED_PARAMETER(Stride);
365
cmsUInt8Number* Unroll3BytesSkip1SwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
366
CMSREGISTER cmsUInt16Number wIn[],
367
CMSREGISTER cmsUInt8Number* accum,
368
CMSREGISTER cmsUInt32Number Stride)
370
wIn[2] = FROM_8_TO_16(*accum); accum++;
371
wIn[1] = FROM_8_TO_16(*accum); accum++;
372
wIn[0] = FROM_8_TO_16(*accum); accum++;
377
cmsUNUSED_PARAMETER(info);
378
cmsUNUSED_PARAMETER(Stride);
382
cmsUInt8Number* Unroll3BytesSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
383
CMSREGISTER cmsUInt16Number wIn[],
384
CMSREGISTER cmsUInt8Number* accum,
385
CMSREGISTER cmsUInt32Number Stride)
388
wIn[0] = FROM_8_TO_16(*accum); accum++;
389
wIn[1] = FROM_8_TO_16(*accum); accum++;
390
wIn[2] = FROM_8_TO_16(*accum); accum++;
394
cmsUNUSED_PARAMETER(info);
395
cmsUNUSED_PARAMETER(Stride);
401
cmsUInt8Number* Unroll3BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
402
CMSREGISTER cmsUInt16Number wIn[],
403
CMSREGISTER cmsUInt8Number* accum,
404
CMSREGISTER cmsUInt32Number Stride)
406
wIn[2] = FROM_8_TO_16(*accum); accum++;
407
wIn[1] = FROM_8_TO_16(*accum); accum++;
408
wIn[0] = FROM_8_TO_16(*accum); accum++;
412
cmsUNUSED_PARAMETER(info);
413
cmsUNUSED_PARAMETER(Stride);
417
cmsUInt8Number* UnrollLabV2_8(CMSREGISTER _cmsTRANSFORM* info,
418
CMSREGISTER cmsUInt16Number wIn[],
419
CMSREGISTER cmsUInt8Number* accum,
420
CMSREGISTER cmsUInt32Number Stride)
422
wIn[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
423
wIn[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
424
wIn[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
428
cmsUNUSED_PARAMETER(info);
429
cmsUNUSED_PARAMETER(Stride);
433
cmsUInt8Number* UnrollALabV2_8(CMSREGISTER _cmsTRANSFORM* info,
434
CMSREGISTER cmsUInt16Number wIn[],
435
CMSREGISTER cmsUInt8Number* accum,
436
CMSREGISTER cmsUInt32Number Stride)
439
wIn[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
440
wIn[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
441
wIn[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
445
cmsUNUSED_PARAMETER(info);
446
cmsUNUSED_PARAMETER(Stride);
450
cmsUInt8Number* UnrollLabV2_16(CMSREGISTER _cmsTRANSFORM* info,
451
CMSREGISTER cmsUInt16Number wIn[],
452
CMSREGISTER cmsUInt8Number* accum,
453
CMSREGISTER cmsUInt32Number Stride)
455
wIn[0] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2;
456
wIn[1] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2;
457
wIn[2] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2;
461
cmsUNUSED_PARAMETER(info);
462
cmsUNUSED_PARAMETER(Stride);
467
cmsUInt8Number* Unroll2Bytes(CMSREGISTER _cmsTRANSFORM* info,
468
CMSREGISTER cmsUInt16Number wIn[],
469
CMSREGISTER cmsUInt8Number* accum,
470
CMSREGISTER cmsUInt32Number Stride)
472
wIn[0] = FROM_8_TO_16(*accum); accum++;
473
wIn[1] = FROM_8_TO_16(*accum); accum++;
477
cmsUNUSED_PARAMETER(info);
478
cmsUNUSED_PARAMETER(Stride);
486
cmsUInt8Number* Unroll1Byte(CMSREGISTER _cmsTRANSFORM* info,
487
CMSREGISTER cmsUInt16Number wIn[],
488
CMSREGISTER cmsUInt8Number* accum,
489
CMSREGISTER cmsUInt32Number Stride)
491
wIn[0] = wIn[1] = wIn[2] = FROM_8_TO_16(*accum); accum++;
495
cmsUNUSED_PARAMETER(info);
496
cmsUNUSED_PARAMETER(Stride);
501
cmsUInt8Number* Unroll1ByteSkip1(CMSREGISTER _cmsTRANSFORM* info,
502
CMSREGISTER cmsUInt16Number wIn[],
503
CMSREGISTER cmsUInt8Number* accum,
504
CMSREGISTER cmsUInt32Number Stride)
506
wIn[0] = wIn[1] = wIn[2] = FROM_8_TO_16(*accum); accum++;
511
cmsUNUSED_PARAMETER(info);
512
cmsUNUSED_PARAMETER(Stride);
516
cmsUInt8Number* Unroll1ByteSkip2(CMSREGISTER _cmsTRANSFORM* info,
517
CMSREGISTER cmsUInt16Number wIn[],
518
CMSREGISTER cmsUInt8Number* accum,
519
CMSREGISTER cmsUInt32Number Stride)
521
wIn[0] = wIn[1] = wIn[2] = FROM_8_TO_16(*accum); accum++;
526
cmsUNUSED_PARAMETER(info);
527
cmsUNUSED_PARAMETER(Stride);
531
cmsUInt8Number* Unroll1ByteReversed(CMSREGISTER _cmsTRANSFORM* info,
532
CMSREGISTER cmsUInt16Number wIn[],
533
CMSREGISTER cmsUInt8Number* accum,
534
CMSREGISTER cmsUInt32Number Stride)
536
wIn[0] = wIn[1] = wIn[2] = REVERSE_FLAVOR_16(FROM_8_TO_16(*accum)); accum++;
540
cmsUNUSED_PARAMETER(info);
541
cmsUNUSED_PARAMETER(Stride);
546
cmsUInt8Number* UnrollAnyWords(CMSREGISTER _cmsTRANSFORM* info,
547
CMSREGISTER cmsUInt16Number wIn[],
548
CMSREGISTER cmsUInt8Number* accum,
549
CMSREGISTER cmsUInt32Number Stride)
551
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
552
cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
553
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
554
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
555
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
556
cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
557
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
561
accum += Extra * sizeof(cmsUInt16Number);
564
for (i=0; i < nChan; i++) {
566
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
567
cmsUInt16Number v = *(cmsUInt16Number*) accum;
570
v = CHANGE_ENDIAN(v);
572
wIn[index] = Reverse ? REVERSE_FLAVOR_16(v) : v;
574
accum += sizeof(cmsUInt16Number);
578
accum += Extra * sizeof(cmsUInt16Number);
581
if (Extra == 0 && SwapFirst) {
583
cmsUInt16Number tmp = wIn[0];
585
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
591
cmsUNUSED_PARAMETER(Stride);
596
cmsUInt8Number* UnrollAnyWordsPremul(CMSREGISTER _cmsTRANSFORM* info,
597
CMSREGISTER cmsUInt16Number wIn[],
598
CMSREGISTER cmsUInt8Number* accum,
599
CMSREGISTER cmsUInt32Number Stride)
601
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
602
cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
603
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
604
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
605
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
606
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
609
cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[nChan - 1]);
610
cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha));
613
accum += sizeof(cmsUInt16Number);
616
for (i=0; i < nChan; i++) {
618
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
619
cmsUInt32Number v = *(cmsUInt16Number*) accum;
622
v = CHANGE_ENDIAN(v);
624
if (alpha_factor > 0) {
626
v = (v << 16) / alpha_factor;
627
if (v > 0xffff) v = 0xffff;
630
wIn[index] = (cmsUInt16Number) (Reverse ? REVERSE_FLAVOR_16(v) : v);
632
accum += sizeof(cmsUInt16Number);
636
accum += sizeof(cmsUInt16Number);
641
cmsUNUSED_PARAMETER(Stride);
647
cmsUInt8Number* UnrollPlanarWords(CMSREGISTER _cmsTRANSFORM* info,
648
CMSREGISTER cmsUInt16Number wIn[],
649
CMSREGISTER cmsUInt8Number* accum,
650
CMSREGISTER cmsUInt32Number Stride)
652
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
653
cmsUInt32Number DoSwap= T_DOSWAP(info ->InputFormat);
654
cmsUInt32Number Reverse= T_FLAVOR(info ->InputFormat);
655
cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
657
cmsUInt8Number* Init = accum;
660
accum += T_EXTRA(info -> InputFormat) * Stride;
663
for (i=0; i < nChan; i++) {
665
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
666
cmsUInt16Number v = *(cmsUInt16Number*) accum;
669
v = CHANGE_ENDIAN(v);
671
wIn[index] = Reverse ? REVERSE_FLAVOR_16(v) : v;
676
return (Init + sizeof(cmsUInt16Number));
680
cmsUInt8Number* UnrollPlanarWordsPremul(CMSREGISTER _cmsTRANSFORM* info,
681
CMSREGISTER cmsUInt16Number wIn[],
682
CMSREGISTER cmsUInt8Number* accum,
683
CMSREGISTER cmsUInt32Number Stride)
685
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
686
cmsUInt32Number DoSwap= T_DOSWAP(info ->InputFormat);
687
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
688
cmsUInt32Number Reverse= T_FLAVOR(info ->InputFormat);
689
cmsUInt32Number SwapEndian = T_ENDIAN16(info -> InputFormat);
691
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
692
cmsUInt8Number* Init = accum;
694
cmsUInt16Number alpha = (ExtraFirst ? accum[0] : accum[(nChan - 1) * Stride]);
695
cmsUInt32Number alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(alpha));
701
for (i=0; i < nChan; i++) {
703
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
704
cmsUInt32Number v = (cmsUInt32Number) *(cmsUInt16Number*) accum;
707
v = CHANGE_ENDIAN(v);
709
if (alpha_factor > 0) {
711
v = (v << 16) / alpha_factor;
712
if (v > 0xffff) v = 0xffff;
715
wIn[index] = (cmsUInt16Number) (Reverse ? REVERSE_FLAVOR_16(v) : v);
720
return (Init + sizeof(cmsUInt16Number));
724
cmsUInt8Number* Unroll4Words(CMSREGISTER _cmsTRANSFORM* info,
725
CMSREGISTER cmsUInt16Number wIn[],
726
CMSREGISTER cmsUInt8Number* accum,
727
CMSREGISTER cmsUInt32Number Stride)
729
wIn[0] = *(cmsUInt16Number*) accum; accum+= 2;
730
wIn[1] = *(cmsUInt16Number*) accum; accum+= 2;
731
wIn[2] = *(cmsUInt16Number*) accum; accum+= 2;
732
wIn[3] = *(cmsUInt16Number*) accum; accum+= 2;
736
cmsUNUSED_PARAMETER(info);
737
cmsUNUSED_PARAMETER(Stride);
741
cmsUInt8Number* Unroll4WordsReverse(CMSREGISTER _cmsTRANSFORM* info,
742
CMSREGISTER cmsUInt16Number wIn[],
743
CMSREGISTER cmsUInt8Number* accum,
744
CMSREGISTER cmsUInt32Number Stride)
746
wIn[0] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2;
747
wIn[1] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2;
748
wIn[2] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2;
749
wIn[3] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2;
753
cmsUNUSED_PARAMETER(info);
754
cmsUNUSED_PARAMETER(Stride);
758
cmsUInt8Number* Unroll4WordsSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
759
CMSREGISTER cmsUInt16Number wIn[],
760
CMSREGISTER cmsUInt8Number* accum,
761
CMSREGISTER cmsUInt32Number Stride)
763
wIn[3] = *(cmsUInt16Number*) accum; accum+= 2;
764
wIn[0] = *(cmsUInt16Number*) accum; accum+= 2;
765
wIn[1] = *(cmsUInt16Number*) accum; accum+= 2;
766
wIn[2] = *(cmsUInt16Number*) accum; accum+= 2;
770
cmsUNUSED_PARAMETER(info);
771
cmsUNUSED_PARAMETER(Stride);
776
cmsUInt8Number* Unroll4WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
777
CMSREGISTER cmsUInt16Number wIn[],
778
CMSREGISTER cmsUInt8Number* accum,
779
CMSREGISTER cmsUInt32Number Stride)
781
wIn[3] = *(cmsUInt16Number*) accum; accum+= 2;
782
wIn[2] = *(cmsUInt16Number*) accum; accum+= 2;
783
wIn[1] = *(cmsUInt16Number*) accum; accum+= 2;
784
wIn[0] = *(cmsUInt16Number*) accum; accum+= 2;
788
cmsUNUSED_PARAMETER(info);
789
cmsUNUSED_PARAMETER(Stride);
793
cmsUInt8Number* Unroll4WordsSwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
794
CMSREGISTER cmsUInt16Number wIn[],
795
CMSREGISTER cmsUInt8Number* accum,
796
CMSREGISTER cmsUInt32Number Stride)
798
wIn[2] = *(cmsUInt16Number*) accum; accum+= 2;
799
wIn[1] = *(cmsUInt16Number*) accum; accum+= 2;
800
wIn[0] = *(cmsUInt16Number*) accum; accum+= 2;
801
wIn[3] = *(cmsUInt16Number*) accum; accum+= 2;
805
cmsUNUSED_PARAMETER(info);
806
cmsUNUSED_PARAMETER(Stride);
810
cmsUInt8Number* Unroll3Words(CMSREGISTER _cmsTRANSFORM* info,
811
CMSREGISTER cmsUInt16Number wIn[],
812
CMSREGISTER cmsUInt8Number* accum,
813
CMSREGISTER cmsUInt32Number Stride)
815
wIn[0] = *(cmsUInt16Number*) accum; accum+= 2;
816
wIn[1] = *(cmsUInt16Number*) accum; accum+= 2;
817
wIn[2] = *(cmsUInt16Number*) accum; accum+= 2;
821
cmsUNUSED_PARAMETER(info);
822
cmsUNUSED_PARAMETER(Stride);
826
cmsUInt8Number* Unroll3WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
827
CMSREGISTER cmsUInt16Number wIn[],
828
CMSREGISTER cmsUInt8Number* accum,
829
CMSREGISTER cmsUInt32Number Stride)
831
wIn[2] = *(cmsUInt16Number*) accum; accum+= 2;
832
wIn[1] = *(cmsUInt16Number*) accum; accum+= 2;
833
wIn[0] = *(cmsUInt16Number*) accum; accum+= 2;
837
cmsUNUSED_PARAMETER(info);
838
cmsUNUSED_PARAMETER(Stride);
842
cmsUInt8Number* Unroll3WordsSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
843
CMSREGISTER cmsUInt16Number wIn[],
844
CMSREGISTER cmsUInt8Number* accum,
845
CMSREGISTER cmsUInt32Number Stride)
848
wIn[2] = *(cmsUInt16Number*) accum; accum += 2;
849
wIn[1] = *(cmsUInt16Number*) accum; accum += 2;
850
wIn[0] = *(cmsUInt16Number*) accum; accum += 2;
854
cmsUNUSED_PARAMETER(info);
855
cmsUNUSED_PARAMETER(Stride);
859
cmsUInt8Number* Unroll3WordsSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
860
CMSREGISTER cmsUInt16Number wIn[],
861
CMSREGISTER cmsUInt8Number* accum,
862
CMSREGISTER cmsUInt32Number Stride)
865
wIn[0] = *(cmsUInt16Number*) accum; accum += 2;
866
wIn[1] = *(cmsUInt16Number*) accum; accum += 2;
867
wIn[2] = *(cmsUInt16Number*) accum; accum += 2;
871
cmsUNUSED_PARAMETER(info);
872
cmsUNUSED_PARAMETER(Stride);
876
cmsUInt8Number* Unroll1Word(CMSREGISTER _cmsTRANSFORM* info,
877
CMSREGISTER cmsUInt16Number wIn[],
878
CMSREGISTER cmsUInt8Number* accum,
879
CMSREGISTER cmsUInt32Number Stride)
881
wIn[0] = wIn[1] = wIn[2] = *(cmsUInt16Number*) accum; accum+= 2;
885
cmsUNUSED_PARAMETER(info);
886
cmsUNUSED_PARAMETER(Stride);
890
cmsUInt8Number* Unroll1WordReversed(CMSREGISTER _cmsTRANSFORM* info,
891
CMSREGISTER cmsUInt16Number wIn[],
892
CMSREGISTER cmsUInt8Number* accum,
893
CMSREGISTER cmsUInt32Number Stride)
895
wIn[0] = wIn[1] = wIn[2] = REVERSE_FLAVOR_16(*(cmsUInt16Number*) accum); accum+= 2;
899
cmsUNUSED_PARAMETER(info);
900
cmsUNUSED_PARAMETER(Stride);
904
cmsUInt8Number* Unroll1WordSkip3(CMSREGISTER _cmsTRANSFORM* info,
905
CMSREGISTER cmsUInt16Number wIn[],
906
CMSREGISTER cmsUInt8Number* accum,
907
CMSREGISTER cmsUInt32Number Stride)
909
wIn[0] = wIn[1] = wIn[2] = *(cmsUInt16Number*) accum;
915
cmsUNUSED_PARAMETER(info);
916
cmsUNUSED_PARAMETER(Stride);
920
cmsUInt8Number* Unroll2Words(CMSREGISTER _cmsTRANSFORM* info,
921
CMSREGISTER cmsUInt16Number wIn[],
922
CMSREGISTER cmsUInt8Number* accum,
923
CMSREGISTER cmsUInt32Number Stride)
925
wIn[0] = *(cmsUInt16Number*) accum; accum += 2;
926
wIn[1] = *(cmsUInt16Number*) accum; accum += 2;
930
cmsUNUSED_PARAMETER(info);
931
cmsUNUSED_PARAMETER(Stride);
937
cmsUInt8Number* UnrollLabDoubleTo16(CMSREGISTER _cmsTRANSFORM* info,
938
CMSREGISTER cmsUInt16Number wIn[],
939
CMSREGISTER cmsUInt8Number* accum,
940
CMSREGISTER cmsUInt32Number Stride)
942
if (T_PLANAR(info -> InputFormat)) {
945
cmsUInt8Number* pos_L;
946
cmsUInt8Number* pos_a;
947
cmsUInt8Number* pos_b;
950
pos_a = accum + Stride;
951
pos_b = accum + Stride * 2;
953
Lab.L = *(cmsFloat64Number*) pos_L;
954
Lab.a = *(cmsFloat64Number*) pos_a;
955
Lab.b = *(cmsFloat64Number*) pos_b;
957
cmsFloat2LabEncoded(wIn, &Lab);
958
return accum + sizeof(cmsFloat64Number);
962
cmsFloat2LabEncoded(wIn, (cmsCIELab*) accum);
963
accum += sizeof(cmsCIELab) + T_EXTRA(info ->InputFormat) * sizeof(cmsFloat64Number);
971
cmsUInt8Number* UnrollLabFloatTo16(CMSREGISTER _cmsTRANSFORM* info,
972
CMSREGISTER cmsUInt16Number wIn[],
973
CMSREGISTER cmsUInt8Number* accum,
974
CMSREGISTER cmsUInt32Number Stride)
978
if (T_PLANAR(info -> InputFormat)) {
980
cmsUInt8Number* pos_L;
981
cmsUInt8Number* pos_a;
982
cmsUInt8Number* pos_b;
985
pos_a = accum + Stride;
986
pos_b = accum + Stride * 2;
988
Lab.L = *(cmsFloat32Number*)pos_L;
989
Lab.a = *(cmsFloat32Number*)pos_a;
990
Lab.b = *(cmsFloat32Number*)pos_b;
992
cmsFloat2LabEncoded(wIn, &Lab);
993
return accum + sizeof(cmsFloat32Number);
997
Lab.L = ((cmsFloat32Number*) accum)[0];
998
Lab.a = ((cmsFloat32Number*) accum)[1];
999
Lab.b = ((cmsFloat32Number*) accum)[2];
1001
cmsFloat2LabEncoded(wIn, &Lab);
1002
accum += (3 + T_EXTRA(info ->InputFormat)) * sizeof(cmsFloat32Number);
1009
cmsUInt8Number* UnrollXYZDoubleTo16(CMSREGISTER _cmsTRANSFORM* info,
1010
CMSREGISTER cmsUInt16Number wIn[],
1011
CMSREGISTER cmsUInt8Number* accum,
1012
CMSREGISTER cmsUInt32Number Stride)
1014
if (T_PLANAR(info -> InputFormat)) {
1017
cmsUInt8Number* pos_X;
1018
cmsUInt8Number* pos_Y;
1019
cmsUInt8Number* pos_Z;
1022
pos_Y = accum + Stride;
1023
pos_Z = accum + Stride * 2;
1025
XYZ.X = *(cmsFloat64Number*)pos_X;
1026
XYZ.Y = *(cmsFloat64Number*)pos_Y;
1027
XYZ.Z = *(cmsFloat64Number*)pos_Z;
1029
cmsFloat2XYZEncoded(wIn, &XYZ);
1031
return accum + sizeof(cmsFloat64Number);
1036
cmsFloat2XYZEncoded(wIn, (cmsCIEXYZ*) accum);
1037
accum += sizeof(cmsCIEXYZ) + T_EXTRA(info ->InputFormat) * sizeof(cmsFloat64Number);
1045
cmsUInt8Number* UnrollXYZFloatTo16(CMSREGISTER _cmsTRANSFORM* info,
1046
CMSREGISTER cmsUInt16Number wIn[],
1047
CMSREGISTER cmsUInt8Number* accum,
1048
CMSREGISTER cmsUInt32Number Stride)
1050
if (T_PLANAR(info -> InputFormat)) {
1053
cmsUInt8Number* pos_X;
1054
cmsUInt8Number* pos_Y;
1055
cmsUInt8Number* pos_Z;
1058
pos_Y = accum + Stride;
1059
pos_Z = accum + Stride * 2;
1061
XYZ.X = *(cmsFloat32Number*)pos_X;
1062
XYZ.Y = *(cmsFloat32Number*)pos_Y;
1063
XYZ.Z = *(cmsFloat32Number*)pos_Z;
1065
cmsFloat2XYZEncoded(wIn, &XYZ);
1067
return accum + sizeof(cmsFloat32Number);
1072
cmsFloat32Number* Pt = (cmsFloat32Number*) accum;
1078
cmsFloat2XYZEncoded(wIn, &XYZ);
1080
accum += 3 * sizeof(cmsFloat32Number) + T_EXTRA(info ->InputFormat) * sizeof(cmsFloat32Number);
1087
cmsINLINE cmsBool IsInkSpace(cmsUInt32Number Type)
1089
switch (T_COLORSPACE(Type)) {
1103
case PT_MCH15: return TRUE;
1105
default: return FALSE;
1111
cmsUInt32Number PixelSize(cmsUInt32Number Format)
1113
cmsUInt32Number fmt_bytes = T_BYTES(Format);
1117
return sizeof(cmsUInt64Number);
1125
cmsUInt8Number* UnrollDoubleTo16(CMSREGISTER _cmsTRANSFORM* info,
1126
CMSREGISTER cmsUInt16Number wIn[],
1127
CMSREGISTER cmsUInt8Number* accum,
1128
CMSREGISTER cmsUInt32Number Stride)
1131
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
1132
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
1133
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
1134
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
1135
cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
1136
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1137
cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
1140
cmsUInt32Number i, start = 0;
1141
cmsFloat64Number maximum = IsInkSpace(info ->InputFormat) ? 655.35 : 65535.0;
1144
Stride /= PixelSize(info->InputFormat);
1149
for (i=0; i < nChan; i++) {
1151
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1154
v = (cmsFloat32Number) ((cmsFloat64Number*) accum)[(i + start) * Stride];
1156
v = (cmsFloat32Number) ((cmsFloat64Number*) accum)[i + start];
1158
vi = _cmsQuickSaturateWord(v * maximum);
1161
vi = REVERSE_FLAVOR_16(vi);
1167
if (Extra == 0 && SwapFirst) {
1168
cmsUInt16Number tmp = wIn[0];
1170
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
1174
if (T_PLANAR(info -> InputFormat))
1175
return accum + sizeof(cmsFloat64Number);
1177
return accum + (nChan + Extra) * sizeof(cmsFloat64Number);
1183
cmsUInt8Number* UnrollFloatTo16(CMSREGISTER _cmsTRANSFORM* info,
1184
CMSREGISTER cmsUInt16Number wIn[],
1185
CMSREGISTER cmsUInt8Number* accum,
1186
CMSREGISTER cmsUInt32Number Stride)
1189
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
1190
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
1191
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
1192
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
1193
cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
1194
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1195
cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
1198
cmsUInt32Number i, start = 0;
1199
cmsFloat64Number maximum = IsInkSpace(info ->InputFormat) ? 655.35 : 65535.0;
1201
Stride /= PixelSize(info->InputFormat);
1206
for (i=0; i < nChan; i++) {
1208
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1211
v = (cmsFloat32Number) ((cmsFloat32Number*) accum)[(i + start) * Stride];
1213
v = (cmsFloat32Number) ((cmsFloat32Number*) accum)[i + start];
1215
vi = _cmsQuickSaturateWord(v * maximum);
1218
vi = REVERSE_FLAVOR_16(vi);
1224
if (Extra == 0 && SwapFirst) {
1225
cmsUInt16Number tmp = wIn[0];
1227
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
1231
if (T_PLANAR(info -> InputFormat))
1232
return accum + sizeof(cmsFloat32Number);
1234
return accum + (nChan + Extra) * sizeof(cmsFloat32Number);
1242
cmsUInt8Number* UnrollDouble1Chan(CMSREGISTER _cmsTRANSFORM* info,
1243
CMSREGISTER cmsUInt16Number wIn[],
1244
CMSREGISTER cmsUInt8Number* accum,
1245
CMSREGISTER cmsUInt32Number Stride)
1247
cmsFloat64Number* Inks = (cmsFloat64Number*) accum;
1249
wIn[0] = wIn[1] = wIn[2] = _cmsQuickSaturateWord(Inks[0] * 65535.0);
1251
return accum + sizeof(cmsFloat64Number);
1253
cmsUNUSED_PARAMETER(info);
1254
cmsUNUSED_PARAMETER(Stride);
1261
cmsUInt8Number* Unroll8ToFloat(_cmsTRANSFORM* info,
1262
cmsFloat32Number wIn[],
1263
cmsUInt8Number* accum,
1264
cmsUInt32Number Stride)
1267
cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
1268
cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
1269
cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
1270
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
1271
cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
1272
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1273
cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
1275
cmsUInt32Number i, start = 0;
1277
Stride /= PixelSize(info->InputFormat);
1282
for (i = 0; i < nChan; i++) {
1284
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1287
v = (cmsFloat32Number) ((cmsUInt8Number *)accum)[(i + start) * Stride];
1289
v = (cmsFloat32Number) ((cmsUInt8Number *)accum)[i + start];
1293
wIn[index] = Reverse ? 1 - v : v;
1297
if (Extra == 0 && SwapFirst) {
1298
cmsFloat32Number tmp = wIn[0];
1300
memmove(&wIn[0], &wIn[1], (nChan - 1) * sizeof(cmsFloat32Number));
1301
wIn[nChan - 1] = tmp;
1304
if (T_PLANAR(info->InputFormat))
1305
return accum + sizeof(cmsUInt8Number);
1307
return accum + (nChan + Extra) * sizeof(cmsUInt8Number);
1313
cmsUInt8Number* Unroll16ToFloat(_cmsTRANSFORM* info,
1314
cmsFloat32Number wIn[],
1315
cmsUInt8Number* accum,
1316
cmsUInt32Number Stride)
1319
cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
1320
cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
1321
cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
1322
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
1323
cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
1324
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1325
cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
1327
cmsUInt32Number i, start = 0;
1329
Stride /= PixelSize(info->InputFormat);
1334
for (i = 0; i < nChan; i++) {
1336
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1339
v = (cmsFloat32Number)((cmsUInt16Number*)accum)[(i + start) * Stride];
1341
v = (cmsFloat32Number)((cmsUInt16Number*)accum)[i + start];
1345
wIn[index] = Reverse ? 1 - v : v;
1349
if (Extra == 0 && SwapFirst) {
1350
cmsFloat32Number tmp = wIn[0];
1352
memmove(&wIn[0], &wIn[1], (nChan - 1) * sizeof(cmsFloat32Number));
1353
wIn[nChan - 1] = tmp;
1356
if (T_PLANAR(info->InputFormat))
1357
return accum + sizeof(cmsUInt16Number);
1359
return accum + (nChan + Extra) * sizeof(cmsUInt16Number);
1365
cmsUInt8Number* UnrollFloatsToFloat(_cmsTRANSFORM* info,
1366
cmsFloat32Number wIn[],
1367
cmsUInt8Number* accum,
1368
cmsUInt32Number Stride)
1371
cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
1372
cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
1373
cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
1374
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
1375
cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
1376
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1377
cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
1378
cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
1380
cmsUInt32Number i, start = 0;
1381
cmsFloat32Number maximum = IsInkSpace(info->InputFormat) ? 100.0F : 1.0F;
1382
cmsFloat32Number alpha_factor = 1.0f;
1383
cmsFloat32Number* ptr = (cmsFloat32Number*)accum;
1385
Stride /= PixelSize(info->InputFormat);
1387
if (Premul && Extra)
1390
alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan * Stride]) / maximum;
1392
alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum;
1398
for (i=0; i < nChan; i++) {
1400
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1403
v = ptr[(i + start) * Stride];
1407
if (Premul && alpha_factor > 0)
1412
wIn[index] = Reverse ? 1 - v : v;
1416
if (Extra == 0 && SwapFirst) {
1417
cmsFloat32Number tmp = wIn[0];
1419
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsFloat32Number));
1423
if (T_PLANAR(info -> InputFormat))
1424
return accum + sizeof(cmsFloat32Number);
1426
return accum + (nChan + Extra) * sizeof(cmsFloat32Number);
1432
cmsUInt8Number* UnrollDoublesToFloat(_cmsTRANSFORM* info,
1433
cmsFloat32Number wIn[],
1434
cmsUInt8Number* accum,
1435
cmsUInt32Number Stride)
1438
cmsUInt32Number nChan = T_CHANNELS(info->InputFormat);
1439
cmsUInt32Number DoSwap = T_DOSWAP(info->InputFormat);
1440
cmsUInt32Number Reverse = T_FLAVOR(info->InputFormat);
1441
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->InputFormat);
1442
cmsUInt32Number Extra = T_EXTRA(info->InputFormat);
1443
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1444
cmsUInt32Number Planar = T_PLANAR(info->InputFormat);
1445
cmsUInt32Number Premul = T_PREMUL(info->InputFormat);
1447
cmsUInt32Number i, start = 0;
1448
cmsFloat64Number maximum = IsInkSpace(info ->InputFormat) ? 100.0 : 1.0;
1449
cmsFloat64Number alpha_factor = 1.0;
1450
cmsFloat64Number* ptr = (cmsFloat64Number*)accum;
1452
Stride /= PixelSize(info->InputFormat);
1454
if (Premul && Extra)
1457
alpha_factor = (ExtraFirst ? ptr[0] : ptr[(nChan) * Stride]) / maximum;
1459
alpha_factor = (ExtraFirst ? ptr[0] : ptr[nChan]) / maximum;
1465
for (i=0; i < nChan; i++) {
1467
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1470
v = (cmsFloat64Number) ((cmsFloat64Number*) accum)[(i + start) * Stride];
1472
v = (cmsFloat64Number) ((cmsFloat64Number*) accum)[i + start];
1475
if (Premul && alpha_factor > 0)
1480
wIn[index] = (cmsFloat32Number) (Reverse ? 1.0 - v : v);
1484
if (Extra == 0 && SwapFirst) {
1485
cmsFloat32Number tmp = wIn[0];
1487
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsFloat32Number));
1491
if (T_PLANAR(info -> InputFormat))
1492
return accum + sizeof(cmsFloat64Number);
1494
return accum + (nChan + Extra) * sizeof(cmsFloat64Number);
1501
cmsUInt8Number* UnrollLabDoubleToFloat(_cmsTRANSFORM* info,
1502
cmsFloat32Number wIn[],
1503
cmsUInt8Number* accum,
1504
cmsUInt32Number Stride)
1506
cmsFloat64Number* Pt = (cmsFloat64Number*) accum;
1508
if (T_PLANAR(info -> InputFormat)) {
1510
Stride /= PixelSize(info->InputFormat);
1512
wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0);
1513
wIn[1] = (cmsFloat32Number) ((Pt[Stride] + 128) / 255.0);
1514
wIn[2] = (cmsFloat32Number) ((Pt[Stride*2] + 128) / 255.0);
1516
return accum + sizeof(cmsFloat64Number);
1520
wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0);
1521
wIn[1] = (cmsFloat32Number) ((Pt[1] + 128) / 255.0);
1522
wIn[2] = (cmsFloat32Number) ((Pt[2] + 128) / 255.0);
1524
accum += sizeof(cmsFloat64Number)*(3 + T_EXTRA(info ->InputFormat));
1531
cmsUInt8Number* UnrollLabFloatToFloat(_cmsTRANSFORM* info,
1532
cmsFloat32Number wIn[],
1533
cmsUInt8Number* accum,
1534
cmsUInt32Number Stride)
1536
cmsFloat32Number* Pt = (cmsFloat32Number*) accum;
1538
if (T_PLANAR(info -> InputFormat)) {
1540
Stride /= PixelSize(info->InputFormat);
1542
wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0);
1543
wIn[1] = (cmsFloat32Number) ((Pt[Stride] + 128) / 255.0);
1544
wIn[2] = (cmsFloat32Number) ((Pt[Stride*2] + 128) / 255.0);
1546
return accum + sizeof(cmsFloat32Number);
1550
wIn[0] = (cmsFloat32Number) (Pt[0] / 100.0);
1551
wIn[1] = (cmsFloat32Number) ((Pt[1] + 128) / 255.0);
1552
wIn[2] = (cmsFloat32Number) ((Pt[2] + 128) / 255.0);
1554
accum += sizeof(cmsFloat32Number)*(3 + T_EXTRA(info ->InputFormat));
1561
cmsUInt8Number* UnrollXYZDoubleToFloat(_cmsTRANSFORM* info,
1562
cmsFloat32Number wIn[],
1563
cmsUInt8Number* accum,
1564
cmsUInt32Number Stride)
1566
cmsFloat64Number* Pt = (cmsFloat64Number*) accum;
1568
if (T_PLANAR(info -> InputFormat)) {
1570
Stride /= PixelSize(info->InputFormat);
1572
wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
1573
wIn[1] = (cmsFloat32Number) (Pt[Stride] / MAX_ENCODEABLE_XYZ);
1574
wIn[2] = (cmsFloat32Number) (Pt[Stride*2] / MAX_ENCODEABLE_XYZ);
1576
return accum + sizeof(cmsFloat64Number);
1580
wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
1581
wIn[1] = (cmsFloat32Number) (Pt[1] / MAX_ENCODEABLE_XYZ);
1582
wIn[2] = (cmsFloat32Number) (Pt[2] / MAX_ENCODEABLE_XYZ);
1584
accum += sizeof(cmsFloat64Number)*(3 + T_EXTRA(info ->InputFormat));
1590
cmsUInt8Number* UnrollXYZFloatToFloat(_cmsTRANSFORM* info,
1591
cmsFloat32Number wIn[],
1592
cmsUInt8Number* accum,
1593
cmsUInt32Number Stride)
1595
cmsFloat32Number* Pt = (cmsFloat32Number*) accum;
1597
if (T_PLANAR(info -> InputFormat)) {
1599
Stride /= PixelSize(info->InputFormat);
1601
wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
1602
wIn[1] = (cmsFloat32Number) (Pt[Stride] / MAX_ENCODEABLE_XYZ);
1603
wIn[2] = (cmsFloat32Number) (Pt[Stride*2] / MAX_ENCODEABLE_XYZ);
1605
return accum + sizeof(cmsFloat32Number);
1609
wIn[0] = (cmsFloat32Number) (Pt[0] / MAX_ENCODEABLE_XYZ);
1610
wIn[1] = (cmsFloat32Number) (Pt[1] / MAX_ENCODEABLE_XYZ);
1611
wIn[2] = (cmsFloat32Number) (Pt[2] / MAX_ENCODEABLE_XYZ);
1613
accum += sizeof(cmsFloat32Number)*(3 + T_EXTRA(info ->InputFormat));
1619
cmsINLINE void lab4toFloat(cmsFloat32Number wIn[], cmsUInt16Number lab4[3])
1621
cmsFloat32Number L = (cmsFloat32Number) lab4[0] / 655.35F;
1622
cmsFloat32Number a = ((cmsFloat32Number) lab4[1] / 257.0F) - 128.0F;
1623
cmsFloat32Number b = ((cmsFloat32Number) lab4[2] / 257.0F) - 128.0F;
1625
wIn[0] = (L / 100.0F);
1626
wIn[1] = ((a + 128.0F) / 255.0F);
1627
wIn[2] = ((b + 128.0F) / 255.0F);
1632
cmsUInt8Number* UnrollLabV2_8ToFloat(_cmsTRANSFORM* info,
1633
cmsFloat32Number wIn[],
1634
cmsUInt8Number* accum,
1635
cmsUInt32Number Stride)
1637
cmsUInt16Number lab4[3];
1639
lab4[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
1640
lab4[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
1641
lab4[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
1643
lab4toFloat(wIn, lab4);
1647
cmsUNUSED_PARAMETER(info);
1648
cmsUNUSED_PARAMETER(Stride);
1652
cmsUInt8Number* UnrollALabV2_8ToFloat(_cmsTRANSFORM* info,
1653
cmsFloat32Number wIn[],
1654
cmsUInt8Number* accum,
1655
cmsUInt32Number Stride)
1657
cmsUInt16Number lab4[3];
1660
lab4[0] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
1661
lab4[1] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
1662
lab4[2] = FomLabV2ToLabV4(FROM_8_TO_16(*accum)); accum++;
1664
lab4toFloat(wIn, lab4);
1668
cmsUNUSED_PARAMETER(info);
1669
cmsUNUSED_PARAMETER(Stride);
1673
cmsUInt8Number* UnrollLabV2_16ToFloat(_cmsTRANSFORM* info,
1674
cmsFloat32Number wIn[],
1675
cmsUInt8Number* accum,
1676
cmsUInt32Number Stride)
1678
cmsUInt16Number lab4[3];
1680
lab4[0] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2;
1681
lab4[1] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2;
1682
lab4[2] = FomLabV2ToLabV4(*(cmsUInt16Number*) accum); accum += 2;
1684
lab4toFloat(wIn, lab4);
1688
cmsUNUSED_PARAMETER(info);
1689
cmsUNUSED_PARAMETER(Stride);
1698
cmsUInt8Number* PackChunkyBytes(CMSREGISTER _cmsTRANSFORM* info,
1699
CMSREGISTER cmsUInt16Number wOut[],
1700
CMSREGISTER cmsUInt8Number* output,
1701
CMSREGISTER cmsUInt32Number Stride)
1703
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
1704
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
1705
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
1706
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
1707
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
1708
cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
1709
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1710
cmsUInt8Number* swap1;
1711
cmsUInt16Number v = 0;
1713
cmsUInt32Number alpha_factor = 0;
1719
if (Premul && Extra)
1720
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[0]));
1726
if (Premul && Extra)
1727
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[nChan]));
1730
for (i=0; i < nChan; i++) {
1732
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1737
v = REVERSE_FLAVOR_16(v);
1741
v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
1744
*output++ = FROM_16_TO_8(v);
1751
if (Extra == 0 && SwapFirst) {
1753
memmove(swap1 + 1, swap1, nChan-1);
1754
*swap1 = FROM_16_TO_8(v);
1759
cmsUNUSED_PARAMETER(Stride);
1763
cmsUInt8Number* PackChunkyWords(CMSREGISTER _cmsTRANSFORM* info,
1764
CMSREGISTER cmsUInt16Number wOut[],
1765
CMSREGISTER cmsUInt8Number* output,
1766
CMSREGISTER cmsUInt32Number Stride)
1768
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
1769
cmsUInt32Number SwapEndian = T_ENDIAN16(info->OutputFormat);
1770
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
1771
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
1772
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
1773
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
1774
cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
1775
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1776
cmsUInt16Number* swap1;
1777
cmsUInt16Number v = 0;
1779
cmsUInt32Number alpha_factor = 0;
1781
swap1 = (cmsUInt16Number*) output;
1785
if (Premul && Extra)
1786
alpha_factor = _cmsToFixedDomain(*(cmsUInt16Number*) output);
1788
output += Extra * sizeof(cmsUInt16Number);
1792
if (Premul && Extra)
1793
alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*) output)[nChan]);
1796
for (i=0; i < nChan; i++) {
1798
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1803
v = CHANGE_ENDIAN(v);
1806
v = REVERSE_FLAVOR_16(v);
1810
v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
1813
*(cmsUInt16Number*) output = v;
1815
output += sizeof(cmsUInt16Number);
1819
output += Extra * sizeof(cmsUInt16Number);
1822
if (Extra == 0 && SwapFirst) {
1824
memmove(swap1 + 1, swap1, (nChan-1)* sizeof(cmsUInt16Number));
1830
cmsUNUSED_PARAMETER(Stride);
1836
cmsUInt8Number* PackPlanarBytes(CMSREGISTER _cmsTRANSFORM* info,
1837
CMSREGISTER cmsUInt16Number wOut[],
1838
CMSREGISTER cmsUInt8Number* output,
1839
CMSREGISTER cmsUInt32Number Stride)
1841
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
1842
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
1843
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
1844
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
1845
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
1846
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1847
cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
1849
cmsUInt8Number* Init = output;
1850
cmsUInt32Number alpha_factor = 0;
1855
if (Premul && Extra)
1856
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[0]));
1858
output += Extra * Stride;
1862
if (Premul && Extra)
1863
alpha_factor = _cmsToFixedDomain(FROM_8_TO_16(output[nChan * Stride]));
1867
for (i=0; i < nChan; i++) {
1869
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1870
cmsUInt16Number v = wOut[index];
1873
v = REVERSE_FLAVOR_16(v);
1877
v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
1880
*(cmsUInt8Number*)output = FROM_16_TO_8(v);
1887
cmsUNUSED_PARAMETER(Stride);
1892
cmsUInt8Number* PackPlanarWords(CMSREGISTER _cmsTRANSFORM* info,
1893
CMSREGISTER cmsUInt16Number wOut[],
1894
CMSREGISTER cmsUInt8Number* output,
1895
CMSREGISTER cmsUInt32Number Stride)
1897
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
1898
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
1899
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
1900
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
1901
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
1902
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
1903
cmsUInt32Number Premul = T_PREMUL(info->OutputFormat);
1904
cmsUInt32Number SwapEndian = T_ENDIAN16(info->OutputFormat);
1906
cmsUInt8Number* Init = output;
1908
cmsUInt32Number alpha_factor = 0;
1912
if (Premul && Extra)
1913
alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*) output)[0]);
1915
output += Extra * Stride;
1919
if (Premul && Extra)
1920
alpha_factor = _cmsToFixedDomain(((cmsUInt16Number*)output)[nChan * Stride]);
1923
for (i=0; i < nChan; i++) {
1925
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
1930
v = CHANGE_ENDIAN(v);
1933
v = REVERSE_FLAVOR_16(v);
1937
v = (cmsUInt16Number)((cmsUInt32Number)((cmsUInt32Number)v * alpha_factor + 0x8000) >> 16);
1940
*(cmsUInt16Number*) output = v;
1944
return (Init + sizeof(cmsUInt16Number));
1950
cmsUInt8Number* Pack6Bytes(CMSREGISTER _cmsTRANSFORM* info,
1951
CMSREGISTER cmsUInt16Number wOut[],
1952
CMSREGISTER cmsUInt8Number* output,
1953
CMSREGISTER cmsUInt32Number Stride)
1955
*output++ = FROM_16_TO_8(wOut[0]);
1956
*output++ = FROM_16_TO_8(wOut[1]);
1957
*output++ = FROM_16_TO_8(wOut[2]);
1958
*output++ = FROM_16_TO_8(wOut[3]);
1959
*output++ = FROM_16_TO_8(wOut[4]);
1960
*output++ = FROM_16_TO_8(wOut[5]);
1964
cmsUNUSED_PARAMETER(info);
1965
cmsUNUSED_PARAMETER(Stride);
1971
cmsUInt8Number* Pack6BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
1972
CMSREGISTER cmsUInt16Number wOut[],
1973
CMSREGISTER cmsUInt8Number* output,
1974
CMSREGISTER cmsUInt32Number Stride)
1976
*output++ = FROM_16_TO_8(wOut[5]);
1977
*output++ = FROM_16_TO_8(wOut[4]);
1978
*output++ = FROM_16_TO_8(wOut[3]);
1979
*output++ = FROM_16_TO_8(wOut[2]);
1980
*output++ = FROM_16_TO_8(wOut[1]);
1981
*output++ = FROM_16_TO_8(wOut[0]);
1985
cmsUNUSED_PARAMETER(info);
1986
cmsUNUSED_PARAMETER(Stride);
1991
cmsUInt8Number* Pack6Words(CMSREGISTER _cmsTRANSFORM* info,
1992
CMSREGISTER cmsUInt16Number wOut[],
1993
CMSREGISTER cmsUInt8Number* output,
1994
CMSREGISTER cmsUInt32Number Stride)
1996
*(cmsUInt16Number*) output = wOut[0];
1998
*(cmsUInt16Number*) output = wOut[1];
2000
*(cmsUInt16Number*) output = wOut[2];
2002
*(cmsUInt16Number*) output = wOut[3];
2004
*(cmsUInt16Number*) output = wOut[4];
2006
*(cmsUInt16Number*) output = wOut[5];
2011
cmsUNUSED_PARAMETER(info);
2012
cmsUNUSED_PARAMETER(Stride);
2017
cmsUInt8Number* Pack6WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
2018
CMSREGISTER cmsUInt16Number wOut[],
2019
CMSREGISTER cmsUInt8Number* output,
2020
CMSREGISTER cmsUInt32Number Stride)
2022
*(cmsUInt16Number*) output = wOut[5];
2024
*(cmsUInt16Number*) output = wOut[4];
2026
*(cmsUInt16Number*) output = wOut[3];
2028
*(cmsUInt16Number*) output = wOut[2];
2030
*(cmsUInt16Number*) output = wOut[1];
2032
*(cmsUInt16Number*) output = wOut[0];
2037
cmsUNUSED_PARAMETER(info);
2038
cmsUNUSED_PARAMETER(Stride);
2043
cmsUInt8Number* Pack4Bytes(CMSREGISTER _cmsTRANSFORM* info,
2044
CMSREGISTER cmsUInt16Number wOut[],
2045
CMSREGISTER cmsUInt8Number* output,
2046
CMSREGISTER cmsUInt32Number Stride)
2048
*output++ = FROM_16_TO_8(wOut[0]);
2049
*output++ = FROM_16_TO_8(wOut[1]);
2050
*output++ = FROM_16_TO_8(wOut[2]);
2051
*output++ = FROM_16_TO_8(wOut[3]);
2055
cmsUNUSED_PARAMETER(info);
2056
cmsUNUSED_PARAMETER(Stride);
2060
cmsUInt8Number* Pack4BytesReverse(CMSREGISTER _cmsTRANSFORM* info,
2061
CMSREGISTER cmsUInt16Number wOut[],
2062
CMSREGISTER cmsUInt8Number* output,
2063
CMSREGISTER cmsUInt32Number Stride)
2065
*output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[0]));
2066
*output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[1]));
2067
*output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[2]));
2068
*output++ = REVERSE_FLAVOR_8(FROM_16_TO_8(wOut[3]));
2072
cmsUNUSED_PARAMETER(info);
2073
cmsUNUSED_PARAMETER(Stride);
2078
cmsUInt8Number* Pack4BytesSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2079
CMSREGISTER cmsUInt16Number wOut[],
2080
CMSREGISTER cmsUInt8Number* output,
2081
CMSREGISTER cmsUInt32Number Stride)
2083
*output++ = FROM_16_TO_8(wOut[3]);
2084
*output++ = FROM_16_TO_8(wOut[0]);
2085
*output++ = FROM_16_TO_8(wOut[1]);
2086
*output++ = FROM_16_TO_8(wOut[2]);
2090
cmsUNUSED_PARAMETER(info);
2091
cmsUNUSED_PARAMETER(Stride);
2096
cmsUInt8Number* Pack4BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
2097
CMSREGISTER cmsUInt16Number wOut[],
2098
CMSREGISTER cmsUInt8Number* output,
2099
CMSREGISTER cmsUInt32Number Stride)
2101
*output++ = FROM_16_TO_8(wOut[3]);
2102
*output++ = FROM_16_TO_8(wOut[2]);
2103
*output++ = FROM_16_TO_8(wOut[1]);
2104
*output++ = FROM_16_TO_8(wOut[0]);
2108
cmsUNUSED_PARAMETER(info);
2109
cmsUNUSED_PARAMETER(Stride);
2113
cmsUInt8Number* Pack4BytesSwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2114
CMSREGISTER cmsUInt16Number wOut[],
2115
CMSREGISTER cmsUInt8Number* output,
2116
CMSREGISTER cmsUInt32Number Stride)
2118
*output++ = FROM_16_TO_8(wOut[2]);
2119
*output++ = FROM_16_TO_8(wOut[1]);
2120
*output++ = FROM_16_TO_8(wOut[0]);
2121
*output++ = FROM_16_TO_8(wOut[3]);
2125
cmsUNUSED_PARAMETER(info);
2126
cmsUNUSED_PARAMETER(Stride);
2130
cmsUInt8Number* Pack4Words(CMSREGISTER _cmsTRANSFORM* info,
2131
CMSREGISTER cmsUInt16Number wOut[],
2132
CMSREGISTER cmsUInt8Number* output,
2133
CMSREGISTER cmsUInt32Number Stride)
2135
*(cmsUInt16Number*) output = wOut[0];
2137
*(cmsUInt16Number*) output = wOut[1];
2139
*(cmsUInt16Number*) output = wOut[2];
2141
*(cmsUInt16Number*) output = wOut[3];
2146
cmsUNUSED_PARAMETER(info);
2147
cmsUNUSED_PARAMETER(Stride);
2151
cmsUInt8Number* Pack4WordsReverse(CMSREGISTER _cmsTRANSFORM* info,
2152
CMSREGISTER cmsUInt16Number wOut[],
2153
CMSREGISTER cmsUInt8Number* output,
2154
CMSREGISTER cmsUInt32Number Stride)
2156
*(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[0]);
2158
*(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[1]);
2160
*(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[2]);
2162
*(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[3]);
2167
cmsUNUSED_PARAMETER(info);
2168
cmsUNUSED_PARAMETER(Stride);
2173
cmsUInt8Number* Pack4WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
2174
CMSREGISTER cmsUInt16Number wOut[],
2175
CMSREGISTER cmsUInt8Number* output,
2176
CMSREGISTER cmsUInt32Number Stride)
2178
*(cmsUInt16Number*) output = wOut[3];
2180
*(cmsUInt16Number*) output = wOut[2];
2182
*(cmsUInt16Number*) output = wOut[1];
2184
*(cmsUInt16Number*) output = wOut[0];
2189
cmsUNUSED_PARAMETER(info);
2190
cmsUNUSED_PARAMETER(Stride);
2195
cmsUInt8Number* Pack4WordsBigEndian(CMSREGISTER _cmsTRANSFORM* info,
2196
CMSREGISTER cmsUInt16Number wOut[],
2197
CMSREGISTER cmsUInt8Number* output,
2198
CMSREGISTER cmsUInt32Number Stride)
2200
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[0]);
2202
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[1]);
2204
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[2]);
2206
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[3]);
2211
cmsUNUSED_PARAMETER(info);
2212
cmsUNUSED_PARAMETER(Stride);
2217
cmsUInt8Number* PackLabV2_8(CMSREGISTER _cmsTRANSFORM* info,
2218
CMSREGISTER cmsUInt16Number wOut[],
2219
CMSREGISTER cmsUInt8Number* output,
2220
CMSREGISTER cmsUInt32Number Stride)
2222
*output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[0]));
2223
*output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[1]));
2224
*output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[2]));
2228
cmsUNUSED_PARAMETER(info);
2229
cmsUNUSED_PARAMETER(Stride);
2233
cmsUInt8Number* PackALabV2_8(CMSREGISTER _cmsTRANSFORM* info,
2234
CMSREGISTER cmsUInt16Number wOut[],
2235
CMSREGISTER cmsUInt8Number* output,
2236
CMSREGISTER cmsUInt32Number Stride)
2239
*output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[0]));
2240
*output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[1]));
2241
*output++ = FROM_16_TO_8(FomLabV4ToLabV2(wOut[2]));
2245
cmsUNUSED_PARAMETER(info);
2246
cmsUNUSED_PARAMETER(Stride);
2250
cmsUInt8Number* PackLabV2_16(CMSREGISTER _cmsTRANSFORM* info,
2251
CMSREGISTER cmsUInt16Number wOut[],
2252
CMSREGISTER cmsUInt8Number* output,
2253
CMSREGISTER cmsUInt32Number Stride)
2255
*(cmsUInt16Number*) output = FomLabV4ToLabV2(wOut[0]);
2257
*(cmsUInt16Number*) output = FomLabV4ToLabV2(wOut[1]);
2259
*(cmsUInt16Number*) output = FomLabV4ToLabV2(wOut[2]);
2264
cmsUNUSED_PARAMETER(info);
2265
cmsUNUSED_PARAMETER(Stride);
2269
cmsUInt8Number* Pack3Bytes(CMSREGISTER _cmsTRANSFORM* info,
2270
CMSREGISTER cmsUInt16Number wOut[],
2271
CMSREGISTER cmsUInt8Number* output,
2272
CMSREGISTER cmsUInt32Number Stride)
2274
*output++ = FROM_16_TO_8(wOut[0]);
2275
*output++ = FROM_16_TO_8(wOut[1]);
2276
*output++ = FROM_16_TO_8(wOut[2]);
2280
cmsUNUSED_PARAMETER(info);
2281
cmsUNUSED_PARAMETER(Stride);
2285
cmsUInt8Number* Pack3BytesOptimized(CMSREGISTER _cmsTRANSFORM* info,
2286
CMSREGISTER cmsUInt16Number wOut[],
2287
CMSREGISTER cmsUInt8Number* output,
2288
CMSREGISTER cmsUInt32Number Stride)
2290
*output++ = (wOut[0] & 0xFFU);
2291
*output++ = (wOut[1] & 0xFFU);
2292
*output++ = (wOut[2] & 0xFFU);
2296
cmsUNUSED_PARAMETER(info);
2297
cmsUNUSED_PARAMETER(Stride);
2301
cmsUInt8Number* Pack3BytesSwap(CMSREGISTER _cmsTRANSFORM* info,
2302
CMSREGISTER cmsUInt16Number wOut[],
2303
CMSREGISTER cmsUInt8Number* output,
2304
CMSREGISTER cmsUInt32Number Stride)
2306
*output++ = FROM_16_TO_8(wOut[2]);
2307
*output++ = FROM_16_TO_8(wOut[1]);
2308
*output++ = FROM_16_TO_8(wOut[0]);
2312
cmsUNUSED_PARAMETER(info);
2313
cmsUNUSED_PARAMETER(Stride);
2317
cmsUInt8Number* Pack3BytesSwapOptimized(CMSREGISTER _cmsTRANSFORM* info,
2318
CMSREGISTER cmsUInt16Number wOut[],
2319
CMSREGISTER cmsUInt8Number* output,
2320
CMSREGISTER cmsUInt32Number Stride)
2322
*output++ = (wOut[2] & 0xFFU);
2323
*output++ = (wOut[1] & 0xFFU);
2324
*output++ = (wOut[0] & 0xFFU);
2328
cmsUNUSED_PARAMETER(info);
2329
cmsUNUSED_PARAMETER(Stride);
2334
cmsUInt8Number* Pack3Words(CMSREGISTER _cmsTRANSFORM* info,
2335
CMSREGISTER cmsUInt16Number wOut[],
2336
CMSREGISTER cmsUInt8Number* output,
2337
CMSREGISTER cmsUInt32Number Stride)
2339
*(cmsUInt16Number*) output = wOut[0];
2341
*(cmsUInt16Number*) output = wOut[1];
2343
*(cmsUInt16Number*) output = wOut[2];
2348
cmsUNUSED_PARAMETER(info);
2349
cmsUNUSED_PARAMETER(Stride);
2353
cmsUInt8Number* Pack3WordsSwap(CMSREGISTER _cmsTRANSFORM* info,
2354
CMSREGISTER cmsUInt16Number wOut[],
2355
CMSREGISTER cmsUInt8Number* output,
2356
CMSREGISTER cmsUInt32Number Stride)
2358
*(cmsUInt16Number*) output = wOut[2];
2360
*(cmsUInt16Number*) output = wOut[1];
2362
*(cmsUInt16Number*) output = wOut[0];
2367
cmsUNUSED_PARAMETER(info);
2368
cmsUNUSED_PARAMETER(Stride);
2372
cmsUInt8Number* Pack3WordsBigEndian(CMSREGISTER _cmsTRANSFORM* info,
2373
CMSREGISTER cmsUInt16Number wOut[],
2374
CMSREGISTER cmsUInt8Number* output,
2375
CMSREGISTER cmsUInt32Number Stride)
2377
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[0]);
2379
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[1]);
2381
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[2]);
2386
cmsUNUSED_PARAMETER(info);
2387
cmsUNUSED_PARAMETER(Stride);
2391
cmsUInt8Number* Pack3BytesAndSkip1(CMSREGISTER _cmsTRANSFORM* info,
2392
CMSREGISTER cmsUInt16Number wOut[],
2393
CMSREGISTER cmsUInt8Number* output,
2394
CMSREGISTER cmsUInt32Number Stride)
2396
*output++ = FROM_16_TO_8(wOut[0]);
2397
*output++ = FROM_16_TO_8(wOut[1]);
2398
*output++ = FROM_16_TO_8(wOut[2]);
2403
cmsUNUSED_PARAMETER(info);
2404
cmsUNUSED_PARAMETER(Stride);
2408
cmsUInt8Number* Pack3BytesAndSkip1Optimized(CMSREGISTER _cmsTRANSFORM* info,
2409
CMSREGISTER cmsUInt16Number wOut[],
2410
CMSREGISTER cmsUInt8Number* output,
2411
CMSREGISTER cmsUInt32Number Stride)
2413
*output++ = (wOut[0] & 0xFFU);
2414
*output++ = (wOut[1] & 0xFFU);
2415
*output++ = (wOut[2] & 0xFFU);
2420
cmsUNUSED_PARAMETER(info);
2421
cmsUNUSED_PARAMETER(Stride);
2426
cmsUInt8Number* Pack3BytesAndSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2427
CMSREGISTER cmsUInt16Number wOut[],
2428
CMSREGISTER cmsUInt8Number* output,
2429
CMSREGISTER cmsUInt32Number Stride)
2432
*output++ = FROM_16_TO_8(wOut[0]);
2433
*output++ = FROM_16_TO_8(wOut[1]);
2434
*output++ = FROM_16_TO_8(wOut[2]);
2438
cmsUNUSED_PARAMETER(info);
2439
cmsUNUSED_PARAMETER(Stride);
2443
cmsUInt8Number* Pack3BytesAndSkip1SwapFirstOptimized(CMSREGISTER _cmsTRANSFORM* info,
2444
CMSREGISTER cmsUInt16Number wOut[],
2445
CMSREGISTER cmsUInt8Number* output,
2446
CMSREGISTER cmsUInt32Number Stride)
2449
*output++ = (wOut[0] & 0xFFU);
2450
*output++ = (wOut[1] & 0xFFU);
2451
*output++ = (wOut[2] & 0xFFU);
2455
cmsUNUSED_PARAMETER(info);
2456
cmsUNUSED_PARAMETER(Stride);
2460
cmsUInt8Number* Pack3BytesAndSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
2461
CMSREGISTER cmsUInt16Number wOut[],
2462
CMSREGISTER cmsUInt8Number* output,
2463
CMSREGISTER cmsUInt32Number Stride)
2466
*output++ = FROM_16_TO_8(wOut[2]);
2467
*output++ = FROM_16_TO_8(wOut[1]);
2468
*output++ = FROM_16_TO_8(wOut[0]);
2472
cmsUNUSED_PARAMETER(info);
2473
cmsUNUSED_PARAMETER(Stride);
2477
cmsUInt8Number* Pack3BytesAndSkip1SwapOptimized(CMSREGISTER _cmsTRANSFORM* info,
2478
CMSREGISTER cmsUInt16Number wOut[],
2479
CMSREGISTER cmsUInt8Number* output,
2480
CMSREGISTER cmsUInt32Number Stride)
2483
*output++ = (wOut[2] & 0xFFU);
2484
*output++ = (wOut[1] & 0xFFU);
2485
*output++ = (wOut[0] & 0xFFU);
2489
cmsUNUSED_PARAMETER(info);
2490
cmsUNUSED_PARAMETER(Stride);
2495
cmsUInt8Number* Pack3BytesAndSkip1SwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2496
CMSREGISTER cmsUInt16Number wOut[],
2497
CMSREGISTER cmsUInt8Number* output,
2498
CMSREGISTER cmsUInt32Number Stride)
2500
*output++ = FROM_16_TO_8(wOut[2]);
2501
*output++ = FROM_16_TO_8(wOut[1]);
2502
*output++ = FROM_16_TO_8(wOut[0]);
2507
cmsUNUSED_PARAMETER(info);
2508
cmsUNUSED_PARAMETER(Stride);
2512
cmsUInt8Number* Pack3BytesAndSkip1SwapSwapFirstOptimized(CMSREGISTER _cmsTRANSFORM* info,
2513
CMSREGISTER cmsUInt16Number wOut[],
2514
CMSREGISTER cmsUInt8Number* output,
2515
CMSREGISTER cmsUInt32Number Stride)
2517
*output++ = (wOut[2] & 0xFFU);
2518
*output++ = (wOut[1] & 0xFFU);
2519
*output++ = (wOut[0] & 0xFFU);
2524
cmsUNUSED_PARAMETER(info);
2525
cmsUNUSED_PARAMETER(Stride);
2529
cmsUInt8Number* Pack3WordsAndSkip1(CMSREGISTER _cmsTRANSFORM* info,
2530
CMSREGISTER cmsUInt16Number wOut[],
2531
CMSREGISTER cmsUInt8Number* output,
2532
CMSREGISTER cmsUInt32Number Stride)
2534
*(cmsUInt16Number*) output = wOut[0];
2536
*(cmsUInt16Number*) output = wOut[1];
2538
*(cmsUInt16Number*) output = wOut[2];
2544
cmsUNUSED_PARAMETER(info);
2545
cmsUNUSED_PARAMETER(Stride);
2549
cmsUInt8Number* Pack3WordsAndSkip1Swap(CMSREGISTER _cmsTRANSFORM* info,
2550
CMSREGISTER cmsUInt16Number wOut[],
2551
CMSREGISTER cmsUInt8Number* output,
2552
CMSREGISTER cmsUInt32Number Stride)
2555
*(cmsUInt16Number*) output = wOut[2];
2557
*(cmsUInt16Number*) output = wOut[1];
2559
*(cmsUInt16Number*) output = wOut[0];
2564
cmsUNUSED_PARAMETER(info);
2565
cmsUNUSED_PARAMETER(Stride);
2570
cmsUInt8Number* Pack3WordsAndSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2571
CMSREGISTER cmsUInt16Number wOut[],
2572
CMSREGISTER cmsUInt8Number* output,
2573
CMSREGISTER cmsUInt32Number Stride)
2576
*(cmsUInt16Number*) output = wOut[0];
2578
*(cmsUInt16Number*) output = wOut[1];
2580
*(cmsUInt16Number*) output = wOut[2];
2585
cmsUNUSED_PARAMETER(info);
2586
cmsUNUSED_PARAMETER(Stride);
2591
cmsUInt8Number* Pack3WordsAndSkip1SwapSwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2592
CMSREGISTER cmsUInt16Number wOut[],
2593
CMSREGISTER cmsUInt8Number* output,
2594
CMSREGISTER cmsUInt32Number Stride)
2596
*(cmsUInt16Number*) output = wOut[2];
2598
*(cmsUInt16Number*) output = wOut[1];
2600
*(cmsUInt16Number*) output = wOut[0];
2606
cmsUNUSED_PARAMETER(info);
2607
cmsUNUSED_PARAMETER(Stride);
2613
cmsUInt8Number* Pack1Byte(CMSREGISTER _cmsTRANSFORM* info,
2614
CMSREGISTER cmsUInt16Number wOut[],
2615
CMSREGISTER cmsUInt8Number* output,
2616
CMSREGISTER cmsUInt32Number Stride)
2618
*output++ = FROM_16_TO_8(wOut[0]);
2622
cmsUNUSED_PARAMETER(info);
2623
cmsUNUSED_PARAMETER(Stride);
2628
cmsUInt8Number* Pack1ByteReversed(CMSREGISTER _cmsTRANSFORM* info,
2629
CMSREGISTER cmsUInt16Number wOut[],
2630
CMSREGISTER cmsUInt8Number* output,
2631
CMSREGISTER cmsUInt32Number Stride)
2633
*output++ = FROM_16_TO_8(REVERSE_FLAVOR_16(wOut[0]));
2637
cmsUNUSED_PARAMETER(info);
2638
cmsUNUSED_PARAMETER(Stride);
2643
cmsUInt8Number* Pack1ByteSkip1(CMSREGISTER _cmsTRANSFORM* info,
2644
CMSREGISTER cmsUInt16Number wOut[],
2645
CMSREGISTER cmsUInt8Number* output,
2646
CMSREGISTER cmsUInt32Number Stride)
2648
*output++ = FROM_16_TO_8(wOut[0]);
2653
cmsUNUSED_PARAMETER(info);
2654
cmsUNUSED_PARAMETER(Stride);
2659
cmsUInt8Number* Pack1ByteSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2660
CMSREGISTER cmsUInt16Number wOut[],
2661
CMSREGISTER cmsUInt8Number* output,
2662
CMSREGISTER cmsUInt32Number Stride)
2665
*output++ = FROM_16_TO_8(wOut[0]);
2669
cmsUNUSED_PARAMETER(info);
2670
cmsUNUSED_PARAMETER(Stride);
2674
cmsUInt8Number* Pack1Word(CMSREGISTER _cmsTRANSFORM* info,
2675
CMSREGISTER cmsUInt16Number wOut[],
2676
CMSREGISTER cmsUInt8Number* output,
2677
CMSREGISTER cmsUInt32Number Stride)
2679
*(cmsUInt16Number*) output = wOut[0];
2684
cmsUNUSED_PARAMETER(info);
2685
cmsUNUSED_PARAMETER(Stride);
2690
cmsUInt8Number* Pack1WordReversed(CMSREGISTER _cmsTRANSFORM* info,
2691
CMSREGISTER cmsUInt16Number wOut[],
2692
CMSREGISTER cmsUInt8Number* output,
2693
CMSREGISTER cmsUInt32Number Stride)
2695
*(cmsUInt16Number*) output = REVERSE_FLAVOR_16(wOut[0]);
2700
cmsUNUSED_PARAMETER(info);
2701
cmsUNUSED_PARAMETER(Stride);
2705
cmsUInt8Number* Pack1WordBigEndian(CMSREGISTER _cmsTRANSFORM* info,
2706
CMSREGISTER cmsUInt16Number wOut[],
2707
CMSREGISTER cmsUInt8Number* output,
2708
CMSREGISTER cmsUInt32Number Stride)
2710
*(cmsUInt16Number*) output = CHANGE_ENDIAN(wOut[0]);
2715
cmsUNUSED_PARAMETER(info);
2716
cmsUNUSED_PARAMETER(Stride);
2721
cmsUInt8Number* Pack1WordSkip1(CMSREGISTER _cmsTRANSFORM* info,
2722
CMSREGISTER cmsUInt16Number wOut[],
2723
CMSREGISTER cmsUInt8Number* output,
2724
CMSREGISTER cmsUInt32Number Stride)
2726
*(cmsUInt16Number*) output = wOut[0];
2731
cmsUNUSED_PARAMETER(info);
2732
cmsUNUSED_PARAMETER(Stride);
2736
cmsUInt8Number* Pack1WordSkip1SwapFirst(CMSREGISTER _cmsTRANSFORM* info,
2737
CMSREGISTER cmsUInt16Number wOut[],
2738
CMSREGISTER cmsUInt8Number* output,
2739
CMSREGISTER cmsUInt32Number Stride)
2742
*(cmsUInt16Number*) output = wOut[0];
2747
cmsUNUSED_PARAMETER(info);
2748
cmsUNUSED_PARAMETER(Stride);
2754
cmsUInt8Number* PackLabDoubleFrom16(CMSREGISTER _cmsTRANSFORM* info,
2755
CMSREGISTER cmsUInt16Number wOut[],
2756
CMSREGISTER cmsUInt8Number* output,
2757
CMSREGISTER cmsUInt32Number Stride)
2760
if (T_PLANAR(info -> OutputFormat)) {
2763
cmsFloat64Number* Out = (cmsFloat64Number*) output;
2764
cmsLabEncoded2Float(&Lab, wOut);
2767
Out[Stride] = Lab.a;
2768
Out[Stride*2] = Lab.b;
2770
return output + sizeof(cmsFloat64Number);
2774
cmsLabEncoded2Float((cmsCIELab*) output, wOut);
2775
return output + (sizeof(cmsCIELab) + T_EXTRA(info ->OutputFormat) * sizeof(cmsFloat64Number));
2781
cmsUInt8Number* PackLabFloatFrom16(CMSREGISTER _cmsTRANSFORM* info,
2782
CMSREGISTER cmsUInt16Number wOut[],
2783
CMSREGISTER cmsUInt8Number* output,
2784
CMSREGISTER cmsUInt32Number Stride)
2787
cmsLabEncoded2Float(&Lab, wOut);
2789
if (T_PLANAR(info -> OutputFormat)) {
2791
cmsFloat32Number* Out = (cmsFloat32Number*) output;
2793
Stride /= PixelSize(info->OutputFormat);
2795
Out[0] = (cmsFloat32Number)Lab.L;
2796
Out[Stride] = (cmsFloat32Number)Lab.a;
2797
Out[Stride*2] = (cmsFloat32Number)Lab.b;
2799
return output + sizeof(cmsFloat32Number);
2803
((cmsFloat32Number*) output)[0] = (cmsFloat32Number) Lab.L;
2804
((cmsFloat32Number*) output)[1] = (cmsFloat32Number) Lab.a;
2805
((cmsFloat32Number*) output)[2] = (cmsFloat32Number) Lab.b;
2807
return output + (3 + T_EXTRA(info ->OutputFormat)) * sizeof(cmsFloat32Number);
2812
cmsUInt8Number* PackXYZDoubleFrom16(CMSREGISTER _cmsTRANSFORM* Info,
2813
CMSREGISTER cmsUInt16Number wOut[],
2814
CMSREGISTER cmsUInt8Number* output,
2815
CMSREGISTER cmsUInt32Number Stride)
2817
if (T_PLANAR(Info -> OutputFormat)) {
2820
cmsFloat64Number* Out = (cmsFloat64Number*) output;
2821
cmsXYZEncoded2Float(&XYZ, wOut);
2823
Stride /= PixelSize(Info->OutputFormat);
2826
Out[Stride] = XYZ.Y;
2827
Out[Stride*2] = XYZ.Z;
2829
return output + sizeof(cmsFloat64Number);
2834
cmsXYZEncoded2Float((cmsCIEXYZ*) output, wOut);
2836
return output + (sizeof(cmsCIEXYZ) + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat64Number));
2841
cmsUInt8Number* PackXYZFloatFrom16(CMSREGISTER _cmsTRANSFORM* Info,
2842
CMSREGISTER cmsUInt16Number wOut[],
2843
CMSREGISTER cmsUInt8Number* output,
2844
CMSREGISTER cmsUInt32Number Stride)
2846
if (T_PLANAR(Info -> OutputFormat)) {
2849
cmsFloat32Number* Out = (cmsFloat32Number*) output;
2850
cmsXYZEncoded2Float(&XYZ, wOut);
2852
Stride /= PixelSize(Info->OutputFormat);
2854
Out[0] = (cmsFloat32Number) XYZ.X;
2855
Out[Stride] = (cmsFloat32Number) XYZ.Y;
2856
Out[Stride*2] = (cmsFloat32Number) XYZ.Z;
2858
return output + sizeof(cmsFloat32Number);
2864
cmsFloat32Number* Out = (cmsFloat32Number*) output;
2865
cmsXYZEncoded2Float(&XYZ, wOut);
2867
Out[0] = (cmsFloat32Number) XYZ.X;
2868
Out[1] = (cmsFloat32Number) XYZ.Y;
2869
Out[2] = (cmsFloat32Number) XYZ.Z;
2871
return output + (3 * sizeof(cmsFloat32Number) + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat32Number));
2876
cmsUInt8Number* PackDoubleFrom16(CMSREGISTER _cmsTRANSFORM* info,
2877
CMSREGISTER cmsUInt16Number wOut[],
2878
CMSREGISTER cmsUInt8Number* output,
2879
CMSREGISTER cmsUInt32Number Stride)
2881
cmsUInt32Number nChan = T_CHANNELS(info -> OutputFormat);
2882
cmsUInt32Number DoSwap = T_DOSWAP(info ->OutputFormat);
2883
cmsUInt32Number Reverse = T_FLAVOR(info ->OutputFormat);
2884
cmsUInt32Number Extra = T_EXTRA(info -> OutputFormat);
2885
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> OutputFormat);
2886
cmsUInt32Number Planar = T_PLANAR(info -> OutputFormat);
2887
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
2888
cmsFloat64Number maximum = IsInkSpace(info ->OutputFormat) ? 655.35 : 65535.0;
2889
cmsFloat64Number v = 0;
2890
cmsFloat64Number* swap1 = (cmsFloat64Number*) output;
2891
cmsUInt32Number i, start = 0;
2893
Stride /= PixelSize(info->OutputFormat);
2898
for (i=0; i < nChan; i++) {
2900
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
2902
v = (cmsFloat64Number) wOut[index] / maximum;
2908
((cmsFloat64Number*) output)[(i + start) * Stride]= v;
2910
((cmsFloat64Number*) output)[i + start] = v;
2914
if (Extra == 0 && SwapFirst) {
2916
memmove(swap1 + 1, swap1, (nChan-1)* sizeof(cmsFloat64Number));
2920
if (T_PLANAR(info -> OutputFormat))
2921
return output + sizeof(cmsFloat64Number);
2923
return output + (nChan + Extra) * sizeof(cmsFloat64Number);
2929
cmsUInt8Number* PackFloatFrom16(CMSREGISTER _cmsTRANSFORM* info,
2930
CMSREGISTER cmsUInt16Number wOut[],
2931
CMSREGISTER cmsUInt8Number* output,
2932
CMSREGISTER cmsUInt32Number Stride)
2934
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
2935
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
2936
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
2937
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
2938
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
2939
cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
2940
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
2941
cmsFloat64Number maximum = IsInkSpace(info->OutputFormat) ? 655.35 : 65535.0;
2942
cmsFloat64Number v = 0;
2943
cmsFloat32Number* swap1 = (cmsFloat32Number*)output;
2944
cmsUInt32Number i, start = 0;
2946
Stride /= PixelSize(info->OutputFormat);
2951
for (i = 0; i < nChan; i++) {
2953
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
2955
v = (cmsFloat64Number)wOut[index] / maximum;
2961
((cmsFloat32Number*)output)[(i + start) * Stride] = (cmsFloat32Number)v;
2963
((cmsFloat32Number*)output)[i + start] = (cmsFloat32Number)v;
2967
if (Extra == 0 && SwapFirst) {
2969
memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsFloat32Number));
2970
*swap1 = (cmsFloat32Number)v;
2973
if (T_PLANAR(info->OutputFormat))
2974
return output + sizeof(cmsFloat32Number);
2976
return output + (nChan + Extra) * sizeof(cmsFloat32Number);
2984
cmsUInt8Number* PackBytesFromFloat(_cmsTRANSFORM* info,
2985
cmsFloat32Number wOut[],
2986
cmsUInt8Number* output,
2987
cmsUInt32Number Stride)
2989
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
2990
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
2991
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
2992
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
2993
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
2994
cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
2995
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
2996
cmsUInt8Number* swap1 = (cmsUInt8Number*)output;
2997
cmsFloat64Number v = 0;
2998
cmsUInt8Number vv = 0;
2999
cmsUInt32Number i, start = 0;
3004
for (i = 0; i < nChan; i++) {
3006
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3008
v = wOut[index] * 65535.0;
3013
vv = FROM_16_TO_8(_cmsQuickSaturateWord(v));
3016
((cmsUInt8Number*)output)[(i + start) * Stride] = vv;
3018
((cmsUInt8Number*)output)[i + start] = vv;
3022
if (Extra == 0 && SwapFirst) {
3024
memmove(swap1 + 1, swap1, (nChan - 1) * sizeof(cmsUInt8Number));
3028
if (T_PLANAR(info->OutputFormat))
3029
return output + sizeof(cmsUInt8Number);
3031
return output + (nChan + Extra) * sizeof(cmsUInt8Number);
3035
cmsUInt8Number* PackWordsFromFloat(_cmsTRANSFORM* info,
3036
cmsFloat32Number wOut[],
3037
cmsUInt8Number* output,
3038
cmsUInt32Number Stride)
3040
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
3041
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
3042
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
3043
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
3044
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
3045
cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
3046
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
3047
cmsUInt16Number* swap1 = (cmsUInt16Number*)output;
3048
cmsFloat64Number v = 0;
3049
cmsUInt16Number vv = 0;
3050
cmsUInt32Number i, start = 0;
3055
for (i = 0; i < nChan; i++) {
3057
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3059
v = wOut[index] * 65535.0;
3064
vv = _cmsQuickSaturateWord(v);
3067
((cmsUInt16Number*)output)[(i + start) * Stride] = vv;
3069
((cmsUInt16Number*)output)[i + start] = vv;
3072
if (Extra == 0 && SwapFirst) {
3074
memmove(swap1 + 1, swap1, (nChan - 1) * sizeof(cmsUInt16Number));
3078
if (T_PLANAR(info->OutputFormat))
3079
return output + sizeof(cmsUInt16Number);
3081
return output + (nChan + Extra) * sizeof(cmsUInt16Number);
3086
cmsUInt8Number* PackFloatsFromFloat(_cmsTRANSFORM* info,
3087
cmsFloat32Number wOut[],
3088
cmsUInt8Number* output,
3089
cmsUInt32Number Stride)
3091
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
3092
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
3093
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
3094
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
3095
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
3096
cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
3097
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
3098
cmsFloat64Number maximum = IsInkSpace(info->OutputFormat) ? 100.0 : 1.0;
3099
cmsFloat32Number* swap1 = (cmsFloat32Number*)output;
3100
cmsFloat64Number v = 0;
3101
cmsUInt32Number i, start = 0;
3103
Stride /= PixelSize(info->OutputFormat);
3108
for (i = 0; i < nChan; i++) {
3110
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3112
v = wOut[index] * maximum;
3118
((cmsFloat32Number*)output)[(i + start)* Stride] = (cmsFloat32Number)v;
3120
((cmsFloat32Number*)output)[i + start] = (cmsFloat32Number)v;
3124
if (Extra == 0 && SwapFirst) {
3126
memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsFloat32Number));
3127
*swap1 = (cmsFloat32Number)v;
3130
if (T_PLANAR(info->OutputFormat))
3131
return output + sizeof(cmsFloat32Number);
3133
return output + (nChan + Extra) * sizeof(cmsFloat32Number);
3137
cmsUInt8Number* PackDoublesFromFloat(_cmsTRANSFORM* info,
3138
cmsFloat32Number wOut[],
3139
cmsUInt8Number* output,
3140
cmsUInt32Number Stride)
3142
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
3143
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
3144
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
3145
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
3146
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
3147
cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
3148
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
3149
cmsFloat64Number maximum = IsInkSpace(info->OutputFormat) ? 100.0 : 1.0;
3150
cmsFloat64Number v = 0;
3151
cmsFloat64Number* swap1 = (cmsFloat64Number*)output;
3152
cmsUInt32Number i, start = 0;
3154
Stride /= PixelSize(info->OutputFormat);
3159
for (i = 0; i < nChan; i++) {
3161
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3163
v = wOut[index] * maximum;
3169
((cmsFloat64Number*)output)[(i + start) * Stride] = v;
3171
((cmsFloat64Number*)output)[i + start] = v;
3174
if (Extra == 0 && SwapFirst) {
3176
memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsFloat64Number));
3181
if (T_PLANAR(info->OutputFormat))
3182
return output + sizeof(cmsFloat64Number);
3184
return output + (nChan + Extra) * sizeof(cmsFloat64Number);
3189
cmsUInt8Number* PackLabFloatFromFloat(_cmsTRANSFORM* Info,
3190
cmsFloat32Number wOut[],
3191
cmsUInt8Number* output,
3192
cmsUInt32Number Stride)
3194
cmsFloat32Number* Out = (cmsFloat32Number*) output;
3196
if (T_PLANAR(Info -> OutputFormat)) {
3198
Stride /= PixelSize(Info->OutputFormat);
3200
Out[0] = (cmsFloat32Number) (wOut[0] * 100.0);
3201
Out[Stride] = (cmsFloat32Number) (wOut[1] * 255.0 - 128.0);
3202
Out[Stride*2] = (cmsFloat32Number) (wOut[2] * 255.0 - 128.0);
3204
return output + sizeof(cmsFloat32Number);
3208
Out[0] = (cmsFloat32Number) (wOut[0] * 100.0);
3209
Out[1] = (cmsFloat32Number) (wOut[1] * 255.0 - 128.0);
3210
Out[2] = (cmsFloat32Number) (wOut[2] * 255.0 - 128.0);
3212
return output + (sizeof(cmsFloat32Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat32Number));
3219
cmsUInt8Number* PackLabDoubleFromFloat(_cmsTRANSFORM* Info,
3220
cmsFloat32Number wOut[],
3221
cmsUInt8Number* output,
3222
cmsUInt32Number Stride)
3224
cmsFloat64Number* Out = (cmsFloat64Number*) output;
3226
if (T_PLANAR(Info -> OutputFormat)) {
3228
Stride /= PixelSize(Info->OutputFormat);
3230
Out[0] = (cmsFloat64Number) (wOut[0] * 100.0);
3231
Out[Stride] = (cmsFloat64Number) (wOut[1] * 255.0 - 128.0);
3232
Out[Stride*2] = (cmsFloat64Number) (wOut[2] * 255.0 - 128.0);
3234
return output + sizeof(cmsFloat64Number);
3238
Out[0] = (cmsFloat64Number) (wOut[0] * 100.0);
3239
Out[1] = (cmsFloat64Number) (wOut[1] * 255.0 - 128.0);
3240
Out[2] = (cmsFloat64Number) (wOut[2] * 255.0 - 128.0);
3242
return output + (sizeof(cmsFloat64Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat64Number));
3249
cmsUInt8Number* PackEncodedBytesLabV2FromFloat(_cmsTRANSFORM* Info,
3250
cmsFloat32Number wOut[],
3251
cmsUInt8Number* output,
3252
cmsUInt32Number Stride)
3255
cmsUInt16Number wlab[3];
3257
Lab.L = (cmsFloat64Number)(wOut[0] * 100.0);
3258
Lab.a = (cmsFloat64Number)(wOut[1] * 255.0 - 128.0);
3259
Lab.b = (cmsFloat64Number)(wOut[2] * 255.0 - 128.0);
3261
cmsFloat2LabEncoded(wlab, &Lab);
3263
if (T_PLANAR(Info -> OutputFormat)) {
3265
Stride /= PixelSize(Info->OutputFormat);
3267
output[0] = wlab[0] >> 8;
3268
output[Stride] = wlab[1] >> 8;
3269
output[Stride*2] = wlab[2] >> 8;
3275
output[0] = wlab[0] >> 8;
3276
output[1] = wlab[1] >> 8;
3277
output[2] = wlab[2] >> 8;
3279
return output + (3 + T_EXTRA(Info ->OutputFormat));
3284
cmsUInt8Number* PackEncodedWordsLabV2FromFloat(_cmsTRANSFORM* Info,
3285
cmsFloat32Number wOut[],
3286
cmsUInt8Number* output,
3287
cmsUInt32Number Stride)
3290
cmsUInt16Number wlab[3];
3292
Lab.L = (cmsFloat64Number)(wOut[0] * 100.0);
3293
Lab.a = (cmsFloat64Number)(wOut[1] * 255.0 - 128.0);
3294
Lab.b = (cmsFloat64Number)(wOut[2] * 255.0 - 128.0);
3296
cmsFloat2LabEncodedV2(wlab, &Lab);
3298
if (T_PLANAR(Info -> OutputFormat)) {
3300
Stride /= PixelSize(Info->OutputFormat);
3302
((cmsUInt16Number*) output)[0] = wlab[0];
3303
((cmsUInt16Number*) output)[Stride] = wlab[1];
3304
((cmsUInt16Number*) output)[Stride*2] = wlab[2];
3306
return output + sizeof(cmsUInt16Number);
3310
((cmsUInt16Number*) output)[0] = wlab[0];
3311
((cmsUInt16Number*) output)[1] = wlab[1];
3312
((cmsUInt16Number*) output)[2] = wlab[2];
3314
return output + (3 + T_EXTRA(Info ->OutputFormat)) * sizeof(cmsUInt16Number);
3321
cmsUInt8Number* PackXYZFloatFromFloat(_cmsTRANSFORM* Info,
3322
cmsFloat32Number wOut[],
3323
cmsUInt8Number* output,
3324
cmsUInt32Number Stride)
3326
cmsFloat32Number* Out = (cmsFloat32Number*) output;
3328
if (T_PLANAR(Info -> OutputFormat)) {
3330
Stride /= PixelSize(Info->OutputFormat);
3332
Out[0] = (cmsFloat32Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
3333
Out[Stride] = (cmsFloat32Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
3334
Out[Stride*2] = (cmsFloat32Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
3336
return output + sizeof(cmsFloat32Number);
3340
Out[0] = (cmsFloat32Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
3341
Out[1] = (cmsFloat32Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
3342
Out[2] = (cmsFloat32Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
3344
return output + (sizeof(cmsFloat32Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat32Number));
3351
cmsUInt8Number* PackXYZDoubleFromFloat(_cmsTRANSFORM* Info,
3352
cmsFloat32Number wOut[],
3353
cmsUInt8Number* output,
3354
cmsUInt32Number Stride)
3356
cmsFloat64Number* Out = (cmsFloat64Number*) output;
3358
if (T_PLANAR(Info -> OutputFormat)) {
3360
Stride /= PixelSize(Info->OutputFormat);
3362
Out[0] = (cmsFloat64Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
3363
Out[Stride] = (cmsFloat64Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
3364
Out[Stride*2] = (cmsFloat64Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
3366
return output + sizeof(cmsFloat64Number);
3370
Out[0] = (cmsFloat64Number) (wOut[0] * MAX_ENCODEABLE_XYZ);
3371
Out[1] = (cmsFloat64Number) (wOut[1] * MAX_ENCODEABLE_XYZ);
3372
Out[2] = (cmsFloat64Number) (wOut[2] * MAX_ENCODEABLE_XYZ);
3374
return output + (sizeof(cmsFloat64Number)*3 + T_EXTRA(Info ->OutputFormat) * sizeof(cmsFloat64Number));
3382
#ifndef CMS_NO_HALF_SUPPORT
3387
cmsUInt8Number* UnrollHalfTo16(CMSREGISTER _cmsTRANSFORM* info,
3388
CMSREGISTER cmsUInt16Number wIn[],
3389
CMSREGISTER cmsUInt8Number* accum,
3390
CMSREGISTER cmsUInt32Number Stride)
3393
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
3394
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
3395
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
3396
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
3397
cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
3398
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
3399
cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
3401
cmsUInt32Number i, start = 0;
3402
cmsFloat32Number maximum = IsInkSpace(info ->InputFormat) ? 655.35F : 65535.0F;
3405
Stride /= PixelSize(info->OutputFormat);
3410
for (i=0; i < nChan; i++) {
3412
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3415
v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[(i + start) * Stride] );
3417
v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[i + start] ) ;
3419
if (Reverse) v = maximum - v;
3421
wIn[index] = _cmsQuickSaturateWord((cmsFloat64Number) v * maximum);
3425
if (Extra == 0 && SwapFirst) {
3426
cmsUInt16Number tmp = wIn[0];
3428
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsUInt16Number));
3432
if (T_PLANAR(info -> InputFormat))
3433
return accum + sizeof(cmsUInt16Number);
3435
return accum + (nChan + Extra) * sizeof(cmsUInt16Number);
3441
cmsUInt8Number* UnrollHalfToFloat(_cmsTRANSFORM* info,
3442
cmsFloat32Number wIn[],
3443
cmsUInt8Number* accum,
3444
cmsUInt32Number Stride)
3447
cmsUInt32Number nChan = T_CHANNELS(info -> InputFormat);
3448
cmsUInt32Number DoSwap = T_DOSWAP(info ->InputFormat);
3449
cmsUInt32Number Reverse = T_FLAVOR(info ->InputFormat);
3450
cmsUInt32Number SwapFirst = T_SWAPFIRST(info -> InputFormat);
3451
cmsUInt32Number Extra = T_EXTRA(info -> InputFormat);
3452
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
3453
cmsUInt32Number Planar = T_PLANAR(info -> InputFormat);
3455
cmsUInt32Number i, start = 0;
3456
cmsFloat32Number maximum = IsInkSpace(info ->InputFormat) ? 100.0F : 1.0F;
3458
Stride /= PixelSize(info->OutputFormat);
3463
for (i=0; i < nChan; i++) {
3465
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3468
v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[(i + start) * Stride] );
3470
v = _cmsHalf2Float ( ((cmsUInt16Number*) accum)[i + start] ) ;
3474
wIn[index] = Reverse ? 1 - v : v;
3478
if (Extra == 0 && SwapFirst) {
3479
cmsFloat32Number tmp = wIn[0];
3481
memmove(&wIn[0], &wIn[1], (nChan-1) * sizeof(cmsFloat32Number));
3485
if (T_PLANAR(info -> InputFormat))
3486
return accum + sizeof(cmsUInt16Number);
3488
return accum + (nChan + Extra) * sizeof(cmsUInt16Number);
3493
cmsUInt8Number* PackHalfFrom16(CMSREGISTER _cmsTRANSFORM* info,
3494
CMSREGISTER cmsUInt16Number wOut[],
3495
CMSREGISTER cmsUInt8Number* output,
3496
CMSREGISTER cmsUInt32Number Stride)
3498
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
3499
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
3500
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
3501
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
3502
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
3503
cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
3504
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
3505
cmsFloat32Number maximum = IsInkSpace(info->OutputFormat) ? 655.35F : 65535.0F;
3506
cmsFloat32Number v = 0;
3507
cmsUInt16Number* swap1 = (cmsUInt16Number*)output;
3508
cmsUInt32Number i, start = 0;
3510
Stride /= PixelSize(info->OutputFormat);
3515
for (i = 0; i < nChan; i++) {
3517
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3519
v = (cmsFloat32Number)wOut[index] / maximum;
3525
((cmsUInt16Number*)output)[(i + start) * Stride] = _cmsFloat2Half(v);
3527
((cmsUInt16Number*)output)[i + start] = _cmsFloat2Half(v);
3531
if (Extra == 0 && SwapFirst) {
3533
memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsUInt16Number));
3534
*swap1 = _cmsFloat2Half(v);
3537
if (T_PLANAR(info->OutputFormat))
3538
return output + sizeof(cmsUInt16Number);
3540
return output + (nChan + Extra) * sizeof(cmsUInt16Number);
3546
cmsUInt8Number* PackHalfFromFloat(_cmsTRANSFORM* info,
3547
cmsFloat32Number wOut[],
3548
cmsUInt8Number* output,
3549
cmsUInt32Number Stride)
3551
cmsUInt32Number nChan = T_CHANNELS(info->OutputFormat);
3552
cmsUInt32Number DoSwap = T_DOSWAP(info->OutputFormat);
3553
cmsUInt32Number Reverse = T_FLAVOR(info->OutputFormat);
3554
cmsUInt32Number Extra = T_EXTRA(info->OutputFormat);
3555
cmsUInt32Number SwapFirst = T_SWAPFIRST(info->OutputFormat);
3556
cmsUInt32Number Planar = T_PLANAR(info->OutputFormat);
3557
cmsUInt32Number ExtraFirst = DoSwap ^ SwapFirst;
3558
cmsFloat32Number maximum = IsInkSpace(info->OutputFormat) ? 100.0F : 1.0F;
3559
cmsUInt16Number* swap1 = (cmsUInt16Number*)output;
3560
cmsFloat32Number v = 0;
3561
cmsUInt32Number i, start = 0;
3563
Stride /= PixelSize(info->OutputFormat);
3568
for (i = 0; i < nChan; i++) {
3570
cmsUInt32Number index = DoSwap ? (nChan - i - 1) : i;
3572
v = wOut[index] * maximum;
3578
((cmsUInt16Number*)output)[(i + start)* Stride] = _cmsFloat2Half(v);
3580
((cmsUInt16Number*)output)[i + start] = _cmsFloat2Half(v);
3584
if (Extra == 0 && SwapFirst) {
3586
memmove(swap1 + 1, swap1, (nChan - 1)* sizeof(cmsUInt16Number));
3587
*swap1 = (cmsUInt16Number)_cmsFloat2Half(v);
3590
if (T_PLANAR(info->OutputFormat))
3591
return output + sizeof(cmsUInt16Number);
3593
return output + (nChan + Extra)* sizeof(cmsUInt16Number);
3601
static const cmsFormatters16 InputFormatters16[] = {
3605
{ TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, UnrollLabDoubleTo16},
3606
{ TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, UnrollXYZDoubleTo16},
3607
{ TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, UnrollLabFloatTo16},
3608
{ TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, UnrollXYZFloatTo16},
3609
{ TYPE_GRAY_DBL, 0, UnrollDouble1Chan},
3610
{ FLOAT_SH(1)|BYTES_SH(0), ANYCHANNELS|ANYPLANAR|ANYSWAPFIRST|ANYFLAVOR|
3611
ANYSWAP|ANYEXTRA|ANYSPACE, UnrollDoubleTo16},
3612
{ FLOAT_SH(1)|BYTES_SH(4), ANYCHANNELS|ANYPLANAR|ANYSWAPFIRST|ANYFLAVOR|
3613
ANYSWAP|ANYEXTRA|ANYSPACE, UnrollFloatTo16},
3614
#ifndef CMS_NO_HALF_SUPPORT
3615
{ FLOAT_SH(1)|BYTES_SH(2), ANYCHANNELS|ANYPLANAR|ANYSWAPFIRST|ANYFLAVOR|
3616
ANYEXTRA|ANYSWAP|ANYSPACE, UnrollHalfTo16},
3619
{ CHANNELS_SH(1)|BYTES_SH(1), ANYSPACE, Unroll1Byte},
3620
{ CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(1), ANYSPACE, Unroll1ByteSkip1},
3621
{ CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(2), ANYSPACE, Unroll1ByteSkip2},
3622
{ CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Unroll1ByteReversed},
3623
{ COLORSPACE_SH(PT_MCH2)|CHANNELS_SH(2)|BYTES_SH(1), 0, Unroll2Bytes},
3625
{ TYPE_LabV2_8, 0, UnrollLabV2_8 },
3626
{ TYPE_ALabV2_8, 0, UnrollALabV2_8 },
3627
{ TYPE_LabV2_16, 0, UnrollLabV2_16 },
3629
{ CHANNELS_SH(3)|BYTES_SH(1), ANYSPACE, Unroll3Bytes},
3630
{ CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll3BytesSwap},
3631
{ CHANNELS_SH(3)|EXTRA_SH(1)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll3BytesSkip1Swap},
3632
{ CHANNELS_SH(3)|EXTRA_SH(1)|BYTES_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll3BytesSkip1SwapFirst},
3634
{ CHANNELS_SH(3)|EXTRA_SH(1)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1),
3635
ANYSPACE, Unroll3BytesSkip1SwapSwapFirst},
3637
{ CHANNELS_SH(4)|BYTES_SH(1), ANYSPACE, Unroll4Bytes},
3638
{ CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Unroll4BytesReverse},
3639
{ CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll4BytesSwapFirst},
3640
{ CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll4BytesSwap},
3641
{ CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll4BytesSwapSwapFirst},
3643
{ BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYPREMUL|
3644
ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollPlanarBytes},
3646
{ BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYPREMUL|
3647
ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollChunkyBytes},
3649
{ CHANNELS_SH(1)|BYTES_SH(2), ANYSPACE, Unroll1Word},
3650
{ CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Unroll1WordReversed},
3651
{ CHANNELS_SH(1)|BYTES_SH(2)|EXTRA_SH(3), ANYSPACE, Unroll1WordSkip3},
3653
{ CHANNELS_SH(2)|BYTES_SH(2), ANYSPACE, Unroll2Words},
3654
{ CHANNELS_SH(3)|BYTES_SH(2), ANYSPACE, Unroll3Words},
3655
{ CHANNELS_SH(4)|BYTES_SH(2), ANYSPACE, Unroll4Words},
3657
{ CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Unroll3WordsSwap},
3658
{ CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll3WordsSkip1SwapFirst},
3659
{ CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|DOSWAP_SH(1), ANYSPACE, Unroll3WordsSkip1Swap},
3660
{ CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Unroll4WordsReverse},
3661
{ CHANNELS_SH(4)|BYTES_SH(2)|SWAPFIRST_SH(1), ANYSPACE, Unroll4WordsSwapFirst},
3662
{ CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Unroll4WordsSwap},
3663
{ CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Unroll4WordsSwapSwapFirst},
3666
{ BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollPlanarWords},
3667
{ BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE, UnrollAnyWords},
3669
{ BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE|PREMUL_SH(1), UnrollPlanarWordsPremul},
3670
{ BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|ANYEXTRA|ANYCHANNELS|ANYSPACE|PREMUL_SH(1), UnrollAnyWordsPremul}
3676
static const cmsFormattersFloat InputFormattersFloat[] = {
3680
{ TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, UnrollLabDoubleToFloat},
3681
{ TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, UnrollLabFloatToFloat},
3683
{ TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, UnrollXYZDoubleToFloat},
3684
{ TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, UnrollXYZFloatToFloat},
3686
{ FLOAT_SH(1)|BYTES_SH(4), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
3687
ANYPREMUL|ANYCHANNELS|ANYSPACE, UnrollFloatsToFloat},
3689
{ FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
3690
ANYCHANNELS|ANYSPACE|ANYPREMUL, UnrollDoublesToFloat},
3692
{ TYPE_LabV2_8, 0, UnrollLabV2_8ToFloat },
3693
{ TYPE_ALabV2_8, 0, UnrollALabV2_8ToFloat },
3694
{ TYPE_LabV2_16, 0, UnrollLabV2_16ToFloat },
3696
{ BYTES_SH(1), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
3697
ANYCHANNELS|ANYSPACE, Unroll8ToFloat},
3699
{ BYTES_SH(2), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
3700
ANYCHANNELS|ANYSPACE, Unroll16ToFloat},
3701
#ifndef CMS_NO_HALF_SUPPORT
3702
{ FLOAT_SH(1)|BYTES_SH(2), ANYPLANAR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
3703
ANYCHANNELS|ANYSPACE, UnrollHalfToFloat},
3710
cmsFormatter _cmsGetStockInputFormatter(cmsUInt32Number dwInput, cmsUInt32Number dwFlags)
3717
case CMS_PACK_FLAGS_16BITS: {
3718
for (i=0; i < sizeof(InputFormatters16) / sizeof(cmsFormatters16); i++) {
3719
const cmsFormatters16* f = InputFormatters16 + i;
3721
if ((dwInput & ~f ->Mask) == f ->Type) {
3729
case CMS_PACK_FLAGS_FLOAT: {
3730
for (i=0; i < sizeof(InputFormattersFloat) / sizeof(cmsFormattersFloat); i++) {
3731
const cmsFormattersFloat* f = InputFormattersFloat + i;
3733
if ((dwInput & ~f ->Mask) == f ->Type) {
3734
fr.FmtFloat = f ->Frm;
3749
static const cmsFormatters16 OutputFormatters16[] = {
3753
{ TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, PackLabDoubleFrom16},
3754
{ TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, PackXYZDoubleFrom16},
3756
{ TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, PackLabFloatFrom16},
3757
{ TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, PackXYZFloatFrom16},
3759
{ FLOAT_SH(1)|BYTES_SH(0), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|
3760
ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackDoubleFrom16},
3761
{ FLOAT_SH(1)|BYTES_SH(4), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|
3762
ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackFloatFrom16},
3763
#ifndef CMS_NO_HALF_SUPPORT
3764
{ FLOAT_SH(1)|BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|
3765
ANYCHANNELS|ANYPLANAR|ANYEXTRA|ANYSPACE, PackHalfFrom16},
3768
{ CHANNELS_SH(1)|BYTES_SH(1), ANYSPACE, Pack1Byte},
3769
{ CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(1), ANYSPACE, Pack1ByteSkip1},
3770
{ CHANNELS_SH(1)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack1ByteSkip1SwapFirst},
3772
{ CHANNELS_SH(1)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Pack1ByteReversed},
3774
{ TYPE_LabV2_8, 0, PackLabV2_8 },
3775
{ TYPE_ALabV2_8, 0, PackALabV2_8 },
3776
{ TYPE_LabV2_16, 0, PackLabV2_16 },
3778
{ CHANNELS_SH(3)|BYTES_SH(1)|OPTIMIZED_SH(1), ANYSPACE, Pack3BytesOptimized},
3779
{ CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|OPTIMIZED_SH(1), ANYSPACE, Pack3BytesAndSkip1Optimized},
3780
{ CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1)|OPTIMIZED_SH(1),
3781
ANYSPACE, Pack3BytesAndSkip1SwapFirstOptimized},
3782
{ CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1)|OPTIMIZED_SH(1),
3783
ANYSPACE, Pack3BytesAndSkip1SwapSwapFirstOptimized},
3784
{ CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|EXTRA_SH(1)|OPTIMIZED_SH(1),
3785
ANYSPACE, Pack3BytesAndSkip1SwapOptimized},
3786
{ CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|OPTIMIZED_SH(1), ANYSPACE, Pack3BytesSwapOptimized},
3790
{ CHANNELS_SH(3)|BYTES_SH(1), ANYSPACE, Pack3Bytes},
3791
{ CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1), ANYSPACE, Pack3BytesAndSkip1},
3792
{ CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack3BytesAndSkip1SwapFirst},
3793
{ CHANNELS_SH(3)|BYTES_SH(1)|EXTRA_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1),
3794
ANYSPACE, Pack3BytesAndSkip1SwapSwapFirst},
3795
{ CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1)|EXTRA_SH(1), ANYSPACE, Pack3BytesAndSkip1Swap},
3796
{ CHANNELS_SH(3)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack3BytesSwap},
3797
{ CHANNELS_SH(4)|BYTES_SH(1), ANYSPACE, Pack4Bytes},
3798
{ CHANNELS_SH(4)|BYTES_SH(1)|FLAVOR_SH(1), ANYSPACE, Pack4BytesReverse},
3799
{ CHANNELS_SH(4)|BYTES_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack4BytesSwapFirst},
3800
{ CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack4BytesSwap},
3801
{ CHANNELS_SH(4)|BYTES_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack4BytesSwapSwapFirst},
3802
{ CHANNELS_SH(6)|BYTES_SH(1), ANYSPACE, Pack6Bytes},
3803
{ CHANNELS_SH(6)|BYTES_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack6BytesSwap},
3805
{ BYTES_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|
3806
ANYSPACE|ANYPREMUL, PackChunkyBytes},
3808
{ BYTES_SH(1)|PLANAR_SH(1), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|
3809
ANYCHANNELS|ANYSPACE|ANYPREMUL, PackPlanarBytes},
3812
{ CHANNELS_SH(1)|BYTES_SH(2), ANYSPACE, Pack1Word},
3813
{ CHANNELS_SH(1)|BYTES_SH(2)|EXTRA_SH(1), ANYSPACE, Pack1WordSkip1},
3814
{ CHANNELS_SH(1)|BYTES_SH(2)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack1WordSkip1SwapFirst},
3815
{ CHANNELS_SH(1)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Pack1WordReversed},
3816
{ CHANNELS_SH(1)|BYTES_SH(2)|ENDIAN16_SH(1), ANYSPACE, Pack1WordBigEndian},
3817
{ CHANNELS_SH(3)|BYTES_SH(2), ANYSPACE, Pack3Words},
3818
{ CHANNELS_SH(3)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Pack3WordsSwap},
3819
{ CHANNELS_SH(3)|BYTES_SH(2)|ENDIAN16_SH(1), ANYSPACE, Pack3WordsBigEndian},
3820
{ CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1), ANYSPACE, Pack3WordsAndSkip1},
3821
{ CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|DOSWAP_SH(1), ANYSPACE, Pack3WordsAndSkip1Swap},
3822
{ CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|SWAPFIRST_SH(1), ANYSPACE, Pack3WordsAndSkip1SwapFirst},
3824
{ CHANNELS_SH(3)|BYTES_SH(2)|EXTRA_SH(1)|DOSWAP_SH(1)|SWAPFIRST_SH(1),
3825
ANYSPACE, Pack3WordsAndSkip1SwapSwapFirst},
3827
{ CHANNELS_SH(4)|BYTES_SH(2), ANYSPACE, Pack4Words},
3828
{ CHANNELS_SH(4)|BYTES_SH(2)|FLAVOR_SH(1), ANYSPACE, Pack4WordsReverse},
3829
{ CHANNELS_SH(4)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Pack4WordsSwap},
3830
{ CHANNELS_SH(4)|BYTES_SH(2)|ENDIAN16_SH(1), ANYSPACE, Pack4WordsBigEndian},
3832
{ CHANNELS_SH(6)|BYTES_SH(2), ANYSPACE, Pack6Words},
3833
{ CHANNELS_SH(6)|BYTES_SH(2)|DOSWAP_SH(1), ANYSPACE, Pack6WordsSwap},
3835
{ BYTES_SH(2), ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYENDIAN|
3836
ANYEXTRA|ANYCHANNELS|ANYSPACE|ANYPREMUL, PackChunkyWords},
3837
{ BYTES_SH(2)|PLANAR_SH(1), ANYFLAVOR|ANYENDIAN|ANYSWAP|ANYEXTRA|
3838
ANYCHANNELS|ANYSPACE|ANYPREMUL, PackPlanarWords}
3843
static const cmsFormattersFloat OutputFormattersFloat[] = {
3846
{ TYPE_Lab_FLT, ANYPLANAR|ANYEXTRA, PackLabFloatFromFloat},
3847
{ TYPE_XYZ_FLT, ANYPLANAR|ANYEXTRA, PackXYZFloatFromFloat},
3849
{ TYPE_Lab_DBL, ANYPLANAR|ANYEXTRA, PackLabDoubleFromFloat},
3850
{ TYPE_XYZ_DBL, ANYPLANAR|ANYEXTRA, PackXYZDoubleFromFloat},
3852
{ TYPE_LabV2_8, ANYPLANAR|ANYEXTRA, PackEncodedBytesLabV2FromFloat},
3853
{ TYPE_LabV2_16, ANYPLANAR|ANYEXTRA, PackEncodedWordsLabV2FromFloat},
3855
{ FLOAT_SH(1)|BYTES_SH(4), ANYPLANAR|
3856
ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackFloatsFromFloat },
3857
{ FLOAT_SH(1)|BYTES_SH(0), ANYPLANAR|
3858
ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackDoublesFromFloat },
3860
{ BYTES_SH(2), ANYPLANAR|
3861
ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackWordsFromFloat },
3863
{ BYTES_SH(1), ANYPLANAR|
3864
ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackBytesFromFloat },
3866
#ifndef CMS_NO_HALF_SUPPORT
3867
{ FLOAT_SH(1)|BYTES_SH(2),
3868
ANYFLAVOR|ANYSWAPFIRST|ANYSWAP|ANYEXTRA|ANYCHANNELS|ANYSPACE, PackHalfFromFloat },
3876
cmsFormatter _cmsGetStockOutputFormatter(cmsUInt32Number dwInput, cmsUInt32Number dwFlags)
3882
dwInput &= ~OPTIMIZED_SH(1);
3887
case CMS_PACK_FLAGS_16BITS: {
3889
for (i=0; i < sizeof(OutputFormatters16) / sizeof(cmsFormatters16); i++) {
3890
const cmsFormatters16* f = OutputFormatters16 + i;
3892
if ((dwInput & ~f ->Mask) == f ->Type) {
3900
case CMS_PACK_FLAGS_FLOAT: {
3902
for (i=0; i < sizeof(OutputFormattersFloat) / sizeof(cmsFormattersFloat); i++) {
3903
const cmsFormattersFloat* f = OutputFormattersFloat + i;
3905
if ((dwInput & ~f ->Mask) == f ->Type) {
3906
fr.FmtFloat = f ->Frm;
3922
typedef struct _cms_formatters_factory_list {
3924
cmsFormatterFactory Factory;
3925
struct _cms_formatters_factory_list *Next;
3927
} cmsFormattersFactoryList;
3929
_cmsFormattersPluginChunkType _cmsFormattersPluginChunk = { NULL };
3934
void DupFormatterFactoryList(struct _cmsContext_struct* ctx,
3935
const struct _cmsContext_struct* src)
3937
_cmsFormattersPluginChunkType newHead = { NULL };
3938
cmsFormattersFactoryList* entry;
3939
cmsFormattersFactoryList* Anterior = NULL;
3940
_cmsFormattersPluginChunkType* head = (_cmsFormattersPluginChunkType*) src->chunks[FormattersPlugin];
3942
_cmsAssert(head != NULL);
3945
for (entry = head->FactoryList;
3947
entry = entry ->Next) {
3949
cmsFormattersFactoryList *newEntry = ( cmsFormattersFactoryList *) _cmsSubAllocDup(ctx ->MemPool, entry, sizeof(cmsFormattersFactoryList));
3951
if (newEntry == NULL)
3955
newEntry -> Next = NULL;
3957
Anterior -> Next = newEntry;
3959
Anterior = newEntry;
3961
if (newHead.FactoryList == NULL)
3962
newHead.FactoryList = newEntry;
3965
ctx ->chunks[FormattersPlugin] = _cmsSubAllocDup(ctx->MemPool, &newHead, sizeof(_cmsFormattersPluginChunkType));
3969
void _cmsAllocFormattersPluginChunk(struct _cmsContext_struct* ctx,
3970
const struct _cmsContext_struct* src)
3972
_cmsAssert(ctx != NULL);
3977
DupFormatterFactoryList(ctx, src);
3980
static _cmsFormattersPluginChunkType FormattersPluginChunk = { NULL };
3981
ctx ->chunks[FormattersPlugin] = _cmsSubAllocDup(ctx ->MemPool, &FormattersPluginChunk, sizeof(_cmsFormattersPluginChunkType));
3988
cmsBool _cmsRegisterFormattersPlugin(cmsContext ContextID, cmsPluginBase* Data)
3990
_cmsFormattersPluginChunkType* ctx = ( _cmsFormattersPluginChunkType*) _cmsContextGetClientChunk(ContextID, FormattersPlugin);
3991
cmsPluginFormatters* Plugin = (cmsPluginFormatters*) Data;
3992
cmsFormattersFactoryList* fl ;
3997
ctx ->FactoryList = NULL;
4001
fl = (cmsFormattersFactoryList*) _cmsPluginMalloc(ContextID, sizeof(cmsFormattersFactoryList));
4002
if (fl == NULL) return FALSE;
4004
fl ->Factory = Plugin ->FormattersFactory;
4006
fl ->Next = ctx -> FactoryList;
4007
ctx ->FactoryList = fl;
4012
cmsFormatter CMSEXPORT _cmsGetFormatter(cmsContext ContextID,
4013
cmsUInt32Number Type,
4014
cmsFormatterDirection Dir,
4015
cmsUInt32Number dwFlags)
4017
_cmsFormattersPluginChunkType* ctx = ( _cmsFormattersPluginChunkType*) _cmsContextGetClientChunk(ContextID, FormattersPlugin);
4018
cmsFormattersFactoryList* f;
4020
if (T_CHANNELS(Type) == 0) {
4021
static const cmsFormatter nullFormatter = { 0 };
4022
return nullFormatter;
4025
for (f =ctx->FactoryList; f != NULL; f = f ->Next) {
4027
cmsFormatter fn = f ->Factory(Type, Dir, dwFlags);
4028
if (fn.Fmt16 != NULL) return fn;
4032
if (Dir == cmsFormatterInput)
4033
return _cmsGetStockInputFormatter(Type, dwFlags);
4035
return _cmsGetStockOutputFormatter(Type, dwFlags);
4040
cmsBool _cmsFormatterIsFloat(cmsUInt32Number Type)
4042
return T_FLOAT(Type) ? TRUE : FALSE;
4046
cmsBool _cmsFormatterIs8bit(cmsUInt32Number Type)
4048
cmsUInt32Number Bytes = T_BYTES(Type);
4050
return (Bytes == 1);
4054
cmsUInt32Number CMSEXPORT cmsFormatterForColorspaceOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat)
4057
cmsColorSpaceSignature ColorSpace = cmsGetColorSpace(hProfile);
4058
cmsUInt32Number ColorSpaceBits = (cmsUInt32Number) _cmsLCMScolorSpace(ColorSpace);
4059
cmsInt32Number nOutputChans = cmsChannelsOfColorSpace(ColorSpace);
4060
cmsUInt32Number Float = lIsFloat ? 1U : 0;
4063
if (nOutputChans < 0) return 0;
4066
return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);
4070
cmsUInt32Number CMSEXPORT cmsFormatterForPCSOfProfile(cmsHPROFILE hProfile, cmsUInt32Number nBytes, cmsBool lIsFloat)
4073
cmsColorSpaceSignature ColorSpace = cmsGetPCS(hProfile);
4075
cmsUInt32Number ColorSpaceBits = (cmsUInt32Number) _cmsLCMScolorSpace(ColorSpace);
4076
cmsInt32Number nOutputChans = cmsChannelsOfColorSpace(ColorSpace);
4077
cmsUInt32Number Float = lIsFloat ? 1U : 0;
4080
if (nOutputChans < 0) return 0;
4083
return FLOAT_SH(Float) | COLORSPACE_SH(ColorSpaceBits) | BYTES_SH(nBytes) | CHANNELS_SH(nOutputChans);