--- ray/src/common/tonemap.h 2005/11/15 06:53:00 3.21 +++ ray/src/common/tonemap.h 2021/01/07 19:13:57 3.29 @@ -1,4 +1,4 @@ -/* RCSid $Id: tonemap.h,v 3.21 2005/11/15 06:53:00 greg Exp $ */ +/* RCSid $Id: tonemap.h,v 3.29 2021/01/07 19:13:57 greg Exp $ */ /* * Header file for tone mapping functions. * @@ -7,7 +7,7 @@ #ifndef _RAD_TONEMAP_H_ #define _RAD_TONEMAP_H_ -#include "tifftypes.h" +#include "tiff.h" /* needed for int32, etc. */ #ifdef __cplusplus extern "C" { @@ -32,8 +32,8 @@ extern "C" { /* special pointer values */ #define TM_XYZPRIM (RGBPRIMP)NULL /* indicate XYZ primaries (Note 1) */ -#define TM_NOCHROM (BYTE *)NULL /* indicate no chrominance */ -#define TM_NOCHROMP (BYTE **)NULL /* indicate no chrominances */ +#define TM_NOCHROM (uby8 *)NULL /* indicate no chrominance */ +#define TM_NOCHROMP (uby8 **)NULL /* indicate no chrominances */ #define TM_GETFILE (FILE *)NULL /* indicate file must be opened */ @@ -51,11 +51,13 @@ extern "C" { /**** Conversion Constants and Table Sizes ****/ -#define TM_BRTSCALE 128 /* brightness scale factor (integer) */ +#define TM_BRTSCALE 256 /* brightness scale factor (integer) */ -#define TM_NOBRT (-1<<15) /* bogus brightness value */ +#define TM_NOBRT (~0x7fff) /* bogus brightness value */ #define TM_NOLUM (1e-17) /* ridiculously small luminance */ +#define TM_BRES 4096 /* luminance tone-map resolution */ + #define TM_MAXPKG 8 /* maximum number of color formats */ @@ -64,6 +66,12 @@ extern "C" { #ifndef MEM_PTR #define MEM_PTR void * #endif +#ifndef HIST_TYP +#define HIST_TYP unsigned long +#endif +#ifndef TMAP_TYP +#define TMAP_TYP uint16 +#endif extern char *tmErrorMessage[]; /* error messages */ @@ -81,9 +89,9 @@ typedef struct { MEM_PTR inpdat; /* current input client data */ COLORMAT cmat; /* color conversion matrix */ TMbright hbrmin, hbrmax; /* histogram brightness limits */ - int *histo; /* input histogram */ + HIST_TYP *histo; /* input histogram */ TMbright mbrmin, mbrmax; /* mapped brightness limits */ - unsigned short *lumap; /* computed luminance map */ + TMAP_TYP *lumap; /* computed luminance map */ MEM_PTR pd[TM_MAXPKG]; /* pointers to private data */ int lastError; /* last error incurred */ const char *lastFunc; /* error-generating function name */ @@ -124,6 +132,18 @@ tmCvLuminance(double lum); Convert a single luminance value to an encoded brightness value. */ +extern int +tmCvLums(TMbright *ls, float *scan, int len); +/* + Convert luminance values to encoded brightness values using lookup. + + ls - returned encoded luminance values. + scan - input scanline. + len - scanline length. + + returns - 0 on success, TM_E_* on error. + */ + extern TMstruct * tmInit(int flags, RGBPRIMP monpri, double gamval); /* @@ -203,7 +223,7 @@ tmComputeMapping(TMstruct *tms, double gamval, double */ extern int -tmMapPixels(TMstruct *tms, BYTE *ps, TMbright *ls, BYTE *cs, int len); +tmMapPixels(TMstruct *tms, uby8 *ps, TMbright *ls, uby8 *cs, int len); /* Apply tone mapping function to pixel values. @@ -235,13 +255,12 @@ tmDone(TMstruct *tms); */ extern int -tmCvColors(TMstruct *tms, TMbright *ls, BYTE *cs, COLOR *scan, int len); +tmCvGrays(TMstruct *tms, TMbright *ls, float *scan, int len); /* - Convert RGB/XYZ float scanline to encoded luminance and chrominance. + Convert gray float scanline to encoded luminance. tms - tone mapping structure pointer. ls - returned encoded luminance values. - cs - returned encoded chrominance values (Note 2). scan - input scanline. len - scanline length. @@ -249,12 +268,13 @@ tmCvColors(TMstruct *tms, TMbright *ls, BYTE *cs, COLO */ extern int -tmCvGrays(TMstruct *tms, TMbright *ls, float *scan, int len); +tmCvColors(TMstruct *tms, TMbright *ls, uby8 *cs, COLOR *scan, int len); /* - Convert gray float scanline to encoded luminance. + Convert RGB/XYZ float scanline to encoded luminance and chrominance. tms - tone mapping structure pointer. ls - returned encoded luminance values. + cs - returned encoded chrominance values (Note 2). scan - input scanline. len - scanline length. @@ -262,7 +282,7 @@ tmCvGrays(TMstruct *tms, TMbright *ls, float *scan, in */ extern int -tmCvColrs(TMstruct *tms, TMbright *ls, BYTE *cs, COLR *scan, int len); +tmCvColrs(TMstruct *tms, TMbright *ls, uby8 *cs, COLR *scan, int len); /* Convert RGBE/XYZE scanline to encoded luminance and chrominance. @@ -276,7 +296,7 @@ tmCvColrs(TMstruct *tms, TMbright *ls, BYTE *cs, COLR */ extern int -tmLoadPicture(TMstruct *tms, TMbright **lpp, BYTE **cpp, int *xp, int *yp, +tmLoadPicture(TMstruct *tms, TMbright **lpp, uby8 **cpp, int *xp, int *yp, char *fname, FILE *fp); /* Load Radiance picture and convert to tone mapping representation. @@ -295,7 +315,7 @@ tmLoadPicture(TMstruct *tms, TMbright **lpp, BYTE **cp */ extern int -tmMapPicture(BYTE **psp, int *xp, int *yp, int flags, +tmMapPicture(uby8 **psp, int *xp, int *yp, int flags, RGBPRIMP monpri, double gamval, double Lddyn, double Ldmax, char *fname, FILE *fp); /* @@ -320,7 +340,7 @@ tmMapPicture(BYTE **psp, int *xp, int *yp, int flags, */ extern int -tmCvRGB48(TMstruct *tms, TMbright *ls, BYTE *cs, uint16 (*scan)[3], +tmCvRGB48(TMstruct *tms, TMbright *ls, uby8 *cs, uint16 (*scan)[3], int len, double gv); /* Convert 48-bit RGB scanline to encoded luminance and chrominance.