[5] | 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 |
---|
[1313] | 4 | * granted under this license. |
---|
[5] | 5 | * |
---|
[1413] | 6 | * Copyright (c) 2010-2017, ITU/ISO/IEC |
---|
[5] | 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. |
---|
[56] | 17 | * * Neither the name of the ITU/ISO/IEC nor the names of its contributors may |
---|
[5] | 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 | */ |
---|
[2] | 33 | |
---|
| 34 | /** \file CommonDef.h |
---|
[1313] | 35 | \brief Defines version information, constants and small in-line functions |
---|
[2] | 36 | */ |
---|
| 37 | |
---|
| 38 | #ifndef __COMMONDEF__ |
---|
| 39 | #define __COMMONDEF__ |
---|
| 40 | |
---|
[56] | 41 | #include <algorithm> |
---|
[1313] | 42 | #include <iostream> |
---|
| 43 | #include <assert.h> |
---|
[1386] | 44 | #include <limits> |
---|
[56] | 45 | |
---|
[2] | 46 | #if _MSC_VER > 1000 |
---|
[56] | 47 | // disable "signed and unsigned mismatch" |
---|
[2] | 48 | #pragma warning( disable : 4018 ) |
---|
[1313] | 49 | // disable Bool coercion "performance warning" |
---|
[56] | 50 | #pragma warning( disable : 4800 ) |
---|
[1313] | 51 | // NH_MV |
---|
| 52 | // disabled decorated name length warning issued for IntAry5d |
---|
| 53 | #pragma warning(disable : 4503) |
---|
| 54 | // |
---|
[2] | 55 | #endif // _MSC_VER > 1000 |
---|
| 56 | #include "TypeDef.h" |
---|
[1313] | 57 | #ifdef _MSC_VER |
---|
| 58 | #if _MSC_VER <= 1500 |
---|
| 59 | inline Int64 abs (Int64 x) { return _abs64(x); }; |
---|
| 60 | #endif |
---|
| 61 | #endif |
---|
| 62 | #if NH_MV |
---|
[622] | 63 | #include <assert.h> |
---|
| 64 | #endif |
---|
[2] | 65 | |
---|
[56] | 66 | //! \ingroup TLibCommon |
---|
| 67 | //! \{ |
---|
[2] | 68 | |
---|
| 69 | // ==================================================================================================================== |
---|
| 70 | // Version information |
---|
| 71 | // ==================================================================================================================== |
---|
[1313] | 72 | #if NH_MV |
---|
[1414] | 73 | #define NV_VERSION "16.3" ///< Current software version |
---|
[1413] | 74 | #define HM_VERSION "16.18" ///< |
---|
[608] | 75 | #else |
---|
[1413] | 76 | #define NV_VERSION "16.18" ///< Current software version |
---|
[608] | 77 | #endif |
---|
[2] | 78 | // ==================================================================================================================== |
---|
| 79 | // Platform information |
---|
| 80 | // ==================================================================================================================== |
---|
| 81 | |
---|
| 82 | #ifdef __GNUC__ |
---|
| 83 | #define NVM_COMPILEDBY "[GCC %d.%d.%d]", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__ |
---|
| 84 | #ifdef __IA64__ |
---|
| 85 | #define NVM_ONARCH "[on 64-bit] " |
---|
| 86 | #else |
---|
| 87 | #define NVM_ONARCH "[on 32-bit] " |
---|
| 88 | #endif |
---|
| 89 | #endif |
---|
| 90 | |
---|
| 91 | #ifdef __INTEL_COMPILER |
---|
| 92 | #define NVM_COMPILEDBY "[ICC %d]", __INTEL_COMPILER |
---|
| 93 | #elif _MSC_VER |
---|
| 94 | #define NVM_COMPILEDBY "[VS %d]", _MSC_VER |
---|
| 95 | #endif |
---|
| 96 | |
---|
| 97 | #ifndef NVM_COMPILEDBY |
---|
| 98 | #define NVM_COMPILEDBY "[Unk-CXX]" |
---|
| 99 | #endif |
---|
| 100 | |
---|
| 101 | #ifdef _WIN32 |
---|
| 102 | #define NVM_ONOS "[Windows]" |
---|
| 103 | #elif __linux |
---|
| 104 | #define NVM_ONOS "[Linux]" |
---|
| 105 | #elif __CYGWIN__ |
---|
| 106 | #define NVM_ONOS "[Cygwin]" |
---|
| 107 | #elif __APPLE__ |
---|
| 108 | #define NVM_ONOS "[Mac OS X]" |
---|
| 109 | #else |
---|
| 110 | #define NVM_ONOS "[Unk-OS]" |
---|
| 111 | #endif |
---|
| 112 | |
---|
[1313] | 113 | #define NVM_BITS "[%d bit] ", (sizeof(Void*) == 8 ? 64 : 32) ///< used for checking 64-bit O/S |
---|
[2] | 114 | |
---|
| 115 | #ifndef NULL |
---|
| 116 | #define NULL 0 |
---|
| 117 | #endif |
---|
| 118 | |
---|
| 119 | // ==================================================================================================================== |
---|
| 120 | // Common constants |
---|
| 121 | // ==================================================================================================================== |
---|
| 122 | |
---|
[1313] | 123 | static const UInt MAX_UINT = 0xFFFFFFFFU; ///< max. value of unsigned 32-bit integer |
---|
| 124 | static const Int MAX_INT = 2147483647; ///< max. value of signed 32-bit integer |
---|
| 125 | #if NH_MV |
---|
| 126 | static const Int MIN_INT = (- MAX_INT - 1); ///< max. value of signed 32-bit integer |
---|
| 127 | #endif |
---|
| 128 | static const Double MAX_DOUBLE = 1.7e+308; ///< max. value of Double-type value |
---|
[2] | 129 | |
---|
[1313] | 130 | // ==================================================================================================================== |
---|
| 131 | // Coding tool configuration |
---|
| 132 | // ==================================================================================================================== |
---|
| 133 | // Most of these should not be changed - they resolve the meaning of otherwise magic numbers. |
---|
[2] | 134 | |
---|
[1313] | 135 | static const Int MAX_GOP = 64; ///< max. value of hierarchical GOP size |
---|
| 136 | static const Int MAX_NUM_REF_PICS = 16; ///< max. number of pictures used for reference |
---|
| 137 | static const Int MAX_NUM_REF = 16; ///< max. number of entries in picture reference list |
---|
| 138 | static const Int MAX_QP = 51; |
---|
| 139 | static const Int NOT_VALID = -1; |
---|
[2] | 140 | |
---|
[1313] | 141 | static const Int AMVP_MAX_NUM_CANDS = 2; ///< AMVP: advanced motion vector prediction - max number of final candidates |
---|
| 142 | static const Int AMVP_DECIMATION_FACTOR = 4; |
---|
| 143 | static const Int MRG_MAX_NUM_CANDS = 5; ///< MERGE |
---|
[738] | 144 | |
---|
[2] | 145 | |
---|
[1313] | 146 | static const Int MAX_TLAYER = 7; ///< Explicit temporal layer QP offset - max number of temporal layer |
---|
[2] | 147 | |
---|
[1313] | 148 | static const Int ADAPT_SR_SCALE = 1; ///< division factor for adaptive search range |
---|
[2] | 149 | |
---|
[1313] | 150 | static const Int MAX_NUM_PICS_IN_SOP = 1024; |
---|
| 151 | |
---|
| 152 | static const Int MAX_NESTING_NUM_OPS = 1024; |
---|
| 153 | static const Int MAX_NESTING_NUM_LAYER = 64; |
---|
| 154 | |
---|
| 155 | #if NH_MV |
---|
| 156 | static const Int MAX_VPS_NUM_HRD_PARAMETERS = 1024; |
---|
| 157 | #else |
---|
| 158 | static const Int MAX_VPS_NUM_HRD_PARAMETERS = 1; |
---|
| 159 | #endif |
---|
| 160 | static const Int MAX_VPS_OP_SETS_PLUS1 = 1024; |
---|
| 161 | #if NH_MV |
---|
| 162 | static const Int MAX_VPS_NUH_LAYER_ID_PLUS1 = 63; |
---|
| 163 | #else |
---|
| 164 | static const Int MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 = 1; |
---|
| 165 | #endif |
---|
| 166 | |
---|
| 167 | static const Int MAXIMUM_INTRA_FILTERED_WIDTH = 16; |
---|
| 168 | static const Int MAXIMUM_INTRA_FILTERED_HEIGHT = 16; |
---|
| 169 | |
---|
| 170 | static const Int MAX_CPB_CNT = 32; ///< Upper bound of (cpb_cnt_minus1 + 1) |
---|
| 171 | #if NH_MV |
---|
| 172 | static const Int MAX_NUM_LAYER_IDS = 63; |
---|
[1356] | 173 | static const Int MAX_NUM_SEIS = 1000; |
---|
[1313] | 174 | #else |
---|
| 175 | static const Int MAX_NUM_LAYER_IDS = 64; |
---|
| 176 | #endif |
---|
| 177 | |
---|
| 178 | static const Int COEF_REMAIN_BIN_REDUCTION = 3; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k) |
---|
| 179 | |
---|
| 180 | static const Int CU_DQP_TU_CMAX = 5; ///< max number bins for truncated unary |
---|
| 181 | static const Int CU_DQP_EG_k = 0; ///< expgolomb order |
---|
| 182 | |
---|
| 183 | static const Int SBH_THRESHOLD = 4; ///< value of the fixed SBH controlling threshold |
---|
| 184 | |
---|
| 185 | static const Int C1FLAG_NUMBER = 8; // maximum number of largerThan1 flag coded in one chunk: 16 in HM5 |
---|
| 186 | static const Int C2FLAG_NUMBER = 1; // maximum number of largerThan2 flag coded in one chunk: 16 in HM5 |
---|
| 187 | |
---|
| 188 | static const Int MAX_NUM_VPS = 16; |
---|
| 189 | static const Int MAX_NUM_SPS = 16; |
---|
| 190 | static const Int MAX_NUM_PPS = 64; |
---|
| 191 | |
---|
| 192 | |
---|
| 193 | static const Int MLS_GRP_NUM = 64; ///< Max number of coefficient groups, max(16, 64) |
---|
| 194 | static const Int MLS_CG_LOG2_WIDTH = 2; |
---|
| 195 | static const Int MLS_CG_LOG2_HEIGHT = 2; |
---|
| 196 | static const Int MLS_CG_SIZE = 4; ///< Coefficient group size of 4x4; = MLS_CG_LOG2_WIDTH + MLS_CG_LOG2_HEIGHT |
---|
| 197 | |
---|
| 198 | #if ADAPTIVE_QP_SELECTION |
---|
| 199 | static const Int ARL_C_PRECISION = 7; ///< G382: 7-bit arithmetic precision |
---|
| 200 | static const Int LEVEL_RANGE = 30; ///< G382: max coefficient level in statistics collection |
---|
| 201 | #endif |
---|
| 202 | |
---|
| 203 | static const Int RVM_VCEGAM10_M = 4; |
---|
| 204 | |
---|
| 205 | static const Int FAST_UDI_MAX_RDMODE_NUM = 35; ///< maximum number of RD comparison in fast-UDI estimation loop |
---|
| 206 | |
---|
| 207 | static const Int NUM_INTRA_MODE = 36; |
---|
| 208 | static const Int PLANAR_IDX = 0; |
---|
| 209 | static const Int VER_IDX = 26; ///< index for intra VERTICAL mode |
---|
| 210 | static const Int HOR_IDX = 10; ///< index for intra HORIZONTAL mode |
---|
| 211 | static const Int DC_IDX = 1; ///< index for intra DC mode |
---|
| 212 | static const Int NUM_CHROMA_MODE = 5; ///< total number of chroma modes |
---|
| 213 | static const Int DM_CHROMA_IDX = 36; ///< chroma mode index for derived from luma intra mode |
---|
| 214 | |
---|
| 215 | static const Int MDCS_ANGLE_LIMIT = 4; ///< 0 = Horizontal/vertical only, 1 = Horizontal/vertical +/- 1, 2 = Horizontal/vertical +/- 2 etc... |
---|
| 216 | static const Int MDCS_MAXIMUM_WIDTH = 8; ///< (measured in pixels) TUs with width greater than this can only use diagonal scan |
---|
| 217 | static const Int MDCS_MAXIMUM_HEIGHT = 8; ///< (measured in pixels) TUs with height greater than this can only use diagonal scan |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | static const Int LOG2_MAX_NUM_COLUMNS_MINUS1 = 7; |
---|
| 221 | static const Int LOG2_MAX_NUM_ROWS_MINUS1 = 7; |
---|
| 222 | |
---|
| 223 | static const Int CABAC_INIT_PRESENT_FLAG = 1; |
---|
| 224 | |
---|
| 225 | static const Int LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS = 4; |
---|
| 226 | static const Int CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS = 8; |
---|
| 227 | |
---|
| 228 | static const Int MAX_NUM_LONG_TERM_REF_PICS = 33; |
---|
| 229 | static const Int NUM_LONG_TERM_REF_PIC_SPS = 0; |
---|
| 230 | |
---|
| 231 | |
---|
| 232 | static const Int MAX_QP_OFFSET_LIST_SIZE = 6; ///< Maximum size of QP offset list is 6 entries |
---|
| 233 | |
---|
| 234 | // Cost mode support |
---|
| 235 | static const Int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP = 0; ///< QP to use for lossless coding. |
---|
| 236 | static const Int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME =4; ///< QP' to use for mixed_lossy_lossless coding. |
---|
| 237 | |
---|
| 238 | static const Int RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS = 4; |
---|
| 239 | static const Int RExt__GOLOMB_RICE_INCREMENT_DIVISOR = 4; |
---|
| 240 | |
---|
| 241 | static const Int RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION = 0; ///< Additional fixed bit precision used during encoder-side weighting prediction analysis. Currently only used when high_precision_prediction_weighting_flag is set, for backwards compatibility reasons. |
---|
| 242 | |
---|
| 243 | static const Int MAX_TIMECODE_SEI_SETS = 3; ///< Maximum number of time sets |
---|
| 244 | |
---|
| 245 | static const Int MAX_CU_DEPTH = 6; ///< log2(CTUSize) |
---|
| 246 | static const Int MAX_CU_SIZE = 64; ///< = 1<<(MAX_CU_DEPTH) |
---|
| 247 | static const Int MIN_PU_SIZE = 4; |
---|
| 248 | static const Int MIN_TU_SIZE = 4; |
---|
| 249 | static const Int MAX_TU_SIZE = 32; |
---|
| 250 | static const Int MAX_NUM_PART_IDXS_IN_CTU_WIDTH = MAX_CU_SIZE/MIN_PU_SIZE; ///< maximum number of partition indices across the width of a CTU (or height of a CTU) |
---|
| 251 | static const Int SCALING_LIST_REM_NUM = 6; |
---|
| 252 | |
---|
| 253 | static const Int QUANT_SHIFT = 14; ///< Q(4) = 2^14 |
---|
| 254 | static const Int IQUANT_SHIFT = 6; |
---|
| 255 | static const Int SCALE_BITS = 15; ///< For fractional bit estimates in RDOQ |
---|
| 256 | |
---|
| 257 | static const Int SCALING_LIST_NUM = MAX_NUM_COMPONENT * NUMBER_OF_PREDICTION_MODES; ///< list number for quantization matrix |
---|
| 258 | |
---|
| 259 | static const Int SCALING_LIST_START_VALUE = 8 ; ///< start value for dpcm mode |
---|
| 260 | static const Int MAX_MATRIX_COEF_NUM = 64 ; ///< max coefficient number for quantization matrix |
---|
| 261 | static const Int MAX_MATRIX_SIZE_NUM = 8 ; ///< max size number for quantization matrix |
---|
| 262 | static const Int SCALING_LIST_BITS = 8 ; ///< bit depth of scaling list entries |
---|
| 263 | static const Int LOG2_SCALING_LIST_NEUTRAL_VALUE = 4 ; ///< log2 of the value that, when used in a scaling list, has no effect on quantisation |
---|
| 264 | static const Int SCALING_LIST_DC = 16 ; ///< default DC value |
---|
| 265 | |
---|
| 266 | static const Int CONTEXT_STATE_BITS = 6 ; |
---|
| 267 | static const Int LAST_SIGNIFICANT_GROUPS = 10 ; |
---|
| 268 | |
---|
[1405] | 269 | static const Int MAX_ENCODER_DEBLOCKING_QUALITY_LAYERS = 8 ; |
---|
| 270 | |
---|
[1313] | 271 | #if NH_MV |
---|
| 272 | static const Int MAX_VPS_NUM_ADD_LAYER_SETS = 1024 ; |
---|
| 273 | static const Int MAX_NUM_SCALABILITY_TYPES = 16 ; |
---|
| 274 | static const Int ENC_CFG_CONSOUT_SPACE = 34 ; |
---|
| 275 | static const Int MAX_NUM_LAYERS = 63 ; |
---|
| 276 | static const Int MAX_VPS_PROFILE_TIER_LEVEL = 64 ; |
---|
| 277 | static const Int MAX_VPS_ADD_OUTPUT_LAYER_SETS = 1024 ; |
---|
| 278 | static const Int MAX_VPS_OUTPUTLAYER_SETS = MAX_VPS_ADD_OUTPUT_LAYER_SETS + MAX_VPS_OP_SETS_PLUS1 + MAX_VPS_OP_SETS_PLUS1 ; |
---|
| 279 | static const Int MAX_NUM_VIDEO_SIGNAL_INFO = 16 ; |
---|
| 280 | static const Int MAX_NUM_SCALED_REF_LAYERS = MAX_NUM_LAYERS - 1 ; |
---|
[1321] | 281 | static const Int MAX_NUM_PICS_RPS = 16 ; |
---|
| 282 | static const Int MAX_NUM_REF_LAYERS = 63 ; |
---|
[1386] | 283 | |
---|
[1356] | 284 | static IntAry1d getRangeVec( Int rngStart, Int rngEnd ) { IntAry1d rng; for (Int i = rngStart; i<=rngEnd; i++) rng.push_back(i); return rng; }; |
---|
| 285 | static const IntAry1d IDR_NAL_UNIT_TYPES = getRangeVec( NAL_UNIT_CODED_SLICE_IDR_W_RADL, NAL_UNIT_CODED_SLICE_IDR_N_LP ); |
---|
| 286 | static const IntAry1d IRAP_NAL_UNIT_TYPES = getRangeVec( NAL_UNIT_CODED_SLICE_BLA_W_LP , NAL_UNIT_CODED_SLICE_CRA ); |
---|
[1313] | 287 | #endif |
---|
| 288 | |
---|
[1413] | 289 | static const UInt LUMA_LEVEL_TO_DQP_LUT_MAXSIZE = 1024; ///< max LUT size for QP offset based on luma |
---|
| 290 | |
---|
| 291 | |
---|
[56] | 292 | // ==================================================================================================================== |
---|
[2] | 293 | // Macro functions |
---|
| 294 | // ==================================================================================================================== |
---|
| 295 | |
---|
[1313] | 296 | template <typename T> inline T Clip3 (const T minVal, const T maxVal, const T a) { return std::min<T> (std::max<T> (minVal, a) , maxVal); } ///< general min/max clip |
---|
| 297 | template <typename T> inline T ClipBD(const T x, const Int bitDepth) { return Clip3(T(0), T((1 << bitDepth)-1), x); } |
---|
[2] | 298 | |
---|
[1313] | 299 | template <typename T> inline Void Check3( T minVal, T maxVal, T a) |
---|
| 300 | { |
---|
| 301 | if ((a > maxVal) || (a < minVal)) |
---|
| 302 | { |
---|
| 303 | std::cerr << "ERROR: Range check " << minVal << " >= " << a << " <= " << maxVal << " failed" << std::endl; |
---|
| 304 | assert(false); |
---|
| 305 | exit(1); |
---|
| 306 | } |
---|
| 307 | } ///< general min/max clip |
---|
[56] | 308 | |
---|
[2] | 309 | #define DATA_ALIGN 1 ///< use 32-bit aligned malloc/free |
---|
| 310 | #if DATA_ALIGN && _WIN32 && ( _MSC_VER > 1300 ) |
---|
| 311 | #define xMalloc( type, len ) _aligned_malloc( sizeof(type)*(len), 32 ) |
---|
| 312 | #define xFree( ptr ) _aligned_free ( ptr ) |
---|
| 313 | #else |
---|
| 314 | #define xMalloc( type, len ) malloc ( sizeof(type)*(len) ) |
---|
| 315 | #define xFree( ptr ) free ( ptr ) |
---|
| 316 | #endif |
---|
| 317 | |
---|
| 318 | #define FATAL_ERROR_0(MESSAGE, EXITCODE) \ |
---|
| 319 | { \ |
---|
| 320 | printf(MESSAGE); \ |
---|
| 321 | exit(EXITCODE); \ |
---|
| 322 | } |
---|
| 323 | |
---|
[1313] | 324 | template <typename ValueType> inline ValueType leftShift (const ValueType value, const Int shift) { return (shift >= 0) ? ( value << shift) : ( value >> -shift); } |
---|
| 325 | template <typename ValueType> inline ValueType rightShift (const ValueType value, const Int shift) { return (shift >= 0) ? ( value >> shift) : ( value << -shift); } |
---|
| 326 | template <typename ValueType> inline ValueType leftShift_round (const ValueType value, const Int shift) { return (shift >= 0) ? ( value << shift) : ((value + (ValueType(1) << (-shift - 1))) >> -shift); } |
---|
| 327 | template <typename ValueType> inline ValueType rightShift_round(const ValueType value, const Int shift) { return (shift >= 0) ? ((value + (ValueType(1) << (shift - 1))) >> shift) : ( value << -shift); } |
---|
| 328 | #if O0043_BEST_EFFORT_DECODING |
---|
| 329 | // when shift = 0, returns value |
---|
| 330 | // when shift = 1, (value + 0 + value[1]) >> 1 |
---|
| 331 | // when shift = 2, (value + 1 + value[2]) >> 2 |
---|
| 332 | // when shift = 3, (value + 3 + value[3]) >> 3 |
---|
| 333 | template <typename ValueType> inline ValueType rightShiftEvenRounding(const ValueType value, const UInt shift) { return (shift == 0) ? value : ((value + (1<<(shift-1))-1 + ((value>>shift)&1)) >> shift) ; } |
---|
| 334 | #endif |
---|
| 335 | #if NH_MV |
---|
[2] | 336 | |
---|
| 337 | #define AOF( exp ) \ |
---|
| 338 | { \ |
---|
| 339 | if( !( exp ) ) \ |
---|
[56] | 340 | { \ |
---|
| 341 | assert( 0 ); \ |
---|
| 342 | } \ |
---|
[2] | 343 | } |
---|
| 344 | |
---|
| 345 | #define AOT( exp ) \ |
---|
| 346 | { \ |
---|
| 347 | if( ( exp ) ) \ |
---|
[56] | 348 | { \ |
---|
| 349 | assert( 0 ); \ |
---|
| 350 | } \ |
---|
[2] | 351 | } |
---|
| 352 | |
---|
[56] | 353 | template <typename T> |
---|
| 354 | __inline T gSign(const T& t) |
---|
| 355 | { |
---|
| 356 | if( t == 0 ) |
---|
| 357 | return T(0); |
---|
| 358 | else |
---|
| 359 | return (t < 0) ? T(-1) : T(1); |
---|
| 360 | } |
---|
[2] | 361 | |
---|
[622] | 362 | template <typename T> |
---|
| 363 | __inline T gCeilLog2( T val ) |
---|
| 364 | { |
---|
| 365 | assert( val > 0 ); |
---|
| 366 | Int ceilLog2 = 0; |
---|
| 367 | while( val > ( 1 << ceilLog2 ) ) ceilLog2++; |
---|
| 368 | return ceilLog2; |
---|
| 369 | } |
---|
| 370 | |
---|
[1313] | 371 | #define RemoveBitIncrement( exp ) ( exp >> ( REN_BIT_DEPTH - 8 ) ) |
---|
[2] | 372 | |
---|
[100] | 373 | #endif |
---|
| 374 | |
---|
[1413] | 375 | #if NH_3D |
---|
[56] | 376 | #define MRG_MAX_NUM_CANDS_MEM (MRG_MAX_NUM_CANDS+1) // one extra for inter-view motion prediction |
---|
| 377 | #endif |
---|
[2] | 378 | |
---|
[1321] | 379 | #if NH_MV |
---|
| 380 | static const std::string NALU_TYPE_STR[] = { |
---|
| 381 | "CODED_SLICE_TRAIL_N ", // 0 |
---|
| 382 | "CODED_SLICE_TRAIL_R ", // 1 |
---|
| 383 | "CODED_SLICE_TSA_N ", // 2 |
---|
| 384 | "CODED_SLICE_TSA_R ", // 3 |
---|
| 385 | "CODED_SLICE_STSA_N ", // 4 |
---|
| 386 | "CODED_SLICE_STSA_R ", // 5 |
---|
| 387 | "CODED_SLICE_RADL_N ", // 6 |
---|
| 388 | "CODED_SLICE_RADL_R ", // 7 |
---|
| 389 | "CODED_SLICE_RASL_N ", // 8 |
---|
| 390 | "CODED_SLICE_RASL_R ", // 9 |
---|
| 391 | "RESERVED_VCL_N10 ", |
---|
| 392 | "RESERVED_VCL_R11 ", |
---|
| 393 | "RESERVED_VCL_N12 ", |
---|
| 394 | "RESERVED_VCL_R13 ", |
---|
| 395 | "RESERVED_VCL_N14 ", |
---|
| 396 | "RESERVED_VCL_R15 ", |
---|
| 397 | "CODED_SLICE_BLA_W_LP ", // 16 |
---|
| 398 | "CODED_SLICE_BLA_W_RADL", // 17 |
---|
| 399 | "CODED_SLICE_BLA_N_LP ", // 18 |
---|
| 400 | "CODED_SLICE_IDR_W_RADL", // 19 |
---|
| 401 | "CODED_SLICE_IDR_N_LP ", // 20 |
---|
| 402 | "CODED_SLICE_CRA ", // 21 |
---|
| 403 | "RESERVED_IRAP_VCL22 ", |
---|
| 404 | "RESERVED_IRAP_VCL23 ", |
---|
| 405 | "RESERVED_VCL24 ", |
---|
| 406 | "RESERVED_VCL25 ", |
---|
| 407 | "RESERVED_VCL26 ", |
---|
| 408 | "RESERVED_VCL27 ", |
---|
| 409 | "RESERVED_VCL28 ", |
---|
| 410 | "RESERVED_VCL29 ", |
---|
| 411 | "RESERVED_VCL30 ", |
---|
| 412 | "RESERVED_VCL31 ", |
---|
| 413 | "VPS ", // 32 |
---|
| 414 | "SPS ", // 33 |
---|
| 415 | "PPS ", // 34 |
---|
| 416 | "ACCESS_UNIT_DELIMITER ", // 35 |
---|
| 417 | "EOS ", // 36 |
---|
| 418 | "EOB ", // 37 |
---|
| 419 | "FILLER_DATA ", // 38 |
---|
| 420 | "PREFIX_SEI ", // 39 |
---|
| 421 | "SUFFIX_SEI ", // 40 |
---|
| 422 | "RESERVED_NVCL41 ", |
---|
| 423 | "RESERVED_NVCL42 ", |
---|
| 424 | "RESERVED_NVCL43 ", |
---|
| 425 | "RESERVED_NVCL44 ", |
---|
| 426 | "RESERVED_NVCL45 ", |
---|
| 427 | "RESERVED_NVCL46 ", |
---|
| 428 | "RESERVED_NVCL47 ", |
---|
| 429 | "UNSPECIFIED_48 ", |
---|
| 430 | "UNSPECIFIED_49 ", |
---|
| 431 | "UNSPECIFIED_50 ", |
---|
| 432 | "UNSPECIFIED_51 ", |
---|
| 433 | "UNSPECIFIED_52 ", |
---|
| 434 | "UNSPECIFIED_53 ", |
---|
| 435 | "UNSPECIFIED_54 ", |
---|
| 436 | "UNSPECIFIED_55 ", |
---|
| 437 | "UNSPECIFIED_56 ", |
---|
| 438 | "UNSPECIFIED_57 ", |
---|
| 439 | "UNSPECIFIED_58 ", |
---|
| 440 | "UNSPECIFIED_59 ", |
---|
| 441 | "UNSPECIFIED_60 ", |
---|
| 442 | "UNSPECIFIED_61 ", |
---|
| 443 | "UNSPECIFIED_62 ", |
---|
| 444 | "UNSPECIFIED_63 ", |
---|
| 445 | "INVALID " |
---|
| 446 | }; |
---|
| 447 | #endif |
---|
[2] | 448 | |
---|
[1396] | 449 | #if NH_3D_VSO || NH_3D |
---|
[56] | 450 | //PICYUV |
---|
| 451 | #define PICYUV_PAD 16 |
---|
[2] | 452 | |
---|
[56] | 453 | //RENDERER |
---|
[1313] | 454 | |
---|
| 455 | |
---|
| 456 | #define REN_BIT_DEPTH 8 |
---|
| 457 | #define REN_LUMA_MARGIN ( PICYUV_PAD + 1 ) // + g_uiMaxCuWidth instead of 1 ??? |
---|
[56] | 458 | #define REN_VDWEIGHT_PREC 8 |
---|
| 459 | #define REN_IS_FILLED ( 1 << REN_VDWEIGHT_PREC ) |
---|
[1313] | 460 | #define REN_USED_PEL ( (1 << REN_BIT_DEPTH) - 1 ) |
---|
[56] | 461 | #define REN_UNUSED_PEL 0 |
---|
| 462 | #define REN_IS_HOLE 0 |
---|
[1313] | 463 | #define ENC_INTERNAL_BIT_DEPTH REN_BIT_DEPTH // consider making this a variable |
---|
[1396] | 464 | #endif // end of NH_3D_VSO |
---|
| 465 | #if NH_3D |
---|
[608] | 466 | // CAMERA PARAMETERS |
---|
| 467 | #define LOG2_DISP_PREC_LUT 2 ///< log2 of disparity precision used in integer disparity LUTs |
---|
| 468 | #define STD_CAM_PARAMETERS_PRECISION 5 ///< quarter luma sample accuarcy for derived disparities (as default) |
---|
[1396] | 469 | #endif |
---|
[56] | 470 | //! \} |
---|
| 471 | |
---|
[2] | 472 | #endif // end of #ifndef __COMMONDEF__ |
---|
| 473 | |
---|