Back to index

radiance  4R0+20100331
tmprivat.h
Go to the documentation of this file.
00001 /* RCSid $Id: tmprivat.h,v 3.19 2009/02/09 20:48:08 greg Exp $ */
00002 /*
00003  * Private header file for tone mapping routines.
00004  */
00005 #ifndef _RAD_TMPRIVAT_H_
00006 #define _RAD_TMPRIVAT_H_
00007 
00008 #ifndef       MEM_PTR
00009 #define       MEM_PTR              void *
00010 #endif
00011 #include      "color.h"
00012 #include      "tonemap.h"
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018                             /* required constants */
00019 #ifndef M_LN2
00020 #define M_LN2        0.69314718055994530942
00021 #endif
00022 #ifndef M_LN10
00023 #define M_LN10              2.30258509299404568402
00024 #endif
00025                             /* minimum values and defaults */
00026 #define       MINGAM        0.75
00027 #define DEFGAM              2.2
00028 #define       MINLDDYN      2.
00029 #define DEFLDDYN     32.
00030 #define       MINLDMAX      1.
00031 #define       DEFLDMAX      100.
00032 
00033 #define BRT2SCALE(l2)       (int)(M_LN2*TM_BRTSCALE*(l2) + ((l2)>0 ? .5 : -.5))
00034 
00035 #define HISTEP              8             /* steps in BRTSCALE for each bin */
00036 
00037 #define MINBRT              (-16*TM_BRTSCALE)    /* minimum usable brightness */
00038 #define MINLUM              (1.125352e-7)        /* tmLuminance(MINBRT) */
00039 
00040 #define HISTI(li)    (((li)-MINBRT)/HISTEP)
00041 #define HISTV(i)     (MINBRT + HISTEP/2 + (i)*HISTEP)
00042 
00043 #define LMESLOWER    (5.62e-3)            /* lower mesopic limit */
00044 #define       LMESUPPER     (5.62)               /* upper mesopic limit */
00045 #if    (TM_BRTSCALE==128)
00046 #define BMESLOWER    (-663)               /* encoded LMESLOWER */
00047 #define BMESUPPER    (221)                /* encoded LMESUPPER */
00048 #else
00049 #define BMESLOWER    ((int)(-5.18*TM_BRTSCALE-.5))
00050 #define BMESUPPER    ((int)(1.73*TM_BRTSCALE+.5))
00051 #endif
00052                                           /* approximate scotopic lum. */
00053 #define       SCO_rf        0.062
00054 #define SCO_gf              0.608
00055 #define SCO_bf              0.330
00056 #define scotlum(c)   (SCO_rf*(c)[RED] + SCO_gf*(c)[GRN] + SCO_bf*(c)[BLU])
00057 #define normscot(c)  ( (    (int32)(SCO_rf*256.+.5)*(c)[RED] + \
00058                             (int32)(SCO_gf*256.+.5)*(c)[GRN] + \
00059                             (int32)(SCO_bf*256.+.5)*(c)[BLU]   ) >> 8 )
00060 
00061 extern int    tmNewMap(TMstruct *tms);    /* allocate new tone-mapping */
00062 
00063 extern int    tmErrorReturn(const char *, TMstruct *, int);
00064 
00065                                           /* lookup for mesopic scaling */
00066 extern BYTE   tmMesofact[BMESUPPER-BMESLOWER];
00067 
00068 extern void   tmMkMesofact(void);                /* build tmMesofact */
00069 
00070 #define       returnErr(code)      return(tmErrorReturn(funcName,tms,code))
00071 #define returnOK     return(TM_E_OK)
00072 
00073 #define       FEQ(a,b)      ((a) < (b)+1e-5 && (b) < (a)+1e-5)
00074 
00075 #define       PRIMEQ(p1,p2) (FEQ((p1)[0][0],(p2)[0][0])&&FEQ((p1)[0][1],(p2)[0][1])\
00076                      &&FEQ((p1)[1][0],(p2)[1][0])&&FEQ((p1)[1][1],(p2)[1][1])\
00077                      &&FEQ((p1)[2][0],(p2)[2][0])&&FEQ((p1)[2][1],(p2)[2][1])\
00078                      &&FEQ((p1)[3][0],(p2)[3][0])&&FEQ((p1)[3][1],(p2)[3][1]))
00079 
00080 #ifdef __cplusplus
00081 }
00082 #endif
00083 #endif /* _RAD_TMPRIVAT_H_ */
00084