source: 3DVCSoftware/trunk/source/Lib/TLibCommon/CommonDef.h @ 300

Last change on this file since 300 was 300, checked in by tech, 11 years ago

Added coding results. Changed version number.

  • Property svn:eol-style set to native
File size: 18.4 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-2012, ITU/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 ITU/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/** \file     CommonDef.h
35    \brief    Defines constants, macros and tool parameters
36*/
37
38#ifndef __COMMONDEF__
39#define __COMMONDEF__
40
41#include <algorithm>
42
43#if _MSC_VER > 1000
44// disable "signed and unsigned mismatch"
45#pragma warning( disable : 4018 )
46// disable bool coercion "performance warning"
47#pragma warning( disable : 4800 )
48#endif // _MSC_VER > 1000
49#include "TypeDef.h"
50
51#include <stdio.h>
52//! \ingroup TLibCommon
53//! \{
54
55// ====================================================================================================================
56// Version information
57// ====================================================================================================================
58
59#define HM_VERSION        "6.1"
60#define NV_VERSION        "6.0"                  ///< 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// Common constants
105// ====================================================================================================================
106
107#define _SUMMARY_OUT_               0           ///< print-out PSNR results of all slices to summary.txt
108#define _SUMMARY_PIC_               0           ///< print-out PSNR results for each slice type to summary.txt
109
110#define MAX_GOP                     64          ///< max. value of hierarchical GOP size
111
112#define MAX_NUM_REF                 4           ///< max. value of multiple reference frames
113#define MAX_NUM_REF_LC              8           ///< max. value of combined reference frames
114
115#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
116#define MAX_INT                     2147483647  ///< max. value of signed 32-bit integer
117#define MIN_INT                     (-2147483647-1) // < min. value of signed 32-bit integer
118#define MAX_DOUBLE                  1.7e+308    ///< max. value of double-type value
119
120#define MIN_QP                      0
121#define MAX_QP                      51
122
123#define NOT_VALID                   -1
124
125// ====================================================================================================================
126// 3D constants
127// ====================================================================================================================
128#define MAX_VIEW_NUM                10
129
130#if ( H3D_IVMP || H3D_IVRP )
131#define DEPTH_MAP_GENERATION        1
132#define PDM_REMOVE_DEPENDENCE       1      //bug-fix for DMDV JCT2-A0095
133#else
134#define DEPTH_MAP_GENERATION        0
135#endif
136
137//>>>>> generation and usage of virtual prediction depth maps >>>>>
138#define PDM_ONE_DEPTH_PER_PU              1         // use only a single depth for a prediction unit (in update)
139#define PDM_NO_INTER_UPDATE               1         // no update for inter (but not inter-view) predicted blocks
140#define PDM_MERGE_POS                     0         // position of pdm in merge list (0..4)
141
142#if H3D_IVMP
143#define DMV_MERGE_POS                     4
144#else
145#define DMV_MERGE_POS                     1
146#endif
147
148#if H3D_IVMP&!H3D_NBDV
149#define PDM_AMVP_POS                      0         // position of pdm in amvp list  (0..3)
150#else
151#define PDM_AMVP_POS                      2         // position of pdm in amvp list  (0..3)
152#endif
153#define PDM_OUTPUT_PRED_DEPTH_MAP         0         // output prediction depth map (for debugging)
154
155#define PDM_INTERNAL_CALC_BIT_DEPTH       31        // bit depth for internal calculations (32 - 1 for signed values)
156#define PDM_BITDEPTH_VIRT_DEPTH           15        // bit depth for virtual depth storage (16 - 1 for signed values)
157#define PDM_LOG2_MAX_ABS_NORMAL_DISPARITY 8         // maximum absolute normal disparity = 256 (for setting accuracy)
158#define PDM_VIRT_DEPTH_PRECISION          4         // must be greater than or equal to 2 (since MVs are given in quarter-pel units)
159
160#define PDM_INTER_CALC_SHIFT              ( PDM_INTERNAL_CALC_BIT_DEPTH - PDM_BITDEPTH_VIRT_DEPTH )         // avoids overflow
161#define PDM_LOG4_SCALE_DENOMINATOR        ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY + PDM_VIRT_DEPTH_PRECISION )  // accuracy of scaling factor
162#define PDM_OFFSET_SHIFT                  ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY )                             // accuracy of offset
163
164#define PDM_MAX_ABS_VIRT_DEPTH            (  ( 1 << PDM_BITDEPTH_VIRT_DEPTH ) - 1 )
165#define PDM_UNDEFINED_DEPTH               ( -( 1 << PDM_BITDEPTH_VIRT_DEPTH )     )
166
167#define PDM_USE_FOR_IVIEW                 1
168#define PDM_USE_FOR_INTER                 2
169#define PDM_USE_FOR_MERGE                 4
170
171#define PDM_SUBSAMPLING_EXP               2         // subsampling factor is 2^PDM_SUBSAMPLING_EXP
172#define PDM_SUB_SAMP_EXP_X(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
173#define PDM_SUB_SAMP_EXP_Y(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
174//<<<<< generation and usage of virtual prediction depth maps <<<<<
175
176#define OUTPUT_RESIDUAL_PICTURES          0         // output residual pictures (for debugging)
177
178#define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
179
180#define LOG2_DISP_PREC_LUT           2          ///< log2 of disparity precision used in integer disparity LUTs
181
182// ====================================================================================================================
183// VPS constants
184// ====================================================================================================================
185#if QC_MVHEVC_B0046
186#define MAX_LAYER_NUM                     MAX_VIEW_NUM
187#endif
188#if VIDYO_VPS_INTEGRATION
189#define MAX_LAYER_NUM                     MAX_VIEW_NUM
190#define VPS_EXTENSION_TYPE_MULTI_VIEW     0
191#endif
192
193// ====================================================================================================================
194// Macro functions
195// ====================================================================================================================
196extern UInt g_uiIBDI_MAX;
197
198/** clip x, such that 0 <= x <= #g_uiIBDI_MAX */
199template <typename T> inline T Clip(T x) { return std::min<T>(T(g_uiIBDI_MAX), std::max<T>( T(0), x)); }
200
201/** clip a, such that minVal <= a <= maxVal */
202template <typename T> inline T Clip3( T minVal, T maxVal, T a) { return std::min<T> (std::max<T> (minVal, a) , maxVal); }  ///< general min/max clip
203
204#define DATA_ALIGN                  1                                                                 ///< use 32-bit aligned malloc/free
205#if     DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
206#define xMalloc( type, len )        _aligned_malloc( sizeof(type)*(len), 32 )
207#define xFree( ptr )                _aligned_free  ( ptr )
208#else
209#define xMalloc( type, len )        malloc   ( sizeof(type)*(len) )
210#define xFree( ptr )                free     ( ptr )
211#endif
212
213#define FATAL_ERROR_0(MESSAGE, EXITCODE)                      \
214{                                                             \
215  printf(MESSAGE);                                            \
216  exit(EXITCODE);                                             \
217}
218
219#define ROF( exp )            \
220{                             \
221  if( !( exp ) )              \
222{                           \
223  assert( 0 );              \
224  return -1;                \
225}                           \
226}
227
228#define ROT( exp )            \
229{                             \
230  if( ( exp ) )               \
231{                           \
232  assert( 0 );              \
233  return -1;                \
234}                           \
235}
236
237#define ROFS( exp )           \
238{                             \
239  if( !( exp ) )              \
240{                           \
241  return -1;                \
242}                           \
243}
244
245#define ROTS( exp )           \
246{                             \
247  if( ( exp ) )               \
248{                           \
249  return -1;                \
250}                           \
251}
252
253#define ROFR( exp, retVal )   \
254{                             \
255  if( !( exp ) )              \
256{                           \
257  assert( 0 );              \
258  return retVal;            \
259}                           \
260}
261
262#define ROTR( exp, retVal )   \
263{                             \
264  if( ( exp ) )               \
265{                           \
266  assert( 0 );              \
267  return retVal;            \
268}                           \
269}
270
271#define ROFRS( exp, retVal )  \
272{                             \
273  if( !( exp ) )              \
274{                           \
275  return retVal;            \
276}                           \
277}
278
279#define ROTRS( exp, retVal )  \
280{                             \
281  if( ( exp ) )               \
282{                           \
283  return retVal;            \
284}                           \
285}
286
287#define ROFV( exp )           \
288{                             \
289  if( !( exp ) )              \
290{                           \
291  assert( 0 );              \
292  return;                   \
293}                           \
294}
295
296#define ROTV( exp )           \
297{                             \
298  if( ( exp ) )               \
299{                           \
300  assert( 0 );              \
301  return;                   \
302}                           \
303}
304
305#define ROFVS( exp )          \
306{                             \
307  if( !( exp ) )              \
308{                           \
309  return;                   \
310}                           \
311}
312
313#define ROTVS( exp )          \
314{                             \
315  if( ( exp ) )               \
316{                           \
317  return;                   \
318}                           \
319}
320
321#define RNOK( exp )                   \
322{                                     \
323  const ErrVal nMSysRetVal = ( exp ); \
324  if( 0 != nMSysRetVal )              \
325{                                   \
326  assert( 0 );                      \
327  return nMSysRetVal;               \
328}                                   \
329}
330
331#define RNOKR( exp, retVal )        \
332{                                   \
333  if( 0 != ( exp ) )                \
334{                                 \
335  assert( 0 );                    \
336  return retVal;                  \
337}                                 \
338}
339
340#define RNOKS( exp )                  \
341{                                     \
342  const ErrVal nMSysRetVal = ( exp ); \
343  if( 0 != nMSysRetVal )              \
344{                                   \
345  return nMSysRetVal;               \
346}                                   \
347}
348
349#define RNOKRS( exp, retVal )       \
350{                                   \
351  if( 0 != ( exp ) )                \
352{                                 \
353  return retVal;                  \
354}                                 \
355}
356
357#define RNOKV( exp )                \
358{                                   \
359  if( 0 != ( exp ) )                \
360{                                 \
361  assert( 0 );                    \
362  return;                         \
363}                                 \
364}
365
366#define RNOKVS( exp )               \
367{                                   \
368  if( 0 != ( exp ) )                \
369{                                 \
370  return;                         \
371}                                 \
372}
373
374#define ANOK( exp )                 \
375{                                   \
376  if( 0 != ( exp ) )                \
377{                                 \
378  assert( 0 );                    \
379}                                 \
380}
381
382#define AOF( exp )                  \
383{                                   \
384  if( !( exp ) )                    \
385{                                 \
386  assert( 0 );                    \
387}                                 \
388}
389
390#define AOT( exp )            \
391{                             \
392  if( ( exp ) )               \
393{                           \
394  assert( 0 );              \
395}                           \
396}
397
398template <typename T>
399__inline T gSign(const T& t)
400{
401  if( t == 0 )
402    return T(0);
403  else
404    return (t < 0) ? T(-1) : T(1);
405}
406
407#define Max(x, y)                   ((x)>(y)?(x):(y))                                                 ///< max of (x, y)
408#define Min(x, y)                   ((x)<(y)?(x):(y))                                                 ///< min of (x, y)
409#define Median(a,b,c)               ((a)>(b)?(a)>(c)?(b)>(c)?(b):(c):(a):(b)>(c)?(a)>(c)?(a):(c):(b)) ///< 3-point median
410#define Clip(x)                     ( Min(g_uiIBDI_MAX, Max( 0, (x)) ) )                              ///< clip with bit-depth range
411#define Clip3( MinVal, MaxVal, a)   ( ((a)<(MinVal)) ? (MinVal) : (((a)>(MaxVal)) ? (MaxVal) :(a)) )  ///< general min/max clip
412#define RemoveBitIncrement(x)       ( (x + ( (1 << g_uiBitIncrement) >> 1 )) >> g_uiBitIncrement )     ///< Remove Bit increment
413
414#if SAIT_VSO_EST_A0033
415#define ROUND(a)  (((a) < 0)? (int)((a) - 0.5) : (int)((a) + 0.5))
416#endif
417
418// ====================================================================================================================
419// Coding tool configuration
420// ====================================================================================================================
421
422// AMVP: advanced motion vector prediction
423#define AMVP_MAX_NUM_CANDS          2           ///< max number of final candidates
424#if H3D_IVMP
425#define AMVP_MAX_NUM_CANDS_MEM      4           ///< max number of candidates
426#else
427#define AMVP_MAX_NUM_CANDS_MEM      3           ///< max number of candidates
428#endif
429// MERGE
430#define MRG_MAX_NUM_CANDS           5
431#if H3D_IVMP
432#define MRG_MAX_NUM_CANDS_MEM       (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction
433#endif
434
435// Reference memory management
436#define DYN_REF_FREE                0           ///< dynamic free of reference memories
437
438// Explicit temporal layer QP offset
439#define MAX_TLAYER                  8           ///< max number of temporal layer
440#define HB_LAMBDA_FOR_LDC           1           ///< use of B-style lambda for non-key pictures in low-delay mode
441
442// Fast estimation of generalized B in low-delay mode
443#define GPB_SIMPLE                  1           ///< Simple GPB mode
444#if     GPB_SIMPLE
445#define GPB_SIMPLE_UNI              1           ///< Simple mode for uni-direction
446#endif
447
448// Fast ME using smoother MV assumption
449#define FASTME_SMOOTHER_MV          1           ///< reduce ME time using faster option
450
451// Adaptive search range depending on POC difference
452#define ADAPT_SR_SCALE              1           ///< division factor for adaptive search range
453
454#define CLIP_TO_709_RANGE           0
455
456// IBDI range restriction for skipping clip
457#define IBDI_NOCLIP_RANGE           0           ///< restrict max. value after IBDI to skip clip
458
459// Early-skip threshold (encoder)
460#define EARLY_SKIP_THRES            1.50        ///< if RD < thres*avg[BestSkipRD]
461
462#define MAX_NUM_REF_PICS 16
463
464
465enum NalUnitType
466{
467  NAL_UNIT_UNSPECIFIED_0 = 0,
468  NAL_UNIT_CODED_SLICE,
469#if QC_REM_IDV_B0046
470  NAL_UNIT_RESERVED,
471#else
472  NAL_UNIT_CODED_SLICE_IDV,
473#endif
474  NAL_UNIT_CODED_SLICE_TLA,
475  NAL_UNIT_CODED_SLICE_CRA,
476  NAL_UNIT_CODED_SLICE_IDR,
477  NAL_UNIT_SEI,
478  NAL_UNIT_SPS,
479  NAL_UNIT_PPS,
480  NAL_UNIT_ACCESS_UNIT_DELIMITER,
481  NAL_UNIT_RESERVED_10,
482  NAL_UNIT_RESERVED_11,
483  NAL_UNIT_FILLER_DATA,
484  NAL_UNIT_RESERVED_13,
485  NAL_UNIT_APS,
486  NAL_UNIT_RESERVED_15,
487  NAL_UNIT_RESERVED_16,
488  NAL_UNIT_RESERVED_17,
489  NAL_UNIT_RESERVED_18,
490  NAL_UNIT_RESERVED_19,
491  NAL_UNIT_RESERVED_20,
492  NAL_UNIT_RESERVED_21,
493  NAL_UNIT_RESERVED_22,
494  NAL_UNIT_RESERVED_23,
495  NAL_UNIT_UNSPECIFIED_24,
496#if VIDYO_VPS_INTEGRATION|QC_MVHEVC_B0046
497  NAL_UNIT_VPS,
498#else
499  NAL_UNIT_UNSPECIFIED_25,
500#endif
501  NAL_UNIT_UNSPECIFIED_26,
502  NAL_UNIT_UNSPECIFIED_27,
503  NAL_UNIT_UNSPECIFIED_28,
504  NAL_UNIT_UNSPECIFIED_29,
505  NAL_UNIT_UNSPECIFIED_30,
506  NAL_UNIT_UNSPECIFIED_31,
507  NAL_UNIT_INVALID,
508};
509
510//PICYUV
511#define PICYUV_PAD         16
512
513//RENDERER
514#define REN_LUMA_MARGIN   ( g_uiMaxCUWidth + PICYUV_PAD )
515#define REN_VDWEIGHT_PREC  8
516#define REN_IS_FILLED     ( 1 << REN_VDWEIGHT_PREC )
517#define REN_USED_PEL       g_uiIBDI_MAX
518#define REN_UNUSED_PEL     0
519#define REN_IS_HOLE        0
520
521
522typedef Int64 PicOrderCnt;
523
524//! \}
525
526#endif // end of #ifndef  __COMMONDEF__
527
Note: See TracBrowser for help on using the repository browser.