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.2 by greg, Tue Apr 15 20:04:41 1997 UTC vs.
Revision 3.4 by greg, Fri Apr 18 13:59:48 1997 UTC

# Line 8 | Line 8
8                                  /* required non-system header files */
9   #include        "color.h"
10  
11 +
12   /****    Argument Macros    ****/
13                                  /* Flags of what to do */
14   #define TM_F_HCONTR     01              /* human contrast sensitivity */
# Line 39 | Line 40
40   #define TM_E_TMINVAL    3               /* no valid tone mapping */
41   #define TM_E_TMFAIL     4               /* cannot compute tone mapping */
42   #define TM_E_BADFILE    5               /* cannot open or understand file */
43 + #define TM_E_CODERR1    6               /* code consistency error 1 */
44 + #define TM_E_CODERR2    7               /* code consistency error 2 */
45  
46 +
47   /****    Conversion Constants and Table Sizes    ****/
48  
49   #define TM_BRTSCALE     128             /* brightness scale factor (integer) */
50  
51 < #define TM_GAMTSZ       1024            /* gamma lookup table size */
51 > #define TM_MAXPKG       8               /* maximum number of color formats */
52  
49 /****    Global Data Structures    ****/
53  
54 + /****    Global Data Types and Structures    ****/
55 +
56 + #ifndef MEM_PTR
57 + #define MEM_PTR         void *
58 + #endif
59 +
60   extern char     *tmErrorMessage[];      /* error messages */
61  
62   typedef short   TMbright;               /* encoded luminance type */
# Line 57 | Line 66 | extern struct tmStruct {
66          int             flags;          /* flags of what to do */
67          RGBPRIMP        monpri;         /* monitor RGB primaries */
68          double          mongam;         /* monitor gamma value (approx.) */
60        BYTE            gamb[TM_GAMTSZ];/* gamma lookup table from mongam */
69          COLOR           clf;            /* computed luminance coefficients */
70 <        COLR            clfb;           /* normalized version of clf */
70 >        int             cdiv[3];        /* computed color divisors */
71          RGBPRIMP        inppri;         /* current input primaries */
72          double          inpsf;          /* current input scalefactor */
65        TMbright        inpsfb;         /* encoded version of inpsf */
73          COLORMAT        cmat;           /* color conversion matrix */
74          TMbright        brmin, brmax;   /* input brightness limits */  
75          int             *histo;         /* input histogram */
76          unsigned short  *lumap;         /* computed luminance map */
77          struct tmStruct *tmprev;        /* previous tone mapping */
78 +        MEM_PTR         pd[TM_MAXPKG];  /* pointers to private data */
79   }       *tmTop;                 /* current tone mapping stack */
80 <
80 >
81 >                                /* conversion package functions */
82 > #ifdef  NOPROTO
83 > struct tmPackage {
84 >        MEM_PTR         (*Init)();      /* initialize private data */
85 >        void            (*NewSpace)();  /* new input color space (optional) */
86 >        void            (*Free)();      /* free private data */
87 > };
88 > #else
89 > struct tmPackage {
90 >        MEM_PTR         (*Init)(struct tmStruct *tms);
91 >        int             (*NewSpace)(struct tmStruct *tms);
92 >        void            (*Free)(MEM_PTR pp);
93 > };
94 > #endif
95 >                                /* our list of conversion packages */
96 > extern struct tmPackage *tmPkg[TM_MAXPKG];
97 > extern int      tmNumPkgs;      /* number of registered packages */
98 >
99 >
100   /****    Useful Macros    ****/
101  
102 +                                /* compute luminance from encoded value */
103   #define tmLuminance(li) exp((li)/(double)TM_BRTSCALE)
104  
105 +                                /* does tone mapping need color matrix? */
106 + #define tmNeedMatrix(t) ((t)->monpri != (t)->inppri)
107 +
108 +                                /* register a conversion package */
109 + #define tmRegPkg(pf)    ( tmNumPkgs >= TM_MAXPKG ? -1 : \
110 +                                (tmPkg[tmNumPkgs] = (pf), tmNumPkgs++) )
111 +
112 +                                /* get the specific package's data */
113 + #define tmPkgData(t,i)  ((t)->pd[i]!=NULL ? (t)->pd[i] : (*tmPkg[i]->Init)(t))
114 +
115 +
116   /****    Library Function Calls    ****/
117  
118 < #ifdef NOPROTO
118 > #ifdef  NOPROTO
119  
120 < extern struct tmStruct  *tmInit(), *tmPop();
120 > extern struct tmStruct  *tmInit(), *tmPop(), *tmDup();
121   extern void     tmClearHisto(), tmDone();
122   extern int      tmSetSpace(), tmCvColors(), tmCvColrs();
123   extern int      tmAddHisto(), tmComputeMapping(), tmMapPixels();
# Line 183 | Line 222 | tmLoadPicture(TMbright **lpp, BYTE **cpp, int *xp, int
222                  char *fname, FILE *fp);
223   /*
224          Load Radiance picture and convert to tone mapping representation.
225 +        Calls tmSetSpace() to calibrate input color space.
226  
227          lpp     -       returned array of encoded luminances, English ordering.
228          cpp     -       returned array of encoded chrominances (Note 2).
# Line 245 | Line 285 | tmPush(struct tmStruct *tms);
285          returns -       0 on success, TM_E_* if tms is invalid.
286   */
287  
288 + extern struct tmStruct *
289 + tmDup(void);
290 + /*
291 +        Duplicate the current tone mapping into a new structure on the stack.
292 +
293 +        returns -       pointer to new top, or NULL on error.
294 + */
295 +
296   extern void
297   tmDone(struct tmStruct *tms);
298   /*
# Line 258 | Line 306 | tmDone(struct tmStruct *tms);
306   */
307  
308   #endif
309 <
309 >
310 >
311   /****    Notes    ****/
312   /*
313          General:
# Line 280 | Line 329 | tmDone(struct tmStruct *tms);
329          used during final mapping, setting the cs parameter to TM_NOCHROM
330          on the first pass will save time.)  Another memory saving option
331          if third and subsequent passes are not needed is to use the
332 <        same array to store the mapped pixels as is used to store
332 >        same array to store the mapped pixels as used to store
333          the encoded chroma values.  This way, only two extra bytes
334          for storing encoded luminances are required per pixel.  This
335          is the method employed by tmMapPicture(), for example.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines