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.31 by greg, Thu Jul 3 03:30:21 2008 UTC vs.
Revision 3.34 by greg, Mon Feb 9 20:48:08 2009 UTC

# Line 12 | Line 12 | static const char      RCSid[] = "$Id$";
12   #include "copyright.h"
13  
14   #include        <stdio.h>
15 + #include        <stdlib.h>
16   #include        <math.h>
17   #include        "tmprivat.h"
18   #include        "tmerrmsg.h"
# Line 419 | Line 420 | double La
420   }
421  
422  
422 static int
423 tmNewMap(                       /* allocate new tone-mapping array */
424 TMstruct        *tms
425 )
426 {
427        if (tms->lumap != NULL && (tms->mbrmax - tms->mbrmin) !=
428                                        (tms->hbrmax - tms->hbrmin)) {
429                free((MEM_PTR)tms->lumap);
430                tms->lumap = NULL;
431        }
432        tms->mbrmin = tms->hbrmin;
433        tms->mbrmax = tms->hbrmax;
434        if (tms->mbrmin > tms->mbrmax)
435                return 0;
436        if (tms->lumap == NULL)
437                tms->lumap = (unsigned short *)malloc(sizeof(unsigned short)*
438                                        (tms->mbrmax-tms->mbrmin+1));
439        return(tms->lumap != NULL);
440 }
441
442
423   int
424   tmFixedMapping(                 /* compute fixed, linear tone-mapping */
425   TMstruct        *tms,
# Line 497 | Line 477 | double Ldmax
477          logLddyn = log(Lddyn);
478          Ldavg = sqrt(Ldmax*Ldmin);
479          i = HISTI(tms->hbrmin);
480 <        brt0 = MINBRT + HISTEP/2 + i*HISTEP;
480 >        brt0 = HISTV(i);
481          histlen = HISTI(tms->hbrmax) + 1 - i;
482                                          /* histogram total and mean */
483          histot = 0; sum = 0;
# Line 615 | Line 595 | int    len
595   }
596  
597  
618
619
598   TMstruct *
599   tmDup(                          /* duplicate top tone mapping */
600   TMstruct        *tms
# Line 691 | Line 669 | tmMkMesofact()                         /* build mesopic lookup factor table
669                  tmMesofact[i-BMESLOWER] = 256. *
670                                  (tmLuminance(i) - LMESLOWER) /
671                                  (LMESUPPER - LMESLOWER);
672 + }
673 +
674 +
675 + int
676 + tmNewMap(                       /* allocate new tone-mapping array */
677 + TMstruct        *tms
678 + )
679 + {
680 +        if (tms->lumap != NULL && (tms->mbrmax - tms->mbrmin) !=
681 +                                        (tms->hbrmax - tms->hbrmin)) {
682 +                free((MEM_PTR)tms->lumap);
683 +                tms->lumap = NULL;
684 +        }
685 +        tms->mbrmin = tms->hbrmin;
686 +        tms->mbrmax = tms->hbrmax;
687 +        if (tms->mbrmin > tms->mbrmax)
688 +                return 0;
689 +        if (tms->lumap == NULL)
690 +                tms->lumap = (unsigned short *)malloc(sizeof(unsigned short)*
691 +                                        (tms->mbrmax-tms->mbrmin+1));
692 +        return(tms->lumap != NULL);
693   }
694  
695  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines