source: 3DVCSoftware/branches/HTM-DEV-0.3-dev2/source/Lib/TLibCommon/CommonDef.h @ 478

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

Minor clean ups.

  • Property svn:eol-style set to native
File size: 14.2 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-2013, 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//! \ingroup TLibCommon
52//! \{
53
54// ====================================================================================================================
55// Version information
56// ====================================================================================================================
57
58#if H_MV
59#define NV_VERSION        "0.3"                 ///< Current software version
60#define HM_VERSION        "10.1"                ///<
61#else
62#define NV_VERSION        "10.1"                 ///< Current software version
63#endif
64
65// ====================================================================================================================
66// Platform information
67// ====================================================================================================================
68
69#ifdef __GNUC__
70#define NVM_COMPILEDBY  "[GCC %d.%d.%d]", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
71#ifdef __IA64__
72#define NVM_ONARCH    "[on 64-bit] "
73#else
74#define NVM_ONARCH    "[on 32-bit] "
75#endif
76#endif
77
78#ifdef __INTEL_COMPILER
79#define NVM_COMPILEDBY  "[ICC %d]", __INTEL_COMPILER
80#elif  _MSC_VER
81#define NVM_COMPILEDBY  "[VS %d]", _MSC_VER
82#endif
83
84#ifndef NVM_COMPILEDBY
85#define NVM_COMPILEDBY "[Unk-CXX]"
86#endif
87
88#ifdef _WIN32
89#define NVM_ONOS        "[Windows]"
90#elif  __linux
91#define NVM_ONOS        "[Linux]"
92#elif  __CYGWIN__
93#define NVM_ONOS        "[Cygwin]"
94#elif __APPLE__
95#define NVM_ONOS        "[Mac OS X]"
96#else
97#define NVM_ONOS "[Unk-OS]"
98#endif
99
100#define NVM_BITS          "[%d bit] ", (sizeof(void*) == 8 ? 64 : 32) ///< used for checking 64-bit O/S
101
102#ifndef NULL
103#define NULL              0
104#endif
105
106// ====================================================================================================================
107// Common constants
108// ====================================================================================================================
109
110#define _SUMMARY_OUT_               0           ///< print-out PSNR results of all slices to summary.txt
111#define _SUMMARY_PIC_               0           ///< print-out PSNR results for each slice type to summary.txt
112
113#define MAX_GOP                     64          ///< max. value of hierarchical GOP size
114
115#define MAX_NUM_REF_PICS            16          ///< max. number of pictures used for reference
116#define MAX_NUM_REF                 16          ///< max. number of entries in picture reference list
117#if !L0034_COMBINED_LIST_CLEANUP
118#define MAX_NUM_REF_LC              MAX_NUM_REF_PICS  // TODO: remove this macro definition (leftover from combined list concept)
119#endif
120
121#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
122#define MAX_INT                     2147483647  ///< max. value of signed 32-bit integer
123#if H_3D
124#define MIN_INT                     (-2147483647-1) // < min. value of signed 32-bit integer
125#endif
126#define MAX_INT64                   0x7FFFFFFFFFFFFFFFLL  ///< max. value of signed 64-bit integer
127#define MAX_DOUBLE                  1.7e+308    ///< max. value of double-type value
128
129#define MIN_QP                      0
130#define MAX_QP                      51
131
132#define NOT_VALID                   -1
133
134// ====================================================================================================================
135// Macro functions
136// ====================================================================================================================
137extern Int g_bitDepthY;
138extern Int g_bitDepthC;
139
140/** clip x, such that 0 <= x <= #g_maxLumaVal */
141template <typename T> inline T ClipY(T x) { return std::min<T>(T((1 << g_bitDepthY)-1), std::max<T>( T(0), x)); }
142template <typename T> inline T ClipC(T x) { return std::min<T>(T((1 << g_bitDepthC)-1), std::max<T>( T(0), x)); }
143
144/** clip a, such that minVal <= a <= maxVal */
145template <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
146
147#define DATA_ALIGN                  1                                                                 ///< use 32-bit aligned malloc/free
148#if     DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
149#define xMalloc( type, len )        _aligned_malloc( sizeof(type)*(len), 32 )
150#define xFree( ptr )                _aligned_free  ( ptr )
151#else
152#define xMalloc( type, len )        malloc   ( sizeof(type)*(len) )
153#define xFree( ptr )                free     ( ptr )
154#endif
155
156#define FATAL_ERROR_0(MESSAGE, EXITCODE)                      \
157{                                                             \
158  printf(MESSAGE);                                            \
159  exit(EXITCODE);                                             \
160}
161
162#if H_MV
163
164#define AOF( exp )                  \
165{                                   \
166  if( !( exp ) )                    \
167{                                 \
168  assert( 0 );                    \
169}                                 \
170}
171
172#define AOT( exp )            \
173{                             \
174  if( ( exp ) )               \
175{                           \
176  assert( 0 );              \
177}                           \
178}
179
180#if H_3D_IV_MERGE
181#define ROFVS( exp )          \
182{                             \
183  if( !( exp ) )              \
184{                           \
185  return;                   \
186}                           \
187}
188
189#define ROTVS( exp )          \
190{                             \
191  if( ( exp ) )               \
192{                           \
193  return;                   \
194}                           \
195}
196
197#define ROTRS( exp, retVal )  \
198{                             \
199  if( ( exp ) )               \
200{                           \
201  return retVal;            \
202}                           \
203}
204
205#define ROFRS( exp, retVal )  \
206{                             \
207  if( !( exp ) )              \
208{                           \
209  return retVal;            \
210}                           \
211}
212#endif
213template <typename T>
214__inline T gSign(const T& t)
215{
216  if( t == 0 )
217    return T(0);
218  else
219    return (t < 0) ? T(-1) : T(1);
220}
221
222#define RemoveBitIncrement( exp ) ( exp >> ( g_bitDepthY - 8 ) )
223
224#endif
225
226// ====================================================================================================================
227// Coding tool configuration
228// ====================================================================================================================
229
230// AMVP: advanced motion vector prediction
231#define AMVP_MAX_NUM_CANDS          2           ///< max number of final candidates
232#define AMVP_MAX_NUM_CANDS_MEM      3           ///< max number of candidates
233// MERGE
234#define MRG_MAX_NUM_CANDS           5
235#if H_3D_IV_MERGE
236#define MRG_MAX_NUM_CANDS_MEM       (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction
237#endif
238// Reference memory management
239#define DYN_REF_FREE                0           ///< dynamic free of reference memories
240
241// Explicit temporal layer QP offset
242#define MAX_TLAYER                  8           ///< max number of temporal layer
243#define HB_LAMBDA_FOR_LDC           1           ///< use of B-style lambda for non-key pictures in low-delay mode
244
245// Fast estimation of generalized B in low-delay mode
246#define GPB_SIMPLE                  1           ///< Simple GPB mode
247#if     GPB_SIMPLE
248#define GPB_SIMPLE_UNI              1           ///< Simple mode for uni-direction
249#endif
250
251// Fast ME using smoother MV assumption
252#define FASTME_SMOOTHER_MV          1           ///< reduce ME time using faster option
253
254// Adaptive search range depending on POC difference
255#define ADAPT_SR_SCALE              1           ///< division factor for adaptive search range
256
257#define CLIP_TO_709_RANGE           0
258
259// Early-skip threshold (encoder)
260#define EARLY_SKIP_THRES            1.50        ///< if RD < thres*avg[BestSkipRD]
261
262
263#define MAX_CHROMA_FORMAT_IDC      3
264
265// TODO: Existing names used for the different NAL unit types can be altered to better reflect the names in the spec.
266//       However, the names in the spec are not yet stable at this point. Once the names are stable, a cleanup
267//       effort can be done without use of macros to alter the names used to indicate the different NAL unit types.
268enum NalUnitType
269{
270  NAL_UNIT_CODED_SLICE_TRAIL_N = 0,   // 0
271  NAL_UNIT_CODED_SLICE_TRAIL_R,   // 1
272 
273  NAL_UNIT_CODED_SLICE_TSA_N,     // 2
274  NAL_UNIT_CODED_SLICE_TLA_R,       // 3
275 
276  NAL_UNIT_CODED_SLICE_STSA_N,    // 4
277  NAL_UNIT_CODED_SLICE_STSA_R,    // 5
278
279  NAL_UNIT_CODED_SLICE_RADL_N,    // 6
280  NAL_UNIT_CODED_SLICE_RADL_R,      // 7
281 
282  NAL_UNIT_CODED_SLICE_RASL_N,    // 8
283  NAL_UNIT_CODED_SLICE_RASL_R,      // 9
284
285  NAL_UNIT_RESERVED_VCL_N10,
286  NAL_UNIT_RESERVED_VCL_R11,
287  NAL_UNIT_RESERVED_VCL_N12,
288  NAL_UNIT_RESERVED_VCL_R13,
289  NAL_UNIT_RESERVED_VCL_N14,
290  NAL_UNIT_RESERVED_VCL_R15,
291
292  NAL_UNIT_CODED_SLICE_BLA_W_LP,    // 16
293  NAL_UNIT_CODED_SLICE_BLA_W_RADL,  // 17
294  NAL_UNIT_CODED_SLICE_BLA_N_LP,  // 18
295  NAL_UNIT_CODED_SLICE_IDR_W_RADL,  // 19
296  NAL_UNIT_CODED_SLICE_IDR_N_LP,  // 20
297  NAL_UNIT_CODED_SLICE_CRA,       // 21
298  NAL_UNIT_RESERVED_IRAP_VCL22,
299  NAL_UNIT_RESERVED_IRAP_VCL23,
300
301  NAL_UNIT_RESERVED_VCL24,
302  NAL_UNIT_RESERVED_VCL25,
303  NAL_UNIT_RESERVED_VCL26,
304  NAL_UNIT_RESERVED_VCL27,
305  NAL_UNIT_RESERVED_VCL28,
306  NAL_UNIT_RESERVED_VCL29,
307  NAL_UNIT_RESERVED_VCL30,
308  NAL_UNIT_RESERVED_VCL31,
309
310  NAL_UNIT_VPS,                   // 32
311  NAL_UNIT_SPS,                   // 33
312  NAL_UNIT_PPS,                   // 34
313  NAL_UNIT_ACCESS_UNIT_DELIMITER, // 35
314  NAL_UNIT_EOS,                   // 36
315  NAL_UNIT_EOB,                   // 37
316  NAL_UNIT_FILLER_DATA,           // 38
317  NAL_UNIT_PREFIX_SEI,              // 39
318  NAL_UNIT_SUFFIX_SEI,              // 40
319  NAL_UNIT_RESERVED_NVCL41,
320  NAL_UNIT_RESERVED_NVCL42,
321  NAL_UNIT_RESERVED_NVCL43,
322  NAL_UNIT_RESERVED_NVCL44,
323  NAL_UNIT_RESERVED_NVCL45,
324  NAL_UNIT_RESERVED_NVCL46,
325  NAL_UNIT_RESERVED_NVCL47,
326  NAL_UNIT_UNSPECIFIED_48,
327  NAL_UNIT_UNSPECIFIED_49,
328  NAL_UNIT_UNSPECIFIED_50,
329  NAL_UNIT_UNSPECIFIED_51,
330  NAL_UNIT_UNSPECIFIED_52,
331  NAL_UNIT_UNSPECIFIED_53,
332  NAL_UNIT_UNSPECIFIED_54,
333  NAL_UNIT_UNSPECIFIED_55,
334  NAL_UNIT_UNSPECIFIED_56,
335  NAL_UNIT_UNSPECIFIED_57,
336  NAL_UNIT_UNSPECIFIED_58,
337  NAL_UNIT_UNSPECIFIED_59,
338  NAL_UNIT_UNSPECIFIED_60,
339  NAL_UNIT_UNSPECIFIED_61,
340  NAL_UNIT_UNSPECIFIED_62,
341  NAL_UNIT_UNSPECIFIED_63,
342  NAL_UNIT_INVALID,
343};
344
345#if H_3D
346//PICYUV
347#define PICYUV_PAD         16
348
349//RENDERER
350#define REN_LUMA_MARGIN   ( g_uiMaxCUWidth + PICYUV_PAD )
351#define REN_VDWEIGHT_PREC  8
352#define REN_IS_FILLED     ( 1 << REN_VDWEIGHT_PREC )
353#define REN_USED_PEL       ( (1 << g_bitDepthY) - 1 )
354#define REN_UNUSED_PEL     0
355#define REN_IS_HOLE        0
356
357
358// CAMERA PARAMETERS
359#define LOG2_DISP_PREC_LUT           2           ///< log2 of disparity precision used in integer disparity LUTs
360#define STD_CAM_PARAMETERS_PRECISION 5        ///< quarter luma sample accuarcy for derived disparities (as default)
361
362#if H_3D_IV_MERGE
363 // GT: To be checked if all of this is still necessary.
364#define PDM_USE_FOR_IVIEW                 1
365#define PDM_USE_FOR_INTER                 2
366#define PDM_USE_FOR_MERGE                 4
367
368#define MAX_VIEW_NUM                      10
369#define PDM_SUBSAMPLING_EXP               2         // subsampling factor is 2^PDM_SUBSAMPLING_EXP
370#define PDM_SUB_SAMP_EXP_X(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
371#define PDM_SUB_SAMP_EXP_Y(Pdm)           ((Pdm)==1?PDM_SUBSAMPLING_EXP:0)
372
373#define PDM_INTERNAL_CALC_BIT_DEPTH       31        // bit depth for internal calculations (32 - 1 for signed values)
374#define PDM_BITDEPTH_VIRT_DEPTH           15        // bit depth for virtual depth storage (16 - 1 for signed values)
375#define PDM_LOG2_MAX_ABS_NORMAL_DISPARITY 8         // maximum absolute normal disparity = 256 (for setting accuracy)
376#define PDM_VIRT_DEPTH_PRECISION          4         // must be greater than or equal to 2 (since MVs are given in quarter-pel units)
377
378#define PDM_INTER_CALC_SHIFT              ( PDM_INTERNAL_CALC_BIT_DEPTH - PDM_BITDEPTH_VIRT_DEPTH )         // avoids overflow
379#define PDM_LOG4_SCALE_DENOMINATOR        ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY + PDM_VIRT_DEPTH_PRECISION )  // accuracy of scaling factor
380#define PDM_OFFSET_SHIFT                  ( PDM_LOG2_MAX_ABS_NORMAL_DISPARITY )                             // accuracy of offset
381
382#endif
383#endif // end of H_3D
384//! \}
385
386#endif // end of #ifndef  __COMMONDEF__
387
Note: See TracBrowser for help on using the repository browser.