ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/tonemap.c
(Generate patch)

Comparing ray/src/common/tonemap.c (file contents):
Revision 3.16 by greg, Fri Jan 7 20:33:02 2005 UTC vs.
Revision 3.18 by greg, Fri Jan 7 22:05:30 2005 UTC

# Line 22 | Line 22 | static const char      RCSid[] = "$Id$";
22   struct tmPackage        *tmPkg[TM_MAXPKG];
23   int     tmNumPkgs = 0;                  /* number of registered packages */
24  
25 int     tmLastError;                    /* last error incurred by library */
26 char    *tmLastFunction;                /* error-generating function name */
25  
28
26   TMstruct *
27   tmInit(                                 /* initialize new tone mapping */
28   int     flags,
# Line 71 | Line 68 | double gamval
68                          tmnew->inpsf = WHTEFFICACY;
69          tmnew->cmat[0][1] = tmnew->cmat[0][2] = tmnew->cmat[1][0] =
70          tmnew->cmat[1][2] = tmnew->cmat[2][0] = tmnew->cmat[2][1] = 0.;
71 +        tmnew->inpdat = NULL;
72          tmnew->hbrmin = 10; tmnew->hbrmax = -10;
73          tmnew->histo = NULL;
74          tmnew->mbrmin = 10; tmnew->mbrmax = -10;
# Line 78 | Line 76 | double gamval
76                                                  /* zero private data */
77          for (i = TM_MAXPKG; i--; )
78                  tmnew->pd[i] = NULL;
79 +        tmnew->lastError = TM_E_OK;
80 +        tmnew->lastFunc = "NoErr";
81                                                  /* return new TMstruct */
82          return(tmnew);
83   }
# Line 87 | Line 87 | int
87   tmSetSpace(                     /* set input color space for conversions */
88   TMstruct        *tms,
89   RGBPRIMP        pri,
90 < double  sf
90 > double  sf,
91 > MEM_PTR dat
92   )
93   {
94 <        static char     funcName[] = "tmSetSpace";
94 >        static const char funcName[] = "tmSetSpace";
95          int     i, j;
96                                                  /* error check */
97          if (tms == NULL)
# Line 98 | Line 99 | double sf
99          if (sf <= 1e-12)
100                  returnErr(TM_E_ILLEGAL);
101                                                  /* check if no change */
102 <        if (pri == tms->inppri && FEQ(sf, tms->inpsf))
102 >        if (pri == tms->inppri && FEQ(sf, tms->inpsf) && dat == tms->inpdat)
103                  returnOK;
104          tms->inppri = pri;                      /* let's set it */
105          tms->inpsf = sf;
106 +        tms->inpdat = dat;
107  
108          if (tms->flags & TM_F_BW) {             /* color doesn't matter */
109                  tms->monpri = tms->inppri;              /* eliminate xform */
# Line 167 | Line 169 | COLOR  *scan,
169   int     len
170   )
171   {
172 <        static char     funcName[] = "tmCvColors";
172 >        static const char funcName[] = "tmCvColors";
173          static COLOR    csmall = {.5*MINLUM, .5*MINLUM, .5*MINLUM};
174          COLOR   cmon;
175          double  lum, slum;
# Line 245 | Line 247 | float  *scan,
247   int     len
248   )
249   {
250 <        static char     funcName[] = "tmCvGrays";
250 >        static const char funcName[] = "tmCvGrays";
251          double  d;
252          int     i;
253  
# Line 272 | Line 274 | int    len,
274   int     wt
275   )
276   {
277 <        static char     funcName[] = "tmAddHisto";
277 >        static const char funcName[] = "tmAddHisto";
278          int     oldorig=0, oldlen, horig, hlen;
279          int     i, j;
280  
# Line 375 | Line 377 | double expmult,
377   double  gamval
378   )
379   {
380 <        static char     funcName[] = "tmFixedMapping";
380 >        static const char funcName[] = "tmFixedMapping";
381          double          d;
382          int     i;
383          
# Line 402 | Line 404 | double Lddyn,
404   double  Ldmax
405   )
406   {
407 <        static char     funcName[] = "tmComputeMapping";
407 >        static const char funcName[] = "tmComputeMapping";
408          int     *histo;
409          float   *cumf;
410          int     brt0, histlen, threshold, ceiling, trimmings;
# Line 510 | Line 512 | BYTE   *cs,
512   int     len
513   )
514   {
515 <        static char     funcName[] = "tmMapPixels";
515 >        static const char funcName[] = "tmMapPixels";
516          int32   li, pv;
517  
518          if (tms == NULL || tms->lumap == NULL)
# Line 622 | Line 624 | tmMkMesofact()                         /* build mesopic lookup factor table
624  
625   int
626   tmErrorReturn(                          /* error return (with message) */
627 < char    *func,
627 > const char      *func,
628   TMstruct        *tms,
629   int     err
630   )
631   {
632 <        tmLastFunction = func;
633 <        tmLastError = err;
634 <        if (tms != NULL && tms->flags & TM_F_NOSTDERR)
635 <                return(err);
632 >        if (tms != NULL) {
633 >                tms->lastFunc = func;
634 >                tms->lastError = err;
635 >                if (tms->flags & TM_F_NOSTDERR)
636 >                        return(err);
637 >        }
638          fputs(func, stderr);
639          fputs(": ", stderr);
640          fputs(tmErrorMessage[err], stderr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines