--- ray/src/common/tmapluv.c 2005/01/07 21:41:06 3.11 +++ ray/src/common/tmapluv.c 2011/05/20 02:06:38 3.16 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: tmapluv.c,v 3.11 2005/01/07 21:41:06 greg Exp $"; +static const char RCSid[] = "$Id: tmapluv.c,v 3.16 2011/05/20 02:06:38 greg Exp $"; #endif /* * Routines for tone-mapping LogLuv encoded pixels. @@ -12,6 +12,7 @@ static const char RCSid[] = "$Id: tmapluv.c,v 3.11 200 #define LOGLUV_PUBLIC 1 #include +#include #include #include #include "tiffio.h" @@ -38,7 +39,7 @@ static void luv24NewSpace(TMstruct *); typedef struct { int offset; /* computed luminance offset */ - BYTE rgbval[1<<16][3]; /* computed RGB value for given uv */ + uby8 rgbval[1<<16][3]; /* computed RGB value for given uv */ uint32 rgbflg[1<<(16-5)]; /* flags for computed values */ } LUV32DATA; /* LogLuv 32-bit conversion data */ @@ -52,7 +53,7 @@ static int luv32Reg = -1; /* 32-bit package reg. numb typedef struct { int offset; /* computed luminance offset */ - BYTE rgbval[1<<14][3]; /* computed rgb value for uv index */ + uby8 rgbval[1<<14][3]; /* computed rgb value for uv index */ uint32 rgbflg[1<<(14-5)]; /* flags for computed values */ } LUV24DATA; /* LogLuv 24-bit conversion data */ @@ -66,7 +67,7 @@ static int uv14neu = -1; /* neutral index for 14-bit static void uv2rgb(rgb, tms, uvp) /* compute RGB from uv coordinate */ -BYTE rgb[3]; +uby8 rgb[3]; register TMstruct *tms; double uvp[2]; { /* Should check that tms->inppri==TM_XYZPRIM beforehand... */ @@ -126,7 +127,7 @@ int tmCvLuv32( /* convert raw 32-bit LogLuv values */ TMstruct *tms, TMbright *ls, -BYTE *cs, +uby8 *cs, uint32 *luvs, int len ) @@ -188,7 +189,7 @@ int tmCvLuv24( /* convert raw 24-bit LogLuv values */ TMstruct *tms, TMbright *ls, -BYTE *cs, +uby8 *cs, uint32 *luvs, int len ) @@ -266,11 +267,7 @@ int len returnErr(TM_E_ILLEGAL); /* check scaling offset */ if (!FEQ(tms->inpsf, lastsf)) { - offset = BRT2SCALE(64); - if (tms->inpsf > 1.0001) - offset -= (int)(TM_BRTSCALE*log(tms->inpsf)+.5); - else if (tms->inpsf < 0.9999) - offset -= (int)(TM_BRTSCALE*log(tms->inpsf)-.5); + offset = BRT2SCALE(64) - tmCvLuminance(tms->inpsf); lastsf = tms->inpsf; } /* convert each pixel */ @@ -295,11 +292,7 @@ TMstruct *tms; exit(1); } ld = (LUV32DATA *)tms->pd[luv32Reg]; - ld->offset = BRT2SCALE(64); - if (tms->inpsf > 1.0001) - ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)+.5); - else if (tms->inpsf < 0.9999) - ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)-.5); + ld->offset = BRT2SCALE(64) - tmCvLuminance(tms->inpsf); clruvall(ld); } @@ -330,11 +323,7 @@ TMstruct *tms; exit(1); } ld = (LUV24DATA *)tms->pd[luv24Reg]; - ld->offset = BRT2SCALE(12); - if (tms->inpsf > 1.0001) - ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)+.5); - else if (tms->inpsf < 0.9999) - ld->offset -= (int)(TM_BRTSCALE*log(tms->inpsf)-.5); + ld->offset = BRT2SCALE(12) - tmCvLuminance(tms->inpsf); clruvall(ld); }