--- ray/src/common/tonemap.h 2005/01/07 21:41:06 3.18 +++ ray/src/common/tonemap.h 2006/05/10 15:21:58 3.22 @@ -1,4 +1,4 @@ -/* RCSid $Id: tonemap.h,v 3.18 2005/01/07 21:41:06 greg Exp $ */ +/* RCSid $Id: tonemap.h,v 3.22 2006/05/10 15:21:58 greg Exp $ */ /* * Header file for tone mapping functions. * @@ -14,7 +14,7 @@ extern "C" { #endif /**** Argument Macros ****/ - /* Flags of what to do */ + /* flags of what to do */ #define TM_F_HCONTR 01 /* human contrast sensitivity */ #define TM_F_MESOPIC 02 /* mesopic color sensitivity */ #define TM_F_LINEAR 04 /* linear brightness mapping */ @@ -70,7 +70,7 @@ extern char *tmErrorMessage[]; /* error messages */ typedef short TMbright; /* encoded luminance type */ /* basic tone mapping data structure */ -typedef struct tmStruct { +typedef struct { int flags; /* flags of what to do */ RGBPRIMP monpri; /* monitor RGB primaries */ double mongam; /* monitor gamma value (approx.) */ @@ -78,6 +78,7 @@ typedef struct tmStruct { int cdiv[3]; /* computed color divisors */ RGBPRIMP inppri; /* current input primaries */ double inpsf; /* current input scalefactor */ + MEM_PTR inpdat; /* current input client data */ COLORMAT cmat; /* color conversion matrix */ TMbright hbrmin, hbrmax; /* histogram brightness limits */ int *histo; /* input histogram */ @@ -117,7 +118,24 @@ extern int tmNumPkgs; /* number of registered packages /**** Library Function Calls ****/ +extern TMbright +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); /* @@ -131,13 +149,14 @@ tmInit(int flags, RGBPRIMP monpri, double gamval); */ extern int -tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf); +tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf, MEM_PTR dat); /* Set color primaries and scale factor for incoming scanlines. tms - tone mapping structure pointer. pri - RGB color input primaries (Note 1). sf - scale factor to get to luminance in cd/m^2. + dat - application-specific data (NULL if not needed) returns - 0 on success, TM_E_* code on failure. */ @@ -228,13 +247,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. @@ -242,12 +260,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, BYTE *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.