--- ray/src/common/tonemap.c 2003/06/20 00:25:49 3.11 +++ ray/src/common/tonemap.c 2004/07/22 17:48:52 3.15 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tonemap.c,v 3.11 2003/06/20 00:25:49 greg Exp $"; +static const char RCSid[] = "$Id: tonemap.c,v 3.15 2004/07/22 17:48:52 greg Exp $"; #endif /* * Tone mapping functions. @@ -43,6 +43,8 @@ double gamval; return(NULL); tmnew->flags = flags & ~TM_F_UNIMPL; + if (tmnew->flags & TM_F_BW) + tmnew->flags &= ~TM_F_MESOPIC; /* set monitor transform */ if (monpri == NULL || monpri == stdprims || tmnew->flags & TM_F_BW) { tmnew->monpri = stdprims; @@ -162,7 +164,7 @@ COLOR *scan; int len; { static char funcName[] = "tmCvColors"; - static COLOR csmall = {1e-6, 1e-6, 1e-6}; + static COLOR csmall = {.5*MINLUM, .5*MINLUM, .5*MINLUM}; COLOR cmon; double lum, slum; register double d; @@ -170,12 +172,12 @@ int len; if (tmTop == NULL) returnErr(TM_E_TMINVAL); - if (ls == NULL | scan == NULL | len < 0) + if ((ls == NULL) | (scan == NULL) | (len < 0)) returnErr(TM_E_ILLEGAL); for (i = len; i--; ) { - if (tmNeedMatrix(tmTop)) /* get monitor RGB */ + if (tmNeedMatrix(tmTop)) { /* get monitor RGB */ colortrans(cmon, tmTop->cmat, scan[i]); - else { + } else { cmon[RED] = tmTop->inpsf*scan[i][RED]; cmon[GRN] = tmTop->inpsf*scan[i][GRN]; cmon[BLU] = tmTop->inpsf*scan[i][BLU]; @@ -243,7 +245,7 @@ int len; if (tmTop == NULL) returnErr(TM_E_TMINVAL); - if (ls == NULL | scan == NULL | len < 0) + if ((ls == NULL) | (scan == NULL) | (len < 0)) returnErr(TM_E_ILLEGAL); for (i = len; i--; ) if (scan[i] <= TM_NOLUM) { @@ -415,7 +417,7 @@ double Ldmax; histot += tmTop->histo[i]; sum += (j -= HISTEP) * tmTop->histo[i]; } - threshold = histot*.025 + .5; + threshold = histot*0.005 + .5; if (threshold < 4) returnErr(TM_E_TMFAIL); Lwavg = tmLuminance( (double)sum / histot ); @@ -428,7 +430,7 @@ double Ldmax; /* clamp histogram */ histo = (int *)malloc(histlen*sizeof(int)); cumf = (float *)malloc((histlen+2)*sizeof(float)); - if (histo == NULL | cumf == NULL) + if ((histo == NULL) | (cumf == NULL)) returnErr(TM_E_NOMEM); cumf[histlen+1] = 1.; /* guard for assignment code */ for (i = histlen; i--; ) /* make malleable copy */ @@ -496,7 +498,7 @@ int len; if (tmTop == NULL || tmTop->lumap == NULL) returnErr(TM_E_TMINVAL); - if (ps == NULL | ls == NULL | len < 0) + if ((ps == NULL) | (ls == NULL) | (len < 0)) returnErr(TM_E_ILLEGAL); while (len--) { if ((li = *ls++) < tmTop->mbrmin) { @@ -538,7 +540,7 @@ register struct tmStruct *tms; { register struct tmStruct *tms2; /* special cases first */ - if (tms == NULL | tmTop == NULL) + if ((tms == NULL) | (tmTop == NULL)) return(0); if (tms == tmTop) { tmTop = tms->tmprev;