1 |
< |
/* Copyright (c) 1997 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1998 Silicon Graphics, Inc. */ |
2 |
|
|
3 |
< |
/* SCCSid "$SunId$ LBL" */ |
3 |
> |
/* SCCSid "$SunId$ SGI" */ |
4 |
|
|
5 |
|
/* |
6 |
|
* Header file for tone mapping functions. |
7 |
+ |
* |
8 |
+ |
* Include after "color.h" |
9 |
|
*/ |
8 |
– |
/* required non-system header files */ |
9 |
– |
#include "color.h" |
10 |
|
|
11 |
|
|
12 |
|
/**** Argument Macros ****/ |
32 |
|
#define TM_NOCHROMP (BYTE **)NULL /* indicate no chrominances */ |
33 |
|
#define TM_GETFILE (FILE *)NULL /* indicate file must be opened */ |
34 |
|
|
35 |
+ |
|
36 |
|
/**** Error Return Values ****/ |
37 |
|
|
38 |
|
#define TM_E_OK 0 /* normal return status */ |
49 |
|
|
50 |
|
#define TM_BRTSCALE 128 /* brightness scale factor (integer) */ |
51 |
|
|
52 |
+ |
#define TM_NOBRT (-1<<15) /* bogus brightness value */ |
53 |
+ |
|
54 |
|
#define TM_MAXPKG 8 /* maximum number of color formats */ |
55 |
|
|
56 |
|
|
61 |
|
#endif |
62 |
|
|
63 |
|
extern char *tmErrorMessage[]; /* error messages */ |
64 |
+ |
extern int tmLastError; /* last error incurred by library */ |
65 |
+ |
extern char *tmLastFunction; /* error-generating function name */ |
66 |
|
|
67 |
|
typedef short TMbright; /* encoded luminance type */ |
68 |
|
|
76 |
|
RGBPRIMP inppri; /* current input primaries */ |
77 |
|
double inpsf; /* current input scalefactor */ |
78 |
|
COLORMAT cmat; /* color conversion matrix */ |
79 |
< |
TMbright brmin, brmax; /* input brightness limits */ |
79 |
> |
TMbright hbrmin, hbrmax; /* histogram brightness limits */ |
80 |
|
int *histo; /* input histogram */ |
81 |
+ |
TMbright mbrmin, mbrmax; /* mapped brightness limits */ |
82 |
|
unsigned short *lumap; /* computed luminance map */ |
83 |
|
struct tmStruct *tmprev; /* previous tone mapping */ |
84 |
|
MEM_PTR pd[TM_MAXPKG]; /* pointers to private data */ |
201 |
|
extern int |
202 |
|
tmComputeMapping(double gamval, double Lddyn, double Ldmax); |
203 |
|
/* |
204 |
< |
Compute tone mapping function. |
204 |
> |
Compute tone mapping function. This mapping will be used |
205 |
> |
in subsequent calls to tmMapPixels() until a new tone mapping |
206 |
> |
is computed. I.e., calls to tmAddHisto() have no immediate effect. |
207 |
|
|
208 |
|
gamval - display gamma response (0. for default). |
209 |
|
Lddyn - the display's dynamic range (0. for default). |
230 |
|
char *fname, FILE *fp); |
231 |
|
/* |
232 |
|
Load Radiance picture and convert to tone mapping representation. |
233 |
+ |
Memory for the luminance and chroma arrays is allocated using |
234 |
+ |
malloc(3), and should be freed with free(3) when no longer needed. |
235 |
|
Calls tmSetSpace() to calibrate input color space. |
236 |
|
|
237 |
< |
lpp - returned array of encoded luminances, English ordering. |
237 |
> |
lpp - returned array of encoded luminances, picture ordering. |
238 |
|
cpp - returned array of encoded chrominances (Note 2). |
239 |
|
xp, yp - returned picture dimensions. |
240 |
|
fname - picture file name. |
253 |
|
If fp is TM_GETFILE and (flags&TM_F_UNIMPL)!=0, tmMapPicture() |
254 |
|
calls pcond to perform the actual conversion, which takes |
255 |
|
longer but gives access to all the TM_F_* features. |
256 |
+ |
Memory for the final pixel array is allocated using malloc(3), |
257 |
+ |
and should be freed with free(3) when it is no longer needed. |
258 |
|
|
259 |
< |
psp - returned array of tone mapped pixels, English ordering. |
259 |
> |
psp - returned array of tone mapped pixels, picture ordering. |
260 |
|
xp, yp - returned picture dimensions. |
261 |
|
flags - TM_F_* flags indicating what is to be done. |
262 |
|
monpri - display monitor primaries (Note 1). |
328 |
|
pixel values to chroma and luminance encodings, which can |
329 |
|
be passed to tmAddHisto() to put into the tone mapping histogram. |
330 |
|
This histogram is then used along with the display parameters |
331 |
< |
by tmComputMapping() to compute the luminance mapping function. |
331 |
> |
by tmComputeMapping() to compute the luminance mapping function. |
332 |
|
(Colors are tone-mapped as they are converted if TM_F_MESOPIC |
333 |
|
is set.) The encoded chroma and luminance values may then be |
334 |
|
passed to tmMapPixels() to apply the computed tone mapping in |