1 | |
---|
2 | |
---|
3 | /** \file CommonDef.h |
---|
4 | \brief Defines constants, macros and tool parameters |
---|
5 | */ |
---|
6 | |
---|
7 | #ifndef __COMMONDEF__ |
---|
8 | #define __COMMONDEF__ |
---|
9 | |
---|
10 | // this pragma can be used for turning off "signed and unsigned mismatch" |
---|
11 | #if _MSC_VER > 1000 |
---|
12 | #pragma warning( disable : 4018 ) |
---|
13 | #endif // _MSC_VER > 1000 |
---|
14 | #include "TypeDef.h" |
---|
15 | #include "TComRom.h" |
---|
16 | |
---|
17 | // SB |
---|
18 | #include <string> |
---|
19 | #include <assert.h> |
---|
20 | #include <stdlib.h> |
---|
21 | #include <vector> |
---|
22 | |
---|
23 | // ==================================================================================================================== |
---|
24 | // Version information |
---|
25 | // ==================================================================================================================== |
---|
26 | |
---|
27 | #define HM_VERSION "3.0rc2" ///< Current software version |
---|
28 | #define NV_VERSION "0.31r4" ///< Current software version |
---|
29 | |
---|
30 | // ==================================================================================================================== |
---|
31 | // Platform information |
---|
32 | // ==================================================================================================================== |
---|
33 | |
---|
34 | #ifdef __GNUC__ |
---|
35 | #define NVM_COMPILEDBY "[GCC %d.%d.%d]", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ |
---|
36 | #ifdef __IA64__ |
---|
37 | #define NVM_ONARCH "[on 64-bit] " |
---|
38 | #else |
---|
39 | #define NVM_ONARCH "[on 32-bit] " |
---|
40 | #endif |
---|
41 | #endif |
---|
42 | |
---|
43 | #ifdef __INTEL_COMPILER |
---|
44 | #define NVM_COMPILEDBY "[ICC %d]", __INTEL_COMPILER |
---|
45 | #elif _MSC_VER |
---|
46 | #define NVM_COMPILEDBY "[VS %d]", _MSC_VER |
---|
47 | #endif |
---|
48 | |
---|
49 | #ifndef NVM_COMPILEDBY |
---|
50 | #define NVM_COMPILEDBY "[Unk-CXX]" |
---|
51 | #endif |
---|
52 | |
---|
53 | #ifdef _WIN32 |
---|
54 | #define NVM_ONOS "[Windows]" |
---|
55 | #elif __linux |
---|
56 | #define NVM_ONOS "[Linux]" |
---|
57 | #elif __CYGWIN__ |
---|
58 | #define NVM_ONOS "[Cygwin]" |
---|
59 | #elif __APPLE__ |
---|
60 | #define NVM_ONOS "[Mac OS X]" |
---|
61 | #else |
---|
62 | #define NVM_ONOS "[Unk-OS]" |
---|
63 | #endif |
---|
64 | |
---|
65 | #define NVM_BITS "[%d bit] ", (sizeof(void*) == 8 ? 64 : 32) ///< used for checking 64-bit O/S |
---|
66 | |
---|
67 | #ifndef NULL |
---|
68 | #define NULL 0 |
---|
69 | #endif |
---|
70 | |
---|
71 | |
---|
72 | #define SEBASTIAN 1 |
---|
73 | #if SEBASTIAN |
---|
74 | #define SB_INTERVIEW_SKIP 1 |
---|
75 | #define SB_INTERVIEW_SKIP_LAMBDA_SCALE 1 |
---|
76 | #define SB_MEM_FIX 1 |
---|
77 | #define SB_NO_LowDelayCoding 0 // noch offen in motionestimation |
---|
78 | #endif |
---|
79 | |
---|
80 | #define GERHARD 1 |
---|
81 | #if GERHARD |
---|
82 | #define GERHARD_VQM_XCHECK 0 |
---|
83 | #define GERHARD_RM_DEBUG_MM 0 |
---|
84 | #define GERHARD_RM_HOLE_EXT 0 |
---|
85 | #define GERHARD_RM_COLOR_PLANES 1 |
---|
86 | #define GERHARD_RM_SPLAT 1 |
---|
87 | #endif |
---|
88 | |
---|
89 | |
---|
90 | // ==================================================================================================================== |
---|
91 | // Common constants |
---|
92 | // ==================================================================================================================== |
---|
93 | |
---|
94 | #define _SUMMARY_OUT_ 0 ///< print-out PSNR results of all slices to summary.txt |
---|
95 | #define _SUMMARY_PIC_ 0 ///< print-out PSNR results for each slice type to summary.txt |
---|
96 | |
---|
97 | #define MAX_REF_PIC_NUM 64 |
---|
98 | #define MAX_GOP 64 ///< max. value of hierarchical GOP size |
---|
99 | |
---|
100 | #define MAX_NUM_REF 4 ///< max. value of multiple reference frames |
---|
101 | #if DCM_COMB_LIST |
---|
102 | #define MAX_NUM_REF_LC 8 ///< max. value of combined reference frames |
---|
103 | #endif |
---|
104 | |
---|
105 | #define MAX_UINT 0xFFFFFFFFU ///< max. value of unsigned 32-bit integer |
---|
106 | #define MAX_UINT64 0xFFFFFFFFFFFFFFFFU |
---|
107 | #define MAX_INT 2147483647 ///< max. value of signed 32-bit integer |
---|
108 | #define MIN_INT (-2147483647-1) // < min. value of signed 32-bit integer |
---|
109 | #define MAX_DOUBLE 1.7e+308 ///< max. value of double-type value |
---|
110 | |
---|
111 | #define MIN_QP 0 |
---|
112 | #define MAX_QP 51 |
---|
113 | |
---|
114 | #define NOT_VALID -1 |
---|
115 | |
---|
116 | #define STD_CAM_PARAMETERS_PRECISION 5 ///< quarter luma sample accuarcy for derived disparities (as default) |
---|
117 | |
---|
118 | // SB |
---|
119 | #define MAX_INPUT_VIEW_NUM 10 ///< max. number of input view for multiview coding |
---|
120 | |
---|
121 | // GT |
---|
122 | #define MAX_ERREF_VIEW_NUM 15 ///< max. number of virtual external reference views |
---|
123 | #define LOG2_DISP_PREC_LUT 2 ///< log2 of disparity precision used in integer disparity LUTs |
---|
124 | |
---|
125 | |
---|
126 | //>>>>> generation and usage of virtual prediction depth maps >>>>> |
---|
127 | #define PDM_DEPTH_MAP_MCP_FILTER 2 // 0: standard filter, 1:bilinear, 2:nearest neighbour |
---|
128 | #define PDM_ONE_DEPTH_PER_PU 1 // use only a single depth for a prediction unit (in update) |
---|
129 | #define PDM_NO_INTER_UPDATE 0 // no update for inter (but not inter-view) predicted blocks |
---|
130 | #define PDM_MERGE_POS 0 // position of pdm in merge list (0..5) |
---|
131 | #define PDM_AMVP_POS 2 // position of pdm in amvp list (0..3) |
---|
132 | #define PDM_OUTPUT_PRED_DEPTH_MAP 0 // output prediction depth map (for debugging) |
---|
133 | |
---|
134 | #define PDM_INTERNAL_CALC_BIT_DEPTH 31 // bit depth for internal calculations (32 - 1 for signed values) |
---|
135 | #define PDM_BITDEPTH_VIRT_DEPTH 15 // bit depth for virtual depth storage (16 - 1 for signed values) |
---|
136 | #define PDM_LOG2_MAX_ABS_NORMAL_DISPARITY 8 // maximum absolute normal disparity = 256 (for setting accuracy) |
---|
137 | #define PDM_VIRT_DEPTH_PRECISION 4 // must be greater than or equal to 2 (since MVs are given in quarter-pel units) |
---|
138 | |
---|
139 | #define PDM_INTER_CALC_SHIFT ( PDM_INTERNAL_CALC_BIT_DEPTH - PDM_BITDEPTH_VIRT_DEPTH ) // avoids overflow |
---|
140 | #define PDM_LOG4_SCALE_DENOMINATOR ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY + PDM_VIRT_DEPTH_PRECISION ) // accuracy of scaling factor |
---|
141 | #define PDM_OFFSET_SHIFT ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY ) // accuracy of offset |
---|
142 | |
---|
143 | #define PDM_MAX_ABS_VIRT_DEPTH ( ( 1 << PDM_BITDEPTH_VIRT_DEPTH ) - 1 ) |
---|
144 | #define PDM_UNDEFINED_DEPTH ( -( 1 << PDM_BITDEPTH_VIRT_DEPTH ) ) |
---|
145 | |
---|
146 | #define PDM_USE_FOR_IVIEW 1 |
---|
147 | #define PDM_USE_FOR_INTER 2 |
---|
148 | #define PDM_USE_FOR_MERGE 4 |
---|
149 | //<<<<< generation and usage of virtual prediction depth maps <<<<< |
---|
150 | |
---|
151 | #define OUTPUT_RESIDUAL_PICTURES 0 // output residual pictures (for debugging) |
---|
152 | |
---|
153 | #define MVI_MERGE_POS 0 // position of mvi in merge list (0..5) |
---|
154 | |
---|
155 | |
---|
156 | // ==================================================================================================================== |
---|
157 | // Macro functions |
---|
158 | // ==================================================================================================================== |
---|
159 | |
---|
160 | #define Max(x, y) ((x)>(y)?(x):(y)) ///< max of (x, y) |
---|
161 | #define Min(x, y) ((x)<(y)?(x):(y)) ///< min of (x, y) |
---|
162 | #define Median(a,b,c) ((a)>(b)?(a)>(c)?(b)>(c)?(b):(c):(a):(b)>(c)?(a)>(c)?(a):(c):(b)) ///< 3-point median |
---|
163 | #define Clip(x) ( Min(g_uiIBDI_MAX, Max( 0, (x)) ) ) ///< clip with bit-depth range |
---|
164 | #define Clip3( MinVal, MaxVal, a) ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) ) ///< general min/max clip |
---|
165 | #define RemoveBitIncrement(x) ( (x + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement ) ///< Remove Bit increment |
---|
166 | |
---|
167 | #define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free |
---|
168 | #if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 ) |
---|
169 | #define xMalloc( type, len ) _aligned_malloc( sizeof(type)*(len), 32 ) |
---|
170 | #define xFree( ptr ) _aligned_free ( ptr ) |
---|
171 | #else |
---|
172 | #define xMalloc( type, len ) malloc ( sizeof(type)*(len) ) |
---|
173 | #define xFree( ptr ) free ( ptr ) |
---|
174 | #endif |
---|
175 | |
---|
176 | #define FATAL_ERROR_0(MESSAGE, EXITCODE) \ |
---|
177 | { \ |
---|
178 | printf(MESSAGE); \ |
---|
179 | exit(EXITCODE); \ |
---|
180 | } |
---|
181 | |
---|
182 | |
---|
183 | // ==================================================================================================================== |
---|
184 | // Coding tool configuration |
---|
185 | // ==================================================================================================================== |
---|
186 | |
---|
187 | // modified LCEC coefficient coding |
---|
188 | #if QC_MOD_LCEC |
---|
189 | #define MAX_TR1 4 |
---|
190 | #endif |
---|
191 | |
---|
192 | // AMVP: advanced motion vector prediction |
---|
193 | #define AMVP_MAX_NUM_CANDS 6 ///< max number of final candidates |
---|
194 | // MERGE |
---|
195 | #define MRG_MAX_NUM_CANDS 6 |
---|
196 | |
---|
197 | // Reference memory management |
---|
198 | #define DYN_REF_FREE 0 ///< dynamic free of reference memories |
---|
199 | |
---|
200 | // defines for multiview coding |
---|
201 | #define MAX_NUMBER_VIEWS 10 |
---|
202 | |
---|
203 | // Explicit temporal layer QP offset |
---|
204 | #define MAX_TLAYER 10 ///< max number of temporal layer |
---|
205 | #define HB_LAMBDA_FOR_LDC 1 ///< use of B-style lambda for non-key pictures in low-delay mode |
---|
206 | |
---|
207 | // Fast estimation of generalized B in low-delay mode |
---|
208 | #define GPB_SIMPLE 1 ///< Simple GPB mode |
---|
209 | #if GPB_SIMPLE |
---|
210 | #define GPB_SIMPLE_UNI 1 ///< Simple mode for uni-direction |
---|
211 | #endif |
---|
212 | |
---|
213 | // Fast ME using smoother MV assumption |
---|
214 | #define FASTME_SMOOTHER_MV 1 ///< reduce ME time using faster option |
---|
215 | |
---|
216 | // Adaptive search range depending on POC difference |
---|
217 | #define ADAPT_SR_SCALE 1 ///< division factor for adaptive search range |
---|
218 | |
---|
219 | #define ENABLE_IBDI 0 |
---|
220 | |
---|
221 | #define CLIP_TO_709_RANGE 0 |
---|
222 | |
---|
223 | // IBDI range restriction for skipping clip |
---|
224 | #define IBDI_NOCLIP_RANGE 0 ///< restrict max. value after IBDI to skip clip |
---|
225 | |
---|
226 | // Early-skip threshold (encoder) |
---|
227 | #define EARLY_SKIP_THRES 1.50 ///< if RD < thres*avg[BestSkipRD] |
---|
228 | |
---|
229 | const int g_iShift8x8 = 2; |
---|
230 | const int g_iShift16x16 = 2; |
---|
231 | const int g_iShift32x32 = 2; |
---|
232 | const int g_iShift64x64 = 2; |
---|
233 | |
---|
234 | |
---|
235 | |
---|
236 | //RENDERER |
---|
237 | #define REN_LUMA_MARGIN ( g_uiMaxCUWidth + 12 ) |
---|
238 | #define REN_VDWEIGHT_PREC 8 |
---|
239 | #define REN_IS_FILLED ( 1 << REN_VDWEIGHT_PREC ) |
---|
240 | #define REN_USED_PEL g_uiIBDI_MAX |
---|
241 | #define REN_UNUSED_PEL 0 |
---|
242 | #define REN_IS_HOLE 0 |
---|
243 | |
---|
244 | /* End of Rounding control */ |
---|
245 | |
---|
246 | enum NalRefIdc |
---|
247 | { |
---|
248 | NAL_REF_IDC_PRIORITY_LOWEST = 0, |
---|
249 | NAL_REF_IDC_PRIORITY_LOW, |
---|
250 | NAL_REF_IDC_PRIORITY_HIGH, |
---|
251 | NAL_REF_IDC_PRIORITY_HIGHEST |
---|
252 | }; |
---|
253 | |
---|
254 | enum NalUnitType |
---|
255 | { |
---|
256 | NAL_UNIT_UNSPECIFIED_0 = 0, |
---|
257 | NAL_UNIT_CODED_SLICE, |
---|
258 | NAL_UNIT_CODED_SLICE_DATAPART_A, |
---|
259 | NAL_UNIT_CODED_SLICE_DATAPART_B, |
---|
260 | #if DCM_DECODING_REFRESH |
---|
261 | NAL_UNIT_CODED_SLICE_CDR, |
---|
262 | #else |
---|
263 | NAL_UNIT_CODED_SLICE_DATAPART_C, |
---|
264 | #endif |
---|
265 | NAL_UNIT_CODED_SLICE_IDR, |
---|
266 | NAL_UNIT_SEI, |
---|
267 | NAL_UNIT_SPS, |
---|
268 | NAL_UNIT_PPS, |
---|
269 | NAL_UNIT_ACCESS_UNIT_DELIMITER, |
---|
270 | NAL_UNIT_END_OF_SEQUENCE, |
---|
271 | NAL_UNIT_END_OF_STREAM, |
---|
272 | NAL_UNIT_FILLER_DATA, |
---|
273 | NAL_UNIT_RESERVED_13, |
---|
274 | NAL_UNIT_RESERVED_14, |
---|
275 | NAL_UNIT_RESERVED_15, |
---|
276 | NAL_UNIT_RESERVED_16, |
---|
277 | NAL_UNIT_RESERVED_17, |
---|
278 | NAL_UNIT_RESERVED_18, |
---|
279 | NAL_UNIT_RESERVED_19, |
---|
280 | NAL_UNIT_RESERVED_20, |
---|
281 | NAL_UNIT_RESERVED_21, |
---|
282 | NAL_UNIT_RESERVED_22, |
---|
283 | NAL_UNIT_RESERVED_23, |
---|
284 | NAL_UNIT_UNSPECIFIED_24, |
---|
285 | NAL_UNIT_UNSPECIFIED_25, |
---|
286 | NAL_UNIT_UNSPECIFIED_26, |
---|
287 | NAL_UNIT_UNSPECIFIED_27, |
---|
288 | NAL_UNIT_UNSPECIFIED_28, |
---|
289 | NAL_UNIT_UNSPECIFIED_29, |
---|
290 | NAL_UNIT_UNSPECIFIED_30, |
---|
291 | NAL_UNIT_UNSPECIFIED_31, |
---|
292 | NAL_UNIT_INVALID, |
---|
293 | }; |
---|
294 | |
---|
295 | typedef _AlfParam ALFParam; |
---|
296 | #if MTK_SAO |
---|
297 | typedef _SaoParam SAOParam; |
---|
298 | #endif |
---|
299 | |
---|
300 | // SB from ViCo for formatted string parsing |
---|
301 | |
---|
302 | class VideoCodecException |
---|
303 | { |
---|
304 | public: |
---|
305 | VideoCodecException() : m_acFile( "unspecified" ), m_uiLine( 0 ) {} |
---|
306 | VideoCodecException( const char *pcFile, UInt uiLine ) : m_acFile( pcFile ), m_uiLine( uiLine ) {} |
---|
307 | |
---|
308 | std::string exceptionFile() const { return m_acFile; } |
---|
309 | UInt exceptionLine() const { return m_uiLine; } |
---|
310 | |
---|
311 | private: |
---|
312 | std::string m_acFile; |
---|
313 | UInt m_uiLine; |
---|
314 | }; |
---|
315 | |
---|
316 | #define RETURN_ERR_ON_EXCEPTION \ |
---|
317 | catch( std::exception &cEx ) \ |
---|
318 | { \ |
---|
319 | std::cerr << "Abnormal program termination: " << cEx.what() << std::endl; \ |
---|
320 | return Err::m_nERR; \ |
---|
321 | } \ |
---|
322 | catch( VideoCodecException &cEx ) \ |
---|
323 | { \ |
---|
324 | std::cerr << std::endl << "VideoCodecExcteption caught at: " << std::endl; \ |
---|
325 | std::cerr << "File: " << cEx.exceptionFile() << std::endl; \ |
---|
326 | std::cerr << "Line: " << cEx.exceptionLine() << std::endl; \ |
---|
327 | return Err::m_nERR; \ |
---|
328 | } \ |
---|
329 | catch( ... ) \ |
---|
330 | { \ |
---|
331 | std::cerr << "Caught unknown exception" << std::endl; \ |
---|
332 | return Err::m_nERR; \ |
---|
333 | } |
---|
334 | |
---|
335 | |
---|
336 | #define TOT( exp ) { if( exp ) { throw VideoCodecException( __FILE__, __LINE__ ); } } |
---|
337 | #define TOF( exp ) { if( !(exp) ) { throw VideoCodecException( __FILE__, __LINE__ ); } } |
---|
338 | #define TNOK( exp ) { if( Err::m_nOK != (exp) ) { throw VideoCodecException( __FILE__, __LINE__ ); } } |
---|
339 | |
---|
340 | #if defined( _DEBUG ) |
---|
341 | |
---|
342 | #define TOT_DBG( exp ) TOT( exp ) |
---|
343 | #define TOF_DBG( exp ) TOF( exp ) |
---|
344 | |
---|
345 | #else |
---|
346 | |
---|
347 | #define TOT_DBG( exp ) ((void)0) |
---|
348 | #define TOF_DBG( exp ) ((void)0) |
---|
349 | |
---|
350 | #endif |
---|
351 | |
---|
352 | typedef int ErrVal; |
---|
353 | |
---|
354 | |
---|
355 | class Err |
---|
356 | { |
---|
357 | public: |
---|
358 | enum |
---|
359 | { |
---|
360 | m_nOK = 0, |
---|
361 | m_nERR = -1, |
---|
362 | m_nEndOfFile = -2, |
---|
363 | m_nEndOfBuffer = -3, |
---|
364 | m_nInvalidParameter = -4, |
---|
365 | m_nDataNotAvailable = -5, |
---|
366 | m_nSizeNotAvailable = -5, |
---|
367 | }; |
---|
368 | }; |
---|
369 | |
---|
370 | |
---|
371 | #define ROF( exp ) \ |
---|
372 | { \ |
---|
373 | if( !( exp ) ) \ |
---|
374 | { \ |
---|
375 | assert( 0 ); \ |
---|
376 | return -1; \ |
---|
377 | } \ |
---|
378 | } |
---|
379 | |
---|
380 | #define ROT( exp ) \ |
---|
381 | { \ |
---|
382 | if( ( exp ) ) \ |
---|
383 | { \ |
---|
384 | assert( 0 ); \ |
---|
385 | return -1; \ |
---|
386 | } \ |
---|
387 | } |
---|
388 | |
---|
389 | #define ROFS( exp ) \ |
---|
390 | { \ |
---|
391 | if( !( exp ) ) \ |
---|
392 | { \ |
---|
393 | return -1; \ |
---|
394 | } \ |
---|
395 | } |
---|
396 | |
---|
397 | #define ROTS( exp ) \ |
---|
398 | { \ |
---|
399 | if( ( exp ) ) \ |
---|
400 | { \ |
---|
401 | return -1; \ |
---|
402 | } \ |
---|
403 | } |
---|
404 | |
---|
405 | #define ROFR( exp, retVal ) \ |
---|
406 | { \ |
---|
407 | if( !( exp ) ) \ |
---|
408 | { \ |
---|
409 | assert( 0 ); \ |
---|
410 | return retVal; \ |
---|
411 | } \ |
---|
412 | } |
---|
413 | |
---|
414 | #define ROTR( exp, retVal ) \ |
---|
415 | { \ |
---|
416 | if( ( exp ) ) \ |
---|
417 | { \ |
---|
418 | assert( 0 ); \ |
---|
419 | return retVal; \ |
---|
420 | } \ |
---|
421 | } |
---|
422 | |
---|
423 | #define ROFRS( exp, retVal ) \ |
---|
424 | { \ |
---|
425 | if( !( exp ) ) \ |
---|
426 | { \ |
---|
427 | return retVal; \ |
---|
428 | } \ |
---|
429 | } |
---|
430 | |
---|
431 | #define ROTRS( exp, retVal ) \ |
---|
432 | { \ |
---|
433 | if( ( exp ) ) \ |
---|
434 | { \ |
---|
435 | return retVal; \ |
---|
436 | } \ |
---|
437 | } |
---|
438 | |
---|
439 | #define ROFV( exp ) \ |
---|
440 | { \ |
---|
441 | if( !( exp ) ) \ |
---|
442 | { \ |
---|
443 | assert( 0 ); \ |
---|
444 | return; \ |
---|
445 | } \ |
---|
446 | } |
---|
447 | |
---|
448 | #define ROTV( exp ) \ |
---|
449 | { \ |
---|
450 | if( ( exp ) ) \ |
---|
451 | { \ |
---|
452 | assert( 0 ); \ |
---|
453 | return; \ |
---|
454 | } \ |
---|
455 | } |
---|
456 | |
---|
457 | #define ROFVS( exp ) \ |
---|
458 | { \ |
---|
459 | if( !( exp ) ) \ |
---|
460 | { \ |
---|
461 | return; \ |
---|
462 | } \ |
---|
463 | } |
---|
464 | |
---|
465 | #define ROTVS( exp ) \ |
---|
466 | { \ |
---|
467 | if( ( exp ) ) \ |
---|
468 | { \ |
---|
469 | return; \ |
---|
470 | } \ |
---|
471 | } |
---|
472 | |
---|
473 | #define RNOK( exp ) \ |
---|
474 | { \ |
---|
475 | const ErrVal nMSysRetVal = ( exp ); \ |
---|
476 | if( 0 != nMSysRetVal ) \ |
---|
477 | { \ |
---|
478 | assert( 0 ); \ |
---|
479 | return nMSysRetVal; \ |
---|
480 | } \ |
---|
481 | } |
---|
482 | |
---|
483 | #define RNOKR( exp, retVal ) \ |
---|
484 | { \ |
---|
485 | if( 0 != ( exp ) ) \ |
---|
486 | { \ |
---|
487 | assert( 0 ); \ |
---|
488 | return retVal; \ |
---|
489 | } \ |
---|
490 | } |
---|
491 | |
---|
492 | #define RNOKS( exp ) \ |
---|
493 | { \ |
---|
494 | const ErrVal nMSysRetVal = ( exp ); \ |
---|
495 | if( 0 != nMSysRetVal ) \ |
---|
496 | { \ |
---|
497 | return nMSysRetVal; \ |
---|
498 | } \ |
---|
499 | } |
---|
500 | |
---|
501 | #define RNOKRS( exp, retVal ) \ |
---|
502 | { \ |
---|
503 | if( 0 != ( exp ) ) \ |
---|
504 | { \ |
---|
505 | return retVal; \ |
---|
506 | } \ |
---|
507 | } |
---|
508 | |
---|
509 | #define RNOKV( exp ) \ |
---|
510 | { \ |
---|
511 | if( 0 != ( exp ) ) \ |
---|
512 | { \ |
---|
513 | assert( 0 ); \ |
---|
514 | return; \ |
---|
515 | } \ |
---|
516 | } |
---|
517 | |
---|
518 | #define RNOKVS( exp ) \ |
---|
519 | { \ |
---|
520 | if( 0 != ( exp ) ) \ |
---|
521 | { \ |
---|
522 | return; \ |
---|
523 | } \ |
---|
524 | } |
---|
525 | |
---|
526 | #define ANOK( exp ) \ |
---|
527 | { \ |
---|
528 | if( 0 != ( exp ) ) \ |
---|
529 | { \ |
---|
530 | assert( 0 ); \ |
---|
531 | } \ |
---|
532 | } |
---|
533 | |
---|
534 | #define AOF( exp ) \ |
---|
535 | { \ |
---|
536 | if( !( exp ) ) \ |
---|
537 | { \ |
---|
538 | assert( 0 ); \ |
---|
539 | } \ |
---|
540 | } |
---|
541 | |
---|
542 | #define AOT( exp ) \ |
---|
543 | { \ |
---|
544 | if( ( exp ) ) \ |
---|
545 | { \ |
---|
546 | assert( 0 ); \ |
---|
547 | } \ |
---|
548 | } |
---|
549 | |
---|
550 | #if defined( _DEBUG ) |
---|
551 | |
---|
552 | #define AOT_DBG( exp ) AOT( exp ) |
---|
553 | #define AOF_DBG( exp ) AOF( exp ) |
---|
554 | |
---|
555 | #else |
---|
556 | |
---|
557 | #define AOT_DBG( exp ) ((void)0) |
---|
558 | #define AOF_DBG( exp ) ((void)0) |
---|
559 | |
---|
560 | #endif |
---|
561 | |
---|
562 | #define DISABLE_DEFAULT_CPYCTOR_AND_ASOP(x) private: x( const x &r ); const x& operator=( const x &r ) |
---|
563 | typedef Int64 PicOrderCnt; |
---|
564 | |
---|
565 | template<class T> |
---|
566 | class AutoDeletePtrVector |
---|
567 | : public std::vector<T*> |
---|
568 | { |
---|
569 | public: |
---|
570 | AutoDeletePtrVector() {} |
---|
571 | |
---|
572 | virtual ~AutoDeletePtrVector() |
---|
573 | { |
---|
574 | while( !std::vector<T*>::empty() ) |
---|
575 | { |
---|
576 | delete std::vector<T*>::back(); |
---|
577 | std::vector<T*>::pop_back(); |
---|
578 | } |
---|
579 | } |
---|
580 | |
---|
581 | DISABLE_DEFAULT_CPYCTOR_AND_ASOP( AutoDeletePtrVector ); |
---|
582 | }; |
---|
583 | |
---|
584 | template<class T> |
---|
585 | __inline T gAbs(const T& x) |
---|
586 | { |
---|
587 | return x < 0 ? -x : x; |
---|
588 | } |
---|
589 | // |
---|
590 | |
---|
591 | template <typename T> |
---|
592 | __inline T gSign(const T& t) |
---|
593 | { |
---|
594 | if( t == 0 ) |
---|
595 | return T(0); |
---|
596 | else |
---|
597 | return (t < 0) ? T(-1) : T(1); |
---|
598 | } |
---|
599 | |
---|
600 | |
---|
601 | |
---|
602 | #endif // end of #ifndef __COMMONDEF__ |
---|
603 | |
---|