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.7 by gregl, Mon Nov 17 13:54:35 1997 UTC vs.
Revision 3.15 by greg, Mon Jul 14 04:56:54 2003 UTC

# Line 1 | Line 1
1 < /* Copyright (c) 1997 Regents of the University of California */
2 <
3 < /* SCCSid "$SunId$ LBL" */
4 <
1 > /* RCSid $Id$ */
2   /*
3   * Header file for tone mapping functions.
4 + *
5 + * Include after "color.h"
6   */
7 <                                /* required non-system header files */
8 < #include        "color.h"
7 > #ifndef _RAD_TONEMAP_H_
8 > #define _RAD_TONEMAP_H_
9 > #ifdef __cplusplus
10 > extern "C" {
11 > #endif
12  
13 + #include        "tifftypes.h"
14  
15   /****    Argument Macros    ****/
16                                  /* Flags of what to do */
# Line 32 | Line 35
35   #define TM_NOCHROMP     (BYTE **)NULL   /* indicate no chrominances */
36   #define TM_GETFILE      (FILE *)NULL    /* indicate file must be opened */
37  
38 +
39   /****    Error Return Values    ****/
40  
41   #define TM_E_OK         0               /* normal return status */
# Line 48 | Line 52
52  
53   #define TM_BRTSCALE     128             /* brightness scale factor (integer) */
54  
55 + #define TM_NOBRT        (-1<<15)        /* bogus brightness value */
56 + #define TM_NOLUM        (1e-17)         /* ridiculously small luminance */
57 +
58   #define TM_MAXPKG       8               /* maximum number of color formats */
59  
60  
# Line 82 | Line 89 | extern struct tmStruct {
89   }       *tmTop;                 /* current tone mapping stack */
90  
91                                  /* conversion package functions */
85 #ifdef  NOPROTO
92   struct tmPackage {
87        MEM_PTR         (*Init)();      /* initialize private data */
88        void            (*NewSpace)();  /* new input color space (optional) */
89        void            (*Free)();      /* free private data */
90 };
91 #else
92 struct tmPackage {
93          MEM_PTR         (*Init)(struct tmStruct *tms);
94 <        int             (*NewSpace)(struct tmStruct *tms);
94 >        void            (*NewSpace)(struct tmStruct *tms);
95          void            (*Free)(MEM_PTR pp);
96   };
97 #endif
97                                  /* our list of conversion packages */
98   extern struct tmPackage *tmPkg[TM_MAXPKG];
99   extern int      tmNumPkgs;      /* number of registered packages */
# Line 103 | Line 102 | extern int     tmNumPkgs;      /* number of registered packages
102   /****    Useful Macros    ****/
103  
104                                  /* compute luminance from encoded value */
105 < #define tmLuminance(li) exp((li)/(double)TM_BRTSCALE)
105 > #define tmLuminance(li) exp((li)*(1./TM_BRTSCALE))
106  
107                                  /* does tone mapping need color matrix? */
108   #define tmNeedMatrix(t) ((t)->monpri != (t)->inppri)
# Line 118 | Line 117 | extern int     tmNumPkgs;      /* number of registered packages
117  
118   /****    Library Function Calls    ****/
119  
121 #ifdef  NOPROTO
120  
123 extern struct tmStruct  *tmInit(), *tmPop(), *tmDup();
124 extern void     tmClearHisto(), tmDone();
125 extern int      tmSetSpace(), tmCvColors(), tmCvColrs();
126 extern int      tmAddHisto(), tmComputeMapping(), tmMapPixels();
127 extern int      tmLoadPicture(), tmMapPicture(), tmPull(), tmPush();
128
129 #else
130
121   extern struct tmStruct *
122   tmInit(int flags, RGBPRIMP monpri, double gamval);
123   /*
# Line 158 | Line 148 | tmClearHisto(void);
148   */
149  
150   extern int
161 tmCvColors(TMbright *ls, BYTE *cs, COLOR *scan, int len);
162 /*
163        Convert RGB/XYZ float scanline to encoded luminance and chrominance.
164
165        ls      -       returned encoded luminance values.
166        cs      -       returned encoded chrominance values (Note 2).
167        scan    -       input scanline.
168        len     -       scanline length.
169
170        returns -       0 on success, TM_E_* on error.
171 */
172
173 extern int
174 tmCvColrs(TMbright *ls, BYTE *cs, COLR *scan, int len);
175 /*
176        Convert RGBE/XYZE scanline to encoded luminance and chrominance.
177
178        ls      -       returned encoded luminance values.
179        cs      -       returned encoded chrominance values (Note 2).
180        scan    -       input scanline.
181        len     -       scanline length.
182
183        returns -       0 on success, TM_E_* on error.
184 */
185
186 extern int
151   tmAddHisto(TMbright *ls, int len, int wt);
152   /*
153          Add brightness values to current histogram.
# Line 196 | Line 160 | tmAddHisto(TMbright *ls, int len, int wt);
160   */
161  
162   extern int
163 + tmFixedMapping(double expmult, double gamval);
164 + /*
165 +        Assign a fixed, linear tone-mapping using the given multiplier,
166 +        which is the ratio of maximum output to uncalibrated input.
167 +        This mapping will be used in subsequent calls to tmMapPixels()
168 +        until a new tone mapping is computed.
169 +        Only the min. and max. values are used from the histogram.
170 +        
171 +        expmult -       the fixed exposure multiplier to use.
172 +        gamval  -       display gamma response (0. for default).
173 +        returns -       0 on success, TM_E_* on error.
174 + */
175 +
176 + extern int
177   tmComputeMapping(double gamval, double Lddyn, double Ldmax);
178   /*
179 <        Compute tone mapping function.  This mapping will be used
180 <        in subsequent calls to tmMapPixels() until a new tone mapping
181 <        is computed.  I.e., calls to tmAddHisto() have no immediate effect.
179 >        Compute tone mapping function from the current histogram.
180 >        This mapping will be used in subsequent calls to tmMapPixels()
181 >        until a new tone mapping is computed.
182 >        I.e., calls to tmAddHisto() have no immediate effect.
183  
184          gamval  -       display gamma response (0. for default).
185          Lddyn   -       the display's dynamic range (0. for default).
# Line 222 | Line 201 | tmMapPixels(BYTE *ps, TMbright *ls, BYTE *cs, int len)
201          returns -       0 on success, TM_E_* on failure.
202   */
203  
204 + extern struct tmStruct *
205 + tmPop(void);
206 + /*
207 +        Pops current tone mapping from stack.
208 +
209 +        returns -       pointer to tone mapping structure, or NULL if none.
210 + */
211 +
212   extern int
213 + tmPull(struct tmStruct *tms);
214 + /*
215 +        Pull tone mapping from anywhere in stack.
216 +
217 +        tms     -       tone mapping structure to find.
218 +
219 +        returns -       1 if found in stack, 0 otherwise.
220 + */
221 +
222 + extern int
223 + tmPush(struct tmStruct *tms);
224 + /*
225 +        Make tone mapping active by (pulling it and) pushing it to the top.
226 +
227 +        tms     -       initialized tone mapping structure.
228 +
229 +        returns -       0 on success, TM_E_* if tms is invalid.
230 + */
231 +
232 + extern struct tmStruct *
233 + tmDup(void);
234 + /*
235 +        Duplicate the current tone mapping into a new structure on the stack.
236 +
237 +        returns -       pointer to new top, or NULL on error.
238 + */
239 +
240 + extern void
241 + tmDone(struct tmStruct *tms);
242 + /*
243 +        Free data associated with the given tone mapping structure.
244 +        Calls tmPull() first to remove it from the stack if present.
245 +        The calls tmDone(tmPop()), tmDone(tmTop) and tmDone(NULL)
246 +        all have the same effect, which is to remove and free
247 +        the current tone mapping.
248 +
249 +        tms     -       tone mapping structure to free.
250 + */
251 +
252 + extern int
253 + tmCvColors(TMbright *ls, BYTE *cs, COLOR *scan, int len);
254 + /*
255 +        Convert RGB/XYZ float scanline to encoded luminance and chrominance.
256 +
257 +        ls      -       returned encoded luminance values.
258 +        cs      -       returned encoded chrominance values (Note 2).
259 +        scan    -       input scanline.
260 +        len     -       scanline length.
261 +
262 +        returns -       0 on success, TM_E_* on error.
263 + */
264 +
265 + extern int
266 + tmCvGrays(TMbright *ls, float *scan, int len);
267 + /*
268 +        Convert gray float scanline to encoded luminance.
269 +
270 +        ls      -       returned encoded luminance values.
271 +        scan    -       input scanline.
272 +        len     -       scanline length.
273 +
274 +        returns -       0 on success, TM_E_* on error.
275 + */
276 +
277 + extern int
278 + tmCvColrs(TMbright *ls, BYTE *cs, COLR *scan, int len);
279 + /*
280 +        Convert RGBE/XYZE scanline to encoded luminance and chrominance.
281 +
282 +        ls      -       returned encoded luminance values.
283 +        cs      -       returned encoded chrominance values (Note 2).
284 +        scan    -       input scanline.
285 +        len     -       scanline length.
286 +
287 +        returns -       0 on success, TM_E_* on error.
288 + */
289 +
290 + extern int
291   tmLoadPicture(TMbright **lpp, BYTE **cpp, int *xp, int *yp,
292                  char *fname, FILE *fp);
293   /*
# Line 231 | Line 296 | tmLoadPicture(TMbright **lpp, BYTE **cpp, int *xp, int
296          malloc(3), and should be freed with free(3) when no longer needed.
297          Calls tmSetSpace() to calibrate input color space.
298  
299 <        lpp     -       returned array of encoded luminances, English ordering.
299 >        lpp     -       returned array of encoded luminances, picture ordering.
300          cpp     -       returned array of encoded chrominances (Note 2).
301          xp, yp  -       returned picture dimensions.
302          fname   -       picture file name.
# Line 253 | Line 318 | tmMapPicture(BYTE **psp, int *xp, int *yp, int flags,
318          Memory for the final pixel array is allocated using malloc(3),
319          and should be freed with free(3) when it is no longer needed.
320  
321 <        psp     -       returned array of tone mapped pixels, English ordering.
321 >        psp     -       returned array of tone mapped pixels, picture ordering.
322          xp, yp  -       returned picture dimensions.
323          flags   -       TM_F_* flags indicating what is to be done.
324          monpri  -       display monitor primaries (Note 1).
# Line 266 | Line 331 | tmMapPicture(BYTE **psp, int *xp, int *yp, int flags,
331          returns -       0 on success, TM_E_* on failure.
332   */
333  
269 extern struct tmStruct *
270 tmPop(void);
271 /*
272        Pops current tone mapping from stack.
273
274        returns -       pointer to tone mapping structure, or NULL if none.
275 */
276
334   extern int
335 < tmPull(struct tmStruct *tms);
335 > tmCvRGB48(TMbright *ls, BYTE *cs, uint16 (*scan)[3], int len, double gv);
336   /*
337 <        Pull tone mapping from anywhere in stack.
337 >        Convert 48-bit RGB scanline to encoded luminance and chrominance.
338  
339 <        tms     -       tone mapping structure to find.
339 >        ls      -       returned encoded luminance values.
340 >        cs      -       returned encoded chrominance values (Note 2).
341 >        scan    -       input scanline.
342 >        len     -       scanline length.
343 >        gv      -       input gamma value.
344  
345 <        returns -       1 if found in stack, 0 otherwise.
345 >        returns -       0 on success, TM_E_* on error.
346   */
347  
348   extern int
349 < tmPush(struct tmStruct *tms);
349 > tmCvGray16(TMbright *ls, uint16 *scan, int len, double gv);
350   /*
351 <        Make tone mapping active by (pulling it and) pushing it to the top.
351 >        Convert 16-bit gray scanline to encoded luminance.
352  
353 <        tms     -       initialized tone mapping structure.
353 >        ls      -       returned encoded luminance values.
354 >        scan    -       input scanline.
355 >        len     -       scanline length.
356 >        gv      -       input gamma value.
357  
358 <        returns -       0 on success, TM_E_* if tms is invalid.
358 >        returns -       0 on success, TM_E_* on error.
359   */
360  
297 extern struct tmStruct *
298 tmDup(void);
299 /*
300        Duplicate the current tone mapping into a new structure on the stack.
301
302        returns -       pointer to new top, or NULL on error.
303 */
304
305 extern void
306 tmDone(struct tmStruct *tms);
307 /*
308        Free data associated with the given tone mapping structure.
309        Calls tmPull() first to remove it from the stack if present.
310        The calls tmDone(tmPop()), tmDone(tmTop) and tmDone(NULL)
311        all have the same effect, which is to remove and free
312        the current tone mapping.
313
314        tms     -       tone mapping structure to free.
315 */
316
317 #endif
318
319
361   /****    Notes    ****/
362   /*
363          General:
# Line 387 | Line 428 | tmDone(struct tmStruct *tms);
428          function will open the file, read its contents and close it
429          before returning, whether or not an error was encountered.
430   */
431 +
432 + #ifdef __cplusplus
433 + }
434 + #endif
435 + #endif /* _RAD_TONEMAP_H_ */
436 +

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines