Hoyt's FORK of DemoIccMAX 2.1.17.hoyt
Documentation for Hoyt's FORK of DemoIccMAX
Loading...
Searching...
No Matches
IccMpeCalc.cpp
Go to the documentation of this file.
1/** @file
2 File: IccMpeCalc.cpp
3
4 Contains: Implementation of Calculator Element
5
6 Version: V1
7
8 Copyright: (c) see ICC Software License
9*/
10
11/*
12 * The ICC Software License, Version 0.1
13 *
14 *
15 * Copyright (c) 2003-2006 The International Color Consortium. All rights
16 * reserved.
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 *
22 * 1. Redistributions of source code must retain the above copyright
23 * notice, this list of conditions and the following disclaimer.
24 *
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in
27 * the documentation and/or other materials provided with the
28 * distribution.
29 *
30 * 3. In the absence of prior written permission, the names "ICC" and "The
31 * International Color Consortium" must not be used to imply that the
32 * ICC organization endorses or promotes products derived from this
33 * software.
34 *
35 *
36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39 * DISCLAIMED. IN NO EVENT SHALL THE INTERNATIONAL COLOR CONSORTIUM OR
40 * ITS CONTRIBUTING MEMBERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47 * SUCH DAMAGE.
48 * ====================================================================
49 *
50 * This software consists of voluntary contributions made by many
51 * individuals on behalf of the The International Color Consortium.
52 *
53 *
54 * Membership in the ICC is encouraged when this software is used for
55 * commercial purposes.
56 *
57 *
58 * For more information on The International Color Consortium, please
59 * see <http://www.color.org/>.
60 *
61 *
62 */
63
64//////////////////////////////////////////////////////////////////////
65// HISTORY:
66//
67// -Initial implementation by Max Derhak 1-30-2006
68//
69//////////////////////////////////////////////////////////////////////
70
71#ifdef WIN32
72#pragma warning( disable: 4786) //disable warning in <list.h>
73#endif
74
75#include <stdio.h>
76#include <math.h>
77#include <string.h>
78#include <stdlib.h>
79#include "IccMpeBasic.h"
80#include "IccMpeCalc.h"
81#include "IccIO.h"
82#include <map>
83#include "IccUtil.h"
84
85//#define ICC_VERBOSE_CALC_APPLY 1
86
87
89{
90public:
91
93
94 virtual void BeginApply()
95 {
96 printf("\nBegin Calc Apply\n");
97 }
98
99 virtual void EndApply()
100 {
101 printf("End Calculator Apply\n\n");
102 fflush(stdout);
103 }
104
105 virtual bool BeforeOp(SIccCalcOp *op, SIccOpState &os, SIccCalcOp *ops)
106 {
107 if (op->sig == icSigIfOp || op->sig == icSigSelectOp) {
108 printf("Start:");
109 std::string opDesc;
110 op->Describe(opDesc, 100); // TODO - propogate nVerboseness
111 printf("%9s\t", opDesc.c_str());
112 for (int j = 0; j < (int)os.pStack->size(); j++)
113 printf(" %.4f", (*os.pStack)[j]);
114 printf("\n");
115 }
116 return false;
117 }
118
119 virtual bool AfterOp(SIccCalcOp *op, SIccOpState &os, SIccCalcOp *ops)
120 {
121 if (op->sig == icSigDataOp) {
122 printf("%9s\t", "data");
123 }
124 else {
125 if (op->sig == icSigIfOp || op->sig == icSigSelectOp) {
126 printf("End:");
127 }
128 std::string opDesc;
129 op->Describe(opDesc, 100); // TODO - propogate nVerboseness
130 printf("%9s\t", opDesc.c_str());
131 }
132
133 for (int j = 0; j < (int)os.pStack->size(); j++)
134 printf(" %.4f", (*os.pStack)[j]);
135 printf("\n");
136
137 if (op->sig==icSigIfOp || op->sig==icSigSelectOp)
138 printf("\n");
139 fflush(stdout);
140
141 return false;
142 }
143 virtual void Error(const char *szMsg)
144 {
145 printf("%s\n", szMsg);
146 }
147};
148
150
151#ifdef ICC_VERBOSE_CALC_APPLY
153#else
155#endif
156
158{
159 if (pDebugger == icCalcDebuggerConsole)
161 else
162 g_pDebugger = pDebugger;
163}
164
165#define OsPopArg(X) { \
166 if (!os.pStack->size()) \
167 return false; \
168 X = *(os.pStack->rbegin()); \
169 os.pStack->pop_back(); \
170}
171
172#define OsPopArgs(X, N) { \
173 icUInt32Number nv=(N); \
174 size_t ss = os.pStack->size(); \
175 if (nv>ss) \
176 return false; \
177 icFloatNumber *sv = &(*os.pStack)[ss-nv]; \
178 memcpy((X), sv, nv*sizeof(icFloatNumber)); \
179 os.pStack->resize(ss-nv); \
180}
181
182
183#define OsPushArg(X) { \
184 icFloatNumber V = (X); \
185 os.pStack->push_back(V); \
186}
187
188#define OsPushArgs(X, N) { \
189 size_t ss = os.pStack->size(); \
190 icUInt32Number nv=(N); \
191 os.pStack->resize(ss+nv); \
192 icFloatNumber *sv = &(*os.pStack)[ss]; \
193 memcpy(sv, (X), nv*sizeof(icFloatNumber)); \
194}
195
196#define OsShrinkArgs(N) { \
197 icUInt32Number nv = (N); \
198 size_t ss = os.pStack->size(); \
199 if (nv>ss) \
200 return false; \
201 os.pStack->resize(ss-nv); \
202}
203
204#define OsExtendArgs(N) { \
205 size_t ss = os.pStack->size(); \
206 os.pStack->resize(ss+(N)); \
207}
208
209
211{
212public:
213 virtual bool IsValid(CIccMpeCalculator *pCalc, SIccCalcOp &op) { return false; }
214 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
215 {
216 if (g_pDebugger)
217 {
218 std::string opDesc;
219 op->Describe(opDesc, 100); // TODO - propogate nVerboseness
220 std::string line = "Unknown operator: ";
221 line += opDesc;
222 g_pDebugger->Error(line.c_str());
223 }
224 return false;
225 }
226};
227
229{
230public:
231 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
232 {
233 icUInt32Number n, j;
234 if (!op->extra) {
235 for (n=1; n+os.idx<os.nOps; n++)
236 if (op[n].sig!=icSigDataOp)
237 break;
238 op->extra = n;
239 }
240 else {
241 n=(icUInt32Number)op->extra;
242 }
243 size_t ss = os.pStack->size();
244 os.pStack->resize(ss+n);
245 icFloatNumber *s = &(*os.pStack)[ss];
246 for (j=0; j<n; j++) {
247 s[j] = op[j].data.num;
248 }
249 os.idx += n-1;
250 return true;
251 }
252};
253
255{
256public:
257 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
258 {
259 size_t ss = os.pStack->size();
260 if ((size_t)(op->data.select.v1+1)>ss)
261 return false;
262 os.pStack->resize(ss-(op->data.select.v1+1));
263 return true;
264 }
265};
266
268{
269public:
270 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
271 {
272 OsPopArgs(&os.output[op->data.select.v1], op->data.select.v2+1);
273 return true;
274 }
275};
276
278{
279public:
280 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
281 {
282 OsPushArgs(&os.pixel[op->data.select.v1], op->data.select.v2+1);
283 return true;
284 }
285};
286
288{
289public:
290 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
291 {
292 OsPushArgs(&os.temp[op->data.select.v1], op->data.select.v2+1);
293 return true;
294 }
295};
296
298{
299public:
300 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
301 {
302 OsPopArgs(&os.temp[op->data.select.v1], op->data.select.v2+1)
303 return true;
304 }
305};
306
308{
309public:
310 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
311 {
312 size_t ss = os.pStack->size();
313 size_t n=op->data.select.v2+1;
314
315 if (n>ss)
316 return false;
317
318 icFloatNumber *s = &(*os.pStack)[ss - n];
319 memcpy(&os.temp[op->data.select.v1], s, n*sizeof(icFloatNumber));
320 return true;
321 }
322};
323
325{
326public:
327 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
328 {
330 icFloatNumber val=0.0;
331
332 if (sig==icSigTrueVar) {
335 }
336 else if (sig==icSigNotDefVar) {
339 }
340 else if (os.pApply->GetEnvVar(sig, val)) {
343 }
344 else {
347 }
348 return true;
349 }
350};
351
353{
354public:
355 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
356 {
357 CIccSubCalcApply *pElemApply = os.pApply->GetApply(op->data.select.v1);
358 if (!pElemApply)
359 return false;
360
361 icUInt16Number nSrc = pElemApply->NumInputChannels();
362 icUInt16Number nDst = pElemApply->NumOutputChannels();
363
364 size_t ss = os.pStack->size();
365 if (nSrc>ss)
366 return false;
367 icFloatNumber *s = &(*os.pStack)[ss - nSrc];
368
369 if (os.pScratch->size()<(size_t)nDst)
370 os.pScratch->resize(nDst);
371
372 icFloatNumber *d = &(*os.pScratch)[0];
373
374 pElemApply->Apply(d, s);
375
376 int ns = (int)ss + (int)nDst - (int)nSrc;
377
378 if (ns != ss)
379 os.pStack->resize(ns);
380
381 s = &(*os.pStack)[ns - nDst];
382 memcpy(s, d, nDst*sizeof(icFloatNumber));
383 return true;
384 }
385};
386
388{
389public:
390 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
391 {
392 size_t ss = os.pStack->size();
393 int j;
394 int n=op->data.select.v1+1;
395 int t=op->data.select.v2+1;
396 if (n>(int)ss)
397 return false;
398
399 if (n && t) {
400 OsExtendArgs(n*t);
401
402 icFloatNumber *to = &(*os.pStack)[ss];
403 icFloatNumber *from = to-n;
404
405 for (j=0; j<t; j++) {
406 memcpy(to, from, n*sizeof(icFloatNumber));
407 to+=n;
408 }
409 }
410 return true;
411 }
412};
413
415{
416public:
417 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
418 {
419 size_t ss = os.pStack->size();
420 int j, n=op->data.select.v1+1;
421 int t=op->data.select.v2+1;
422 if (n>(int)ss)
423 return false;
424
425 if (n && t) {
426 OsExtendArgs(t);
427
428 icFloatNumber *to = &(*os.pStack)[ss];
429 icFloatNumber *from = to-n;
430
431 for (j=0; j<t; j++) {
432 to[j] = *from;
433 }
434 }
435 return true;
436 }
437};
438
440{
441public:
442 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
443 {
444 int n = op->data.select.v1+2;
445 size_t ss = os.pStack->size();
446 if (n>(int)ss)
447 return false;
448 icFloatNumber *s = &(*os.pStack)[ss-n];
450 int j, k;
451 for (j=0, k=n-1; j<k; j++, k--) {
452 t = s[j];
453 s[j] = s[k];
454 s[k] = t;
455 }
456 return true;
457 }
458};
459
461{
462public:
463 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
464 {
465 int nCopy = op->data.select.v1+1;
466 int nPos = op->data.select.v2+1;
467
468 if (nCopy) {
469 int next = nPos;
470 if (os.pScratch->size()<(size_t)nCopy)
471 os.pScratch->resize(nCopy);
472
473 icFloatNumber *copyList = &(*os.pScratch)[0];
474
475 OsPopArgs(copyList, nCopy);
476
477 int j;
478 for (j=0; j<nCopy; j++) {
479 OsPushArg(copyList[(j+next)%nCopy]);
480 }
481 }
482 return true;
483 }
484};
485
487{
488public:
489 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
490 {
491 int nCopy = op->data.select.v1+1;
492 int nPos = (op->data.select.v2+1)%nCopy;
493
494 if (nCopy) {
495 int next = nCopy - nPos;
496 if (os.pScratch->size()<(size_t)nCopy)
497 os.pScratch->resize(nCopy);
498
499 icFloatNumber *copyList = &(*os.pScratch)[0];
500
501 OsPopArgs(copyList, nCopy);
502
503 int j;
504 for (j=0; j<nCopy; j++) {
505 OsPushArg(copyList[(j+next)%nCopy]);
506 }
507 }
508 return true;
509 }
510};
511
513{
514public:
515 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
516 {
517 size_t ss = os.pStack->size();
518 int r=op->data.select.v1+1;
519 int c=op->data.select.v2+1;
520 int nSize = r*c;
521
522 if (nSize>(int)ss)
523 return false;
524
525 if (r>1 && c>1) {
526 int j, k;
527
528 if (os.pScratch->size()<(size_t)nSize)
529 os.pScratch->resize(nSize);
530
531 icFloatNumber *ptrStack = &(*os.pStack)[ss-nSize];
532 icFloatNumber *ptrScratch = &(*os.pScratch)[0];
533 icFloatNumber *start = ptrStack;
534 icFloatNumber *to = ptrScratch;
535
536 for (k=0; k<c; k++) {
537 icFloatNumber *from = start;
538 for (j=0; j<r; j++) {
539 *to++ = *from;
540 from += c;
541 }
542 start++;
543 }
544 memcpy(ptrStack, ptrScratch, nSize*sizeof(icFloatNumber));
545 }
546 return true;
547 }
548};
549
551{
552public:
553 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
554 {
555 size_t ss = os.pStack->size();
556 int r=op->data.select.v1+1;
557 int c=op->data.select.v2+1;
558 int nMSize = r*c;
559 int nSize = nMSize + c;
560
561 if (nSize>(int)ss)
562 return false;
563
564 if (r>1 && c>1) {
565
566 if (os.pScratch->size()<(size_t)c)
567 os.pScratch->resize(c);
568
569 icFloatNumber *ptrStack = &(*os.pStack)[ss-nSize];
570 icFloatNumber *x = &(*os.pScratch)[0];
571 icFloatNumber *mtx = ptrStack;
572 icFloatNumber *y = &ptrStack[nMSize];
573
574 bool bResult = false;
575
576 if (g_pIccMatrixSolver) {
577 bResult = g_pIccMatrixSolver->Solve(x, mtx, y, r, c);
578 }
579 if (bResult) {
580 memcpy(ptrStack, x, c*sizeof(icFloatNumber));
581 ptrStack[c] = 1.0;
582 }
583 else {
584 memset(ptrStack, 0, c*sizeof(icFloatNumber));
585 ptrStack[c] = 0.0;
586 }
587 os.pStack->resize(ss-nSize+r+1);
588 }
589 return true;
590 }
591};
592
593class CIccOpDefPi : public IIccOpDef
594{
595public:
596 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
597 {
599 return true;
600 }
601};
602
604{
605public:
606 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
607 {
609 return true;
610 }
611};
612
614{
615public:
616 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
617 {
619 return true;
620 }
621};
622
624{
625public:
626 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
627 {
629 return true;
630 }
631};
632
634{
635public:
636 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
637 {
638 int j, n = op->data.select.v1+2;
639 size_t ss = os.pStack->size();
640 if (n>(int)ss)
641 return false;
642 icFloatNumber *s = &(*os.pStack)[ss-n];
643 if (n==2) {
644 s[0] += s[1];
645 OsShrinkArgs(1);
646 }
647 else {
648 for (j=1; j<n; j++) {
649 s[0] += s[j];
650 }
651 OsShrinkArgs(n-1);
652 }
653 return true;
654 }
655};
656
658{
659public:
660 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
661 {
662 int j, n = op->data.select.v1+2;
663 size_t ss = os.pStack->size();
664 if (n>(int)ss)
665 return false;
666 icFloatNumber *s = &(*os.pStack)[ss-n];
667 if (n==2) {
668 s[0] *= s[1];
669 OsShrinkArgs(1);
670 }
671 else {
672 for (j=1; j<n; j++) {
673 s[0] *= s[j];
674 }
675 OsShrinkArgs(n-1);
676 }
677 return true;
678 }
679};
680
682{
683public:
684 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
685 {
686 int j, n = op->data.select.v1+2;
687 size_t ss = os.pStack->size();
688 if (n>(int)ss)
689 return false;
690 icFloatNumber *s = &(*os.pStack)[ss-n];
691 if (n==2) {
692 s[0] = icMin(s[0], s[1]);
693 OsShrinkArgs(1);
694 }
695 else {
696 icFloatNumber mv = s[0];
697 for (j=1; j<n; j++) {
698 if (s[j]<mv)
699 mv = s[j];
700 }
701 s[0] = mv;
702 OsShrinkArgs(n-1);
703 }
704 return true;
705 }
706};
707
709{
710public:
711 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
712 {
713 int j, n = op->data.select.v1+2;
714 size_t ss = os.pStack->size();
715 if (n>(int)ss)
716 return false;
717 icFloatNumber *s = &(*os.pStack)[ss-n];
718 if (n==2) {
719 s[0] = icMax(s[0], s[1]);
720 OsShrinkArgs(1);
721 }
722 else {
723 icFloatNumber mv = s[0];
724 for (j=1; j<n; j++) {
725 if (s[j]>mv)
726 mv = s[j];
727 }
728 s[0] = mv;
729 OsShrinkArgs(n-1);
730 }
731 return true;
732 }
733};
734
736{
737public:
738 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
739 {
740 int j, n = op->data.select.v1+2;
741 size_t ss = os.pStack->size();
742 if (n>(int)ss)
743 return false;
744 icFloatNumber *s = &(*os.pStack)[ss-n];
745
746 for (j=0; j<n; j++) {
747 if (s[j]<0.5f)
748 break;
749 }
750 s[0] = j<n ? 0.0f : 1.0f;
751
752 OsShrinkArgs(n-1);
753 return true;
754 }
755};
756
757class CIccOpDefOr : public IIccOpDef
758{
759public:
760 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
761 {
762 int j,n = op->data.select.v1+2;
763 size_t ss = os.pStack->size();
764 if (n>(int)ss)
765 return false;
766 icFloatNumber *s = &(*os.pStack)[ss-n];
767
768 for (j=0; j<n; j++) {
769 if (s[j]>=0.5f)
770 break;
771 }
772 s[0] = j<n ? 1.0f : 0.0f;
773
774 OsShrinkArgs(n-1);
775 return true;
776 }
777};
778
780{
781public:
782 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
783 {
784 int j, n = op->data.select.v1+1;
785 int tn = n*2;
786 size_t ss = os.pStack->size();
787 if (tn>(int)ss)
788 return false;
789 icFloatNumber *s = &(*os.pStack)[ss-tn];
790 for (j=0; j<n; j++) {
791 s[j] = icMin(s[j], s[j+n]);
792 }
793 OsShrinkArgs(n);
794 return true;
795 }
796};
797
799{
800public:
801 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
802 {
803 int j, n = op->data.select.v1+1;
804 int tn = n*2;
805 size_t ss = os.pStack->size();
806 if (tn>(int)ss)
807 return false;
808 icFloatNumber *s = &(*os.pStack)[ss-tn];
809 for (j=0; j<n; j++) {
810 s[j] = icMax(s[j], s[j+n]);
811 }
812 OsShrinkArgs(n);
813 return true;
814 }
815};
816
818{
819public:
820 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
821 {
822 int j, n = op->data.select.v1+1;
823 int tn = n*2;
824 size_t ss = os.pStack->size();
825 if (tn>(int)ss)
826 return false;
827 icFloatNumber *s = &(*os.pStack)[ss-tn];
828 for (j=0; j<n; j++) {
829 s[j] = (s[j]>=0.5f && s[j+n]>=0.5) ? 1.0f : 0.0f;
830 }
831 OsShrinkArgs(n);
832 return true;
833 }
834};
835
837{
838public:
839 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
840 {
841 int j, n = op->data.select.v1+1;
842 int tn = n*2;
843 size_t ss = os.pStack->size();
844 if (tn>(int)ss)
845 return false;
846 icFloatNumber *s = &(*os.pStack)[ss-tn];
847 for (j=0; j<n; j++) {
848 s[j] = (s[j]>=0.5f || s[j+n]>=0.5) ? 1.0f : 0.0f;
849 }
850 OsShrinkArgs(n);
851 return true;
852 }
853};
854
856{
857public:
858 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
859 {
860 int j, n = op->data.select.v1+1;
861 int tn = n*2;
862 size_t ss = os.pStack->size();
863 if (tn>(int)ss)
864 return false;
865 icFloatNumber *s = &(*os.pStack)[ss-tn];
866 for (j=0; j<n; j++) {
867 s[j] += s[j+n];
868 }
869 OsShrinkArgs(n);
870 return true;
871 }
872};
873
875{
876public:
877 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
878 {
879 int j, n = op->data.select.v1+1;
880 int tn = n*2;
881 size_t ss = os.pStack->size();
882 if (tn>(int)ss)
883 return false;
884 icFloatNumber *s = &(*os.pStack)[ss-tn];
885 for (j=0; j<n; j++) {
886 s[j] -= s[j+n];
887 }
888 OsShrinkArgs(n);
889 return true;
890 }
891};
892
894{
895public:
896 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
897 {
898 int j, n = op->data.select.v1+1;
899 int tn = n*2;
900 size_t ss = os.pStack->size();
901 if (tn>(int)ss)
902 return false;
903 icFloatNumber *s = &(*os.pStack)[ss-tn];
904 for (j=0; j<n; j++) {
905 s[j] *= s[j+n];
906 }
907 OsShrinkArgs(n);
908 return true;
909 }
910};
911
913{
914public:
915 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
916 {
917 int j, n = op->data.select.v1+1;
918 int tn = n*2;
919 size_t ss = os.pStack->size();
920 if (tn>(int)ss)
921 return false;
922 icFloatNumber *s = &(*os.pStack)[ss-tn];
923 for (j=0; j<n; j++) {
924 s[j] /= s[j+n];
925 }
926 OsShrinkArgs(n);
927 return true;
928 }
929};
930
932{
933public:
934 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
935 {
936 int j, n = op->data.select.v1+1;
937 int tn = n*2;
938 size_t ss = os.pStack->size();
939 if (tn>(int)ss)
940 return false;
941 icFloatNumber *s = &(*os.pStack)[ss-tn];
942 for (j=0; j<n; j++) {
943 s[j] = s[j] - (icFloatNumber)((int)(s[j] / s[j+n]))*s[j+n];
944 }
945 OsShrinkArgs(n);
946 return true;
947 }
948};
949
951{
952public:
953 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
954 {
955 int j, n = op->data.select.v1+1;
956 int tn = n+1;
957 size_t ss = os.pStack->size();
958 if (tn>(int)ss)
959 return false;
960 icFloatNumber *s = &(*os.pStack)[ss-tn];
961 icFloatNumber p = s[n];
962 for (j=0; j<n; j++) {
963 s[j] = (icFloatNumber)pow(s[j], p);
964 }
965 OsShrinkArgs(1);
966 return true;
967 }
968};
969
971{
972public:
973 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
974 {
975 int j, n = op->data.select.v1+1;
976 int tn = n+1;
977 size_t ss = os.pStack->size();
978 if (tn>(int)ss)
979 return false;
980 icFloatNumber *s = &(*os.pStack)[ss-tn];
981 icFloatNumber p = s[n];
982 for (j=0; j<n; j++) {
983 s[j] = s[j] + p;
984 }
985 OsShrinkArgs(1);
986 return true;
987 }
988};
989
991{
992public:
993 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
994 {
995 int j, n = op->data.select.v1+1;
996 int tn = n+1;
997 size_t ss = os.pStack->size();
998 if (tn>(int)ss)
999 return false;
1000 icFloatNumber *s = &(*os.pStack)[ss-tn];
1001 icFloatNumber p = s[n];
1002 for (j=0; j<n; j++) {
1003 s[j] = s[j] - p;
1004 }
1005 OsShrinkArgs(1);
1006 return true;
1007 }
1008};
1009
1011{
1012public:
1013 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1014 {
1015 int j, n = op->data.select.v1+1;
1016 int tn = n+1;
1017 size_t ss = os.pStack->size();
1018 if (tn>(int)ss)
1019 return false;
1020 icFloatNumber *s = &(*os.pStack)[ss-tn];
1021 icFloatNumber p = s[n];
1022 for (j=0; j<n; j++) {
1023 s[j] = s[j] * p;
1024 }
1025 OsShrinkArgs(1);
1026 return true;
1027 }
1028};
1029
1031{
1032public:
1033 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1034 {
1035 int j, n = op->data.select.v1+1;
1036 int tn = n+1;
1037 size_t ss = os.pStack->size();
1038 if (tn>(int)ss)
1039 return false;
1040 icFloatNumber *s = &(*os.pStack)[ss-tn];
1041 icFloatNumber p = s[n];
1042 for (j=0; j<n; j++) {
1043 s[j] = s[j] / p;
1044 }
1045 OsShrinkArgs(1);
1046 return true;
1047 }
1048};
1049
1051{
1052public:
1053 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1054 {
1055 int j, n = op->data.select.v1+1;
1056 int tn = n*2;
1057 size_t ss = os.pStack->size();
1058 if (tn>(int)ss)
1059 return false;
1060 icFloatNumber *s = &(*os.pStack)[ss-tn];
1061 for (j=0; j<n; j++) {
1062 s[j] = (icFloatNumber)pow(s[j], s[j+n]);
1063 }
1064 OsShrinkArgs(n);
1065 return true;
1066 }
1067};
1068
1070{
1071public:
1072 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1073 {
1074 int j, n = op->data.select.v1+1;
1075 icFloatNumber a1;
1076 size_t ss = os.pStack->size();
1077 if (n>(int)ss)
1078 return false;
1079 icFloatNumber *s = &(*os.pStack)[ss-n];
1080 for (j=0; j<n; j++) {
1081 a1 = s[j];
1082 s[j] = a1*a1;
1083 }
1084 return true;
1085 }
1086};
1087
1089{
1090public:
1091 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1092 {
1093 int j, n = op->data.select.v1+1;
1094 icFloatNumber a1;
1095 size_t ss = os.pStack->size();
1096 if (n>(int)ss)
1097 return false;
1098 icFloatNumber *s = &(*os.pStack)[ss-n];
1099 for (j=0; j<n; j++) {
1100 a1 = s[j];
1101 s[j] = (icFloatNumber)sqrt(a1);
1102 }
1103 return true;
1104 }
1105};
1106
1108{
1109public:
1110 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1111 {
1112 int j, n = op->data.select.v1+1;
1113 icFloatNumber a1;
1114 size_t ss = os.pStack->size();
1115 if (n>(int)ss)
1116 return false;
1117 icFloatNumber *s = &(*os.pStack)[ss-n];
1118 for (j=0; j<n; j++) {
1119 a1 = s[j];
1120 s[j] = a1*a1*a1;
1121 }
1122 return true;
1123 }
1124};
1125
1127{
1128public:
1129 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1130 {
1131 int j, n = op->data.select.v1+1;
1132 icFloatNumber a1;
1133 size_t ss = os.pStack->size();
1134 if (n>(int)ss)
1135 return false;
1136 icFloatNumber *s = &(*os.pStack)[ss-n];
1137 for (j=0; j<n; j++) {
1138 a1 = s[j];
1139 s[j] = (icFloatNumber)ICC_CBRTF(a1);
1140 }
1141 return true;
1142 }
1143};
1144
1146{
1147public:
1148 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1149 {
1150 int j, n = op->data.select.v1 + 1;
1151 icFloatNumber a1;
1152 size_t ss = os.pStack->size();
1153 if (n > (int)ss)
1154 return false;
1155 icFloatNumber *s = &(*os.pStack)[ss - n];
1156 for (j = 0; j < n; j++) {
1157 a1 = s[j];
1158 s[j] = (icFloatNumber)(a1 < 0 ? -1 : (a1 > 0 ? 1 : 0));
1159 }
1160 return true;
1161 }
1162};
1163
1165{
1166public:
1167 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1168 {
1169 int j, n = op->data.select.v1+1;
1170 icFloatNumber a1;
1171 size_t ss = os.pStack->size();
1172 if (n>(int)ss)
1173 return false;
1174 icFloatNumber *s = &(*os.pStack)[ss-n];
1175 for (j=0; j<n; j++) {
1176 a1 = s[j];
1177 s[j] = (a1 < 0 ? -a1 : a1);
1178 }
1179 return true;
1180 }
1181};
1182
1184{
1185public:
1186 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1187 {
1188 int j, n = op->data.select.v1+1;
1189 size_t ss = os.pStack->size();
1190 if (n>(int)ss)
1191 return false;
1192 icFloatNumber *s = &(*os.pStack)[ss-n];
1193 for (j=0; j<n; j++) {
1194 //Casting to an int results in truncation
1195 s[j] = (icFloatNumber)((int)(s[j]));
1196 }
1197 return true;
1198 }
1199};
1200
1202{
1203public:
1204 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1205 {
1206 int j, n = op->data.select.v1+1;
1207 size_t ss = os.pStack->size();
1208 if (n>(int)ss)
1209 return false;
1210 icFloatNumber *s = &(*os.pStack)[ss-n];
1211 for (j=0; j<n; j++) {
1212 s[j] = (icFloatNumber)floor(s[j]);
1213 }
1214 return true;
1215 }
1216};
1217
1219{
1220public:
1221 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1222 {
1223 int j, n = op->data.select.v1+1;
1224 size_t ss = os.pStack->size();
1225 if (n>(int)ss)
1226 return false;
1227 icFloatNumber *s = &(*os.pStack)[ss-n];
1228 for (j=0; j<n; j++) {
1229 s[j] = (icFloatNumber)ceil(s[j]);
1230 }
1231 return true;
1232 }
1233};
1234
1236{
1237public:
1238 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1239 {
1240 int j, n = op->data.select.v1+1;
1241 size_t ss = os.pStack->size();
1242 if (n>(int)ss)
1243 return false;
1244 icFloatNumber *s = &(*os.pStack)[ss-n];
1245 for (j=0; j<n; j++) {
1246 if (s[j]<0.0)
1247 s[j] = icFloatNumber((int)(s[j]-0.5));
1248 else
1249 s[j] = icFloatNumber((int)(s[j]+0.5));
1250 }
1251 return true;
1252 }
1253};
1254
1256{
1257public:
1258 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1259 {
1260 int j, n = op->data.select.v1+1;
1261 icFloatNumber a1;
1262 size_t ss = os.pStack->size();
1263 if (n>(int)ss)
1264 return false;
1265 icFloatNumber *s = &(*os.pStack)[ss-n];
1266 for (j=0; j<n; j++) {
1267 a1 = s[j];
1268 s[j] = (icFloatNumber)exp(a1);
1269 }
1270 return true;
1271 }
1272};
1273
1275{
1276public:
1277 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1278 {
1279 int j, n = op->data.select.v1+1;
1280 icFloatNumber a1;
1281 size_t ss = os.pStack->size();
1282 if (n>(int)ss)
1283 return false;
1284 icFloatNumber *s = &(*os.pStack)[ss-n];
1285 for (j=0; j<n; j++) {
1286 a1 = s[j];
1287 s[j] = (icFloatNumber)log10(a1);
1288 }
1289 return true;
1290 }
1291};
1292
1294{
1295public:
1296 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1297 {
1298 int j, n = op->data.select.v1+1;
1299 icFloatNumber a1;
1300 size_t ss = os.pStack->size();
1301 if (n>(int)ss)
1302 return false;
1303 icFloatNumber *s = &(*os.pStack)[ss-n];
1304 for (j=0; j<n; j++) {
1305 a1 = s[j];
1306 s[j] = (icFloatNumber)log(a1);
1307 }
1308 return true;
1309 }
1310};
1311
1313{
1314public:
1315 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1316 {
1317 int j, n = op->data.select.v1+1;
1318 icFloatNumber a1;
1319 size_t ss = os.pStack->size();
1320 if (n>(int)ss)
1321 return false;
1322 icFloatNumber *s = &(*os.pStack)[ss-n];
1323 for (j=0; j<n; j++) {
1324 a1 = s[j];
1325 s[j] = (icFloatNumber)sin(a1);
1326 }
1327 return true;
1328 }
1329};
1330
1332{
1333public:
1334 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1335 {
1336 int j, n = op->data.select.v1+1;
1337 icFloatNumber a1;
1338 size_t ss = os.pStack->size();
1339 if (n>(int)ss)
1340 return false;
1341 icFloatNumber *s = &(*os.pStack)[ss-n];
1342 for (j=0; j<n; j++) {
1343 a1 = s[j];
1344 s[j] = (icFloatNumber)cos(a1);
1345 }
1346 return true;
1347 }
1348};
1349
1351{
1352public:
1353 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1354 {
1355 int j, n = op->data.select.v1+1;
1356 icFloatNumber a1;
1357 size_t ss = os.pStack->size();
1358 if (n>(int)ss)
1359 return false;
1360 icFloatNumber *s = &(*os.pStack)[ss-n];
1361 for (j=0; j<n; j++) {
1362 a1 = s[j];
1363 s[j] = (icFloatNumber)tan(a1);
1364 }
1365 return true;
1366 }
1367};
1368
1370{
1371public:
1372 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1373 {
1374 int j, n = op->data.select.v1+1;
1375 icFloatNumber a1;
1376 size_t ss = os.pStack->size();
1377 if (n>(int)ss)
1378 return false;
1379 icFloatNumber *s = &(*os.pStack)[ss-n];
1380 for (j=0; j<n; j++) {
1381 a1 = s[j];
1382 s[j] = (icFloatNumber)asin(a1);
1383 }
1384 return true;
1385 }
1386};
1387
1389{
1390public:
1391 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1392 {
1393 int j, n = op->data.select.v1+1;
1394 icFloatNumber a1;
1395 size_t ss = os.pStack->size();
1396 if (n>(int)ss)
1397 return false;
1398 icFloatNumber *s = &(*os.pStack)[ss-n];
1399 for (j=0; j<n; j++) {
1400 a1 = s[j];
1401 s[j] = (icFloatNumber)acos(a1);
1402 }
1403 return true;
1404 }
1405};
1406
1408{
1409public:
1410 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1411 {
1412 int j, n = op->data.select.v1+1;
1413 icFloatNumber a1;
1414 size_t ss = os.pStack->size();
1415 if (n>(int)ss)
1416 return false;
1417 icFloatNumber *s = &(*os.pStack)[ss-n];
1418 for (j=0; j<n; j++) {
1419 a1 = s[j];
1420 s[j] = (icFloatNumber)atan(a1);
1421 }
1422 return true;
1423 }
1424};
1425
1427{
1428public:
1429 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1430 {
1431 int j, n = op->data.select.v1+1;
1432 icFloatNumber a1, a2;
1433 int tn = n*2;
1434 size_t ss = os.pStack->size();
1435 if (tn>(int)ss)
1436 return false;
1437 icFloatNumber *s = &(*os.pStack)[ss-tn];
1438 for (j=0; j<n; j++) {
1439 a1 = s[j];
1440 a2 = s[j+n];
1441 s[j] = (icFloatNumber)atan2(a2, a1);
1442 }
1443 OsShrinkArgs(n);
1444 return true;
1445 }
1446};
1447
1449{
1450public:
1451 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1452 {
1453 int j, n = op->data.select.v1+1;
1454 icFloatNumber a1, a2;
1455 int tn = n*2;
1456 size_t ss = os.pStack->size();
1457 if (tn>(int)ss)
1458 return false;
1459 icFloatNumber *s = &(*os.pStack)[ss-tn];
1460 for (j=0; j<n; j++) {
1461 a1 = s[j];
1462 a2 = s[j+n];
1463 s[j] = (icFloatNumber)sqrt(a2*a2 + a1*a1);
1464 icFloatNumber h = (icFloatNumber)atan2(a2, a1) * 180.0f / (icFloatNumber)icPiNum;
1465 if (h<0.0f)
1466 h += 360.0f;
1467 s[j+n] = h;
1468 }
1469 return true;
1470 }
1471};
1472
1474{
1475public:
1476 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1477 {
1478 int j, n = op->data.select.v1+1;
1479 icFloatNumber a1, a2;
1480 int tn = n*2;
1481 size_t ss = os.pStack->size();
1482 if (tn>(int)ss)
1483 return false;
1484 icFloatNumber *s = &(*os.pStack)[ss-tn];
1485 for (j=0; j<n; j++) {
1486 a1 = s[j];
1487 a2 = s[j+n] * (icFloatNumber)icPiNum / 180.0f;
1488
1489 s[j] = a1 * (icFloatNumber)cos(a2);
1490 s[j+n] = a1 * (icFloatNumber)sin(a2);
1491 }
1492 return true;
1493 }
1494};
1495
1497{
1498public:
1499 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1500 {
1501 int j, n =op->data.select.v1+1;
1502 icFloatNumber a1, a2;
1503 int tn = n*2;
1504 size_t ss = os.pStack->size();
1505 if (tn>(int)ss)
1506 return false;
1507 icFloatNumber *s = &(*os.pStack)[ss-tn];
1508 for (j=0; j<n; j++) {
1509 a1 = s[j];
1510 a2 = s[j+n];
1511 s[j] = (a1 < a2 ? (icFloatNumber)1.0 : (icFloatNumber)0.0);
1512 }
1513 OsShrinkArgs(n);
1514 return true;
1515 }
1516};
1517
1519{
1520public:
1521 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1522 {
1523 int j, n = op->data.select.v1+1;
1524 icFloatNumber a1;
1525 size_t ss = os.pStack->size();
1526 if (n>(int)ss)
1527 return false;
1528 icFloatNumber *s = &(*os.pStack)[ss-n];
1530 for (j=0; j<n; j++) {
1531 a1 = s[j];
1532 if (a1==icPosInfinity || a1==icNegInfinity || !memcmp(&a1,&nan, sizeof(nan)))
1533 s[j] = 0.0;
1534 else
1535 s[j] = 1.0;
1536 }
1537 return true;
1538 }
1539};
1540
1542{
1543public:
1544 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1545 {
1546 int j, n = op->data.select.v1+1;
1547 icFloatNumber a1, a2;
1548 int tn = n*2;
1549 size_t ss = os.pStack->size();
1550 if (tn>(int)ss)
1551 return false;
1552 icFloatNumber *s = &(*os.pStack)[ss-tn];
1553 for (j=0; j<n; j++) {
1554 a1 = s[j];
1555 a2 = s[j+n];
1556 s[j] = (a1 <= a2 ? (icFloatNumber)1.0 : (icFloatNumber)0.0);
1557 }
1558 OsShrinkArgs(n);
1559 return true;
1560 }
1561};
1562
1564{
1565public:
1566 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1567 {
1568 int j, n = op->data.select.v1+1;
1569 icFloatNumber a1, a2;
1570 int tn = n*2;
1571 size_t ss = os.pStack->size();
1572 if (tn>(int)ss)
1573 return false;
1575 icFloatNumber *s = &(*os.pStack)[ss-tn];
1576 for (j=0; j<n; j++) {
1577 a1 = s[j];
1578 a2 = s[j+n];
1579 s[j] = (a1 == a2 ?
1580 (icFloatNumber)1.0 :
1581 ((!memcmp(&a1, &nan, sizeof(icFloatNumber)) && !memcmp(&a1, &a2, sizeof(a1))) ?
1582 (icFloatNumber)1.0 :
1583 (icFloatNumber)0.0));
1584 }
1585 OsShrinkArgs(n);
1586 return true;
1587 }
1588};
1589
1591{
1592public:
1593 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1594 {
1595 int j, n = op->data.select.v1 + 1;
1596 icFloatNumber a1, a2;
1597 int tn = n * 2;
1598 size_t ss = os.pStack->size();
1599 if (tn > (int)ss)
1600 return false;
1602 icFloatNumber *s = &(*os.pStack)[ss - tn];
1603 for (j = 0; j < n; j++) {
1604 a1 = s[j];
1605 a2 = s[j + n];
1606 s[j] = (a1 == a2 ?
1607 (icFloatNumber)0.0 :
1608 ((!memcmp(&a1, &nan, sizeof(icFloatNumber)) && !memcmp(&a1, &a2, sizeof(a1))) ?
1609 (icFloatNumber)0.0 :
1610 (icFloatNumber)1.0));
1611 }
1612 OsShrinkArgs(n);
1613 return true;
1614 }
1615};
1616
1618{
1619public:
1620 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1621 {
1622 int j, n = op->data.select.v1+1;
1623 icFloatNumber a1, a2;
1624 int tn = n*2;
1625 size_t ss = os.pStack->size();
1626 if (tn>(int)ss)
1627 return false;
1628 icFloatNumber *s = &(*os.pStack)[ss-tn];
1629 for (j=0; j<n; j++) {
1630 a1 = s[j];
1631 a2 = s[j+n];
1632 s[j] = (fabs(a1-a2)<1.0e-5 ? (icFloatNumber)1.0 : (icFloatNumber)0.0);
1633 }
1634 OsShrinkArgs(n);
1635 return true;
1636 }
1637};
1638
1640{
1641public:
1642 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1643 {
1644 int j, n = op->data.select.v1+1;
1645 icFloatNumber a1, a2;
1646 int tn = n*2;
1647 size_t ss = os.pStack->size();
1648 if (tn>(int)ss)
1649 return false;
1650 icFloatNumber *s = &(*os.pStack)[ss-tn];
1651 for (j=0; j<n; j++) {
1652 a1 = s[j];
1653 a2 = s[j+n];
1654 s[j] = (a1 >= a2 ? (icFloatNumber)1.0 : (icFloatNumber)0.0);
1655 }
1656 OsShrinkArgs(n);
1657 return true;
1658 }
1659};
1660
1662{
1663public:
1664 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1665 {
1666 int j, n = op->data.select.v1+1;
1667 icFloatNumber a1, a2;
1668 int tn = n*2;
1669 size_t ss = os.pStack->size();
1670 if (tn>(int)ss)
1671 return false;
1672 icFloatNumber *s = &(*os.pStack)[ss-tn];
1673 for (j=0; j<n; j++) {
1674 a1 = s[j];
1675 a2 = s[j+n];
1676 s[j] = (a1 > a2 ? (icFloatNumber)1.0 : (icFloatNumber)0.0);
1677 }
1678 OsShrinkArgs(n);
1679 return true;
1680 }
1681};
1682
1684{
1685public:
1686 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1687 {
1688 int j, n = op->data.select.v1+1;
1689 icFloatNumber a1;
1690 size_t ss = os.pStack->size();
1691 if (n>(int)ss)
1692 return false;
1693 icFloatNumber *s = &(*os.pStack)[ss-n];
1694 for (j=0; j<n; j++) {
1695 a1 = s[j];
1696 s[j] = (a1 >= (icFloatNumber)0.5 ? (icFloatNumber)0.0 : (icFloatNumber)1.0);
1697 }
1698 return true;
1699 }
1700};
1701
1703{
1704public:
1705 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1706 {
1707 int j, n = op->data.select.v1+1;
1708 icFloatNumber a1;
1709 size_t ss = os.pStack->size();
1710 if (n>(int)ss)
1711 return false;
1712 icFloatNumber *s = &(*os.pStack)[ss-n];
1713 for (j=0; j<n; j++) {
1714 a1 = s[j];
1715 s[j] = -a1;
1716 }
1717 return true;
1718 }
1719};
1720
1722{
1723public:
1724 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1725 {
1726 int j, n = op->data.select.v1+1;
1727 int n2 = n+n;
1728 int tn = n*3;
1729 icFloatNumber a1, a2, a3;
1730 size_t ss = os.pStack->size();
1731 if (tn>(int)ss)
1732 return false;
1733 icFloatNumber *s = &(*os.pStack)[ss-tn];
1734 for (j=0; j<n; j++) {
1735 a1 = icCubeth(s[j]);
1736 a2 = icCubeth(s[j+n]);
1737 a3 = icCubeth(s[j+n2]);
1738
1739 s[j] = (icFloatNumber)(116.0 * a2 - 16.0);
1740 s[j+n] = (icFloatNumber)(500.0 * (a1 - a2));
1741 s[j+n2] = (icFloatNumber)(200.0 * (a2 - a3));
1742 }
1743 return true;
1744 }
1745};
1746
1748{
1749public:
1750 virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
1751 {
1752 int j, n = op->data.select.v1+1;
1753 int n2 = n+n;
1754 int tn = n*3;
1755 icFloatNumber a1, a2, a3;
1756 size_t ss = os.pStack->size();
1757 if (tn>(int)ss)
1758 return false;
1759 icFloatNumber fy, *s = &(*os.pStack)[ss-tn];
1760 for (j=0; j<n; j++) {
1761 a1 = s[j];
1762 a2 = s[j+n];
1763 a3 = s[j+n2];
1764
1765 fy = (icFloatNumber)((a1 + 16.0f) / 116.0f);
1766
1767 s[j] = icICubeth((icFloatNumber)(a2/500.0 + fy));
1768 s[j+n] = icICubeth(fy);
1769 s[j+n2] = icICubeth((icFloatNumber)(fy - a3/200.0));
1770 }
1771 return true;
1772 }
1773};
1774
1775
1776
1777/**
1778******************************************************************************
1779* Name: SIccCalcOp::Describe
1780*
1781* Purpose:
1782*
1783* Args:
1784*
1785* Return:
1786******************************************************************************/
1787void SIccCalcOp::Describe(std::string &desc, int nVerboseness)
1788{
1789 char buf[300];
1790 if (sig==icSigDataOp) {
1791 sprintf(buf, "%.8g", data.num);
1792 desc = buf;
1793 return;
1794 }
1795
1796 char name[10];
1797 int i;
1798
1799 icGetSig(name, sig, false);
1800 name[5]=0;
1801 for (i=4; i>0; i--)
1802 if (name[i]==' ')
1803 name[i] = 0;
1804 if (!name[1])
1805 name[1] = '?';
1806 desc = &name[1];
1807
1808 switch (sig) {
1809 case icSigInputChanOp:
1810 case icSigOutputChanOp:
1811 case icSigTempGetChanOp:
1812 case icSigTempPutChanOp:
1814 if (!data.select.v2)
1815 sprintf(buf, "[%d]", data.select.v1);
1816 else
1817 sprintf(buf, "[%d,%d]", data.select.v1, data.select.v2+1);
1818 desc += buf;
1819 break;
1820
1821 case icSigEnvVarOp:
1822 {
1823 char varName[10];
1824 icGetSigStr(varName, (icSignature)data.size);
1825 int l=(int)strlen(varName);
1826 if (l==9) { //Remove h at end
1827 varName[8]=0;
1828 }
1829 else {
1830 for (l--; l>0; l--) {
1831 if (varName[l]!=' ')
1832 break;
1833 varName[l]=0;
1834 }
1835 }
1836 sprintf(buf, "(%s)", varName);
1837 desc += buf;
1838 }
1839 break;
1840
1841 case icSigApplyCurvesOp:
1842 case icSigApplyMatrixOp:
1843 case icSigApplyCLutOp:
1844 case icSigApplyTintOp:
1845 case icSigApplyToJabOp:
1847 case icSigApplyCalcOp:
1848 case icSigApplyElemOp:
1849 sprintf(buf, "(%d)", data.select.v1);
1850 desc += buf;
1851 break;
1852
1853 case icSigPopOp:
1854 sprintf(buf, "(%d)", data.select.v1+1);
1855 desc += buf;
1856 break;
1857
1858 case icSigSolveOp:
1859 case icSigTransposeOp:
1860 sprintf(buf, "(%d,%d)", data.select.v1+1, data.select.v2+1);
1861 desc += buf;
1862 break;
1863
1864 case icSigRotateLeftOp:
1865 case icSigRotateRightOp:
1866 sprintf(buf, "(%d,%d)", data.select.v1, data.select.v2);
1867 break;
1868
1869 case icSigCopyOp:
1870 case icSigPositionDupOp:
1871 if (!data.select.v2) {
1872 if (data.select.v1) {
1873 sprintf(buf, "(%d)", data.select.v1+1);
1874 desc += buf;
1875 }
1876 }
1877 else {
1878 sprintf(buf, "(%d,%d)", data.select.v1+1, data.select.v2+1);
1879 desc += buf;
1880 }
1881 break;
1882
1883 case icSigFlipOp:
1884 case icSigSumOp:
1885 case icSigProductOp:
1886 case icSigMinimumOp:
1887 case icSigMaximumOp:
1888 case icSigAndOp:
1889 case icSigOrOp:
1890 if (data.select.v1) {
1891 sprintf(buf, "(%d)", data.select.v1+2);
1892 desc += buf;
1893 }
1894 break;
1895
1896 case icSigGammaOp:
1897 case icSigScalarAddOp:
1901 case icSigAddOp:
1902 case icSigSubtractOp:
1903 case icSigMultiplyOp:
1904 case icSigDivideOp:
1905 case icSigModulusOp:
1906 case icSigPowOp:
1907 case icSigArcTan2Op:
1908 case icSigLessThanOp:
1910 case icSigEqualOp:
1911 case icSigNotEqualOp:
1912 case icSigNearOp:
1914 case icSigGreaterThanOp:
1915 case icSigSquareOp:
1916 case icSigSquareRootOp:
1917 case icSigCubeOp:
1918 case icSigCubeRootOp:
1919 case icSigSignOp:
1920 case icSigAbsoluteValOp:
1921 case icSigTruncateOp:
1922 case icSigFloorOp:
1923 case icSigCeilingOp:
1924 case icSigRoundOp:
1925 case icSigRealNumberOp:
1926 case icSigNegOp:
1927 case icSigExpOp:
1928 case icSigLogrithmOp:
1929 case icSigNaturalLogOp:
1930 case icSigSineOp:
1931 case icSigCosineOp:
1932 case icSigTangentOp:
1933 case icSigArcSineOp:
1934 case icSigArcCosineOp:
1935 case icSigArcTangentOp:
1938 case icSigNotOp:
1939 case icSigToLabOp:
1940 case icSigToXYZOp:
1943 case icSigVectorAndOp:
1944 case icSigVectorOrOp:
1945 if (data.select.v1) {
1946 sprintf(buf, "[%d]", data.select.v1+1);
1947 desc += buf;
1948 }
1949 break;
1950 }
1951}
1952
1953typedef std::map<icSigCalcOp, IIccOpDef*> icCalcOpMap;
1954
1956{
1957 CIccCalcOpMgr();
1959public:
1960 static CIccCalcOpMgr* GetInstance();
1961 static IIccOpDef *getOpDef(icSigCalcOp opSig);
1962
1963protected:
1966};
1968
1970{
1991 m_map[icSigPopOp] = new CIccOpDefPop();
1994 m_map[icSigPiOp] = new CIccOpDefPi();
1998 m_map[icSigSumOp] = new CIccOpDefSum();
2000 m_map[icSigAddOp] = new CIccOpDefAdd();
2005 m_map[icSigPowOp] = new CIccOpDefPow();
2021 m_map[icSigNegOp] = new CIccOpDefNeg();
2022 m_map[icSigExpOp] = new CIccOpDefExp();
2048 m_map[icSigAndOp] = new CIccOpDefAnd();
2049 m_map[icSigOrOp] = new CIccOpDefOr();
2050 m_map[icSigNotOp] = new CIccOpDefNot();
2053}
2054
2056{
2057 if (!m_inst)
2058 m_inst = new CIccCalcOpMgr();
2059 return m_inst;
2060}
2061
2062
2063/**
2064******************************************************************************
2065* Name: SIccCalcOp::IsValidOp
2066*
2067* Purpose:
2068*
2069* Args:
2070*
2071* Return:
2072******************************************************************************/
2074{
2075 switch (sig) {
2076 case icSigDataOp:
2077 case icSigInputChanOp:
2078 case icSigOutputChanOp:
2079 case icSigTempGetChanOp:
2080 case icSigTempPutChanOp:
2082 case icSigEnvVarOp:
2083 case icSigApplyCurvesOp:
2084 case icSigApplyMatrixOp:
2085 case icSigApplyCLutOp:
2086 case icSigApplyTintOp:
2087 case icSigApplyToJabOp:
2089 case icSigApplyCalcOp:
2090 case icSigApplyElemOp:
2091 case icSigCopyOp:
2092 case icSigRotateLeftOp:
2093 case icSigRotateRightOp:
2094 case icSigPositionDupOp:
2095 case icSigFlipOp:
2096 case icSigPopOp:
2097 case icSigSolveOp:
2098 case icSigTransposeOp:
2099 case icSigPiOp:
2100 case icSigPosInfinityOp:
2101 case icSigNegInfinityOp:
2102 case icSigNotaNumberOp:
2103 case icSigSumOp:
2104 case icSigProductOp:
2105 case icSigAddOp:
2106 case icSigSubtractOp:
2107 case icSigMultiplyOp:
2108 case icSigDivideOp:
2109 case icSigModulusOp:
2110 case icSigPowOp:
2111 case icSigGammaOp:
2112 case icSigScalarAddOp:
2116 case icSigSquareOp:
2117 case icSigSquareRootOp:
2118 case icSigCubeOp:
2119 case icSigCubeRootOp:
2120 case icSigSignOp:
2121 case icSigAbsoluteValOp:
2122 case icSigTruncateOp:
2123 case icSigFloorOp:
2124 case icSigCeilingOp:
2125 case icSigRoundOp:
2126 case icSigNegOp:
2127 case icSigExpOp:
2128 case icSigLogrithmOp:
2129 case icSigNaturalLogOp:
2130 case icSigSineOp:
2131 case icSigCosineOp:
2132 case icSigTangentOp:
2133 case icSigArcSineOp:
2134 case icSigArcCosineOp:
2135 case icSigArcTangentOp:
2136 case icSigArcTan2Op:
2141 case icSigVectorAndOp:
2142 case icSigVectorOrOp:
2143 case icSigMinimumOp:
2144 case icSigMaximumOp:
2145 case icSigRealNumberOp:
2146 case icSigLessThanOp:
2148 case icSigEqualOp:
2149 case icSigNotEqualOp:
2150 case icSigNearOp:
2152 case icSigGreaterThanOp:
2153 case icSigAndOp:
2154 case icSigOrOp:
2155 case icSigNotOp:
2156 case icSigToLabOp:
2157 case icSigToXYZOp:
2158 case icSigIfOp:
2159 case icSigElseOp:
2160 case icSigSelectOp:
2161 case icSigCaseOp:
2162 case icSigDefaultOp:
2163 return true;
2164
2165 default:
2166 return false;
2167 }
2168}
2169
2171{
2172 icCalcOpMap::iterator pos;
2173 CIccCalcOpMgr *inst = GetInstance();
2174 pos = inst->m_map.find(opSig);
2175 if (pos==inst->m_map.end())
2176 return &inst->m_invalid;
2177 return pos->second;
2178}
2179
2180
2181
2182/******************************************************************************
2183* Name: SIccCalcOp::IsValidOp
2184*
2185* Purpose:
2186*
2187* Args:
2188*
2189* Return:
2190******************************************************************************/
2192{
2193 switch(sig) {
2194 case icSigApplyCurvesOp:
2195 case icSigApplyMatrixOp:
2196 case icSigApplyCLutOp:
2197 case icSigApplyTintOp:
2198 case icSigApplyToJabOp:
2200 case icSigApplyCalcOp:
2201 case icSigApplyElemOp:
2202 {
2203 CIccMultiProcessElement *pMpe = pCalc->GetElem(sig, data.select.v1);
2204 return pMpe != NULL;
2205 }
2206
2207 default:
2208 return IsValidOp(sig);
2209 }
2210}
2211
2212/**
2213******************************************************************************
2214* Name: SIccCalcOp::ArgsUsed
2215*
2216* Purpose:
2217*
2218* Args:
2219*
2220* Return:
2221******************************************************************************/
2223{
2224 switch (sig) {
2225 case icSigDataOp:
2226 case icSigPiOp:
2227 case icSigPosInfinityOp:
2228 case icSigNegInfinityOp:
2229 case icSigNotaNumberOp:
2230 case icSigInputChanOp:
2231 case icSigTempGetChanOp:
2232 case icSigEnvVarOp:
2233 return 0;
2234
2235 case icSigApplyCurvesOp:
2236 case icSigApplyMatrixOp:
2237 case icSigApplyCLutOp:
2238 case icSigApplyTintOp:
2239 case icSigApplyToJabOp:
2241 case icSigApplyCalcOp:
2242 case icSigApplyElemOp:
2243 {
2244 CIccMultiProcessElement *pMpe = pCalc->GetElem(sig, data.select.v1);
2245 return (pMpe ? pMpe->NumInputChannels() : 0);
2246 }
2247
2248 case icSigOutputChanOp:
2249 case icSigTempPutChanOp:
2251 return data.select.v2+1;
2252
2253 case icSigCopyOp:
2254 case icSigRotateLeftOp:
2255 case icSigRotateRightOp:
2256 case icSigPositionDupOp:
2257 case icSigPopOp:
2258 return data.select.v1+1;
2259
2260 case icSigSolveOp:
2261 return (data.select.v1+1)*(data.select.v2+1) + (data.select.v1+1);
2262
2263 case icSigTransposeOp:
2264 return (data.select.v1+1)*(data.select.v2+1);
2265
2266 case icSigFlipOp:
2267 return data.select.v1+2;
2268
2269 case icSigSumOp:
2270 case icSigProductOp:
2271 case icSigMinimumOp:
2272 case icSigMaximumOp:
2273 case icSigAndOp:
2274 case icSigOrOp:
2275 return data.select.v1+2;
2276
2277 case icSigGammaOp:
2278 case icSigScalarAddOp:
2282 return data.select.v1+2;
2283
2284 case icSigAddOp:
2285 case icSigSubtractOp:
2286 case icSigMultiplyOp:
2287 case icSigDivideOp:
2288 case icSigModulusOp:
2289 case icSigPowOp:
2290 case icSigArcTan2Op:
2291 case icSigLessThanOp:
2293 case icSigEqualOp:
2294 case icSigNotEqualOp:
2295 case icSigNearOp:
2297 case icSigGreaterThanOp:
2302 case icSigVectorAndOp:
2303 case icSigVectorOrOp:
2304 return (data.select.v1+1)*2;
2305
2306 case icSigSquareOp:
2307 case icSigSquareRootOp:
2308 case icSigCubeOp:
2309 case icSigCubeRootOp:
2310 case icSigSignOp:
2311 case icSigAbsoluteValOp:
2312 case icSigTruncateOp:
2313 case icSigFloorOp:
2314 case icSigCeilingOp:
2315 case icSigRoundOp:
2316 case icSigRealNumberOp:
2317 case icSigNegOp:
2318 case icSigExpOp:
2319 case icSigLogrithmOp:
2320 case icSigNaturalLogOp:
2321 case icSigSineOp:
2322 case icSigCosineOp:
2323 case icSigTangentOp:
2324 case icSigArcSineOp:
2325 case icSigArcCosineOp:
2326 case icSigArcTangentOp:
2327 case icSigNotOp:
2328 return data.select.v1+1;
2329
2330 case icSigToLabOp:
2331 case icSigToXYZOp:
2332 return (data.select.v1+1)*3;
2333
2334 case icSigIfOp:
2335 case icSigSelectOp:
2336 return 1;
2337
2338 default:
2339 return 0;
2340 }
2341}
2342
2343
2344/**
2345******************************************************************************
2346* Name: SIccCalcOp::ArgsPushed
2347*
2348* Purpose:
2349*
2350* Args:
2351*
2352* Return:
2353******************************************************************************/
2355{
2356 switch (sig) {
2357 case icSigOutputChanOp:
2358 case icSigTempPutChanOp:
2359
2360 case icSigPopOp:
2361 case icSigIfOp:
2362 case icSigSelectOp:
2363 /*case icSigElseOp:*/ //This is only valid after an icSigIfOp is parsed
2364 /*case icSigCaseOp:*/ //This is only valid after an icSigSelectOp is parsed
2365 /*case icSigDefaultOp:*/ //This is only valid after an icSigSelectOp is parsed
2366 return 0;
2367
2368 case icSigDataOp:
2369 case icSigPiOp:
2370 case icSigPosInfinityOp:
2371 case icSigNegInfinityOp:
2372 case icSigNotaNumberOp:
2373 return 1;
2374
2375 case icSigEnvVarOp:
2376 return 2;
2377
2378 case icSigInputChanOp:
2379 case icSigTempGetChanOp:
2381 return data.select.v2+1;
2382
2383 case icSigApplyCurvesOp:
2384 case icSigApplyMatrixOp:
2385 case icSigApplyCLutOp:
2386 case icSigApplyTintOp:
2387 case icSigApplyToJabOp:
2389 case icSigApplyCalcOp:
2390 case icSigApplyElemOp:
2391 {
2392 CIccMultiProcessElement *pMpe = pCalc->GetElem(sig, data.select.v1);
2393 return (pMpe ? pMpe->NumOutputChannels() : 0);
2394 }
2395
2396 case icSigCopyOp:
2397 return (data.select.v1+1)*(data.select.v2+2);
2398 case icSigRotateLeftOp:
2399 case icSigRotateRightOp:
2400 return (data.select.v1+1);
2401
2402 case icSigFlipOp:
2403 return (data.select.v1+2);
2404
2405 case icSigPositionDupOp:
2406 return data.select.v1+2+data.select.v2;
2407
2408 case icSigSolveOp:
2409 return (data.select.v2+1) + 1;
2410
2411 case icSigTransposeOp:
2412 return (data.select.v1+1)*(data.select.v2+1);
2413
2414 case icSigSumOp:
2415 case icSigProductOp:
2416 case icSigMinimumOp:
2417 case icSigMaximumOp:
2418 case icSigAndOp:
2419 case icSigOrOp:
2420 return 1;
2421
2422 case icSigAddOp:
2423 case icSigSubtractOp:
2424 case icSigMultiplyOp:
2425 case icSigDivideOp:
2426 case icSigModulusOp:
2427 case icSigPowOp:
2428 case icSigGammaOp:
2429 case icSigScalarAddOp:
2433 case icSigSquareOp:
2434 case icSigSquareRootOp:
2435 case icSigCubeOp:
2436 case icSigCubeRootOp:
2437 case icSigSignOp:
2438 case icSigAbsoluteValOp:
2439 case icSigTruncateOp:
2440 case icSigFloorOp:
2441 case icSigCeilingOp:
2442 case icSigRoundOp:
2443 case icSigRealNumberOp:
2444 case icSigNegOp:
2445 case icSigExpOp:
2446 case icSigLogrithmOp:
2447 case icSigNaturalLogOp:
2448 case icSigSineOp:
2449 case icSigCosineOp:
2450 case icSigTangentOp:
2451 case icSigArcSineOp:
2452 case icSigArcCosineOp:
2453 case icSigArcTangentOp:
2454 case icSigArcTan2Op:
2455 case icSigLessThanOp:
2457 case icSigEqualOp:
2458 case icSigNotEqualOp:
2459 case icSigNearOp:
2461 case icSigGreaterThanOp:
2462 case icSigNotOp:
2465 case icSigVectorAndOp:
2466 case icSigVectorOrOp:
2467 return data.select.v1+1;
2468
2471 return (data.select.v1+1)*2;
2472
2473 case icSigToLabOp:
2474 case icSigToXYZOp:
2475 return (data.select.v1+1)*3;
2476
2477 default:
2478 return 0;
2479 }
2480}
2481
2482CIccFuncTokenizer::CIccFuncTokenizer(const char *szText, bool bAllowNamedReferences)
2483{
2484 m_token = new std::string();
2485 m_text = szText;
2486 m_bUseRefs = bAllowNamedReferences;
2487}
2488
2493
2494
2495bool CIccFuncTokenizer::GetNext(bool bForceNoRefs)
2496{
2497 m_token->clear();
2498
2499try_again:
2500
2501 while (*m_text && IsWhiteSpace())
2502 m_text++;
2503
2504 if (!*m_text) {
2505 return false;
2506 }
2507
2508 if (!m_bUseRefs || bForceNoRefs) {
2509 if (*m_text == '{') {
2510 m_text++;
2511 *m_token = "{";
2512 return true;
2513 }
2514
2515 if (*m_text == '}') {
2516 m_text++;
2517 *m_token = "}";
2518 return true;
2519 }
2520
2521 if (*m_text == '[') {
2522 m_text++;
2523 *m_token = "[";
2524 while (*m_text && *m_text != ']') {
2525 *m_token += *m_text;
2526 m_text++;
2527 }
2528 }
2529
2530 if (*m_text == '(') {
2531 m_text++;
2532 *m_token = "(";
2533 while (*m_text && *m_text != ')') {
2534 *m_token += *m_text;
2535 m_text++;
2536 }
2537 if (!*m_text) {
2538 return false;
2539 }
2540 }
2541 }
2542
2543 if (!*m_text) {
2544 return false;
2545 }
2546
2547 if (IsComment()) {
2548 SkipComment();
2549 goto try_again;
2550 }
2551
2552 if (m_bUseRefs && !bForceNoRefs) {
2553 while (!IsWhiteSpace() && *m_text && !IsComment()) {
2554 *m_token += *m_text;
2555 m_text++;
2556 }
2557 }
2558 else {
2559 while (!IsWhiteSpace() && *m_text && *m_text != '{' && *m_text != '[' &&
2560 *m_text != '(' && *m_text != '}' && !IsComment()) {
2561 *m_token += *m_text;
2562 m_text++;
2563 }
2564 }
2565 return true;
2566}
2567
2568
2570{
2571 const unsigned char *szToken = (unsigned char*) m_token->c_str();
2572 int i;
2573
2574 if ((szToken[0]>='0' && szToken[0]<='9') || szToken[0]=='.' || (szToken[0]=='-' && szToken[1]!='I')) {
2575 return icSigDataOp;
2576 }
2577
2578 if (szToken[0]=='{')
2579 return icSigBeginBlockOp;
2580
2581 if (szToken[0]=='}')
2582 return icSigEndBlockOp;
2583
2584 if (szToken[0]=='[')
2585 return icSigBadOp;
2586
2587 icUInt32Number sig = 0;
2588 for (i=0; i<4 && szToken[i]; i++) {
2589 sig <<= 8;
2590 sig |= szToken[i];
2591 }
2592
2593 for (;i<4; i++) {
2594 sig <<= 8;
2595 sig |= 0x20;
2596 }
2597
2598 return (icSigCalcOp)sig;
2599}
2600
2602{
2603 std::string rv;
2604 const char *pos = m_token->c_str();
2605
2606 while (*pos && *pos != '{' && *pos != '[' && *pos != '(') {
2607 rv += *pos;
2608 pos++;
2609 }
2610
2611 return rv;
2612}
2613
2615{
2616 const char *pos = strchr(m_token->c_str(), '{');
2617 if (!m_bUseRefs || !pos)
2618 return "";
2619
2620 std::string rv;
2621 pos++;
2622 while (*pos && *pos != '}') {
2623 rv += *pos;
2624 pos++;
2625 }
2626
2627 return rv;
2628}
2629
2631{
2632 unsigned int iv1, iv2;
2633 const char *pos = GetPos();
2634
2635 if (!GetNext(true))
2636 return false;
2637 iv1=initV1;
2638 iv2=initV2;
2639 const char *szToken = m_token->c_str();
2640 if (*szToken=='[' || *szToken=='(') {
2641 if (strchr(szToken, ',')) {
2642 if (*szToken=='(')
2643 sscanf(m_token->c_str(), "(%u,%u)", &iv1, &iv2);
2644 else
2645 sscanf(m_token->c_str(), "[%u,%u]", &iv1, &iv2);
2646 }
2647 else {
2648 if (*szToken=='(')
2649 sscanf(m_token->c_str(), "(%u)", &iv1);
2650 else
2651 sscanf(m_token->c_str(), "[%u]", &iv1);
2652 }
2653 }
2654 else {
2655 SetPos(pos); //Undo get token
2656 }
2657 v1 = (icUInt16Number)iv1 - initV1;
2658 v2 = (icUInt16Number)iv2 - initV2;
2659
2660 return true;
2661}
2662
2663
2665{
2666 const char * ascii = m_token->c_str();
2667 char * p = NULL;
2668 double d = strtod( ascii, &p );
2669 return (icFloat32Number)d;
2670}
2671
2672
2674{
2675 const char *pos = GetPos();
2676
2677 if (!GetNext())
2678 return false;
2679 const char *szToken = m_token->c_str();
2680 int l=(int)strlen(szToken);
2681 if ((*szToken=='[' && szToken[l-1]==']') ||
2682 (*szToken=='(' && szToken[l-1]==')')) {
2683
2684 int i;
2685
2686 icUInt32Number sig = 0;
2687 if (l==10) {
2688 sscanf(szToken+1, "%x", &sig);
2689
2690 envSig = (icSigCmmEnvVar)sig;
2691 return true;
2692 }
2693
2694 for (i=1; i<=4 && i<l-1; i++) {
2695 sig <<= 8;
2696 sig |= szToken[i];
2697 }
2698
2699 for (;i<=4; i++) {
2700 sig <<= 8;
2701 sig |= 0x20;
2702 }
2703
2704 envSig = (icSigCmmEnvVar)sig;
2705 }
2706 else {
2707 SetPos(pos); //Undo get token
2708 envSig = (icSigCmmEnvVar)0;
2709 return false;
2710 }
2711
2712 return true;
2713}
2714
2715
2717{
2718 if (*m_text==' ' || *m_text=='\n' || *m_text=='\r' || *m_text=='\t')
2719 return true;
2720 return false;
2721}
2722
2724{
2725 if (*m_text=='%' || *m_text==';' || *m_text=='/')
2726 return true;
2727 return false;
2728}
2729
2731{
2732 while(*m_text && !(*m_text=='\n' || *m_text=='\r')) {
2733 m_text++;
2734 }
2735}
2736
2737/**
2738 ******************************************************************************
2739 * Name: CIccCalculatorFunc::CIccCalculatorFunc
2740 *
2741 * Purpose:
2742 *
2743 * Args:
2744 *
2745 * Return:
2746 ******************************************************************************/
2748{
2749 m_pCalc = pCalc;
2750 m_nReserved = 0;
2751
2752 m_nOps = 0;
2753 m_Op = NULL;
2754}
2755
2756/**
2757 ******************************************************************************
2758 * Name: CIccCalculatorFunc::CIccCalculatorFunc
2759 *
2760 * Purpose:
2761 *
2762 * Args:
2763 *
2764 * Return:
2765 ******************************************************************************/
2767{
2768 m_pCalc = func.m_pCalc;
2769
2771
2772 m_nOps = func.m_nOps;
2773
2774 if (m_nOps) {
2775 m_Op = (SIccCalcOp*)malloc(m_nOps * sizeof(SIccCalcOp));
2776 memcpy(m_Op, func.m_Op, m_nOps*sizeof(SIccCalcOp));
2777 }
2778 else
2779 m_Op = NULL;
2780}
2781
2782/**
2783 ******************************************************************************
2784 * Name: &CIccCalculatorFunc::operator=
2785 *
2786 * Purpose:
2787 *
2788 * Args:
2789 *
2790 * Return:
2791 ******************************************************************************/
2793{
2794 m_pCalc = func.m_pCalc;
2795
2797
2798 if (m_Op)
2799 free(m_Op);
2800
2801 m_nOps = func.m_nOps;
2802
2803 if (m_nOps) {
2804 m_Op = (SIccCalcOp*)malloc(m_nOps * sizeof(SIccCalcOp));
2805 memcpy(m_Op, func.m_Op, m_nOps*sizeof(SIccCalcOp));
2806 }
2807 else
2808 m_Op = NULL;
2809
2810 return (*this);
2811}
2812
2813/**
2814 ******************************************************************************
2815 * Name: CIccCalculatorFunc::~CIccChannelFunc
2816 *
2817 * Purpose:
2818 *
2819 * Args:
2820 *
2821 * Return:
2822 ******************************************************************************/
2824{
2825 if (m_Op) {
2826 free(m_Op);
2827 }
2828}
2829
2830void CIccCalculatorFunc::InsertBlanks(std::string &sDescription, int nBlanks)
2831{
2832 char blanks[21]=" ";
2833 int i;
2834
2835 while (nBlanks>0) {
2836 i = nBlanks < 20 ? nBlanks : 20;
2837 blanks[i] = 0;
2838 sDescription += blanks;
2839 nBlanks -= i;
2840 }
2841}
2842
2843void CIccCalculatorFunc::DescribeSequence(std::string &sDescription,
2844 icUInt32Number nOps, SIccCalcOp *op, int nBlanks)
2845{
2847 int pos;
2848 std::string opName;
2849 std::string funcDesc;
2850
2851 InsertBlanks(funcDesc, nBlanks);
2852 funcDesc += "{ ";
2853
2854 pos = nBlanks + 2;
2855
2856 for (i=0; i<nOps;) {
2857 if (pos >nBlanks + 65) {
2858 funcDesc += "\n";
2859 InsertBlanks(funcDesc, nBlanks + 2);
2860 pos = nBlanks + 2;
2861 }
2862
2863 op->Describe(opName, 100); // TODO - propogate nVerboseness
2864 funcDesc += opName;
2865 funcDesc += " ";
2866 pos += (int)opName.size() + 1;
2867
2868 if (op->sig == icSigIfOp) {
2869 SIccCalcOp *ifop = op;
2870
2871 if (i+1<nOps && op[1].sig == icSigElseOp) {
2872 SIccCalcOp *elseop = &op[1];
2873 icUInt32Number nSubOps = (icUInt32Number)icIntMin(nOps-i, ifop->data.size);
2874 op++;
2875 i++;
2876 funcDesc += "\n";
2877 DescribeSequence(funcDesc, nSubOps, &op[1], nBlanks+2);
2878 op += nSubOps;
2879 i += nSubOps;
2880
2881 InsertBlanks(funcDesc, nBlanks+2);
2882 funcDesc += "else\n";
2883 pos = 0;
2884
2885 nSubOps = (icUInt32Number)icIntMin(nOps-i, elseop->data.size);
2886 DescribeSequence(funcDesc, nSubOps, &op[1], nBlanks+2);
2887 op += nSubOps;
2888 i += nSubOps;
2889 }
2890 else {
2891 icUInt32Number nSubOps = (icUInt32Number)icIntMin(nOps-i, ifop->data.size);
2892 funcDesc += "\n";
2893 DescribeSequence(funcDesc, nSubOps, &op[1], nBlanks+2);
2894 op += nSubOps;
2895 i += nSubOps;
2896 }
2897
2898 InsertBlanks(funcDesc, nBlanks + 2);
2899 pos = nBlanks + 2;
2900 }
2901 else if (op->sig == icSigSelectOp) {
2902 op++;
2903 i++;
2904 funcDesc += "\n";
2905
2906 int j, n;
2907
2908 for (n=0; i+n<nOps; ) {
2909 if (op[n].sig==icSigCaseOp)
2910 n++;
2911 else if (n>1 && op[n].sig==icSigDefaultOp) {
2912 n++;
2913 break;
2914 }
2915 else
2916 break;
2917 }
2918
2919 int p = n;
2920 for (j=0; j<n; j++) {
2921 icUInt32Number nSubOps = (icUInt32Number)icIntMin(nOps-(i+p), op[j].data.size);
2922 InsertBlanks(funcDesc, nBlanks+2);
2923 if (op[j].sig==icSigCaseOp)
2924 funcDesc += "case\n";
2925 else
2926 funcDesc += "dflt\n";
2927
2928 DescribeSequence(funcDesc, nSubOps, &op[p], nBlanks+2);
2929 p += nSubOps;
2930 }
2931
2932 op += p-1;
2933 i += p-1;
2934
2935 InsertBlanks(funcDesc, nBlanks + 2);
2936 pos = nBlanks + 2;
2937 }
2938 op++;
2939 i++;
2940 }
2941 funcDesc += "}\n";
2942
2943 sDescription += funcDesc;
2944}
2945
2946/**
2947 ******************************************************************************
2948 * Name: CIccCalculatorFunc::Describe
2949 *
2950 * Purpose:
2951 *
2952 * Args:
2953 *
2954 * Return:
2955 ******************************************************************************/
2956void CIccCalculatorFunc::Describe(std::string &sDescription, int nVerboseness, int nBlanks)
2957{
2958 if (m_nOps) {
2959 DescribeSequence(sDescription, m_nOps, m_Op, nBlanks);
2960 }
2961 else {
2962 sDescription += "Undefined Function!\n";
2963 }
2964}
2965
2966static void AppendOpList(CIccCalcOpList &toList, const CIccCalcOpList &fromList)
2967{
2968 CIccCalcOpList::const_iterator o;
2969
2970 for (o=fromList.begin(); o!=fromList.end(); o++) {
2971 toList.push_back(*o);
2972 }
2973}
2974
2975/**
2976******************************************************************************
2977* Name: CIccCalculatorFunc::ParseFuncDef
2978*
2979* Purpose:
2980*
2981* Args:
2982*
2983* Return:
2984******************************************************************************/
2985const char *CIccCalculatorFunc::ParseFuncDef(const char *szFuncDef, CIccCalcOpList &scanList, std::string &sReport)
2986{
2987 SIccCalcOp op;
2988 op.extra = 0;
2989 op.def=NULL;
2990
2991 scanList.clear();
2992
2993 if (!szFuncDef)
2994 return szFuncDef;
2995
2996 CIccFuncTokenizer scan(szFuncDef);
2997 if (!scan.GetNext())
2998 return NULL;
2999
3000 if (scan.GetSig() != icSigBeginBlockOp)
3001 return NULL;
3002
3003 while(scan.GetNext()) {
3004 op.sig = scan.GetSig();
3005
3006 if (op.sig == icSigEndBlockOp)
3007 return scan.GetPos();
3008
3009 switch(op.sig) {
3010 case icSigDataOp:
3011 op.data.num = scan.GetValue();
3012 scanList.push_back(op);
3013 break;
3014
3015 case icSigIfOp:
3016 {
3017 CIccCalcOpList trueList, falseList;
3018 bool bHasElse;
3019
3020 szFuncDef = ParseFuncDef(scan.GetPos(), trueList, sReport);
3021 if (!szFuncDef)
3022 return NULL;
3023
3024 scan.SetPos(szFuncDef);
3025 bHasElse = false;
3026 if (scan.GetNext() && scan.GetSig()==icSigElseOp) {
3027 bHasElse = true;
3028 szFuncDef = ParseFuncDef(scan.GetPos(), falseList, sReport);
3029
3030 if (!szFuncDef)
3031 return NULL;
3032 }
3033
3034 scan.SetPos(szFuncDef);
3035 op.data.size = (icUInt32Number)trueList.size();
3036 scanList.push_back(op);
3037
3038 if (bHasElse) {
3039 op.sig = icSigElseOp;
3040 op.data.size = (icUInt32Number)falseList.size();
3041 scanList.push_back(op);
3042
3043 AppendOpList(scanList, trueList);
3044 AppendOpList(scanList, falseList);
3045 }
3046 else {
3047 AppendOpList(scanList, trueList);
3048 }
3049 }
3050 break;
3051
3052 case icSigSelectOp:
3053 {
3054 op.sig = icSigSelectOp;
3055 op.data.size = 0;
3056 scanList.push_back(op);
3057
3058 int c;
3059 CIccCalcOpListPtrList selList;
3060 for (c=0; ; c++) {
3061 szFuncDef = scan.GetPos();
3062 scan.GetNext();
3063 if (scan.GetSig()==icSigCaseOp) {
3064 CIccCalcOpListPtr pCaseList = new CIccCalcOpList();
3065
3066 szFuncDef = ParseFuncDef(scan.GetPos(), *pCaseList, sReport);
3067
3068 if (!szFuncDef) {
3069 delete pCaseList;
3070 return NULL;
3071 }
3072
3073 scan.SetPos(szFuncDef);
3074 op.sig = icSigCaseOp;
3075 op.data.size = (icUInt32Number)pCaseList->size();
3076 scanList.push_back(op);
3077
3078 selList.push_back(pCaseList);
3079 }
3080 else if (c && scan.GetSig()==icSigDefaultOp) {
3081 CIccCalcOpListPtr pDefaultList = new CIccCalcOpList();
3082
3083 szFuncDef = ParseFuncDef(scan.GetPos(), *pDefaultList, sReport);
3084
3085 if (!szFuncDef) {
3086 delete pDefaultList;
3087 return NULL;
3088 }
3089
3090 scan.SetPos(szFuncDef);
3091 op.sig = icSigDefaultOp;
3092 op.data.size = (icUInt32Number)pDefaultList->size();
3093 scanList.push_back(op);
3094
3095 selList.push_back(pDefaultList);
3096 break;
3097 }
3098 else {
3099 scan.SetPos(szFuncDef);
3100 break;
3101 }
3102 }
3103 CIccCalcOpListPtrList::iterator l;
3104 for (l=selList.begin(); l!=selList.end(); l++) {
3105 CIccCalcOpListPtr pCaseList = *l;
3106
3107 AppendOpList(scanList, *pCaseList);
3108 delete pCaseList;
3109 }
3110 }
3111 break;
3112
3113 case icSigInputChanOp:
3114 case icSigOutputChanOp:
3115 case icSigTempGetChanOp:
3116 case icSigTempPutChanOp:
3118 if (!scan.GetIndex(op.data.select.v1, op.data.select.v2, 0, 1))
3119 return NULL;
3120 scanList.push_back(op);
3121 break;
3122
3123 case icSigEnvVarOp:
3124 {
3125 icSigCmmEnvVar envSig;
3126 if (!scan.GetEnvSig(envSig))
3127 return NULL;
3128 op.data.size = (icUInt32Number)envSig;
3129 scanList.push_back(op);
3130 }
3131 break;
3132
3133 case icSigCopyOp:
3134 case icSigRotateLeftOp:
3135 case icSigRotateRightOp:
3136 case icSigPositionDupOp:
3137 case icSigSolveOp:
3138 case icSigTransposeOp:
3139 if (!scan.GetIndex(op.data.select.v1, op.data.select.v2, 1, 1))
3140 return NULL;
3141 scanList.push_back(op);
3142 break;
3143
3144 case icSigPopOp:
3145 if (!scan.GetIndex(op.data.select.v1, op.data.select.v2, 1))
3146 return NULL;
3147 op.data.select.v2 = 0;
3148 scanList.push_back(op);
3149 break;
3150
3151 case icSigFlipOp:
3152 case icSigSumOp:
3153 case icSigProductOp:
3154 case icSigMinimumOp:
3155 case icSigMaximumOp:
3156 case icSigAndOp:
3157 case icSigOrOp:
3158 if (!scan.GetIndex(op.data.select.v1, op.data.select.v2, 2))
3159 return NULL;
3160 op.data.select.v2 = 0;
3161 scanList.push_back(op);
3162 break;
3163
3164 case icSigApplyCurvesOp:
3165 case icSigApplyMatrixOp:
3166 case icSigApplyCLutOp:
3167 case icSigApplyTintOp:
3168 case icSigApplyToJabOp:
3170 case icSigApplyCalcOp:
3171 case icSigApplyElemOp:
3172 if (!scan.GetIndex(op.data.select.v1, op.data.select.v2))
3173 return NULL;
3174 op.data.select.v2 = 0;
3175 scanList.push_back(op);
3176 break;
3177
3178 case icSigGammaOp:
3179 case icSigScalarAddOp:
3183 case icSigAddOp:
3184 case icSigSubtractOp:
3185 case icSigMultiplyOp:
3186 case icSigDivideOp:
3187 case icSigModulusOp:
3188 case icSigPowOp:
3189 case icSigArcTan2Op:
3190 case icSigLessThanOp:
3192 case icSigEqualOp:
3193 case icSigNotEqualOp:
3194 case icSigNearOp:
3196 case icSigGreaterThanOp:
3197 case icSigSquareOp:
3198 case icSigSquareRootOp:
3199 case icSigCubeOp:
3200 case icSigCubeRootOp:
3201 case icSigSignOp:
3202 case icSigAbsoluteValOp:
3203 case icSigTruncateOp:
3204 case icSigFloorOp:
3205 case icSigCeilingOp:
3206 case icSigRoundOp:
3207 case icSigRealNumberOp:
3208 case icSigNegOp:
3209 case icSigExpOp:
3210 case icSigLogrithmOp:
3211 case icSigNaturalLogOp:
3212 case icSigSineOp:
3213 case icSigCosineOp:
3214 case icSigTangentOp:
3215 case icSigArcSineOp:
3216 case icSigArcCosineOp:
3217 case icSigArcTangentOp:
3220 case icSigNotOp:
3221 case icSigToLabOp:
3222 case icSigToXYZOp:
3225 case icSigVectorAndOp:
3226 case icSigVectorOrOp:
3227 if (!scan.GetIndex(op.data.select.v1, op.data.select.v2, 1))
3228 return NULL;
3229 op.data.select.v2 = 0;
3230 scanList.push_back(op);
3231 break;
3232
3233 default:
3234 if (!SIccCalcOp::IsValidOp(op.sig)) {
3235 std::string opDesc;
3236
3237 op.Describe(opDesc, 100); // TODO - propogate nVerboseness
3238 sReport += "Invalid Operator \"";
3239 sReport += opDesc;
3240 sReport += "\"\n";
3241
3242 if (scanList.rbegin()!=scanList.rend()) {
3243 sReport += "Last Few operators in reverse:\n";
3244
3245 CIccCalcOpList::reverse_iterator opi;
3246 int i;
3247 for (i=0, opi=scanList.rbegin(); i<10 && opi!=scanList.rend(); i++, opi++) {
3248 opi->Describe(opDesc, 100); // TODO - propogate nVerboseness
3249 sReport += " ";
3250 sReport += opDesc;
3251 }
3252 sReport += "\n";
3253 }
3254 return NULL;
3255 }
3256 op.data.select.v1 = 0;
3257 op.data.select.v2 = 0;
3258 scanList.push_back(op);
3259 break;
3260 }
3261 }
3262 return NULL;
3263}
3264
3265
3266/**
3267 ******************************************************************************
3268 * Name: CIccCalculatorFunc::SetFunction
3269 *
3270 * Purpose:
3271 *
3272 * Args:
3273 *
3274 * Return:
3275 ******************************************************************************/
3276icFuncParseStatus CIccCalculatorFunc::SetFunction(const char *szFuncDef, std::string &sReport)
3277{
3278 CIccCalcOpList opList;
3279
3280 if (ParseFuncDef(szFuncDef, opList, sReport)) {
3281 return SetFunction(opList, sReport);
3282 }
3284}
3285
3286/**
3287******************************************************************************
3288* Name: CIccCalculatorFunc::SetFunction
3289*
3290* Purpose:
3291*
3292* Args:
3293*
3294* Return:
3295******************************************************************************/
3297{
3298 if (m_Op) {
3299 free(m_Op);
3300 }
3301
3302 m_nOps = (icUInt32Number)opList.size();
3303
3304 if (m_nOps) {
3305 CIccCalcOpList::iterator i;
3306 int j;
3307
3308 m_Op = (SIccCalcOp*)calloc(m_nOps , sizeof(SIccCalcOp));
3309
3310 for (i=opList.begin(), j=0; i!= opList.end(); i++, j++) {
3311 m_Op[j] = *i;
3312 }
3313 }
3314 else {
3316 }
3317
3318 if (!HasValidOperations(sReport))
3320
3321 return DoesStackUnderflowOverflow(sReport);
3322}
3323
3324/**
3325 ******************************************************************************
3326 * Name: CIccCalculatorFunc::Read
3327 *
3328 * Purpose:
3329 *
3330 * Args:
3331 *
3332 * Return:
3333 ******************************************************************************/
3335{
3336 icUInt32Number headerSize = sizeof(icUInt32Number);
3337
3338 headerSize += sizeof(icChannelFuncSignature) + sizeof(icUInt32Number);
3339
3340 if (headerSize > size)
3341 return false;
3342
3343 if (!pIO) {
3344 return false;
3345 }
3346
3348
3349 if (!pIO->Read32(&sig))
3350 return false;
3351
3352 if (sig!= GetType())
3353 return false;
3354
3355 if (!pIO->Read32(&m_nReserved))
3356 return false;
3357
3358 if (!pIO->Read32(&m_nOps))
3359 return false;
3360
3361 if ((icUInt64Number)m_nOps * sizeof(icUInt32Number) * 2 > (icUInt64Number)size - headerSize)
3362 return false;
3363
3364 if (m_Op) {
3365 free(m_Op);
3366 }
3367
3368 if (m_nOps) {
3369 m_Op = (SIccCalcOp*)calloc(m_nOps, sizeof(SIccCalcOp));
3370
3371 if (!m_Op) {
3372 m_nOps = 0;
3373 return false;
3374 }
3375
3377 for (i=0; i<m_nOps; i++) {
3378 if (!pIO->Read32(&m_Op[i].sig))
3379 return false;
3380 if (!pIO->Read32(&m_Op[i].data.num))
3381 return false;
3382 }
3383 }
3384
3385 return true;
3386}
3387
3388/**
3389 ******************************************************************************
3390 * Name: CIccCalculatorFunc::Write
3391 *
3392 * Purpose:
3393 *
3394 * Args:
3395 *
3396 * Return:
3397 ******************************************************************************/
3399{
3400 if (!pIO)
3401 return false;
3402
3404 sig = GetType();
3405 if (!pIO->Write32(&sig))
3406 return false;
3407
3408 if (!pIO->Write32(&m_nReserved))
3409 return false;
3410
3411 if (!pIO->Write32(&m_nOps))
3412 return false;
3413
3415 for (i=0; i<m_nOps; i++) {
3416 if (!pIO->Write32(&m_Op[i].sig))
3417 return false;
3418 if (!pIO->Write32(&m_Op[i].data.num))
3419 return false;
3420 }
3421
3422 return true;
3423}
3424
3425
3426/**
3427 ******************************************************************************
3428 * Name: CIccCalculatorFunc::SetOpDefs
3429 *
3430 * Purpose:
3431 *
3432 * Args:
3433 *
3434 * Return:
3435 ******************************************************************************/
3437{
3438 if (!m_Op)
3439 return false;
3440
3442 for (i=0; i<m_nOps; i++) {
3444 if (!m_Op[i].def)
3445 return false;
3446 }
3447 return true;
3448}
3449
3450
3451/**
3452 ******************************************************************************
3453 * Name: CIccCalculatorFunc::Begin
3454 *
3455 * Purpose:
3456 *
3457 * Args:
3458 *
3459 * Return:
3460 ******************************************************************************/
3462{
3463 if (!pChannelCalc)
3464 return false;
3465 std::string sReport;
3466
3467 if (!InitSelectOps())
3468 return false;
3469
3470 if (!HasValidOperations(sReport))
3471 return false;
3472
3473 if (!SetOpDefs())
3474 return false;
3475
3476 if (DoesOverflowInput(pChannelCalc->NumInputChannels()))
3477 return false;
3478
3479 if (DoesOverflowOutput(pChannelCalc->NumOutputChannels()))
3480 return false;
3481
3483 return false;
3484
3485 return true;
3486}
3487
3488/**
3489 ******************************************************************************
3490 * Name: CIccCalculatorFunc::InitSelectOps
3491 *
3492 * Purpose:
3493 *
3494 * Args:
3495 *
3496 * Return:
3497 ******************************************************************************/
3499{
3501
3502 for (i=0; i<m_nOps; i++) {
3503 if (m_Op[i].sig==icSigSelectOp) {
3504 if (!InitSelectOp(&m_Op[i], m_nOps-i))
3505 return false;
3506 }
3507 }
3508
3509 return true;
3510}
3511
3512/**
3513 ******************************************************************************
3514 * Name: CIccCalculatorFunc::InitSelectOp
3515 *
3516 * Purpose:
3517 *
3518 * Args:
3519 *
3520 * Return:
3521 ******************************************************************************/
3523{
3524
3525 if (ops->sig != icSigSelectOp)
3526 return false;
3527
3528 if (ops->extra)
3529 return true;
3530
3531
3532 icUInt32Number i, n, pos;
3533 for (n=0; n<nOps && ops[n+1].sig==icSigCaseOp; n++);
3534 ops->extra=n;
3535 if (ops[n+1].sig==icSigDefaultOp) {
3536 n++;
3537 }
3538 pos = n;
3539 for (i=1; i<=n && pos<nOps; i++) {
3540 ops[i].extra = pos;
3541 pos += ops[i].data.size;
3542 }
3543
3544 if (i<=n)
3545 return false;
3546
3547 return true;
3548}
3549
3550/**
3551******************************************************************************
3552* Name: CIccCalculatorFunc::ApplySequence
3553*
3554* Purpose:
3555*
3556* Args:
3557*
3558* Return:
3559******************************************************************************/
3561{
3562 SIccCalcOp *op;
3563 SIccOpState os;
3564
3565 os.pApply = pApply;
3566 os.pStack = pApply->GetStack();
3567 os.pScratch = pApply->GetScratch();
3568 os.temp = pApply->GetTemp();
3569 os.pixel = pApply->GetInput();
3570 os.output = pApply->GetOutput();
3571 os.nOps = nOps;
3572
3573 for (os.idx=0; os.idx<os.nOps; os.idx++) {
3574 op = &ops[os.idx];
3575
3576 if (g_pDebugger)
3577 g_pDebugger->BeforeOp(op, os, ops);
3578
3579 if (op->sig==icSigIfOp) {
3580 icFloatNumber a1;
3581 OsPopArg(a1);
3582
3583 if (os.idx+1<nOps && ops[os.idx+1].sig==icSigElseOp) {
3584 os.idx++;
3585 if (a1>=0.5) {
3586 if (os.idx+1 + op->data.size >= nOps)
3587 return false;
3588
3589 if (!ApplySequence(pApply, op->data.size, &ops[os.idx+1]))
3590 return false;
3591 }
3592 else {
3593 if (os.idx+1 + op->data.size + ops[os.idx].data.size > nOps)
3594 return false;
3595
3596 if (!ApplySequence(pApply, ops[os.idx].data.size, &ops[os.idx+1 + op->data.size]))
3597 return false;
3598 }
3599 os.idx += op->data.size + ops[os.idx].data.size;
3600 }
3601 else {
3602 if (a1>=0.5) {
3603 if (os.idx+op->data.size >= nOps)
3604 return false;
3605
3606 if (!ApplySequence(pApply, op->data.size, &ops[os.idx+1]))
3607 return false;
3608 }
3609 os.idx+= op->data.size;
3610 }
3611 }
3612 else if (op->sig==icSigSelectOp) {
3613 icFloatNumber a1;
3614 OsPopArg(a1);
3615 icInt32Number nSel = (a1 >= 0.0) ? (icInt32Number)(a1+0.5f) : (icInt32Number)(a1-0.5f);
3616
3617 if (!op->extra) {
3618 return false;
3619 }
3620
3621 icUInt32Number nDefOff = (icUInt32Number)(os.idx+1 + op->extra);
3622 if (nDefOff >= nOps)
3623 return false;
3624
3625 if (nSel<0 || (icUInt32Number)nSel>=op->extra) {
3626
3627 if (ops[nDefOff].sig==icSigDefaultOp) {
3628 if (os.idx+1 + ops[nDefOff].extra >= nOps)
3629 return false;
3630
3631 if (!ApplySequence(pApply, ops[nDefOff].data.size, &ops[os.idx+1 + ops[nDefOff].extra]))
3632 break;
3633 }
3634 }
3635 else {
3636 icUInt32Number nOff = os.idx+1 + nSel;
3637
3638 if (nOff >= nOps)
3639 return false;
3640
3641 if (!ApplySequence(pApply, ops[nOff].data.size, &ops[os.idx+1 + ops[nOff].extra]))
3642 break;
3643 }
3644
3645 if (ops[nDefOff].sig==icSigDefaultOp) {
3646 if (os.idx+1 + ops[nDefOff].extra + ops[nDefOff].data.size >nOps)
3647 return false;
3648
3649 os.idx = (icUInt32Number)(os.idx + ops[nDefOff].extra + ops[nDefOff].data.size);
3650 }
3651 else if (op->extra) {
3652 unsigned long nOff = os.idx + op->extra;
3653
3654 if (os.idx+1 + ops[nOff].extra + ops[nOff].data.size > nOps)
3655 return false;
3656
3657 os.idx = (icUInt32Number)(os.idx + ops[nOff].extra + ops[nOff].data.size);
3658 }
3659 else
3660 return false;
3661 }
3662 else {
3663 if (!op->def->Exec(op, os))
3664 return false;
3665 }
3666
3667 if (g_pDebugger) {
3668 g_pDebugger->AfterOp(op, os, ops);
3669 }
3670 }
3671 return true;
3672}
3673
3674/**
3675 ******************************************************************************
3676 * Name: CIccCalculatorFunc::Apply
3677 *
3678 * Purpose:
3679 *
3680 * Args:
3681 *
3682 * Return:
3683 ******************************************************************************/
3685{
3686 CIccFloatVector *pStack = pApply->GetStack();
3687
3688 pStack->clear();
3689
3690 if (!ApplySequence(pApply, m_nOps, m_Op)) {
3691 icFloatNumber *pOut = pApply->GetOutput();
3693 for (i=0; i<m_pCalc->NumOutputChannels(); i++)
3694 pOut[i] = -1;
3695 return false;
3696 }
3697
3698 return true;
3699}
3700
3701/**
3702 ******************************************************************************
3703 * Name: CIccCalculatorFunc::Validate
3704 *
3705 * Purpose:
3706 *
3707 * Args:
3708 *
3709 * Return:
3710 ******************************************************************************/
3711icValidateStatus CIccCalculatorFunc::Validate(std::string sigPath, std::string &sReport,
3712 const CIccMpeCalculator* pChannelCalc/*=NULL*/,
3713 const CIccProfile *pProfile/*=NULL*/) const
3714{
3715 CIccInfo Info;
3716 std::string sSigPathName = Info.GetSigPathName(sigPath);
3717
3719 if (m_nReserved) {
3720 sReport += icMsgValidateWarning;
3721 sReport += sSigPathName;
3722 sReport += " function has non zero reserved data.\n";
3723 rv = icValidateWarning;
3724 }
3725
3726 if (GetMaxTemp()>65535) {
3727 sReport += icMsgValidateCriticalError;
3728 sReport += sSigPathName;
3729 sReport += " accesses illegal temporary channels.\n";
3731 }
3732
3733 if (!HasValidOperations(sReport)) {
3734 sReport += icMsgValidateCriticalError;
3735 sReport += sSigPathName;
3736 sReport += " function has invalid operations.\n";
3738 }
3739
3740 if (HasUnsupportedOperations(sReport, pProfile)) {
3741 sReport += icMsgValidateWarning;
3742 sReport += sSigPathName;
3743 sReport += " function has unsupported operations.\r\n";
3744 rv = icValidateWarning;
3745 }
3746
3747 if (DoesOverflowInput(pChannelCalc->NumInputChannels())) {
3748 sReport += icMsgValidateCriticalError;
3749 sReport += sSigPathName;
3750 sReport += " accesses illegal input channels.\n";
3752 }
3753
3754 if (DoesOverflowOutput(pChannelCalc->NumOutputChannels())) {
3755 sReport += icMsgValidateCriticalError;
3756 sReport += sSigPathName;
3757 sReport += " accesses illegal output channels.\n";
3759 }
3760
3761 icFuncParseStatus parseStat = DoesStackUnderflowOverflow(sReport);
3762 if (parseStat!=icFuncParseNoError) {
3763 sReport += icMsgValidateCriticalError;
3764 sReport += sSigPathName;
3765 if (parseStat==icFuncParseStackUnderflow)
3766 sReport += " causes an evaluation stack underflow.\n";
3767 else
3768 sReport += " causes an evaluation stack overflow.\n";
3770 }
3771
3772 return rv;
3773}
3774
3775/**
3776******************************************************************************
3777* Name: CIccCalculatorFunc::GetMaxTemp
3778*
3779* Purpose:
3780*
3781* Args:
3782*
3783* Return:
3784******************************************************************************/
3786{
3787 icUInt32Number i, nMaxTemp = 0;
3788
3789 for (i=0; i<m_nOps; i++) {
3791 icUInt32Number last = (icUInt32Number)(m_Op[i].data.select.v1) + (icUInt32Number)(m_Op[i].data.select.v2);
3792 if (last>nMaxTemp)
3793 nMaxTemp = last;
3794 }
3795 }
3796 return nMaxTemp;
3797}
3798
3799/**
3800******************************************************************************
3801* Name: CIccCalculatorFunc::NeedTempReset
3802*
3803* Purpose:
3804*
3805* Args:
3806*
3807* Return:
3808******************************************************************************/
3810{
3811 return SequenceNeedTempReset(m_Op, m_nOps, tempUsage, nMaxTemp);
3812}
3813
3814/**
3815******************************************************************************
3816* Name: CIccCalculatorFunc::SequenceNeedTempReset
3817*
3818* Purpose:
3819*
3820* Args:
3821*
3822* Return:
3823******************************************************************************/
3825{
3826 icUInt32Number i, j;
3827
3828 for (i=0; i<nOps; i++) {
3829 icSigCalcOp sig = op[i].sig;
3830 if (sig==icSigTempGetChanOp) {
3831 icUInt32Number p = op[i].data.select.v1;
3832 icUInt32Number n = op[i].data.select.v2+1;
3833 for (j=0; j<n; j++) {
3834 if (!tempUsage[p+j]) {
3835 return true;
3836 }
3837 }
3838 }
3839 else if (sig==icSigTempPutChanOp) {
3840 icUInt32Number p = op[i].data.select.v1;
3841 icUInt32Number n = op[i].data.select.v2+1;
3842 memset(tempUsage+p, 1, n);
3843 }
3844 else if (sig==icSigTempSaveChanOp) {
3845 icUInt32Number p = op[i].data.select.v1;
3846 icUInt32Number n = op[i].data.select.v2+1;
3847 memset(tempUsage+p, 1, n);
3848 }
3849 else if (sig==icSigIfOp) {
3850 bool rv = false;
3851 icUInt8Number *ifTemps = (icUInt8Number *)malloc(nMaxTemp);
3853 if (!ifTemps)
3854 return true;
3855
3856 memcpy(ifTemps, tempUsage, nMaxTemp);
3857
3858 p=i+2;
3859 rv = rv || SequenceNeedTempReset(&op[p], icIntMin(nOps-p, op[i].data.size), ifTemps, nMaxTemp);
3860
3861 if (i<nOps && op[i+1].sig==icSigElseOp) {
3862 icUInt8Number *elseTemps = (icUInt8Number *)malloc(nMaxTemp);
3863 if (!elseTemps) {
3864 free(ifTemps);
3865 return true;
3866 }
3867
3868 memcpy(elseTemps, tempUsage, nMaxTemp);
3869
3870 p=i+2+op[i].data.size;
3871 rv = rv || SequenceNeedTempReset(&op[p], icIntMin(nOps-p, op[i+1].data.size), elseTemps, nMaxTemp);
3872
3873 if (!rv) {
3874 for (j=0; j<nMaxTemp; j++) {
3875 tempUsage[j] |= (ifTemps[j] && elseTemps[j]);
3876 }
3877 }
3878
3879 free(elseTemps);
3880
3881 i += 1 + op[i].data.size + op[i+1].data.size;
3882 }
3883 else {
3884 i += op[i].data.size;
3885 }
3886
3887 free(ifTemps);
3888
3889 if (rv)
3890 return true;
3891 }
3892 }
3893 return false;
3894}
3895
3896
3897/**
3898******************************************************************************
3899* Name: CIccCalculatorFunc::CheckUnderflow
3900*
3901* Purpose:
3902*
3903* Args:
3904*
3905* Return:
3906******************************************************************************/
3907int CIccCalculatorFunc::CheckUnderflowOverflow(SIccCalcOp *op, icUInt32Number nOps, int nArgs, bool bCheckUnderflow, std::string &sReport) const
3908{
3909 icUInt32Number i, p;
3910 int n, nIfArgs, nElseArgs, nSelArgs, nCaseArgs;
3911
3912 for (i=0; i<nOps; i++) {
3913 n = op[i].ArgsUsed(m_pCalc);
3914
3915#if 0
3916 std::string opstr;
3917 op[i].Describe(opstr);
3918 printf("%s : %d %d\n", opstr.c_str(), n, nArgs);
3919#endif
3920
3921 if (n > nArgs) {
3922 std::string opDesc;
3923 icUInt32Number j, l;
3924 icInt32Number f;
3925
3926 op[i].Describe(opDesc, 100); // TODO - propogate nVerboseness
3927 sReport += "Stack underflow at operation \"" + opDesc + "\" in \"";
3928 f=i-2;
3929 if (f<0) f=0;
3930 l=i+2;
3931 if (l>nOps-1)
3932 l=nOps-1;
3933 for (j=(icUInt32Number)f; j<=l; j++) {
3934 op[j].Describe(opDesc, 100); // TODO - propogate nVerboseness
3935 if (j!=f)
3936 sReport += " ";
3937 sReport += opDesc;
3938 }
3939 sReport += "\"\n";
3940 return -1;
3941 }
3942
3943 nArgs -= n;
3944 nArgs += op[i].ArgsPushed(m_pCalc);
3945
3946 if (nArgs>icMaxDataStackSize)
3947 return -2;
3948
3949 if (op[i].sig == icSigIfOp) {
3950 int incI = 0;
3951 if (i+1<nOps && op[i+1].sig==icSigElseOp) {
3952 p = i+2;
3953 nIfArgs = CheckUnderflowOverflow(&op[p], icIntMin(nOps-p, op[i].data.size), nArgs, bCheckUnderflow, sReport);
3954 if (nIfArgs<0)
3955 return -1;
3956 incI =op[i].data.size;
3957
3958 p = i+2+op[i].data.size;
3959 nElseArgs = CheckUnderflowOverflow(&op[p], icIntMin(nOps-p, op[i+1].data.size), nArgs, bCheckUnderflow, sReport);
3960 if (nElseArgs<0)
3961 return -1;
3962 incI += op[i+1].data.size;
3963
3964 nArgs = bCheckUnderflow ? icIntMin(nIfArgs, nElseArgs) : icIntMax(nIfArgs, nElseArgs) ;
3965 i++;
3966 i+=incI;
3967 }
3968 else {
3969 p = i+1;
3970 nIfArgs = CheckUnderflowOverflow(&op[p], icIntMin(nOps-p, op[i].data.size), nArgs, bCheckUnderflow, sReport);
3971 if (nIfArgs<0)
3972 return -1;
3973 nArgs = bCheckUnderflow ? icIntMin(nArgs, nIfArgs) : icIntMax(nArgs, nIfArgs);
3974
3975 i+= op[i].data.size;
3976 }
3977 }
3978 else if (op[i].sig == icSigSelectOp) {
3980 nSelArgs = nArgs;
3981
3982 for (n=1; i+n<nOps; ) {
3983 if (op[i+n].sig==icSigCaseOp)
3984 n++;
3985 else if (n>1 && op[i+n].sig==icSigDefaultOp) {
3986 n++;
3987 break;
3988 }
3989 else
3990 break;
3991 }
3992 n--;
3993
3994 if (!n)
3995 return -1;
3996
3997 icUInt32Number pos = i+1 + n;
3998 for (p=0; p<n; p++) {
3999 SIccCalcOp *sop = &op[i+1+p];
4000 int len = sop->data.size;
4001 if (pos>=nOps)
4002 return -1;
4003
4004 nCaseArgs = CheckUnderflowOverflow(&op[pos], icIntMin(nOps-pos, len), nArgs, bCheckUnderflow, sReport);
4005 if (nCaseArgs<0)
4006 return -1;
4007
4008 if (!p)
4009 nSelArgs = nCaseArgs;
4010 else
4011 nSelArgs = bCheckUnderflow ? icIntMin(nSelArgs, nCaseArgs) : icIntMax(nSelArgs, nCaseArgs);
4012
4013 pos += sop->data.size;
4014 }
4015 nArgs = nSelArgs;
4016
4017 i = pos - 1;
4018 }
4019 }
4020
4021 return nArgs;
4022}
4023
4024/**
4025******************************************************************************
4026* Name: CIccCalculatorFunc::DoesStackUnderflowOverflow
4027*
4028* Purpose:
4029*
4030* Args:
4031*
4032* Return:
4033******************************************************************************/
4035{
4036 int rv = CheckUnderflowOverflow(m_Op, m_nOps, 0, true, sReport);
4037
4038 if (rv==-1)
4040 else if (rv<0)
4042
4043 rv = CheckUnderflowOverflow(m_Op, m_nOps, 0, false, sReport);
4044
4045 if (rv==-1)
4047 else if (rv<0)
4049
4050 return icFuncParseNoError;
4051}
4052
4053/**
4054******************************************************************************
4055* Name: CIccCalculatorFunc::HasValidOperations
4056*
4057* Purpose:
4058*
4059* Args:
4060*
4061* Return:
4062******************************************************************************/
4063bool CIccCalculatorFunc::HasValidOperations(std::string &sReport) const
4064{
4066 for (i=0; i<m_nOps; i++) {
4067 if (!m_Op[i].IsValidOp(m_pCalc)) {
4068 std::string opDesc;
4069 m_Op[i].Describe(opDesc, 100); // TODO - propogate nVerboseness
4070 sReport += "Invalid Operation (" + opDesc + ")\n";
4071 return false;
4072 }
4073 if (m_Op[i].sig==icSigSelectOp && i+1<m_nOps && m_Op[i+1].sig!=icSigCaseOp) {
4074 sReport += "A case operator does not follow a sel operator\n";
4075 return false;
4076 }
4077 if (i) {
4078 if (m_Op[i].sig==icSigElseOp) {
4079 if (m_Op[i-1].sig!=icSigIfOp) {
4080 sReport += "An else operator has no proceeding if operator\n";
4081 return false;
4082 }
4083 }
4084 else if (m_Op[i].sig==icSigCaseOp) {
4085 if (m_Op[i-1].sig!=icSigSelectOp && m_Op[i-1].sig!=icSigCaseOp) {
4086 sReport += "A case operator has no proceeding sel or case operator\n";
4087 return false;
4088 }
4089 }
4090 else if (m_Op[i].sig==icSigDefaultOp) {
4091 if (m_Op[i-1].sig!=icSigCaseOp) {
4092 sReport += "An dflt operator has no proceeding case operator\n";
4093 return false;
4094 }
4095 }
4096 }
4097 }
4098 return true;
4099}
4100
4101/**
4102******************************************************************************
4103* Name: CIccCalculatorFunc::HasUnsupportedOperations
4104*
4105* Purpose:
4106*
4107* Args:
4108*
4109* Return:
4110******************************************************************************/
4111bool CIccCalculatorFunc::HasUnsupportedOperations(std::string &sReport, const CIccProfile *pProfile) const
4112{
4114 if (pProfile) {
4115 icUInt32Number version = pProfile->m_Header.version;
4116
4117 icCalcOpMap map;
4118 for (i = 0; i < m_nOps; i++) {
4119 if (version < icVersionNumberV5_1 &&
4120 (m_Op[i].sig == icSigNotOp ||
4121 m_Op[i].sig == icSigNotEqualOp)) {
4122 map[m_Op[i].sig] = NULL;
4123 }
4124 }
4125 if (map.size()) {
4126 icCalcOpMap::iterator sig;
4127 sReport += "Calculator operator(s) not supported by profile version:";
4128 for (sig = map.begin(); sig != map.end(); sig++) {
4129 SIccCalcOp op;
4130 op.sig = sig->first;
4131 std::string opname;
4132 op.Describe(opname, 100);
4133 sReport += std::string(" (") + opname + ")";
4134 }
4135 sReport += "\n";
4136
4137 return true;
4138 }
4139 }
4140 return false;
4141}
4142
4143
4144/**
4145******************************************************************************
4146* Name: CIccChannelFunc::DoesOverflowInput
4147*
4148* Purpose:
4149*
4150* Args:
4151*
4152* Return:
4153******************************************************************************/
4155{
4157 for (i=0; i<m_nOps; i++) {
4158 if (m_Op[i].sig == icSigInputChanOp) {
4159 if (m_Op[i].data.select.v1+m_Op[i].data.select.v2 >= nInputChannels)
4160 return true;
4161 }
4162 }
4163 return false;
4164}
4165
4166
4167/**
4168******************************************************************************
4169* Name: CIccChannelFunc::DoesOverflowOutput
4170*
4171* Purpose:
4172*
4173* Args:
4174*
4175* Return:
4176******************************************************************************/
4178{
4180 for (i=0; i<m_nOps; i++) {
4181 if (m_Op[i].sig == icSigOutputChanOp) {
4182 if (m_Op[i].data.select.v1 + m_Op[i].data.select.v2 >= nOutputChannels)
4183 return true;
4184 }
4185 }
4186 return false;
4187}
4188
4189
4190/**
4191 ******************************************************************************
4192 * Name: CIccMpeCalculator::CIccMpeCalculator
4193 *
4194 * Purpose:
4195 *
4196 * Args:
4197 *
4198 * Return:
4199 ******************************************************************************/
4201 icUInt16Number nOutputChannels /*=0*/)
4202{
4203 m_nReserved = 0;
4204 m_nInputChannels = nInputChannels;
4205 m_nOutputChannels = nOutputChannels;
4206 m_nTempChannels = 0;
4207 m_bNeedTempReset = true;
4208 m_nSubElem = 0;
4209 m_SubElem = NULL;
4210 m_calcFunc = NULL;
4211 m_pCmmEnvVarLookup = NULL;
4212}
4213
4214/**
4215 ******************************************************************************
4216 * Name: CIccMpeCalculator::CIccMpeCalculator
4217 *
4218 * Purpose:
4219 *
4220 * Args:
4221 *
4222 * Return:
4223 ******************************************************************************/
4225{
4226 m_nReserved = channelGen.m_nReserved;
4227
4230 m_nTempChannels = channelGen.m_nTempChannels;
4231
4233
4234 m_nSubElem = channelGen.m_nSubElem;
4236
4238
4239 icCalculatorFuncPtr ptr = channelGen.m_calcFunc;
4240
4241 if (ptr)
4242 m_calcFunc = ptr->NewCopy();
4243 else
4244 m_calcFunc = NULL;
4245
4246 if (channelGen.m_nSubElem) {
4248
4250 if (m_SubElem) {
4251 for (i=0; i<m_nSubElem; i++) {
4252 if (channelGen.m_SubElem[i])
4253 m_SubElem[i] = channelGen.m_SubElem[i]->NewCopy();
4254 }
4255 }
4256 else {
4257 m_nSubElem = 0;
4258 m_SubElem = NULL;
4259 }
4260 }
4261 else {
4262 m_nSubElem = 0;
4263 m_SubElem = NULL;
4264 }
4265}
4266
4267/**
4268 ******************************************************************************
4269 * Name: &CIccMpeCalculator::operator=
4270 *
4271 * Purpose:
4272 *
4273 * Args:
4274 *
4275 * Return:
4276 ******************************************************************************/
4278{
4279 m_nReserved = channelGen.m_nReserved;
4280
4281 SetSize(0,0);
4282
4285
4287
4288 icCalculatorFuncPtr ptr = channelGen.m_calcFunc;
4289
4290 if (ptr)
4291 m_calcFunc = ptr->NewCopy();
4292 else
4293 m_calcFunc = NULL;
4294
4295 if (channelGen.m_nSubElem) {
4297
4299 if (m_SubElem) {
4300 for (i=0; i<m_nSubElem; i++) {
4301 if (channelGen.m_SubElem[i])
4302 m_SubElem[i] = channelGen.m_SubElem[i]->NewCopy();
4303 }
4304 }
4305 else {
4306 m_nSubElem = 0;
4307 m_SubElem = NULL;
4308 }
4309 }
4310 else {
4311 m_nSubElem = 0;
4312 m_SubElem = NULL;
4313 }
4314
4315 return *this;
4316}
4317
4318/**
4319 ******************************************************************************
4320 * Name: CIccMpeCalculator::~CIccMpeCalculator
4321 *
4322 * Purpose:
4323 *
4324 * Args:
4325 *
4326 * Return:
4327 ******************************************************************************/
4332
4333/**
4334 ******************************************************************************
4335 * Name: CIccMpeCalculator::SetSize
4336 *
4337 * Purpose:
4338 *
4339 * Args:
4340 *
4341 * Return:
4342 ******************************************************************************/
4343void CIccMpeCalculator::SetSize(icUInt16Number nInputChannels, icUInt16Number nOutputChannels)
4344{
4345 if (m_calcFunc) {
4346 delete m_calcFunc;
4347 m_calcFunc = NULL;
4348 }
4350
4351 if (m_SubElem) {
4352 for (i=0; i<m_nSubElem; i++) {
4353 if (m_SubElem[i])
4354 delete m_SubElem[i];
4355 }
4356 free(m_SubElem);
4357 m_SubElem = NULL;
4358 m_nSubElem = 0;
4359 }
4360
4361 m_nInputChannels = nInputChannels;
4362 m_nOutputChannels = nOutputChannels;
4363}
4364
4365/**
4366 ******************************************************************************
4367 * Name: CIccMpeCalculator::SetCalcFunc
4368 *
4369 * Purpose:
4370 *
4371 * Args:
4372 *
4373 * Return:
4374 ******************************************************************************/
4376{
4377 if (m_calcFunc) {
4378 delete m_calcFunc;
4379 }
4380 m_calcFunc = newChannelFunc;
4381
4382 return icFuncParseNoError;
4383}
4384
4385/**
4386******************************************************************************
4387* Name: CIccMpeCalculator::SetCalcFunc
4388*
4389* Purpose:
4390*
4391* Args:
4392*
4393* Return:
4394******************************************************************************/
4395icFuncParseStatus CIccMpeCalculator::SetCalcFunc(const char *szFuncDef, std::string &sReport)
4396{
4397
4398 if (m_calcFunc) {
4399 delete m_calcFunc;
4400 m_calcFunc = NULL;
4401 }
4402
4403 CIccCalculatorFunc *pFunc = new CIccCalculatorFunc(this);
4404 icFuncParseStatus rv = pFunc->SetFunction(szFuncDef, sReport);
4405
4406 if (rv!=icFuncParseNoError) {
4407 delete pFunc;
4408 m_calcFunc = NULL;
4409
4410 return rv;
4411 }
4412
4413 m_calcFunc = pFunc;
4414
4415 return rv;
4416}
4417
4418
4419/**
4420 ******************************************************************************
4421 * Name: CIccMpeCalculator::Describe
4422 *
4423 * Purpose:
4424 *
4425 * Args:
4426 *
4427 * Return:
4428 ******************************************************************************/
4429void CIccMpeCalculator::Describe(std::string &sDescription, int nVerboseness)
4430{
4431 if (m_calcFunc) {
4432 icChar buf[81];
4433
4434 sprintf(buf, "BEGIN_CALC_ELEMENT %u %u\n", m_nInputChannels, m_nOutputChannels);
4435 sDescription += buf;
4436
4437 if (m_nSubElem && m_SubElem) {
4439 for (i=0; i<m_nSubElem; i++) {
4440 sprintf(buf, "BEGIN_SUBCALCELEM %u\n", i);
4441 sDescription += buf;
4442 m_SubElem[i]->Describe(sDescription, nVerboseness);
4443 sprintf(buf, "END_SUBCALCELEM %u\n\n", i);
4444 sDescription += buf;
4445 }
4446 }
4447
4448 if (m_calcFunc) {
4449 sDescription += "BEGIN_CALC_FUNCTION\n";
4450 m_calcFunc->Describe(sDescription, nVerboseness);
4451 sDescription += "END_CALC_FUNCTION\n";
4452 }
4453
4454 sprintf(buf, "END_CALC_ELEMENT\n");
4455 sDescription += buf;
4456
4457 }
4458}
4459
4460typedef std::map<icUInt32Number, CIccCalculatorFunc*> icChannelFuncOffsetMap;
4461typedef std::map<CIccCalculatorFunc*, icPositionNumber> icChannelFuncPtrMap;
4462
4463/**
4464 ******************************************************************************
4465 * Name: CIccMpeCalculator::Read
4466 *
4467 * Purpose:
4468 *
4469 * Args:
4470 *
4471 * Return:
4472 ******************************************************************************/
4474{
4476
4477 icUInt32Number startPos = pIO->Tell();
4478
4479 icUInt32Number headerSize = sizeof(icTagTypeSignature) +
4480 sizeof(icUInt32Number) +
4481 sizeof(icUInt16Number) +
4482 sizeof(icUInt16Number) +
4483 sizeof(icUInt16Number) +
4484 sizeof(icUInt16Number) +
4485 sizeof(icUInt16Number) +
4486 sizeof(icUInt16Number);
4487
4488 if (headerSize > size)
4489 return false;
4490
4491 if (!pIO) {
4492 return false;
4493 }
4494
4495 icUInt16Number nInputChannels, nOutputChannels;
4496
4497 if (!pIO->Read32(&sig))
4498 return false;
4499
4500 if (!pIO->Read32(&m_nReserved))
4501 return false;
4502
4503 if (!pIO->Read16(&nInputChannels))
4504 return false;
4505
4506 if (!pIO->Read16(&nOutputChannels))
4507 return false;
4508
4509 SetSize(nInputChannels, nOutputChannels);
4510
4511 icUInt32Number nSubElem;
4512
4513 if (!pIO->Read32(&nSubElem))
4514 return false;
4515
4516 icUInt32Number nPos = nSubElem + 1;
4517
4518 if (headerSize + (icUInt64Number)nPos*sizeof(icPositionNumber) > size) {
4519 return false;
4520 }
4521
4522 icPositionNumber *pos, *posvals = (icPositionNumber*)malloc(nPos*sizeof(icPositionNumber));
4523 if (!posvals) {
4524 return false;
4525 }
4526
4527 icUInt32Number n = nPos * (sizeof(icPositionNumber)/sizeof(icUInt32Number));
4528 if (pIO->Read32(posvals, n)!=n) {
4529 free(posvals);
4530 return false;
4531 }
4532
4533 pos = &posvals[1];
4534 if (nSubElem) {
4535 icElemTypeSignature elemSig;
4536
4537 SetSubElem(nSubElem-1, NULL); //Initialize array
4538
4539 for (n=0; n<nSubElem; n++) {
4540 if (pos->offset + pos->size > size) {
4541 free(posvals);
4542 return false;
4543 }
4544 pIO->Seek(startPos + pos->offset, icSeekSet);
4545
4546 if (!pIO->Read32(&elemSig)) {
4547 free(posvals);
4548 return false;
4549 }
4550
4552 if (!pElem) {
4553 free(posvals);
4554 return false;
4555 }
4556
4557 pIO->Seek(startPos + pos->offset, icSeekSet);
4558 if (!pElem->Read(pos->size, pIO)) {
4559 free(posvals);
4560 return false;
4561 }
4563 pos++;
4564 }
4565 }
4566
4567 m_calcFunc = new CIccCalculatorFunc(this);
4568 pos = posvals;
4569
4570 if (!m_calcFunc || pos->offset + pos->size > size) {
4571 free(posvals);
4572 return false;
4573 }
4574
4575 pIO->Seek(startPos + pos->offset, icSeekSet);
4576
4577 if (!m_calcFunc->Read(pos->size, pIO)) {
4578 return false;
4579 }
4580 free(posvals);
4581
4582 pIO->Seek(startPos + size, icSeekSet);
4583
4584 return true;
4585}
4586
4587/**
4588 ******************************************************************************
4589 * Name: CIccMpeCalculator::Write
4590 *
4591 * Purpose:
4592 *
4593 * Args:
4594 *
4595 * Return:
4596 ******************************************************************************/
4598{
4600
4601 if (!pIO)
4602 return false;
4603
4604 icUInt32Number elemStart = pIO->Tell();
4605
4606 if (!pIO->Write32(&sig))
4607 return false;
4608
4609 if (!pIO->Write32(&m_nReserved))
4610 return false;
4611
4612 if (!pIO->Write16(&m_nInputChannels))
4613 return false;
4614
4615 if (!pIO->Write16(&m_nOutputChannels))
4616 return false;
4617
4618 if (!pIO->Write32(&m_nSubElem))
4619 return false;
4620
4621 icUInt32Number nPos = m_nSubElem + 1;
4622
4623 icPositionNumber *pos, *posvals = (icPositionNumber*)calloc(nPos, sizeof(icPositionNumber));
4624 if (!posvals) {
4625 return false;
4626 }
4627 icUInt32Number nPositionStart = pIO->Tell();
4628
4629 icUInt32Number n, np = nPos * (sizeof(icPositionNumber)/sizeof(icUInt32Number));
4630 if (pIO->Write32(posvals, np)!=np) {
4631 free(posvals);
4632 return false;
4633 }
4634
4635 if (m_calcFunc) {
4636 posvals[0].offset = pIO->Tell()-elemStart;
4637 if (!m_calcFunc->Write(pIO)) {
4638 free(posvals);
4639 return false;
4640 }
4641 posvals[0].size = pIO->Tell()-elemStart - posvals[nPos-1].offset;
4642 pIO->Align32();
4643 }
4644
4645 pos = &posvals[1];
4646
4647 if (m_nSubElem) {
4648 for(n=0; n<m_nSubElem; n++) {
4649 if (m_SubElem[n]) {
4650 pos->offset = pIO->Tell()-elemStart;
4651 if (!m_SubElem[n]->Write(pIO)) {
4652 free(posvals);
4653 return false;
4654 }
4655 pos->size = pIO->Tell()-elemStart - pos->offset;
4656 pIO->Align32();
4657 }
4658 pos++;
4659 }
4660 }
4661 icUInt32Number endPos = pIO->Tell();
4662
4663 pIO->Seek(nPositionStart, icSeekSet);
4664
4665 if (pIO->Write32(posvals, np)!=np) {
4666 free(posvals);
4667 return false;
4668 }
4669 free(posvals);
4670
4671 pIO->Seek(endPos, icSeekSet);
4672
4673 return true;
4674}
4675
4676/**
4677 ******************************************************************************
4678 * Name: CIccMpeCalculator::Begin
4679 *
4680 * Purpose:
4681 *
4682 * Args:
4683 *
4684 * Return:
4685 ******************************************************************************/
4687{
4688 if (!m_calcFunc)
4689 return false;
4690
4692
4694
4695 if (m_nTempChannels>65536)
4696 return false;
4697
4698 if (m_nTempChannels) {
4699 icUInt8Number *tempUsage = (icUInt8Number *)calloc(m_nTempChannels, sizeof(icUInt8Number));
4700 if (tempUsage) {
4702 free(tempUsage);
4703 }
4704 else
4705 m_bNeedTempReset = true;
4706 }
4707 else {
4708 m_bNeedTempReset = false;
4709 }
4710
4711 if (!m_calcFunc->Begin(this, pMPE))
4712 return false;
4713
4715 for (n=0; n<m_nSubElem; n++) {
4716 if (m_SubElem[n] && !m_SubElem[n]->Begin(nInterp, pMPE))
4717 return false;
4718 }
4719
4720 return true;
4721}
4722
4723/**
4724******************************************************************************
4725* Name: CIccMpeCalculator::Begin
4726*
4727* Purpose:
4728*
4729* Args:
4730*
4731* Return:
4732******************************************************************************/
4734{
4735 CIccApplyTagMpe *pApplyTagEx = (CIccApplyTagMpe*)pApplyTag;
4736
4738
4739 if (!pApply)
4740 return NULL;
4741
4742 if (m_nTempChannels) {
4743 pApply->m_temp = (icFloatNumber*)malloc(m_nTempChannels*sizeof(icFloatNumber));
4744 }
4745 pApply->m_stack = new CIccFloatVector;
4746 pApply->m_scratch = new CIccFloatVector;
4747 pApply->m_scratch->resize(50);
4749
4751
4752 pApply->m_nSubElem = m_nSubElem;
4753 if(m_nSubElem) {
4754 pApply->m_SubElem = (CIccSubCalcApply **)calloc(m_nSubElem, sizeof(CIccSubCalcApply));
4755
4756 if (m_SubElem) {
4757 for (i=0; i<m_nSubElem; i++) {
4758 if (m_SubElem[i]) {
4759 pApply->m_SubElem[i] = new CIccSubCalcApply(m_SubElem[i]->GetNewApply(pApplyTag));
4760 }
4761 }
4762 }
4763 }
4764 else {
4765 m_SubElem=NULL;
4766 }
4767 return pApply;
4768}
4769
4770
4771/**
4772 ******************************************************************************
4773 * Name: CIccMpeCalculator::Apply
4774 *
4775 * Purpose:
4776 *
4777 * Args:
4778 *
4779 * Return:
4780 ******************************************************************************/
4781void CIccMpeCalculator::Apply(CIccApplyMpe *pApply, icFloatNumber *pDestPixel, const icFloatNumber *pSrcPixel) const
4782{
4783 CIccApplyMpeCalculator *pApplyCalc = (CIccApplyMpeCalculator*)pApply;
4784 icFloatNumber *pSrcTemp = pApplyCalc->m_temp;
4785 bool rv;
4786
4787 pApplyCalc->m_temp = pSrcTemp;
4788 pApplyCalc->m_input = pSrcPixel;
4789 pApplyCalc->m_output = pDestPixel;
4790
4791 if (m_bNeedTempReset) {
4792 memset(pSrcTemp, 0, m_nTempChannels*sizeof(icFloatNumber));
4793 }
4794
4795 if (g_pDebugger) {
4797 rv = m_calcFunc->Apply(pApplyCalc);
4798 if (!rv)
4799 g_pDebugger->Error("Calc Function Apply Terminated with an error!");
4800
4802 }
4803 else {
4804 rv = m_calcFunc->Apply(pApplyCalc);
4805 }
4806}
4807
4808/**
4809 ******************************************************************************
4810 * Name: CIccMpeCalculator::Validate
4811 *
4812 * Purpose:
4813 *
4814 * Args:
4815 *
4816 * Return:
4817 ******************************************************************************/
4818icValidateStatus CIccMpeCalculator::Validate(std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement* pMPE/*=NULL*/, const CIccProfile *pProfile/*=NULL*/) const
4819{
4820 std::string mpeSigPath = sigPath + icGetSigPath(GetType());
4821 icValidateStatus rv = CIccMultiProcessElement::Validate(sigPath, sReport, pMPE, pProfile);
4822
4824
4825 if (m_SubElem) {
4826 for (i=0; i<m_nSubElem; i++) {
4827 if (m_SubElem[i])
4828 rv = icMaxStatus(rv, m_SubElem[i]->Validate(mpeSigPath, sReport, pMPE, pProfile));
4829 }
4830 }
4831
4832 bool empty=false;
4833 if (m_calcFunc) {
4834 rv = icMaxStatus(rv, m_calcFunc->Validate(mpeSigPath, sReport, this, pProfile));
4835 }
4836 else
4837 empty = true;
4838
4839 if (empty) {
4840 CIccInfo Info;
4841 std::string sSigPathName = Info.GetSigPathName(sigPath);
4842
4843 sReport += icMsgValidateCriticalError;
4844 sReport += sSigPathName;
4845 sReport += " - Has an Empty Calculator Functions!\n";
4847 }
4848
4849 return rv;
4850}
4851
4852
4853/**
4854 ******************************************************************************
4855 * Name: CIccMpeCalculator::IsLateBinding
4856 *
4857 * Purpose:
4858 *
4859 * Args:
4860 *
4861 * Return:
4862 ******************************************************************************/
4864{
4866
4867 if (m_SubElem) {
4868 for (i=0; i<m_nSubElem; i++) {
4869 if (m_SubElem[i] && m_SubElem[i]->IsLateBinding())
4870 return true;
4871 }
4872 }
4873
4874 return false;
4875}
4876
4877/**
4878 ******************************************************************************
4879 * Name: CIccMpeCalculator::IsLateBindingReflectance
4880 *
4881 * Purpose:
4882 *
4883 * Args:
4884 *
4885 * Return:
4886 ******************************************************************************/
4888{
4890
4891 if (m_SubElem) {
4892 for (i=0; i<m_nSubElem; i++) {
4894 return true;
4895 }
4896 }
4897
4898 return false;
4899}
4900
4901
4902/**
4903******************************************************************************
4904* Name: CIccMpeCalculator::GetSubApply
4905*
4906* Purpose:
4907*
4908* Args:
4909*
4910* Return:
4911******************************************************************************/
4913{
4914 if (m_SubElem && index<m_nSubElem) {
4915 CIccMultiProcessElement *pMpe = m_SubElem[index];
4916 if (opsig==icSigApplyElemOp)
4917 return pMpe;
4918
4919 if ((opsig==icSigApplyCurvesOp && pMpe->GetType() != icSigCurveSetElemType) ||
4920 (opsig==icSigApplyMatrixOp && pMpe->GetType() != icSigMatrixElemType) ||
4921 (opsig==icSigApplyCLutOp && !(pMpe->GetType() == icSigCLutElemType || pMpe->GetType() == icSigExtCLutElemType)) ||
4922 (opsig==icSigApplyTintOp && pMpe->GetType() != icSigTintArrayElemType) ||
4923 (opsig==icSigApplyToJabOp && pMpe->GetType() != icSigXYZToJabElemType) ||
4924 (opsig==icSigApplyFromJabOp && pMpe->GetType() != icSigJabToXYZElemType) ||
4925 (opsig==icSigApplyCalcOp && pMpe->GetType() != icSigCalculatorElemType))
4926 return NULL;
4927
4928 return pMpe;
4929 }
4930
4931 return NULL;
4932}
4933
4934
4935/**
4936******************************************************************************
4937* Name: CIccMpeCalculator::GetSubApply
4938*
4939* Purpose:
4940*
4941* Args:
4942*
4943* Return:
4944******************************************************************************/
4946{
4947 bool rv = true;
4948
4949 if (idx+1>count) {
4950 if (*pArray) {
4951 *pArray = (CIccMultiProcessElement**)icRealloc(*pArray, (idx+1)*sizeof(CIccMultiProcessElement*));
4952
4953 if (!(*pArray))
4954 return false;
4955
4957 for (i=count; i<=idx; i++) {
4958 (*pArray)[i] = NULL;
4959 }
4960 }
4961 else {
4962 *pArray = (CIccMultiProcessElement**)calloc(idx+1, sizeof(CIccMultiProcessElement*));
4963
4964 if (!(*pArray))
4965 return false;
4966 }
4967 count = idx+1;
4968 }
4969
4970 if ((*pArray)[idx]) {
4971 delete (*pArray)[idx];
4972 rv = false;
4973 }
4974
4975 (*pArray)[idx] = pElem;
4976
4977 return rv;
4978}
4979
4980/**
4981******************************************************************************
4982* Name: CIccMpeCalculator::CIccApplyMpeCalculator
4983*
4984* Purpose:
4985*
4986* Args:
4987*
4988* Return:
4989******************************************************************************/
4991{
4992 m_temp = NULL;
4993
4994 m_input = NULL;
4995 m_output = NULL;
4996
4997 m_stack = NULL;
4998 m_scratch = NULL;
4999
5000 m_nSubElem = 0;
5001 m_SubElem = NULL;
5002
5003}
5004
5005
5006/**
5007******************************************************************************
5008* Name: CIccMpeCalculator::~CIccApplyMpeCalculator
5009*
5010* Purpose:
5011*
5012* Args:
5013*
5014* Return:
5015******************************************************************************/
5017{
5018 if (m_stack) {
5019 delete m_stack;
5020 }
5021 if (m_scratch) {
5022 delete m_scratch;
5023 }
5024
5025 if (m_temp) {
5026 free(m_temp);
5027 }
5028
5030
5031 if (m_SubElem) {
5032 for (i=0; i<m_nSubElem; i++) {
5033 if (m_SubElem[i])
5034 delete m_SubElem[i];
5035 }
5036 }
5037}
5038
5039/**
5040******************************************************************************
5041* Name: CIccApplyMpeCalculator::GetSubApply
5042*
5043* Purpose:
5044*
5045* Args:
5046*
5047* Return:
5048******************************************************************************/
5050{
5051 if (m_SubElem && index<m_nSubElem)
5052 return m_SubElem[index];
5053
5054 return NULL;
5055}
5056
5057
5058/**
5059******************************************************************************
5060* Name: CIccApplyMpeCalculator::GetSubApply
5061*
5062* Purpose:
5063*
5064* Args:
5065*
5066* Return:
5067******************************************************************************/
5069{
5070 if (!m_pCmmEnvVarLookup) {
5071 val = 0;
5072 return false;
5073 }
5074 return m_pCmmEnvVarLookup->GetEnvVar(sigEnv, val);
5075}
5076
5077
5078
icArraySignature sig
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
Definition IccDefs.h:100
char icChar
Definition IccDefs.h:109
icValidateStatus
Definition IccDefs.h:118
@ icValidateOK
Definition IccDefs.h:119
@ icValidateWarning
Definition IccDefs.h:120
@ icValidateCriticalError
Definition IccDefs.h:122
File: IccIO.h.
@ icSeekSet
Definition IccIO.h:83
File: IccMpeBasic.h.
std::map< icUInt32Number, CIccCalculatorFunc * > icChannelFuncOffsetMap
#define OsPopArgs(X, N)
#define OsPushArg(X)
std::map< icSigCalcOp, IIccOpDef * > icCalcOpMap
#define OsPopArg(X)
std::map< CIccCalculatorFunc *, icPositionNumber > icChannelFuncPtrMap
#define OsShrinkArgs(N)
static void AppendOpList(CIccCalcOpList &toList, const CIccCalcOpList &fromList)
static CIccConsoleDebugger g_ConsoleDebugger
#define OsPushArgs(X, N)
#define OsExtendArgs(N)
static IIccCalcDebugger * g_pDebugger
File: IccMpeCalc.h.
icSigCalcOp
Definition IccMpeCalc.h:110
@ icSigPiOp
Definition IccMpeCalc.h:113
@ icSigCubeOp
Definition IccMpeCalc.h:169
@ icSigEnvVarOp
Definition IccMpeCalc.h:126
@ icSigArcTangentOp
Definition IccMpeCalc.h:185
@ icSigSquareRootOp
Definition IccMpeCalc.h:168
@ icSigFloorOp
Definition IccMpeCalc.h:173
@ icSigApplyFromJabOp
Definition IccMpeCalc.h:134
@ icSigOrOp
Definition IccMpeCalc.h:152
@ icSigScalarAddOp
Definition IccMpeCalc.h:163
@ icSigMinimumOp
Definition IccMpeCalc.h:149
@ icSigApplyCLutOp
Definition IccMpeCalc.h:131
@ icSigSineOp
Definition IccMpeCalc.h:180
@ icSigSumOp
Definition IccMpeCalc.h:147
@ icSigSignOp
Definition IccMpeCalc.h:171
@ icSigProductOp
Definition IccMpeCalc.h:148
@ icSigPolarToCartesianOp
Definition IccMpeCalc.h:188
@ icSigTempPutChanOp
Definition IccMpeCalc.h:122
@ icSigCosineOp
Definition IccMpeCalc.h:181
@ icSigNaturalLogOp
Definition IccMpeCalc.h:179
@ icSigNegInfinityOp
Definition IccMpeCalc.h:115
@ icSigLessThanOp
Definition IccMpeCalc.h:190
@ icSigAndOp
Definition IccMpeCalc.h:151
@ icSigSquareOp
Definition IccMpeCalc.h:167
@ icSigNotOp
Definition IccMpeCalc.h:197
@ icSigGreaterThanOp
Definition IccMpeCalc.h:196
@ icSigRotateRightOp
Definition IccMpeCalc.h:141
@ icSigModulusOp
Definition IccMpeCalc.h:160
@ icSigNegOp
Definition IccMpeCalc.h:155
@ icSigGammaOp
Definition IccMpeCalc.h:162
@ icSigNotaNumberOp
Definition IccMpeCalc.h:116
@ icSigApplyCurvesOp
Definition IccMpeCalc.h:129
@ icSigFlipOp
Definition IccMpeCalc.h:143
@ icSigArcSineOp
Definition IccMpeCalc.h:183
@ icSigEqualOp
Definition IccMpeCalc.h:192
@ icSigNearOp
Definition IccMpeCalc.h:194
@ icSigDataOp
Definition IccMpeCalc.h:112
@ icSigPowOp
Definition IccMpeCalc.h:161
@ icSigVectorMaximumOp
Definition IccMpeCalc.h:201
@ icSigScalarSubtractOp
Definition IccMpeCalc.h:164
@ icSigSelectOp
Definition IccMpeCalc.h:214
@ icSigCartesianToPolarOp
Definition IccMpeCalc.h:187
@ icSigArcCosineOp
Definition IccMpeCalc.h:184
@ icSigAddOp
Definition IccMpeCalc.h:156
@ icSigRealNumberOp
Definition IccMpeCalc.h:189
@ icSigRoundOp
Definition IccMpeCalc.h:176
@ icSigApplyElemOp
Definition IccMpeCalc.h:136
@ icSigAbsoluteValOp
Definition IccMpeCalc.h:172
@ icSigOutputChanOp
Definition IccMpeCalc.h:120
@ icSigLessThanEqualOp
Definition IccMpeCalc.h:191
@ icSigDefaultOp
Definition IccMpeCalc.h:216
@ icSigCopyOp
Definition IccMpeCalc.h:139
@ icSigSubtractOp
Definition IccMpeCalc.h:157
@ icSigCubeRootOp
Definition IccMpeCalc.h:170
@ icSigPopOp
Definition IccMpeCalc.h:144
@ icSigLogrithmOp
Definition IccMpeCalc.h:178
@ icSigScalarDivideOp
Definition IccMpeCalc.h:166
@ icSigApplyToJabOp
Definition IccMpeCalc.h:133
@ icSigDivideOp
Definition IccMpeCalc.h:159
@ icSigTangentOp
Definition IccMpeCalc.h:182
@ icSigApplyTintOp
Definition IccMpeCalc.h:132
@ icSigTruncateOp
Definition IccMpeCalc.h:175
@ icSigRotateLeftOp
Definition IccMpeCalc.h:140
@ icSigApplyCalcOp
Definition IccMpeCalc.h:135
@ icSigIfOp
Definition IccMpeCalc.h:210
@ icSigApplyMatrixOp
Definition IccMpeCalc.h:130
@ icSigScalarMultiplyOp
Definition IccMpeCalc.h:165
@ icSigPositionDupOp
Definition IccMpeCalc.h:142
@ icSigArcTan2Op
Definition IccMpeCalc.h:186
@ icSigGreaterThanEqualOp
Definition IccMpeCalc.h:195
@ icSigToXYZOp
Definition IccMpeCalc.h:199
@ icSigVectorOrOp
Definition IccMpeCalc.h:203
@ icSigSolveOp
Definition IccMpeCalc.h:206
@ icSigToLabOp
Definition IccMpeCalc.h:198
@ icSigInputChanOp
Definition IccMpeCalc.h:119
@ icSigCaseOp
Definition IccMpeCalc.h:215
@ icSigVectorMinimumOp
Definition IccMpeCalc.h:200
@ icSigExpOp
Definition IccMpeCalc.h:177
@ icSigTransposeOp
Definition IccMpeCalc.h:207
@ icSigNotEqualOp
Definition IccMpeCalc.h:193
@ icSigVectorAndOp
Definition IccMpeCalc.h:202
@ icSigPosInfinityOp
Definition IccMpeCalc.h:114
@ icSigTempSaveChanOp
Definition IccMpeCalc.h:123
@ icSigMultiplyOp
Definition IccMpeCalc.h:158
@ icSigTempGetChanOp
Definition IccMpeCalc.h:121
@ icSigMaximumOp
Definition IccMpeCalc.h:150
@ icSigCeilingOp
Definition IccMpeCalc.h:174
@ icSigElseOp
Definition IccMpeCalc.h:211
std::list< SIccCalcOp > CIccCalcOpList
Definition IccMpeCalc.h:259
#define icMaxDataStackSize
Definition IccMpeCalc.h:95
CIccCalcOpList * CIccCalcOpListPtr
Definition IccMpeCalc.h:260
#define icSigEndBlockOp
Definition IccMpeCalc.h:319
icChannelFuncSignature
Definition IccMpeCalc.h:102
icFuncParseStatus
Definition IccMpeCalc.h:308
@ icFuncParseStackOverflow
Definition IccMpeCalc.h:313
@ icFuncParseSyntaxError
Definition IccMpeCalc.h:310
@ icFuncParseNoError
Definition IccMpeCalc.h:309
@ icFuncParseStackUnderflow
Definition IccMpeCalc.h:312
@ icFuncParseEmptyFunction
Definition IccMpeCalc.h:315
@ icFuncParseInvalidOperation
Definition IccMpeCalc.h:311
#define icCalcDebuggerNone
Definition IccMpeCalc.h:559
std::vector< icFloatNumber > CIccFloatVector
Definition IccMpeCalc.h:263
std::list< CIccCalcOpListPtr > CIccCalcOpListPtrList
Definition IccMpeCalc.h:261
#define icSigBadOp
Definition IccMpeCalc.h:320
#define icCalcDebuggerConsole
Definition IccMpeCalc.h:560
#define icSigBeginBlockOp
Definition IccMpeCalc.h:318
#define ICC_CBRTF(v)
IIccMatrixSolver * g_pIccMatrixSolver
Global Variable: g_pIccMatrixSolver.
Definition IccSolve.cpp:186
icElemInterp
Definition IccTagMPE.h:93
icValidateStatus icMaxStatus(icValidateStatus s1, icValidateStatus s2)
Name: icMaxStatus.
Definition IccUtil.cpp:244
std::string icGetSigPath(icUInt32Number nSig)
Definition IccUtil.cpp:1191
const char * icMsgValidateWarning
Definition IccUtil.cpp:90
icFloatNumber icCubeth(icFloatNumber v)
Definition IccUtil.cpp:805
void * icRealloc(void *ptr, size_t size)
Name: icRealloc.
Definition IccUtil.cpp:111
icFloatNumber icICubeth(icFloatNumber v)
Definition IccUtil.cpp:815
icFloatNumber icMin(icFloatNumber v1, icFloatNumber v2)
Definition IccUtil.cpp:898
icUInt32Number icIntMax(icUInt32Number v1, icUInt32Number v2)
Definition IccUtil.cpp:913
icFloatNumber icMax(icFloatNumber v1, icFloatNumber v2)
Definition IccUtil.cpp:903
icUInt32Number icIntMin(icUInt32Number v1, icUInt32Number v2)
Definition IccUtil.cpp:908
const char * icMsgValidateCriticalError
Definition IccUtil.cpp:92
const icChar * icGetSigStr(icChar *pBuf, icUInt32Number nSig)
Definition IccUtil.cpp:1056
const icChar * icGetSig(icChar *pBuf, icUInt32Number nSig, bool bGetHexVal)
Definition IccUtil.cpp:1028
File: IccUtil.h.
#define icPosInfinity
Definition IccUtil.h:86
#define icNotANumber
Definition IccUtil.h:88
#define icNegInfinity
Definition IccUtil.h:87
#define icPiNum
Definition IccUtil.h:85
icTagTypeSignature
unsigned int icUInt32Number
Class: CIccApplyMpeCalculator.
Definition IccMpeCalc.h:505
CIccApplyMpeCalculator(CIccMultiProcessElement *pElem)
Name: CIccMpeCalculator::CIccApplyMpeCalculator.
CIccFloatVector * GetStack()
Definition IccMpeCalc.h:517
icFloatNumber * m_output
Definition IccMpeCalc.h:533
virtual ~CIccApplyMpeCalculator()
Name: CIccMpeCalculator::~CIccApplyMpeCalculator.
icUInt32Number m_nSubElem
Definition IccMpeCalc.h:537
CIccFloatVector * GetScratch()
Definition IccMpeCalc.h:519
icFloatNumber * GetTemp()
Definition IccMpeCalc.h:515
const icFloatNumber * m_input
Definition IccMpeCalc.h:532
CIccSubCalcApply ** m_SubElem
Definition IccMpeCalc.h:538
const icFloatNumber * GetInput()
Definition IccMpeCalc.h:513
CIccSubCalcApply * GetApply(icUInt16Number index)
Name: CIccApplyMpeCalculator::GetSubApply.
icFloatNumber * m_temp
Definition IccMpeCalc.h:534
icFloatNumber * GetOutput()
Definition IccMpeCalc.h:514
bool GetEnvVar(icSigCmmEnvVar sigEnv, icFloatNumber &val)
Name: CIccApplyMpeCalculator::GetSubApply.
CIccFloatVector * m_stack
Definition IccMpeCalc.h:528
CIccFloatVector * m_scratch
Definition IccMpeCalc.h:529
IIccCmmEnvVarLookup * m_pCmmEnvVarLookup
Definition IccMpeCalc.h:540
Class: CIccApplyMpe.
Definition IccTagMPE.h:203
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:321
static CIccCalcOpMgr * m_inst
static IIccOpDef * getOpDef(icSigCalcOp opSig)
static CIccCalcOpMgr * GetInstance()
icCalcOpMap m_map
CIccOpDefInvalid m_invalid
Class: CIccCalculatorFunc.
Definition IccMpeCalc.h:364
CIccCalculatorFunc & operator=(const CIccCalculatorFunc &ICF)
Name: &CIccCalculatorFunc::operator=.
void InsertBlanks(std::string &sDescription, int nBlanks)
void DescribeSequence(std::string &sDescription, icUInt32Number nOps, SIccCalcOp *op, int nBlanks)
bool DoesOverflowInput(icUInt16Number nInputChannels) const
Name: CIccChannelFunc::DoesOverflowInput.
virtual bool Read(icUInt32Number size, CIccIO *pIO)
Name: CIccCalculatorFunc::Read.
virtual icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccMpeCalculator *pChannelCalc=NULL, const CIccProfile *pProfile=NULL) const
Name: CIccCalculatorFunc::Validate.
icUInt32Number m_nReserved
Definition IccMpeCalc.h:414
icFuncParseStatus SetFunction(const char *szFuncDef, std::string &sReport)
Name: CIccCalculatorFunc::SetFunction.
virtual ~CIccCalculatorFunc()
Name: CIccCalculatorFunc::~CIccChannelFunc.
virtual void Describe(std::string &sDescription, int nVerboseness=0, int nBlanks=0)
Name: CIccCalculatorFunc::Describe.
CIccMpeCalculator * m_pCalc
Definition IccMpeCalc.h:412
bool ApplySequence(CIccApplyMpeCalculator *pApply, icUInt32Number nOps, SIccCalcOp *op) const
Name: CIccCalculatorFunc::ApplySequence.
SIccCalcOp * m_Op
Definition IccMpeCalc.h:417
bool HasValidOperations(std::string &sReport) const
Name: CIccCalculatorFunc::HasValidOperations.
bool InitSelectOp(SIccCalcOp *ops, icUInt32Number nOps)
Name: CIccCalculatorFunc::InitSelectOp.
virtual bool Begin(const CIccMpeCalculator *pChannelMux, CIccTagMultiProcessElement *pMPE)
Name: CIccCalculatorFunc::Begin.
icUInt32Number GetMaxTemp() const
Name: CIccCalculatorFunc::GetMaxTemp.
icFuncParseStatus DoesStackUnderflowOverflow(std::string &sReport) const
Name: CIccCalculatorFunc::DoesStackUnderflowOverflow.
int CheckUnderflowOverflow(SIccCalcOp *op, icUInt32Number nOps, int nArgs, bool bCheckUnderflow, std::string &sReport) const
Name: CIccCalculatorFunc::CheckUnderflow.
bool SequenceNeedTempReset(SIccCalcOp *op, icUInt32Number nOps, icUInt8Number *tempUsage, icUInt32Number nMaxTemp)
Name: CIccCalculatorFunc::SequenceNeedTempReset.
bool DoesOverflowOutput(icUInt16Number nOutputChannels) const
Name: CIccChannelFunc::DoesOverflowOutput.
virtual bool Apply(CIccApplyMpeCalculator *pApply) const
Name: CIccCalculatorFunc::Apply.
icUInt32Number m_nOps
Definition IccMpeCalc.h:416
CIccCalculatorFunc(CIccMpeCalculator *pCalc)
Name: CIccCalculatorFunc::CIccCalculatorFunc.
virtual bool Write(CIccIO *pIO)
Name: CIccCalculatorFunc::Write.
bool HasUnsupportedOperations(std::string &sReport, const CIccProfile *pProfile) const
Name: CIccCalculatorFunc::HasUnsupportedOperations.
bool InitSelectOps()
Name: CIccCalculatorFunc::InitSelectOps.
bool SetOpDefs()
Name: CIccCalculatorFunc::SetOpDefs.
const char * ParseFuncDef(const char *szFuncDef, CIccCalcOpList &m_list, std::string &sReport)
Name: CIccCalculatorFunc::ParseFuncDef.
virtual CIccCalculatorFunc * NewCopy() const
Definition IccMpeCalc.h:369
bool NeedTempReset(icUInt8Number *tempUsage, icUInt32Number nMaxTemp)
Name: CIccCalculatorFunc::NeedTempReset.
virtual icChannelFuncSignature GetType() const
Definition IccMpeCalc.h:372
virtual ~CIccConsoleDebugger()
virtual bool AfterOp(SIccCalcOp *op, SIccOpState &os, SIccCalcOp *ops)
virtual void Error(const char *szMsg)
virtual bool BeforeOp(SIccCalcOp *op, SIccOpState &os, SIccCalcOp *ops)
virtual void EndApply()
virtual void BeginApply()
bool GetEnvSig(icSigCmmEnvVar &envSig)
icFloat32Number GetValue()
CIccFuncTokenizer(const char *szText, bool bAllowReferences=false)
icSigCalcOp GetSig()
bool GetIndex(icUInt16Number &v1, icUInt16Number &v2, icUInt16Number initV1=0, icUInt16Number initV2=0)
std::string GetName() const
void SetPos(const char *szText)
Definition IccMpeCalc.h:330
const char * GetPos()
Definition IccMpeCalc.h:329
const char * m_text
Definition IccMpeCalc.h:348
virtual ~CIccFuncTokenizer()
std::string GetReference() const
std::string * m_token
Definition IccMpeCalc.h:349
bool GetNext(bool bForceNoRefs=false)
Type: Class.
Definition IccIO.h:97
icInt32Number Write16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:122
icInt32Number Read16(void *pBuf16, icInt32Number nNum=1)
Definition IccIO.cpp:114
virtual icInt32Number Tell()
Definition IccIO.h:133
bool Align32()
Write operation to make sure that filelength is evenly divisible by 4.
Definition IccIO.cpp:341
icInt32Number Write32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:152
virtual icInt32Number Seek(icInt32Number nOffset, icSeekVal pos)
Definition IccIO.h:132
icInt32Number Read32(void *pBuf32, icInt32Number nNum=1)
Definition IccIO.cpp:143
Type: Class.
Definition IccUtil.h:303
std::string GetSigPathName(std::string sigPath)
Definition IccUtil.cpp:1614
Class: CIccMpeCalculator.
Definition IccMpeCalc.h:447
icFuncParseStatus SetCalcFunc(icCalculatorFuncPtr newFunc)
Name: CIccMpeCalculator::SetCalcFunc.
virtual bool IsLateBindingReflectance() const
Name: CIccMpeCalculator::IsLateBindingReflectance.
CIccMultiProcessElement * GetElem(icSigCalcOp op, icUInt16Number index)
Name: CIccMpeCalculator::GetSubApply.
icUInt32Number m_nTempChannels
Definition IccMpeCalc.h:485
void SetSize(icUInt16Number nInputChannels, icUInt16Number nOutputChannels)
Name: CIccMpeCalculator::SetSize.
icCalculatorFuncPtr m_calcFunc
Definition IccMpeCalc.h:491
virtual icElemTypeSignature GetType() const
Definition IccMpeCalc.h:463
virtual bool Begin(icElemInterp nInterp, CIccTagMultiProcessElement *pMPE)
Name: CIccMpeCalculator::Begin.
virtual void Describe(std::string &sDescription, int nVerboseness)
Name: CIccMpeCalculator::Describe.
IIccCmmEnvVarLookup * m_pCmmEnvVarLookup
Definition IccMpeCalc.h:493
virtual bool Read(icUInt32Number size, CIccIO *pIO)
Name: CIccMpeCalculator::Read.
virtual icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const
Name: CIccMpeCalculator::Validate.
virtual bool Write(CIccIO *pIO)
Name: CIccMpeCalculator::Write.
CIccMpeCalculator(icUInt16Number nInputChannels=0, icUInt16Number nOutputChannels=0)
Name: CIccMpeCalculator::CIccMpeCalculator.
icUInt32Number m_nSubElem
Definition IccMpeCalc.h:488
virtual CIccApplyMpe * GetNewApply(CIccApplyTagMpe *pApplyTag)
Name: CIccMpeCalculator::Begin.
bool SetElem(icUInt32Number idx, CIccMultiProcessElement *pElem, icUInt32Number &count, CIccMultiProcessElement ***pArray)
Name: CIccMpeCalculator::GetSubApply.
CIccMultiProcessElement ** m_SubElem
Definition IccMpeCalc.h:489
CIccMpeCalculator & operator=(const CIccMpeCalculator &curveSet)
Name: &CIccMpeCalculator::operator=.
virtual bool IsLateBinding() const
Name: CIccMpeCalculator::IsLateBinding.
bool SetSubElem(icUInt32Number idx, CIccMultiProcessElement *pElem)
Definition IccMpeCalc.h:461
virtual ~CIccMpeCalculator()
Name: CIccMpeCalculator::~CIccMpeCalculator.
virtual void Apply(CIccApplyMpe *pApply, icFloatNumber *pDestPixel, const icFloatNumber *pSrcPixel) const
Name: CIccMpeCalculator::Apply.
Class: CIccMultiProcessElement.
Definition IccTagMPE.h:146
virtual icUInt16Number NumInputChannels() const
Definition IccTagMPE.h:159
icUInt16Number m_nOutputChannels
Definition IccTagMPE.h:192
virtual icUInt16Number NumOutputChannels() const
Definition IccTagMPE.h:160
virtual CIccMultiProcessElement * NewCopy() const =0
virtual bool Read(icUInt32Number size, CIccIO *pIO)=0
static CIccMultiProcessElement * Create(icElemTypeSignature sig)
Name: CIccMultiProcessElement::Create.
virtual icElemTypeSignature GetType() const =0
icUInt16Number m_nInputChannels
Definition IccTagMPE.h:191
virtual void Describe(std::string &sDescription, int nVerboseness)=0
icUInt32Number m_nReserved
Definition IccTagMPE.h:188
virtual icValidateStatus Validate(std::string sigPath, std::string &sReport, const CIccTagMultiProcessElement *pMPE=NULL, const CIccProfile *pProfile=NULL) const =0
Name: CIccProcessElement::Validate.
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool IsValid(CIccMpeCalculator *pCalc, SIccCalcOp &op)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
virtual bool Exec(SIccCalcOp *op, SIccOpState &os)
icUInt16Number NumInputChannels()
Definition IccMpeCalc.h:429
void Apply(icFloatNumber *pDestPixel, const icFloatNumber *pSrcPixel)
Definition IccMpeCalc.h:432
icUInt16Number NumOutputChannels()
Definition IccMpeCalc.h:430
Class: CIccTagMultiProcessElement.
Definition IccTagMPE.h:358
IIccCmmEnvVarLookup * GetCmmEnvLookup()
Definition IccTagMPE.h:405
virtual void EndApply()=0
virtual bool BeforeOp(SIccCalcOp *op, SIccOpState &os, SIccCalcOp *ops)=0
virtual bool AfterOp(SIccCalcOp *op, SIccOpState &os, SIccCalcOp *ops)=0
static void SetDebugger(IIccCalcDebugger *pDebugger)
virtual void Error(const char *msg)=0
virtual void BeginApply()=0
virtual bool GetEnvVar(icSigCmmEnvVar sig, icFloatNumber &val)=0
virtual bool Solve(icFloatNumber *dXVector, const icFloatNumber *dMatrix, const icFloatNumber *dYVector, icUInt16Number nRows, icUInt16Number nCols)=0
Member Function: Solve.
Interface: IIccOpDef.
Definition IccMpeCalc.h:292
virtual bool Exec(SIccCalcOp *op, SIccOpState &s)
Definition IccMpeCalc.h:304
unsigned char icUInt8Number
Number definitions.
float icFloat32Number
unsigned short icUInt16Number
long icInt32Number
icElemTypeSignature
Multi-Processing Element type signatures.
@ icSigCurveSetElemType
@ icSigCLutElemType
@ icSigExtCLutElemType
@ icSigTintArrayElemType
@ icSigXYZToJabElemType
@ icSigJabToXYZElemType
@ icSigMatrixElemType
@ icSigCalculatorElemType
#define icVersionNumberV5_1
icUInt32Number icSignature
icUInt32Number icUInt64Number[2]
icSigCmmEnvVar
@ icSigTrueVar
@ icSigNotDefVar
Structure: SIccCalcOp.
Definition IccMpeCalc.h:231
static bool IsValidOp(icSigCalcOp sig)
Name: SIccCalcOp::IsValidOp.
icUInt16Number v2
Definition IccMpeCalc.h:242
IIccOpDef * def
Definition IccMpeCalc.h:248
icUInt16Number v1
Definition IccMpeCalc.h:243
icUInt16Number ArgsUsed(CIccMpeCalculator *pCalc)
Name: SIccCalcOp::ArgsUsed.
icSigCalcOp sig
Definition IccMpeCalc.h:233
unsigned long extra
Definition IccMpeCalc.h:247
void Describe(std::string &desc, int nVerboseness=100)
Name: SIccCalcOp::Describe.
icUInt32Number size
Definition IccMpeCalc.h:236
struct SIccCalcOp::@1::@2 select
union SIccCalcOp::@1 data
icUInt16Number ArgsPushed(CIccMpeCalculator *pCalc)
Name: SIccCalcOp::ArgsPushed.
icFloat32Number num
Definition IccMpeCalc.h:235
Structure: SIccOpState.
Definition IccMpeCalc.h:273
icUInt32Number idx
Definition IccMpeCalc.h:280
icFloatNumber * temp
Definition IccMpeCalc.h:277
icUInt32Number nOps
Definition IccMpeCalc.h:281
icFloatNumber * output
Definition IccMpeCalc.h:279
CIccFloatVector * pScratch
Definition IccMpeCalc.h:276
CIccFloatVector * pStack
Definition IccMpeCalc.h:275
const icFloatNumber * pixel
Definition IccMpeCalc.h:278
CIccApplyMpeCalculator * pApply
Definition IccMpeCalc.h:274
icUInt32Number offset
icUInt32Number size