00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TIL_DEFINES_H
00020 #define TIL_DEFINES_H
00021
00022 #include "TIL_API.h"
00023 #include <limits.h>
00024 #include <SYS/SYS_Types.h>
00025 #include <SYS/SYS_Math.h>
00026 #include <UT/UT_SysClone.h>
00027 #include <IMG/IMG_FileTypes.h>
00028 #include <UT/UT_Lock.h>
00029 #include <PXL/PXL_Common.h>
00030
00031 #define TIL_Lookup PXL_Lookup
00032 #define TIL_Fill PXL_Fill
00033 #define TIL_FillParms PXL_FillParms
00034 #define TIL_Pixel PXL_Pixel
00035 #define TIL_Convert PXL_Convert
00036
00037 class UT_String;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 #ifdef WIN32
00054 #define TIL_MAX_THREADS 8
00055 #else
00056 #define TIL_MAX_THREADS 32
00057 #endif
00058
00059 #ifdef CELLBE
00060 #define TIL_DEFAULT_TILE_SIZE 640
00061 #else
00062 #define TIL_DEFAULT_TILE_SIZE 200
00063 #endif
00064
00065 #define TIL_DEFAULT_INT8_SIZE (TIL_DEFAULT_TILE_SIZE*TIL_DEFAULT_TILE_SIZE)
00066 #define TIL_DEFAULT_INT16_SIZE (TIL_DEFAULT_INT8_SIZE * 2)
00067 #define TIL_DEFAULT_FLOAT32_SIZE (TIL_DEFAULT_INT8_SIZE * 4)
00068
00069
00070 #define TILE_LOCK_WRITE 0
00071 #define TILE_LOCK_READ_ONLY 1
00072
00073
00074 #ifdef WIN32
00075 #include <UT/UT_SpinLock.h>
00076 typedef UT_RecursiveSpinLock TIL_FastLock;
00077 #else
00078 typedef UT_Lock TIL_FastLock;
00079 #endif
00080
00081
00082
00083
00084
00085
00086
00087
00088 #define TIL_DataFormat PXL_DataFormat
00089 #define TILE_INT8 PXL_INT8
00090 #define TILE_INT16 PXL_INT16
00091 #define TILE_INT32 PXL_INT32
00092 #define TILE_FLOAT32 PXL_FLOAT32
00093 #define TILE_FLOAT16 PXL_FLOAT16
00094 #define TILE_MAX_DATA_FORMAT PXL_MAX_DATA_FORMAT
00095
00096 #define TIL_Packing PXL_Packing
00097
00098 enum TIL_Interlace
00099 {
00100 INTERLACE_OFF = 0,
00101 INTERLACE_HALF = 1,
00102 INTERLACE_BLACK = 2,
00103 INTERLACE_DOUBLE = 3
00104 };
00105
00106 enum TIL_Dominance
00107 {
00108 ODD_DOMINANT = 0,
00109 EVEN_DOMINANT = 1,
00110 ODD_ONLY = 2,
00111 EVEN_ONLY = 3
00112 };
00113
00114
00115
00116 enum TIL_Extend
00117 {
00118 EXTEND_BLACK = 0,
00119 EXTEND_CYCLE,
00120 EXTEND_MIRROR,
00121 EXTEND_HOLD_FOREVER,
00122 EXTEND_HOLD
00123 };
00124
00125 enum TIL_Storage
00126 {
00127 STORE_CACHE = 0,
00128 STORE_NO_CACHE,
00129 STORE_LOCKED,
00130 STORE_PROXY,
00131 STORE_NEVER
00132 };
00133
00134 enum TIL_HistogramType
00135 {
00136 TIL_RAW_HISTOGRAM = 0,
00137 TIL_HUE_HISTOGRAM,
00138 TIL_SAT_HISTOGRAM,
00139 TIL_LUM_HISTOGRAM,
00140 TIL_RAW_VS_U,
00141 TIL_RAW_VS_V,
00142 TIL_HUE_VS_U,
00143 TIL_HUE_VS_V,
00144 TIL_SAT_VS_U,
00145 TIL_SAT_VS_V,
00146 TIL_LUM_VS_U,
00147 TIL_LUM_VS_V,
00148 TIL_HUE_VS_SAT,
00149 TIL_HUE_VS_LUM
00150 };
00151
00152 enum TIL_ViewerType
00153 {
00154 TIL_VIEW_2D = 0,
00155 TIL_VIEW_TIME,
00156 TIL_VIEW_GRAPH_RAWHIST,
00157 TIL_VIEW_GRAPH_HUEHIST,
00158 TIL_VIEW_GRAPH_SATHIST,
00159 TIL_VIEW_GRAPH_LUMHIST,
00160 TIL_VIEW_GRAPH_CURVES,
00161 TIL_VIEW_GRAPH_RAW_VS_U,
00162 TIL_VIEW_GRAPH_RAW_VS_V,
00163 TIL_VIEW_GRAPH_HUE_VS_U,
00164 TIL_VIEW_GRAPH_HUE_VS_V,
00165 TIL_VIEW_GRAPH_SAT_VS_U,
00166 TIL_VIEW_GRAPH_SAT_VS_V,
00167 TIL_VIEW_GRAPH_LUM_VS_U,
00168 TIL_VIEW_GRAPH_LUM_VS_V,
00169 TIL_VIEW_GRAPH_HUE_VS_SAT,
00170 TIL_VIEW_GRAPH_HUE_VS_LUM
00171 };
00172
00173 #define TILE_WHITE_8 UCHAR_MAX
00174 #define TILE_WHITE_16 USHRT_MAX
00175 #define TILE_WHITE_32 UINT_MAX
00176
00177 #define TILE_CACHE_MANAGER_MAX_LOCKS 4096
00178
00179 #define PLANE_MAX_ARRAY_SIZE 4096
00180 #define PLANE_MAX_VECTOR_SIZE 4
00181
00182 #define PROXY_TABLE_SIZE 309
00183 #define POOL_TABLE_SIZE 509
00184
00185
00186
00187
00188
00189 #define FOR_EACH_TILE(list,tile, i) \
00190 for(i=0, tile=list->myItems[0]; i<PLANE_MAX_VECTOR_SIZE; \
00191 i++, tile=list->myItems[SYSmin(i, PLANE_MAX_VECTOR_SIZE-1)])\
00192 if(tile)
00193
00194 #define GET_TILE(list,tile,i) \
00195 for(tile=0, i=0, tile=list->myItems[0]; i<PLANE_MAX_VECTOR_SIZE; \
00196 i++, tile=list->myItems[SYSmin(i, PLANE_MAX_VECTOR_SIZE-1)]) \
00197 if(tile) break;
00198
00199 #define GET_UNCOOKED_TILE(list,tile,i) \
00200 for(tile=0, i=0, tile=list->myItems[0]; \
00201 i<PLANE_MAX_VECTOR_SIZE; \
00202 i++, tile=list->myItems[SYSmin(i, PLANE_MAX_VECTOR_SIZE-1)])\
00203 if(tile && !tile->isCooked()) break;
00204
00205 #define FOR_EACH_UNCOOKED_TILE(list,tile,i) \
00206 for(i=0, tile=list->myItems[0]; i<PLANE_MAX_VECTOR_SIZE; \
00207 i++, tile=list->myItems[SYSmin(i, PLANE_MAX_VECTOR_SIZE-1)])\
00208 if(tile && !tile->isCooked())
00209
00210 #define FOR_EACH_UNCOOKED_PAIR(outlist, inlist, out, in, i) \
00211 for(i=0, out=outlist->myItems[0], in=inlist->myItems[0]; \
00212 i<PLANE_MAX_VECTOR_SIZE; \
00213 i++, out=outlist->myItems[SYSmin(i,PLANE_MAX_VECTOR_SIZE-1)],\
00214 in=inlist->myItems[SYSmin(i, PLANE_MAX_VECTOR_SIZE-1)]) \
00215 if(out && in && !out->isCooked())
00216
00217
00218 #define TILE_INPUT1(list,a) { \
00219 a = list->myItems[0]; }
00220
00221 #define TILE_INPUT2(list,a,b) { \
00222 a = list->myItems[0]; \
00223 b = list->myItems[1]; }
00224
00225 #define TILE_INPUT3(list,a,b,c) { \
00226 a = list->myItems[0]; \
00227 b = list->myItems[1]; \
00228 c = list->myItems[2]; }
00229
00230 #define TILE_INPUT4(list,a,b,c,d) { \
00231 a = list->myItems[0]; \
00232 b = list->myItems[1]; \
00233 c = list->myItems[2]; \
00234 d = list->myItems[3]; }
00235
00236
00237
00238 #define TILE_SCALAR(list,a) { \
00239 a = list->myItems[0]; \
00240 if(a && a->isCooked()) a = 0; \
00241 }
00242
00243 #define TILE_VECTOR2(list,a,b) { \
00244 a = list->myItems[0]; \
00245 b = list->myItems[1]; \
00246 if(a && a->isCooked()) a = 0; \
00247 if(b && b->isCooked()) b = 0; \
00248 }
00249
00250 #define TILE_VECTOR3(list,a,b,c) { \
00251 a = list->myItems[0]; \
00252 b = list->myItems[1]; \
00253 c = list->myItems[2]; \
00254 if(a && a->isCooked()) a = 0; \
00255 if(b && b->isCooked()) b = 0; \
00256 if(c && c->isCooked()) c = 0; \
00257 }
00258
00259 #define TILE_VECTOR4(list,a,b,c,d){ \
00260 a = list->myItems[0]; \
00261 b = list->myItems[1]; \
00262 c = list->myItems[2]; \
00263 d = list->myItems[3]; \
00264 if(a && a->isCooked()) a = 0; \
00265 if(b && b->isCooked()) b = 0; \
00266 if(c && c->isCooked()) c = 0; \
00267 if(d && d->isCooked()) d = 0; \
00268 }
00269
00270
00271
00272 #ifdef TIL_DEBUG_LOCK_BLOCKING
00273 #define TIL_LOCK(loc) TILlock(loc, __FILE__ ":", __LINE__)
00274 #define TIL_UNLOCK(loc) loc.unlock()
00275 #define TILwait(n) TILwaitF(n, __FILE__ ":", __LINE__)
00276 #else
00277 #define TIL_LOCK(loc) loc.lockLW()
00278 #define TIL_UNLOCK(loc) loc.unlock()
00279 #define TILwait(n) TILwaitF(n)
00280 #endif
00281
00282 inline int TILformatDepth(PXL_DataFormat d)
00283 { return PXLformatDepth(d); }
00284
00285 inline int TILpackingComponents(PXL_Packing p)
00286 { return PXLpackingComponents(p); }
00287
00288 inline int TILpackingDepth(PXL_Packing p)
00289 { return PXLpackingDepth(p); }
00290
00291 inline unsigned int TILwhitePoint(PXL_DataFormat dt)
00292 { return PXLwhitePoint(dt); }
00293
00294
00295 TIL_API TIL_DataFormat TILformatConvert(IMG_DataType);
00296 TIL_API IMG_DataType TILformatConvert(TIL_DataFormat);
00297 TIL_API void TILparsePlaneName(const char *name, UT_String &pname,
00298 int &arrayindex);
00299 TIL_API void TILgetBWPoints(TIL_DataFormat d, float b, float w,
00300 unsigned &ib, unsigned &iw, bool &fast);
00301 TIL_API void TILgetFloatBWPoints(TIL_DataFormat d,
00302 unsigned ib, unsigned iw,
00303 float &b, float &w);
00304 TIL_API void TILgetBestFormat(TIL_DataFormat d1, float b1, float w1,
00305 TIL_DataFormat d2, float b2, float w2,
00306 TIL_DataFormat &best,
00307 float &black, float &white);
00308
00309
00310 TIL_API void TILlock(UT_Lock &lock,const char *file=0, int line=0);
00311 TIL_API void TILprintLockBlockStats();
00312 TIL_API void TILclearTotalWait();
00313 TIL_API void TILwaitF(int n, const char *file=0, int line=0);
00314 TIL_API double TILgetTotalWait();
00315
00316
00317
00318 TIL_API bool TILcopyOrRefPlaneName(const char *&dname,
00319 const char *name);
00320 TIL_API bool TILcopyOrRefCompName(const char *&dname,
00321 const char *name);
00322 TIL_API void TILinitNameRefs();
00323
00324
00325
00326 TIL_API bool TILcheckConstant(void *idata, TIL_DataFormat format,
00327 int xres,int yres);
00328
00329 TIL_API bool TILemulationNeeded(int comp, float b, float w,
00330 float sc, float sh, float gamma,
00331 const char *lut, float aspect,
00332 TIL_DataFormat type,
00333 bool use8bit, bool hard_accel,
00334 bool hardlut, bool frag_shader);
00335
00336
00337 class TIL_API til_AlignedBlock
00338 {
00339 public:
00340
00341
00342
00343 static til_AlignedBlock *allocBlock(int size, int alignment);
00344
00345
00346
00347
00348 static til_AlignedBlock *allocBlock(void *aligned);
00349
00350 static void freeBlock(til_AlignedBlock *&block);
00351
00352 operator void *() { return myAligned; }
00353 operator const void *() { return myAligned; }
00354
00355 private:
00356 til_AlignedBlock();
00357 ~til_AlignedBlock();
00358
00359 void reset();
00360
00361
00362
00363
00364
00365
00366 void *myReal;
00367 union {
00368 void *myAligned;
00369 til_AlignedBlock *myNext;
00370 };
00371 };
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385 #endif // TIL_DEFINES_H