--- ray/src/common/tonemap.c 2008/07/03 03:30:21 3.31 +++ ray/src/common/tonemap.c 2009/02/09 20:48:08 3.34 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tonemap.c,v 3.31 2008/07/03 03:30:21 greg Exp $"; +static const char RCSid[] = "$Id: tonemap.c,v 3.34 2009/02/09 20:48:08 greg Exp $"; #endif /* * Tone mapping functions. @@ -12,6 +12,7 @@ static const char RCSid[] = "$Id: tonemap.c,v 3.31 200 #include "copyright.h" #include +#include #include #include "tmprivat.h" #include "tmerrmsg.h" @@ -419,27 +420,6 @@ double La } -static int -tmNewMap( /* allocate new tone-mapping array */ -TMstruct *tms -) -{ - if (tms->lumap != NULL && (tms->mbrmax - tms->mbrmin) != - (tms->hbrmax - tms->hbrmin)) { - free((MEM_PTR)tms->lumap); - tms->lumap = NULL; - } - tms->mbrmin = tms->hbrmin; - tms->mbrmax = tms->hbrmax; - if (tms->mbrmin > tms->mbrmax) - return 0; - if (tms->lumap == NULL) - tms->lumap = (unsigned short *)malloc(sizeof(unsigned short)* - (tms->mbrmax-tms->mbrmin+1)); - return(tms->lumap != NULL); -} - - int tmFixedMapping( /* compute fixed, linear tone-mapping */ TMstruct *tms, @@ -497,7 +477,7 @@ double Ldmax logLddyn = log(Lddyn); Ldavg = sqrt(Ldmax*Ldmin); i = HISTI(tms->hbrmin); - brt0 = MINBRT + HISTEP/2 + i*HISTEP; + brt0 = HISTV(i); histlen = HISTI(tms->hbrmax) + 1 - i; /* histogram total and mean */ histot = 0; sum = 0; @@ -615,8 +595,6 @@ int len } - - TMstruct * tmDup( /* duplicate top tone mapping */ TMstruct *tms @@ -691,6 +669,27 @@ tmMkMesofact() /* build mesopic lookup factor table tmMesofact[i-BMESLOWER] = 256. * (tmLuminance(i) - LMESLOWER) / (LMESUPPER - LMESLOWER); +} + + +int +tmNewMap( /* allocate new tone-mapping array */ +TMstruct *tms +) +{ + if (tms->lumap != NULL && (tms->mbrmax - tms->mbrmin) != + (tms->hbrmax - tms->hbrmin)) { + free((MEM_PTR)tms->lumap); + tms->lumap = NULL; + } + tms->mbrmin = tms->hbrmin; + tms->mbrmax = tms->hbrmax; + if (tms->mbrmin > tms->mbrmax) + return 0; + if (tms->lumap == NULL) + tms->lumap = (unsigned short *)malloc(sizeof(unsigned short)* + (tms->mbrmax-tms->mbrmin+1)); + return(tms->lumap != NULL); }