ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/tonemap.h
(Generate patch)

Comparing ray/src/common/tonemap.h (file contents):
Revision 3.17 by greg, Fri Jan 7 20:33:02 2005 UTC vs.
Revision 3.26 by greg, Fri May 20 02:06:38 2011 UTC

# Line 7 | Line 7
7   #ifndef _RAD_TONEMAP_H_
8   #define _RAD_TONEMAP_H_
9  
10 < #include        "tifftypes.h"
10 > #include        "tiff.h"        /* needed for int32, etc. */
11  
12   #ifdef __cplusplus
13   extern "C" {
14   #endif
15  
16   /****    Argument Macros    ****/
17 <                                /* Flags of what to do */
17 >                                /* flags of what to do */
18   #define TM_F_HCONTR     01              /* human contrast sensitivity */
19   #define TM_F_MESOPIC    02              /* mesopic color sensitivity */
20   #define TM_F_LINEAR     04              /* linear brightness mapping */
# Line 32 | Line 32 | extern "C" {
32  
33                                  /* special pointer values */
34   #define TM_XYZPRIM      (RGBPRIMP)NULL  /* indicate XYZ primaries (Note 1) */
35 < #define TM_NOCHROM      (BYTE *)NULL    /* indicate no chrominance */
36 < #define TM_NOCHROMP     (BYTE **)NULL   /* indicate no chrominances */
35 > #define TM_NOCHROM      (uby8 *)NULL    /* indicate no chrominance */
36 > #define TM_NOCHROMP     (uby8 **)NULL   /* indicate no chrominances */
37   #define TM_GETFILE      (FILE *)NULL    /* indicate file must be opened */
38  
39  
# Line 51 | Line 51 | extern "C" {
51  
52   /****    Conversion Constants and Table Sizes    ****/
53  
54 < #define TM_BRTSCALE     128             /* brightness scale factor (integer) */
54 > #define TM_BRTSCALE     256             /* brightness scale factor (integer) */
55  
56   #define TM_NOBRT        (-1<<15)        /* bogus brightness value */
57   #define TM_NOLUM        (1e-17)         /* ridiculously small luminance */
# Line 66 | Line 66 | extern "C" {
66   #endif
67  
68   extern char     *tmErrorMessage[];      /* error messages */
69 extern int      tmLastError;            /* last error incurred by library */
70 extern char     *tmLastFunction;        /* error-generating function name */
69  
70   typedef short   TMbright;               /* encoded luminance type */
71  
72                                  /* basic tone mapping data structure */
73 < typedef struct tmStruct {
73 > typedef struct {
74          int             flags;          /* flags of what to do */
75          RGBPRIMP        monpri;         /* monitor RGB primaries */
76          double          mongam;         /* monitor gamma value (approx.) */
# Line 80 | Line 78 | typedef struct tmStruct {
78          int             cdiv[3];        /* computed color divisors */
79          RGBPRIMP        inppri;         /* current input primaries */
80          double          inpsf;          /* current input scalefactor */
81 +        MEM_PTR         inpdat;         /* current input client data */
82          COLORMAT        cmat;           /* color conversion matrix */
83          TMbright        hbrmin, hbrmax; /* histogram brightness limits */      
84          int             *histo;         /* input histogram */
85          TMbright        mbrmin, mbrmax; /* mapped brightness limits */
86          unsigned short  *lumap;         /* computed luminance map */
87          MEM_PTR         pd[TM_MAXPKG];  /* pointers to private data */
88 +        int             lastError;      /* last error incurred */
89 +        const char      *lastFunc;      /* error-generating function name */
90   } TMstruct;
91  
92                                  /* conversion package functions */
# Line 117 | Line 118 | extern int     tmNumPkgs;      /* number of registered packages
118  
119   /****    Library Function Calls    ****/
120  
121 + extern TMbright
122 + tmCvLuminance(double lum);
123 + /*
124 +        Convert a single luminance value to an encoded brightness value.
125 + */
126  
127 + extern int
128 + tmCvLums(TMbright *ls, float *scan, int len);
129 + /*
130 +        Convert luminance values to encoded brightness values using lookup.
131 +
132 +        ls      -       returned encoded luminance values.
133 +        scan    -       input scanline.
134 +        len     -       scanline length.
135 +
136 +        returns -       0 on success, TM_E_* on error.
137 + */
138 +
139   extern TMstruct *
140   tmInit(int flags, RGBPRIMP monpri, double gamval);
141   /*
# Line 131 | Line 149 | tmInit(int flags, RGBPRIMP monpri, double gamval);
149   */
150  
151   extern int
152 < tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf);
152 > tmSetSpace(TMstruct *tms, RGBPRIMP pri, double sf, MEM_PTR dat);
153   /*
154          Set color primaries and scale factor for incoming scanlines.
155  
156          tms     -       tone mapping structure pointer.
157          pri     -       RGB color input primaries (Note 1).
158          sf      -       scale factor to get to luminance in cd/m^2.
159 +        dat     -       application-specific data (NULL if not needed)
160  
161          returns -       0 on success, TM_E_* code on failure.
162   */
# Line 175 | Line 194 | tmFixedMapping(TMstruct *tms, double expmult, double g
194          tms     -       tone mapping structure pointer.
195          expmult -       the fixed exposure multiplier to use.
196          gamval  -       display gamma response (0. for default).
197 +
198          returns -       0 on success, TM_E_* on error.
199   */
200  
# Line 195 | Line 215 | tmComputeMapping(TMstruct *tms, double gamval, double
215   */
216  
217   extern int
218 < tmMapPixels(TMstruct *tms, BYTE *ps, TMbright *ls, BYTE *cs, int len);
218 > tmMapPixels(TMstruct *tms, uby8 *ps, TMbright *ls, uby8 *cs, int len);
219   /*
220          Apply tone mapping function to pixel values.
221  
# Line 214 | Line 234 | tmDup(TMstruct *orig);
234          Duplicate the given tone mapping into a new struct.
235  
236          orig    -       tone mapping structure to duplicate.
237 +
238          returns -       pointer to new struct, or NULL on error.
239   */
240  
# Line 226 | Line 247 | tmDone(TMstruct *tms);
247   */
248  
249   extern int
250 < tmCvColors(TMstruct *tms, TMbright *ls, BYTE *cs, COLOR *scan, int len);
250 > tmCvGrays(TMstruct *tms, TMbright *ls, float *scan, int len);
251   /*
252 <        Convert RGB/XYZ float scanline to encoded luminance and chrominance.
252 >        Convert gray float scanline to encoded luminance.
253  
254          tms     -       tone mapping structure pointer.
255          ls      -       returned encoded luminance values.
235        cs      -       returned encoded chrominance values (Note 2).
256          scan    -       input scanline.
257          len     -       scanline length.
258  
# Line 240 | Line 260 | tmCvColors(TMstruct *tms, TMbright *ls, BYTE *cs, COLO
260   */
261  
262   extern int
263 < tmCvGrays(TMstruct *tms, TMbright *ls, float *scan, int len);
263 > tmCvColors(TMstruct *tms, TMbright *ls, uby8 *cs, COLOR *scan, int len);
264   /*
265 <        Convert gray float scanline to encoded luminance.
265 >        Convert RGB/XYZ float scanline to encoded luminance and chrominance.
266  
267          tms     -       tone mapping structure pointer.
268          ls      -       returned encoded luminance values.
269 +        cs      -       returned encoded chrominance values (Note 2).
270          scan    -       input scanline.
271          len     -       scanline length.
272  
# Line 253 | Line 274 | tmCvGrays(TMstruct *tms, TMbright *ls, float *scan, in
274   */
275  
276   extern int
277 < tmCvColrs(TMstruct *tms, TMbright *ls, BYTE *cs, COLR *scan, int len);
277 > tmCvColrs(TMstruct *tms, TMbright *ls, uby8 *cs, COLR *scan, int len);
278   /*
279          Convert RGBE/XYZE scanline to encoded luminance and chrominance.
280  
# Line 267 | Line 288 | tmCvColrs(TMstruct *tms, TMbright *ls, BYTE *cs, COLR
288   */
289  
290   extern int
291 < tmLoadPicture(TMstruct *tms, TMbright **lpp, BYTE **cpp, int *xp, int *yp,
291 > tmLoadPicture(TMstruct *tms, TMbright **lpp, uby8 **cpp, int *xp, int *yp,
292                  char *fname, FILE *fp);
293   /*
294          Load Radiance picture and convert to tone mapping representation.
# Line 286 | Line 307 | tmLoadPicture(TMstruct *tms, TMbright **lpp, BYTE **cp
307   */
308  
309   extern int
310 < tmMapPicture(BYTE **psp, int *xp, int *yp, int flags,
310 > tmMapPicture(uby8 **psp, int *xp, int *yp, int flags,
311                  RGBPRIMP monpri, double gamval, double Lddyn, double Ldmax,
312                  char *fname, FILE *fp);
313   /*
# Line 311 | Line 332 | tmMapPicture(BYTE **psp, int *xp, int *yp, int flags,
332   */
333  
334   extern int
335 < tmCvRGB48(TMstruct *tms, TMbright *ls, BYTE *cs, uint16 (*scan)[3],
335 > tmCvRGB48(TMstruct *tms, TMbright *ls, uby8 *cs, uint16 (*scan)[3],
336                  int len, double gv);
337   /*
338          Convert 48-bit RGB scanline to encoded luminance and chrominance.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines