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.19 by greg, Tue Nov 15 06:53:00 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 237 | Line 239 | int    len
239   }
240  
241  
242 + TMbright
243 + tmCvLuminance(                          /* convert a single luminance */
244 + double  lum
245 + )
246 + {
247 +        double  d;
248 +
249 +        if (lum <= TM_NOLUM)
250 +                return(TM_NOBRT);
251 +        d = TM_BRTSCALE*log(lum);
252 +        if (d > 0.)
253 +                return((TMbright)(d+.5));
254 +        return((TMbright)(d-.5));
255 + }
256 +
257 +
258   int
259   tmCvGrays(                              /* convert float gray values */
260   TMstruct        *tms,
# Line 245 | Line 263 | float  *scan,
263   int     len
264   )
265   {
266 <        static char     funcName[] = "tmCvGrays";
266 >        static const char funcName[] = "tmCvGrays";
267          double  d;
268          int     i;
269  
# Line 272 | Line 290 | int    len,
290   int     wt
291   )
292   {
293 <        static char     funcName[] = "tmAddHisto";
293 >        static const char funcName[] = "tmAddHisto";
294          int     oldorig=0, oldlen, horig, hlen;
295          int     i, j;
296  
# Line 375 | Line 393 | double expmult,
393   double  gamval
394   )
395   {
396 <        static char     funcName[] = "tmFixedMapping";
396 >        static const char funcName[] = "tmFixedMapping";
397          double          d;
398          int     i;
399          
# Line 402 | Line 420 | double Lddyn,
420   double  Ldmax
421   )
422   {
423 <        static char     funcName[] = "tmComputeMapping";
423 >        static const char funcName[] = "tmComputeMapping";
424          int     *histo;
425          float   *cumf;
426          int     brt0, histlen, threshold, ceiling, trimmings;
# Line 510 | Line 528 | BYTE   *cs,
528   int     len
529   )
530   {
531 <        static char     funcName[] = "tmMapPixels";
531 >        static const char funcName[] = "tmMapPixels";
532          int32   li, pv;
533  
534          if (tms == NULL || tms->lumap == NULL)
# Line 622 | Line 640 | tmMkMesofact()                         /* build mesopic lookup factor table
640  
641   int
642   tmErrorReturn(                          /* error return (with message) */
643 < char    *func,
643 > const char      *func,
644   TMstruct        *tms,
645   int     err
646   )
647   {
648 <        tmLastFunction = func;
649 <        tmLastError = err;
650 <        if (tms != NULL && tms->flags & TM_F_NOSTDERR)
651 <                return(err);
648 >        if (tms != NULL) {
649 >                tms->lastFunc = func;
650 >                tms->lastError = err;
651 >                if (tms->flags & TM_F_NOSTDERR)
652 >                        return(err);
653 >        }
654          fputs(func, stderr);
655          fputs(": ", stderr);
656          fputs(tmErrorMessage[err], stderr);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines