source: 3DVCSoftware/branches/0.3-poznan-univ/source/Lib/TLibCommon/CommonDef.h @ 28

Last change on this file since 28 was 28, checked in by poznan-univ, 13 years ago

Poznan Tools

  • Encoding only disoccluded CUs in depended views
  • Depth based motion prediction
  • Texture QP adjustment based on depth data
  • Nonlinear depth representation
  • Property svn:eol-style set to native
File size: 21.7 KB
Line 
1/* The copyright in this software is being made available under the BSD
2 * License, included below. This software may be subject to other third party
3 * and contributor rights, including patent rights, and no such rights are
4 * granted under this license.
5 *
6 * Copyright (c) 2010-2011, ISO/IEC
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 *  * Redistributions of source code must retain the above copyright notice,
13 *    this list of conditions and the following disclaimer.
14 *  * Redistributions in binary form must reproduce the above copyright notice,
15 *    this list of conditions and the following disclaimer in the documentation
16 *    and/or other materials provided with the distribution.
17 *  * Neither the name of the ISO/IEC nor the names of its contributors may
18 *    be used to endorse or promote products derived from this software without
19 *    specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */
33
34
35
36/** \file     CommonDef.h
37    \brief    Defines constants, macros and tool parameters
38*/
39
40#ifndef __COMMONDEF__
41#define __COMMONDEF__
42
43// this pragma can be used for turning off "signed and unsigned mismatch"
44#if _MSC_VER > 1000
45#pragma warning( disable : 4018 )
46#endif // _MSC_VER > 1000
47#include "TypeDef.h"
48#include "TComRom.h"
49
50#include <string>
51#include <assert.h>
52#include <stdlib.h>
53#include <vector>
54
55// ====================================================================================================================
56// Version information
57// ====================================================================================================================
58
59#define HM_VERSION        "3.0rc2"                 ///< Current software version
60#define NV_VERSION        "0.3"                    ///< Current software version
61
62// ====================================================================================================================
63// Platform information
64// ====================================================================================================================
65
66#ifdef __GNUC__
67#define NVM_COMPILEDBY  "[GCC %d.%d.%d]", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
68#ifdef __IA64__
69#define NVM_ONARCH    "[on 64-bit] "
70#else
71#define NVM_ONARCH    "[on 32-bit] "
72#endif
73#endif
74
75#ifdef __INTEL_COMPILER
76#define NVM_COMPILEDBY  "[ICC %d]", __INTEL_COMPILER
77#elif  _MSC_VER
78#define NVM_COMPILEDBY  "[VS %d]", _MSC_VER
79#endif
80
81#ifndef NVM_COMPILEDBY
82#define NVM_COMPILEDBY "[Unk-CXX]"
83#endif
84
85#ifdef _WIN32
86#define NVM_ONOS        "[Windows]"
87#elif  __linux
88#define NVM_ONOS        "[Linux]"
89#elif  __CYGWIN__
90#define NVM_ONOS        "[Cygwin]"
91#elif __APPLE__
92#define NVM_ONOS        "[Mac OS X]"
93#else
94#define NVM_ONOS "[Unk-OS]"
95#endif
96
97#define NVM_BITS          "[%d bit] ", (sizeof(void*) == 8 ? 64 : 32) ///< used for checking 64-bit O/S
98
99#ifndef NULL
100#define NULL              0
101#endif
102
103
104// ====================================================================================================================
105// Common constants
106// ====================================================================================================================
107
108#define _SUMMARY_OUT_               0           ///< print-out PSNR results of all slices to summary.txt
109#define _SUMMARY_PIC_               0           ///< print-out PSNR results for each slice type to summary.txt
110
111#define MAX_REF_PIC_NUM             64
112#define MAX_GOP                     64          ///< max. value of hierarchical GOP size
113
114#define MAX_NUM_REF                 4           ///< max. value of multiple reference frames
115#if DCM_COMB_LIST
116#define MAX_NUM_REF_LC              8           ///< max. value of combined reference frames
117#endif
118
119#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
120#define MAX_UINT64                  0xFFFFFFFFFFFFFFFFU
121#define MAX_INT                     2147483647  ///< max. value of signed 32-bit integer
122#define MIN_INT                     (-2147483647-1) // < min. value of signed 32-bit integer
123#define MAX_DOUBLE                  1.7e+308    ///< max. value of double-type value
124
125#define MIN_QP                      0
126#define MAX_QP                      51
127
128#define NOT_VALID                   -1
129
130#define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
131
132#define MAX_INPUT_VIEW_NUM                                      10                              ///< max. number of input view for multiview coding
133
134#if HHI_VSO
135#define MAX_ERREF_VIEW_NUM                                      15                              ///< max. number of virtual external reference views
136#endif
137#define LOG2_DISP_PREC_LUT                              2                               ///< log2 of disparity precision used in integer disparity LUTs
138
139
140#if ( HHI_INTER_VIEW_MOTION_PRED || HHI_INTER_VIEW_RESIDUAL_PRED || POZNAN_MP_USE_DEPTH_MAP_GENERATION)
141#define DEPTH_MAP_GENERATION        1
142#else
143#define DEPTH_MAP_GENERATION        0
144#endif
145
146#if POZNAN_NONLINEAR_DEPTH
147#define POZNAN_LUT_INCREASED_PRECISION 0 // 1 //to do
148#else
149#define POZNAN_LUT_INCREASED_PRECISION 0
150#endif
151
152//>>>>> generation and usage of virtual prediction depth maps >>>>>
153#define PDM_ONE_DEPTH_PER_PU              1         // use only a single depth for a prediction unit (in update)
154#define PDM_NO_INTER_UPDATE               1         // no update for inter (but not inter-view) predicted blocks
155#define PDM_MERGE_POS                     0         // position of pdm in merge list (0..5)
156#define PDM_AMVP_POS                      2         // position of pdm in amvp list  (0..3)
157#define PDM_OUTPUT_PRED_DEPTH_MAP         0         // output prediction depth map (for debugging)
158
159#define PDM_INTERNAL_CALC_BIT_DEPTH       31        // bit depth for internal calculations (32 - 1 for signed values)
160#define PDM_BITDEPTH_VIRT_DEPTH           15        // bit depth for virtual depth storage (16 - 1 for signed values)
161#define PDM_LOG2_MAX_ABS_NORMAL_DISPARITY 8         // maximum absolute normal disparity = 256 (for setting accuracy)
162#define PDM_VIRT_DEPTH_PRECISION          4         // must be greater than or equal to 2 (since MVs are given in quarter-pel units)
163
164#define PDM_INTER_CALC_SHIFT              ( PDM_INTERNAL_CALC_BIT_DEPTH - PDM_BITDEPTH_VIRT_DEPTH )         // avoids overflow
165#define PDM_LOG4_SCALE_DENOMINATOR        ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY + PDM_VIRT_DEPTH_PRECISION )  // accuracy of scaling factor
166#define PDM_OFFSET_SHIFT                  ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY )                             // accuracy of offset
167
168#define PDM_MAX_ABS_VIRT_DEPTH            (  ( 1 << PDM_BITDEPTH_VIRT_DEPTH ) - 1 )
169#define PDM_UNDEFINED_DEPTH               ( -( 1 << PDM_BITDEPTH_VIRT_DEPTH )     )
170
171#define PDM_USE_FOR_IVIEW                 1
172#define PDM_USE_FOR_INTER                 2
173#define PDM_USE_FOR_MERGE                 4
174
175#define PDM_SUBSAMPLING_EXP               2         // subsampling factor is 2^PDM_SUBSAMPLING_EXP
176#define PDM_SUB_SAMP_EXP_X(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
177#define PDM_SUB_SAMP_EXP_Y(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
178//<<<<< generation and usage of virtual prediction depth maps <<<<<
179
180#define OUTPUT_RESIDUAL_PICTURES          0         // output residual pictures (for debugging)
181
182#define HHI_MPI_MERGE_POS                 0         // position of mvi in merge list (0..5)
183
184// ====================================================================================================================
185// POZNAN DEFINE SECTION
186// ====================================================================================================================
187#define POZNAN_OUTPUT_AVAILABLE_MAP       0           // output available map (for debugging)
188#define POZNAN_OUTPUT_SYNTH               0           // output synthesised view (for debugging)
189
190#if POZNAN_DBMP
191#define POZNAN_DBMP_MERGE_POS             0         // position of DBMP candidate in merge list for coding (0..6) - overwrites PDM_MERGE_POS settings, is overwritten by HHI_MPI_MERGE_POS settings!!!
192#endif
193
194#if POZNAN_NONLINEAR_DEPTH
195inline UChar quantizeDepthPower(Float fDepthPower)
196{
197  Int r = (Int) ( (fDepthPower-1.0f)*128.0f + 0.5f);
198  if (r<=0) return 0;
199  if (r>255) r=255; 
200  return r;
201};
202
203inline Float dequantizeDepthPower(Int iDepthQuant)
204{
205  return iDepthQuant/128.0f + 1.0f; 
206};
207#endif
208
209// ====================================================================================================================
210// Macro functions
211// ====================================================================================================================
212
213#define Max(x, y)                   ((x)>(y)?(x):(y))                                                 ///< max of (x, y)
214#define Min(x, y)                   ((x)<(y)?(x):(y))                                                 ///< min of (x, y)
215#define Median(a,b,c)               ((a)>(b)?(a)>(c)?(b)>(c)?(b):(c):(a):(b)>(c)?(a)>(c)?(a):(c):(b)) ///< 3-point median
216#define Clip(x)                     ( Min(g_uiIBDI_MAX, Max( 0, (x)) ) )                              ///< clip with bit-depth range
217#define Clip3( MinVal, MaxVal, a)   ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) )  ///< general min/max clip
218#define RemoveBitIncrement(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
219
220#if POZNAN_LUT_INCREASED_PRECISION
221#define RemoveBitIncrementLUT(x)       (x)     ///< Remove Bit increment
222#define SizeOfLUT                      (256 << g_uiBitIncrement) 
223#else
224#define SizeOfLUT                      256
225#define RemoveBitIncrementLUT(x)       ( ((x) + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
226#endif
227
228#define DATA_ALIGN                  1                                                                 ///< use 32-bit aligned malloc/free
229#if     DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
230#define xMalloc( type, len )        _aligned_malloc( sizeof(type)*(len), 32 )
231#define xFree( ptr )                _aligned_free  ( ptr )
232#else
233#define xMalloc( type, len )        malloc   ( sizeof(type)*(len) )
234#define xFree( ptr )                free     ( ptr )
235#endif
236
237#define FATAL_ERROR_0(MESSAGE, EXITCODE)                      \
238{                                                             \
239  printf(MESSAGE);                                            \
240  exit(EXITCODE);                                             \
241}
242
243
244// ====================================================================================================================
245// Coding tool configuration
246// ====================================================================================================================
247
248// modified LCEC coefficient coding
249#if QC_MOD_LCEC
250#define MAX_TR1                           4
251#endif
252
253// AMVP: advanced motion vector prediction
254#define AMVP_MAX_NUM_CANDS          6           ///< max number of final candidates
255// MERGE
256#if POZNAN_DBMP
257#define MRG_MAX_NUM_CANDS           7
258#define POZNAN_DBMP_MRG_CAND    MRG_MAX_NUM_CANDS-1                     // position of DBMP candidate in merge list (0..6)
259#else
260#define MRG_MAX_NUM_CANDS           6
261#endif
262
263// Reference memory management
264#define DYN_REF_FREE                0           ///< dynamic free of reference memories
265
266// defines for multiview coding
267#define MAX_NUMBER_VIEWS            10
268
269// Explicit temporal layer QP offset
270#define MAX_TLAYER                  10           ///< max number of temporal layer
271#define HB_LAMBDA_FOR_LDC           1           ///< use of B-style lambda for non-key pictures in low-delay mode
272
273// Fast estimation of generalized B in low-delay mode
274#define GPB_SIMPLE                  1           ///< Simple GPB mode
275#if     GPB_SIMPLE
276#define GPB_SIMPLE_UNI              1           ///< Simple mode for uni-direction
277#endif
278
279// Fast ME using smoother MV assumption
280#define FASTME_SMOOTHER_MV          1           ///< reduce ME time using faster option
281
282// Adaptive search range depending on POC difference
283#define ADAPT_SR_SCALE              1           ///< division factor for adaptive search range
284
285#define ENABLE_IBDI                 0
286
287#define CLIP_TO_709_RANGE           0
288
289// IBDI range restriction for skipping clip
290#define IBDI_NOCLIP_RANGE           0           ///< restrict max. value after IBDI to skip clip
291
292// Early-skip threshold (encoder)
293#define EARLY_SKIP_THRES            1.50        ///< if RD < thres*avg[BestSkipRD]
294
295const int g_iShift8x8    = 2;
296const int g_iShift16x16  = 2;
297const int g_iShift32x32  = 2;
298const int g_iShift64x64  = 2;
299
300
301
302//RENDERER
303#define REN_LUMA_MARGIN   ( g_uiMaxCUWidth + 12 )
304#define REN_VDWEIGHT_PREC  8
305#define REN_IS_FILLED     ( 1 << REN_VDWEIGHT_PREC )
306#define REN_USED_PEL       g_uiIBDI_MAX
307#define REN_UNUSED_PEL     0
308#define REN_IS_HOLE        0
309
310/* End of Rounding control */
311
312enum NalRefIdc
313{
314  NAL_REF_IDC_PRIORITY_LOWEST = 0,
315  NAL_REF_IDC_PRIORITY_LOW,
316  NAL_REF_IDC_PRIORITY_HIGH,
317  NAL_REF_IDC_PRIORITY_HIGHEST
318};
319
320enum NalUnitType
321{
322  NAL_UNIT_UNSPECIFIED_0 = 0,
323  NAL_UNIT_CODED_SLICE,
324  NAL_UNIT_CODED_SLICE_DATAPART_A,
325  NAL_UNIT_CODED_SLICE_DATAPART_B,
326#if DCM_DECODING_REFRESH
327  NAL_UNIT_CODED_SLICE_CDR,
328#else
329  NAL_UNIT_CODED_SLICE_DATAPART_C,
330#endif
331  NAL_UNIT_CODED_SLICE_IDR,
332  NAL_UNIT_SEI,
333  NAL_UNIT_SPS,
334  NAL_UNIT_PPS,
335  NAL_UNIT_ACCESS_UNIT_DELIMITER,
336  NAL_UNIT_END_OF_SEQUENCE,
337  NAL_UNIT_END_OF_STREAM,
338  NAL_UNIT_FILLER_DATA,
339  NAL_UNIT_RESERVED_13,
340  NAL_UNIT_RESERVED_14,
341  NAL_UNIT_RESERVED_15,
342  NAL_UNIT_RESERVED_16,
343  NAL_UNIT_RESERVED_17,
344  NAL_UNIT_RESERVED_18,
345  NAL_UNIT_RESERVED_19,
346  NAL_UNIT_RESERVED_20,
347  NAL_UNIT_RESERVED_21,
348  NAL_UNIT_RESERVED_22,
349  NAL_UNIT_RESERVED_23,
350  NAL_UNIT_UNSPECIFIED_24,
351  NAL_UNIT_UNSPECIFIED_25,
352  NAL_UNIT_UNSPECIFIED_26,
353  NAL_UNIT_UNSPECIFIED_27,
354  NAL_UNIT_UNSPECIFIED_28,
355  NAL_UNIT_UNSPECIFIED_29,
356  NAL_UNIT_UNSPECIFIED_30,
357  NAL_UNIT_UNSPECIFIED_31,
358  NAL_UNIT_INVALID,
359};
360
361typedef _AlfParam    ALFParam;
362#if MTK_SAO
363typedef _SaoParam    SAOParam;
364#endif
365
366
367class VideoCodecException
368{
369public:
370  VideoCodecException() : m_acFile( "unspecified" ), m_uiLine( 0 ) {}
371  VideoCodecException( const char *pcFile, UInt uiLine ) : m_acFile( pcFile ), m_uiLine( uiLine ) {}
372
373  std::string exceptionFile() const { return m_acFile; }
374  UInt        exceptionLine() const { return m_uiLine; }
375
376private:
377  std::string m_acFile;
378  UInt        m_uiLine;
379};
380
381#define RETURN_ERR_ON_EXCEPTION \
382catch( std::exception &cEx ) \
383{ \
384  std::cerr << "Abnormal program termination: " << cEx.what() << std::endl; \
385  return Err::m_nERR; \
386} \
387catch( VideoCodecException &cEx ) \
388{ \
389  std::cerr << std::endl << "VideoCodecExcteption caught at: " << std::endl; \
390  std::cerr << "File: " << cEx.exceptionFile() << std::endl; \
391  std::cerr << "Line: " << cEx.exceptionLine() << std::endl; \
392  return Err::m_nERR; \
393} \
394catch( ... ) \
395{ \
396  std::cerr << "Caught unknown exception" << std::endl; \
397  return Err::m_nERR; \
398}
399
400
401#define TOT(  exp ) { if(                exp  ) { throw VideoCodecException( __FILE__, __LINE__ ); } }
402#define TOF(  exp ) { if(              !(exp) ) { throw VideoCodecException( __FILE__, __LINE__ ); } }
403#define TNOK( exp ) { if( Err::m_nOK != (exp) ) { throw VideoCodecException( __FILE__, __LINE__ ); } }
404
405#if defined( _DEBUG )
406
407  #define TOT_DBG( exp )    TOT( exp )
408  #define TOF_DBG( exp )    TOF( exp )
409
410#else
411
412  #define TOT_DBG( exp )    ((void)0)
413  #define TOF_DBG( exp )    ((void)0)
414
415#endif
416
417typedef int            ErrVal;
418
419
420class Err
421{
422public:
423  enum
424  {
425    m_nOK               =  0,
426    m_nERR              = -1,
427    m_nEndOfFile        = -2,
428    m_nEndOfBuffer      = -3,
429    m_nInvalidParameter = -4,
430    m_nDataNotAvailable = -5,
431    m_nSizeNotAvailable = -5,
432  };
433};
434
435
436#define ROF( exp )            \
437{                             \
438  if( !( exp ) )              \
439  {                           \
440    assert( 0 );              \
441    return -1;                \
442  }                           \
443}
444
445#define ROT( exp )            \
446{                             \
447  if( ( exp ) )               \
448  {                           \
449    assert( 0 );              \
450    return -1;                \
451  }                           \
452}
453
454#define ROFS( exp )           \
455{                             \
456  if( !( exp ) )              \
457  {                           \
458    return -1;                \
459  }                           \
460}
461
462#define ROTS( exp )           \
463{                             \
464  if( ( exp ) )               \
465  {                           \
466    return -1;                \
467  }                           \
468}
469
470#define ROFR( exp, retVal )   \
471{                             \
472  if( !( exp ) )              \
473  {                           \
474    assert( 0 );              \
475    return retVal;            \
476  }                           \
477}
478
479#define ROTR( exp, retVal )   \
480{                             \
481  if( ( exp ) )               \
482  {                           \
483    assert( 0 );              \
484    return retVal;            \
485  }                           \
486}
487
488#define ROFRS( exp, retVal )  \
489{                             \
490  if( !( exp ) )              \
491  {                           \
492    return retVal;            \
493  }                           \
494}
495
496#define ROTRS( exp, retVal )  \
497{                             \
498  if( ( exp ) )               \
499  {                           \
500    return retVal;            \
501  }                           \
502}
503
504#define ROFV( exp )           \
505{                             \
506  if( !( exp ) )              \
507  {                           \
508    assert( 0 );              \
509    return;                   \
510  }                           \
511}
512
513#define ROTV( exp )           \
514{                             \
515  if( ( exp ) )               \
516  {                           \
517    assert( 0 );              \
518    return;                   \
519  }                           \
520}
521
522#define ROFVS( exp )          \
523{                             \
524  if( !( exp ) )              \
525  {                           \
526    return;                   \
527  }                           \
528}
529
530#define ROTVS( exp )          \
531{                             \
532  if( ( exp ) )               \
533  {                           \
534    return;                   \
535  }                           \
536}
537
538#define RNOK( exp )                   \
539{                                     \
540  const ErrVal nMSysRetVal = ( exp ); \
541  if( 0 != nMSysRetVal )              \
542  {                                   \
543    assert( 0 );                      \
544    return nMSysRetVal;               \
545  }                                   \
546}
547
548#define RNOKR( exp, retVal )        \
549{                                   \
550  if( 0 != ( exp ) )                \
551  {                                 \
552    assert( 0 );                    \
553    return retVal;                  \
554  }                                 \
555}
556
557#define RNOKS( exp )                  \
558{                                     \
559  const ErrVal nMSysRetVal = ( exp ); \
560  if( 0 != nMSysRetVal )              \
561  {                                   \
562    return nMSysRetVal;               \
563  }                                   \
564}
565
566#define RNOKRS( exp, retVal )       \
567{                                   \
568  if( 0 != ( exp ) )                \
569  {                                 \
570    return retVal;                  \
571  }                                 \
572}
573
574#define RNOKV( exp )                \
575{                                   \
576  if( 0 != ( exp ) )                \
577  {                                 \
578    assert( 0 );                    \
579    return;                         \
580  }                                 \
581}
582
583#define RNOKVS( exp )               \
584{                                   \
585  if( 0 != ( exp ) )                \
586  {                                 \
587    return;                         \
588  }                                 \
589}
590
591#define ANOK( exp )                 \
592{                                   \
593  if( 0 != ( exp ) )                \
594  {                                 \
595    assert( 0 );                    \
596  }                                 \
597}
598
599#define AOF( exp )                  \
600{                                   \
601  if( !( exp ) )                    \
602  {                                 \
603    assert( 0 );                    \
604  }                                 \
605}
606
607#define AOT( exp )            \
608{                             \
609  if( ( exp ) )               \
610  {                           \
611    assert( 0 );              \
612  }                           \
613}
614
615#if defined( _DEBUG )
616
617  #define AOT_DBG( exp )    AOT( exp )
618  #define AOF_DBG( exp )    AOF( exp )
619
620#else
621
622  #define AOT_DBG( exp )    ((void)0)
623  #define AOF_DBG( exp )    ((void)0)
624
625#endif
626
627#define DISABLE_DEFAULT_CPYCTOR_AND_ASOP(x) private: x( const x &r ); const x& operator=( const x &r )
628typedef Int64 PicOrderCnt;
629
630template<class T>
631class AutoDeletePtrVector
632  : public std::vector<T*>
633{
634public:
635  AutoDeletePtrVector() {}
636
637  virtual ~AutoDeletePtrVector()
638  {
639    while( !std::vector<T*>::empty() )
640    {
641      delete std::vector<T*>::back();
642      std::vector<T*>::pop_back();
643    }
644  }
645
646  DISABLE_DEFAULT_CPYCTOR_AND_ASOP( AutoDeletePtrVector );
647};
648
649  template<class T>
650  __inline T gAbs(const T& x)
651  {
652    return x < 0 ? -x : x;
653  }
654//
655
656template <typename T>
657__inline T gSign(const T& t)
658{
659    if( t == 0 )
660        return T(0);
661    else
662        return (t < 0) ? T(-1) : T(1);
663}
664
665
666
667#endif // end of #ifndef  __COMMONDEF__
668
Note: See TracBrowser for help on using the repository browser.