--- ray/src/common/tonemap.h 2010/08/18 15:25:03 3.25 +++ ray/src/common/tonemap.h 2022/01/15 16:57:46 3.32 @@ -1,4 +1,4 @@ -/* RCSid $Id: tonemap.h,v 3.25 2010/08/18 15:25:03 greg Exp $ */ +/* RCSid $Id: tonemap.h,v 3.32 2022/01/15 16:57:46 greg Exp $ */ /* * Header file for tone mapping functions. * @@ -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 */ @@ -53,17 +53,22 @@ extern "C" { #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 */ /**** Global Data Types and Structures ****/ -#ifndef MEM_PTR -#define MEM_PTR void * +#ifndef HIST_TYP +#define HIST_TYP unsigned long #endif +#ifndef TMAP_TYP +#define TMAP_TYP uint16 +#endif extern char *tmErrorMessage[]; /* error messages */ @@ -78,22 +83,22 @@ typedef struct { int cdiv[3]; /* computed color divisors */ RGBPRIMP inppri; /* current input primaries */ double inpsf; /* current input scalefactor */ - MEM_PTR inpdat; /* current input client data */ + void *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 */ - MEM_PTR pd[TM_MAXPKG]; /* pointers to private data */ + TMAP_TYP *lumap; /* computed luminance map */ + void *pd[TM_MAXPKG]; /* pointers to private data */ int lastError; /* last error incurred */ const char *lastFunc; /* error-generating function name */ } TMstruct; /* conversion package functions */ struct tmPackage { - MEM_PTR (*Init)(TMstruct *tms); + void * (*Init)(TMstruct *tms); void (*NewSpace)(TMstruct *tms); - void (*Free)(MEM_PTR pp); + void (*Free)(void *pp); }; /* our list of conversion packages */ extern struct tmPackage *tmPkg[TM_MAXPKG]; @@ -149,7 +154,7 @@ tmInit(int flags, RGBPRIMP monpri, double gamval); */ extern int -tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf, MEM_PTR dat); +tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf, void *dat); /* Set color primaries and scale factor for incoming scanlines. @@ -183,7 +188,7 @@ tmAddHisto(TMstruct *tms, TMbright *ls, int len, int w */ extern int -tmFixedMapping(TMstruct *tms, double expmult, double gamval); +tmFixedMapping(TMstruct *tms, double expmult, double gamval, double Lddyn); /* Assign a fixed, linear tone-mapping using the given multiplier, which is the ratio of maximum output to uncalibrated input. @@ -194,6 +199,7 @@ tmFixedMapping(TMstruct *tms, double expmult, double g tms - tone mapping structure pointer. expmult - the fixed exposure multiplier to use. gamval - display gamma response (0. for default). + Lddyn - the display's dynamic range (0. for default). returns - 0 on success, TM_E_* on error. */ @@ -215,7 +221,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. @@ -260,7 +266,7 @@ tmCvGrays(TMstruct *tms, TMbright *ls, float *scan, in */ extern int -tmCvColors(TMstruct *tms, TMbright *ls, BYTE *cs, COLOR *scan, int len); +tmCvColors(TMstruct *tms, TMbright *ls, uby8 *cs, COLOR *scan, int len); /* Convert RGB/XYZ float scanline to encoded luminance and chrominance. @@ -274,7 +280,7 @@ tmCvColors(TMstruct *tms, TMbright *ls, BYTE *cs, COLO */ 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. @@ -288,7 +294,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. @@ -307,7 +313,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); /* @@ -332,7 +338,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.