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.23 by greg, Wed May 10 15:21:58 2006 UTC vs.
Revision 3.25 by greg, Thu May 11 00:58:48 2006 UTC

# Line 23 | Line 23 | struct tmPackage       *tmPkg[TM_MAXPKG];
23   int     tmNumPkgs = 0;                  /* number of registered packages */
24  
25                                          /* luminance->brightness lookup */
26 < static TMbright         *tmFloat2BrtLUT;
26 > static TMbright         *tmFloat2BrtLUT = NULL;
27  
28   #define tmCvLumLUfp(pf) tmFloat2BrtLUT[*(int32 *)(pf) >> 15]
29  
# Line 239 | Line 239 | int            len
239                  returnErr(TM_E_TMINVAL);
240          if ((ls == NULL) | (scan == NULL) | (len < 0))
241                  returnErr(TM_E_ILLEGAL);
242 +        if (tmFloat2BrtLUT == NULL)                     /* initialize */
243 +                tmCvLums(NULL, NULL, 0);
244          for (i = len; i--; ) {
245                  float   lum = tms->inpsf * scan[i];
246                  if (lum <= TM_NOLUM)
# Line 260 | Line 262 | int    len
262   )
263   {
264          static const char funcName[] = "tmCvColors";
263        static COLOR    csmall = {.5*MINLUM, .5*MINLUM, .5*MINLUM};
265          static BYTE     gamtab[1024];
266          static double   curgam = .0;
267          COLOR   cmon;
# Line 271 | Line 272 | int    len
272                  returnErr(TM_E_TMINVAL);
273          if ((ls == NULL) | (scan == NULL) | (len < 0))
274                  returnErr(TM_E_ILLEGAL);
275 <        tmCvLums(NULL, NULL, 0);                        /* initialize */
275 >        if (tmFloat2BrtLUT == NULL)                     /* initialize */
276 >                tmCvLums(NULL, NULL, 0);
277          if (cs != TM_NOCHROM && fabs(tms->mongam - curgam) > .02) {
278                  curgam = tms->mongam;                   /* (re)build table */
279                  for (i = 1024; i--; )
# Line 298 | Line 300 | int    len
300                  lum =   tms->clf[RED]*cmon[RED] +
301                          tms->clf[GRN]*cmon[GRN] +
302                          tms->clf[BLU]*cmon[BLU] ;
303 <                if (lum <= TM_NOLUM)                    /* convert brightness */
303 >                if (lum <= TM_NOLUM) {                  /* convert brightness */
304 >                        lum = cmon[RED] = cmon[GRN] = cmon[BLU] = TM_NOLUM;
305                          ls[i] = TM_NOBRT;
306 <                else
306 >                } else
307                          ls[i] = tmCvLumLUfp(&lum);
308                  if (cs == TM_NOCHROM)                   /* no color? */
309                          continue;
310                  if (tms->flags & TM_F_MESOPIC && lum < LMESUPPER) {
311                          slum = scotlum(cmon);           /* mesopic adj. */
312 <                        if (lum < LMESLOWER)
312 >                        if (lum < LMESLOWER) {
313                                  cmon[RED] = cmon[GRN] = cmon[BLU] = slum;
314 <                        else {
314 >                        } else {
315                                  d = (lum - LMESLOWER)/(LMESUPPER - LMESLOWER);
316                                  if (tms->flags & TM_F_BW)
317                                          cmon[RED] = cmon[GRN] =

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines