source: SHVCSoftware/branches/SHM-2.0-dev/source/Lib/TLibCommon/CommonDef.h @ 583

Last change on this file since 583 was 188, checked in by seregin, 12 years ago

change version to 2.0rc1

File size: 10.5 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#define NV_VERSION        "2.0rc1"                 ///< Current software version
59
60// ====================================================================================================================
61// Platform information
62// ====================================================================================================================
63
64#ifdef __GNUC__
65#define NVM_COMPILEDBY  "[GCC %d.%d.%d]", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__
66#ifdef __IA64__
67#define NVM_ONARCH    "[on 64-bit] "
68#else
69#define NVM_ONARCH    "[on 32-bit] "
70#endif
71#endif
72
73#ifdef __INTEL_COMPILER
74#define NVM_COMPILEDBY  "[ICC %d]", __INTEL_COMPILER
75#elif  _MSC_VER
76#define NVM_COMPILEDBY  "[VS %d]", _MSC_VER
77#endif
78
79#ifndef NVM_COMPILEDBY
80#define NVM_COMPILEDBY "[Unk-CXX]"
81#endif
82
83#ifdef _WIN32
84#define NVM_ONOS        "[Windows]"
85#elif  __linux
86#define NVM_ONOS        "[Linux]"
87#elif  __CYGWIN__
88#define NVM_ONOS        "[Cygwin]"
89#elif __APPLE__
90#define NVM_ONOS        "[Mac OS X]"
91#else
92#define NVM_ONOS "[Unk-OS]"
93#endif
94
95#define NVM_BITS          "[%d bit] ", (sizeof(void*) == 8 ? 64 : 32) ///< used for checking 64-bit O/S
96
97#ifndef NULL
98#define NULL              0
99#endif
100
101// ====================================================================================================================
102// Common constants
103// ====================================================================================================================
104
105#define _SUMMARY_OUT_               0           ///< print-out PSNR results of all slices to summary.txt
106#define _SUMMARY_PIC_               0           ///< print-out PSNR results for each slice type to summary.txt
107
108#define MAX_GOP                     64          ///< max. value of hierarchical GOP size
109
110#define MAX_NUM_REF_PICS            16          ///< max. number of pictures used for reference
111#define MAX_NUM_REF                 16          ///< max. number of entries in picture reference list
112#if !L0034_COMBINED_LIST_CLEANUP
113#define MAX_NUM_REF_LC              MAX_NUM_REF_PICS  // TODO: remove this macro definition (leftover from combined list concept)
114#endif
115
116#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
117#define MAX_INT                     2147483647  ///< max. value of signed 32-bit integer
118#define MAX_INT64                   0x7FFFFFFFFFFFFFFFLL  ///< max. value of signed 64-bit integer
119#define MAX_DOUBLE                  1.7e+308    ///< max. value of double-type value
120
121#define MIN_QP                      0
122#define MAX_QP                      51
123
124#define NOT_VALID                   -1
125
126// ====================================================================================================================
127// Macro functions
128// ====================================================================================================================
129extern Int g_bitDepthY;
130extern Int g_bitDepthC;
131
132/** clip x, such that 0 <= x <= #g_maxLumaVal */
133template <typename T> inline T ClipY(T x) { return std::min<T>(T((1 << g_bitDepthY)-1), std::max<T>( T(0), x)); }
134template <typename T> inline T ClipC(T x) { return std::min<T>(T((1 << g_bitDepthC)-1), std::max<T>( T(0), x)); }
135
136/** clip a, such that minVal <= a <= maxVal */
137template <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
138
139#define DATA_ALIGN                  1                                                                 ///< use 32-bit aligned malloc/free
140#if     DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 )
141#define xMalloc( type, len )        _aligned_malloc( sizeof(type)*(len), 32 )
142#define xFree( ptr )                _aligned_free  ( ptr )
143#else
144#define xMalloc( type, len )        malloc   ( sizeof(type)*(len) )
145#define xFree( ptr )                free     ( ptr )
146#endif
147
148#define FATAL_ERROR_0(MESSAGE, EXITCODE)                      \
149{                                                             \
150  printf(MESSAGE);                                            \
151  exit(EXITCODE);                                             \
152}
153
154
155// ====================================================================================================================
156// Coding tool configuration
157// ====================================================================================================================
158
159// AMVP: advanced motion vector prediction
160#define AMVP_MAX_NUM_CANDS          2           ///< max number of final candidates
161#define AMVP_MAX_NUM_CANDS_MEM      3           ///< max number of candidates
162// MERGE
163#define MRG_MAX_NUM_CANDS           5
164
165// Reference memory management
166#define DYN_REF_FREE                0           ///< dynamic free of reference memories
167
168// Explicit temporal layer QP offset
169#define MAX_TLAYER                  8           ///< max number of temporal layer
170#define HB_LAMBDA_FOR_LDC           1           ///< use of B-style lambda for non-key pictures in low-delay mode
171
172// Fast estimation of generalized B in low-delay mode
173#define GPB_SIMPLE                  1           ///< Simple GPB mode
174#if     GPB_SIMPLE
175#define GPB_SIMPLE_UNI              1           ///< Simple mode for uni-direction
176#endif
177
178// Fast ME using smoother MV assumption
179#define FASTME_SMOOTHER_MV          1           ///< reduce ME time using faster option
180
181// Adaptive search range depending on POC difference
182#define ADAPT_SR_SCALE              1           ///< division factor for adaptive search range
183
184#define CLIP_TO_709_RANGE           0
185
186// Early-skip threshold (encoder)
187#define EARLY_SKIP_THRES            1.50        ///< if RD < thres*avg[BestSkipRD]
188
189
190#define MAX_CHROMA_FORMAT_IDC      3
191
192// TODO: Existing names used for the different NAL unit types can be altered to better reflect the names in the spec.
193//       However, the names in the spec are not yet stable at this point. Once the names are stable, a cleanup
194//       effort can be done without use of macros to alter the names used to indicate the different NAL unit types.
195enum NalUnitType
196{
197  NAL_UNIT_CODED_SLICE_TRAIL_N = 0,   // 0
198  NAL_UNIT_CODED_SLICE_TRAIL_R,   // 1
199 
200  NAL_UNIT_CODED_SLICE_TSA_N,     // 2
201  NAL_UNIT_CODED_SLICE_TLA_R,       // 3
202 
203  NAL_UNIT_CODED_SLICE_STSA_N,    // 4
204  NAL_UNIT_CODED_SLICE_STSA_R,    // 5
205
206  NAL_UNIT_CODED_SLICE_RADL_N,    // 6
207  NAL_UNIT_CODED_SLICE_RADL_R,      // 7
208 
209  NAL_UNIT_CODED_SLICE_RASL_N,    // 8
210  NAL_UNIT_CODED_SLICE_RASL_R,      // 9
211
212  NAL_UNIT_RESERVED_VCL_N10,
213  NAL_UNIT_RESERVED_VCL_R11,
214  NAL_UNIT_RESERVED_VCL_N12,
215  NAL_UNIT_RESERVED_VCL_R13,
216  NAL_UNIT_RESERVED_VCL_N14,
217  NAL_UNIT_RESERVED_VCL_R15,
218
219  NAL_UNIT_CODED_SLICE_BLA_W_LP,    // 16
220  NAL_UNIT_CODED_SLICE_BLA_W_RADL,  // 17
221  NAL_UNIT_CODED_SLICE_BLA_N_LP,  // 18
222  NAL_UNIT_CODED_SLICE_IDR_W_RADL,  // 19
223  NAL_UNIT_CODED_SLICE_IDR_N_LP,  // 20
224  NAL_UNIT_CODED_SLICE_CRA,       // 21
225  NAL_UNIT_RESERVED_IRAP_VCL22,
226  NAL_UNIT_RESERVED_IRAP_VCL23,
227
228  NAL_UNIT_RESERVED_VCL24,
229  NAL_UNIT_RESERVED_VCL25,
230  NAL_UNIT_RESERVED_VCL26,
231  NAL_UNIT_RESERVED_VCL27,
232  NAL_UNIT_RESERVED_VCL28,
233  NAL_UNIT_RESERVED_VCL29,
234  NAL_UNIT_RESERVED_VCL30,
235  NAL_UNIT_RESERVED_VCL31,
236
237  NAL_UNIT_VPS,                   // 32
238  NAL_UNIT_SPS,                   // 33
239  NAL_UNIT_PPS,                   // 34
240  NAL_UNIT_ACCESS_UNIT_DELIMITER, // 35
241  NAL_UNIT_EOS,                   // 36
242  NAL_UNIT_EOB,                   // 37
243  NAL_UNIT_FILLER_DATA,           // 38
244  NAL_UNIT_PREFIX_SEI,              // 39
245  NAL_UNIT_SUFFIX_SEI,              // 40
246  NAL_UNIT_RESERVED_NVCL41,
247  NAL_UNIT_RESERVED_NVCL42,
248  NAL_UNIT_RESERVED_NVCL43,
249  NAL_UNIT_RESERVED_NVCL44,
250  NAL_UNIT_RESERVED_NVCL45,
251  NAL_UNIT_RESERVED_NVCL46,
252  NAL_UNIT_RESERVED_NVCL47,
253  NAL_UNIT_UNSPECIFIED_48,
254  NAL_UNIT_UNSPECIFIED_49,
255  NAL_UNIT_UNSPECIFIED_50,
256  NAL_UNIT_UNSPECIFIED_51,
257  NAL_UNIT_UNSPECIFIED_52,
258  NAL_UNIT_UNSPECIFIED_53,
259  NAL_UNIT_UNSPECIFIED_54,
260  NAL_UNIT_UNSPECIFIED_55,
261  NAL_UNIT_UNSPECIFIED_56,
262  NAL_UNIT_UNSPECIFIED_57,
263  NAL_UNIT_UNSPECIFIED_58,
264  NAL_UNIT_UNSPECIFIED_59,
265  NAL_UNIT_UNSPECIFIED_60,
266  NAL_UNIT_UNSPECIFIED_61,
267  NAL_UNIT_UNSPECIFIED_62,
268  NAL_UNIT_UNSPECIFIED_63,
269  NAL_UNIT_INVALID,
270};
271
272//! \}
273
274#endif // end of #ifndef  __COMMONDEF__
275
Note: See TracBrowser for help on using the repository browser.