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-2014, 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 TypeDef.h 35 \brief Define basic types, new types and enumerations 36 */ 37 38 #ifndef __TYPEDEF__ 39 #define __TYPEDEF__ 40 41 #include <vector> 42 43 //! \ingroup TLibCommon 44 //! \{ 45 46 // ==================================================================================================================== 47 // Debugging 48 // ==================================================================================================================== 49 50 // #define DEBUG_STRING // enable to print out final decision debug info at encoder and decoder 51 // #define DEBUG_ENCODER_SEARCH_BINS // enable to print out each bin as it is coded during encoder search 52 // #define DEBUG_CABAC_BINS // enable to print out each bin as it is coded during final encode and decode 53 // #define DEBUG_INTRA_SEARCH_COSTS // enable to print out the cost for each mode during encoder search 54 // #define DEBUG_TRANSFORM_AND_QUANTISE // enable to print out each TU as it passes through the transform-quantise-dequantise-inverseTransform process 55 56 #ifdef DEBUG_STRING 57 #define DEBUG_STRING_PASS_INTO(name) , name 58 #define DEBUG_STRING_PASS_INTO_OPTIONAL(name, exp) , (exp==0)?0:name 59 #define DEBUG_STRING_FN_DECLARE(name) , std::string &name 60 #define DEBUG_STRING_FN_DECLAREP(name) , std::string *name 61 #define DEBUG_STRING_NEW(name) std::string name; 62 #define DEBUG_STRING_OUTPUT(os, name) os << name; 63 #define DEBUG_STRING_APPEND(str1, str2) str1+=str2; 64 #define DEBUG_STRING_SWAP(str1, str2) str1.swap(str2); 65 #define DEBUG_STRING_CHANNEL_CONDITION(compID) (true) 66 #include <sstream> 67 #include <iomanip> 68 #else 69 #define DEBUG_STRING_PASS_INTO(name) 70 #define DEBUG_STRING_PASS_INTO_OPTIONAL(name, exp) 71 #define DEBUG_STRING_FN_DECLARE(name) 72 #define DEBUG_STRING_FN_DECLAREP(name) 73 #define DEBUG_STRING_NEW(name) 74 #define DEBUG_STRING_OUTPUT(os, name) 75 #define DEBUG_STRING_APPEND(str1, str2) 76 #define DEBUG_STRING_SWAP(srt1, str2) 77 #define DEBUG_STRING_CHANNEL_CONDITION(compID) 78 #endif 79 80 81 // ==================================================================================================================== 82 // Tool Switches 83 // ==================================================================================================================== 84 85 #define HARMONIZE_GOP_FIRST_FIELD_COUPLE 1 86 #define EFFICIENT_FIELD_IRAP 1 87 #define ALLOW_RECOVERY_POINT_AS_RAP 1 88 #define BUGFIX_INTRAPERIOD 1 89 90 #define SAO_ENCODE_ALLOW_USE_PREDEBLOCK 1 91 92 #define TILE_SIZE_CHECK 1 93 94 #define MAX_NUM_PICS_IN_SOP 1024 95 96 #define MAX_NESTING_NUM_OPS 1024 97 #define MAX_NESTING_NUM_LAYER 64 98 99 #define MAX_VPS_NUM_HRD_PARAMETERS 1 100 #define MAX_VPS_OP_SETS_PLUS1 1024 101 #define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 1 102 103 #define MAXIMUM_INTRA_FILTERED_WIDTH 16 104 #define MAXIMUM_INTRA_FILTERED_HEIGHT 16 105 106 #define MAX_CPB_CNT 32 ///< Upper bound of (cpb_cnt_minus1 + 1) 107 #define MAX_NUM_LAYER_IDS 64 108 109 #define COEF_REMAIN_BIN_REDUCTION 3 ///< indicates the level at which the VLC 110 ///< transitions from Golomb-Rice to TU+EG(k) 111 112 #define CU_DQP_TU_CMAX 5 ///< max number bins for truncated unary 113 #define CU_DQP_EG_k 0 ///< expgolomb order 114 115 #define SBH_THRESHOLD 4 ///< I0156: value of the fixed SBH controlling threshold 116 117 #define DISABLING_CLIP_FOR_BIPREDME 1 ///< Ticket #175 118 119 #define C1FLAG_NUMBER 8 // maximum number of largerThan1 flag coded in one chunk : 16 in HM5 120 #define C2FLAG_NUMBER 1 // maximum number of largerThan2 flag coded in one chunk: 16 in HM5 121 122 #define SAO_ENCODING_CHOICE 1 ///< I0184: picture early termination 123 #if SAO_ENCODING_CHOICE 124 #define SAO_ENCODING_RATE 0.75 125 #define SAO_ENCODING_CHOICE_CHROMA 1 ///< J0044: picture early termination Luma and Chroma are handled separately 126 #if SAO_ENCODING_CHOICE_CHROMA 127 #define SAO_ENCODING_RATE_CHROMA 0.5 128 #endif 129 #endif 130 131 #define MAX_NUM_SAO_OFFSETS 4 132 133 #define MAX_NUM_VPS 16 134 #define MAX_NUM_SPS 16 135 #define MAX_NUM_PPS 64 136 137 #define RDOQ_CHROMA_LAMBDA 1 ///< F386: weighting of chroma for RDOQ 138 139 #define MIN_SCAN_POS_CROSS 4 140 141 #define FAST_BIT_EST 1 ///< G763: Table-based bit estimation for CABAC 142 143 #define MLS_GRP_NUM 64 ///< G644 : Max number of coefficient groups, max(16, 64) 144 #define MLS_CG_LOG2_WIDTH 2 145 #define MLS_CG_LOG2_HEIGHT 2 146 #define MLS_CG_SIZE (MLS_CG_LOG2_WIDTH + MLS_CG_LOG2_HEIGHT) ///< G644 : Coefficient group size of 4x4 147 148 #define ADAPTIVE_QP_SELECTION 1 ///< G382: Adaptive reconstruction levels, non-normative part for adaptive QP selection 149 #if ADAPTIVE_QP_SELECTION 150 #define ARL_C_PRECISION 7 ///< G382: 7-bit arithmetic precision 151 #define LEVEL_RANGE 30 ///< G382: max coefficient level in statistics collection 152 #endif 153 154 #define HHI_RQT_INTRA_SPEEDUP 1 ///< tests one best mode with full rqt 155 #define HHI_RQT_INTRA_SPEEDUP_MOD 0 ///< tests two best modes with full rqt 156 157 #if HHI_RQT_INTRA_SPEEDUP_MOD && !HHI_RQT_INTRA_SPEEDUP 158 #error 159 #endif 160 161 #define VERBOSE_RATE 0 ///< Print additional rate information in encoder 162 163 #define AMVP_DECIMATION_FACTOR 4 164 165 #define SCAN_SET_SIZE 16 166 #define LOG2_SCAN_SET_SIZE 4 167 168 #define FAST_UDI_MAX_RDMODE_NUM 35 ///< maximum number of RD comparison in fast-UDI estimation loop 169 170 #define NUM_INTRA_MODE 36 171 172 #define WRITE_BACK 1 ///< Enable/disable the encoder to replace the deltaPOC and Used by current from the config file with the values derived by the refIdc parameter. 173 #define AUTO_INTER_RPS 1 ///< Enable/disable the automatic generation of refIdc from the deltaPOC and Used by current from the config file. 174 #define PRINT_RPS_INFO 0 ///< Enable/disable the printing of bits used to send the RPS. 175 // using one nearest frame as reference frame, and the other frames are high quality (POC%4==0) frames (1+X) 176 // this should be done with encoder only decision 177 // but because of the absence of reference frame management, the related code was hard coded currently 178 179 #define RVM_VCEGAM10_M 4 180 181 #define PLANAR_IDX 0 182 #define VER_IDX 26 // index for intra VERTICAL mode 183 #define HOR_IDX 10 // index for intra HORIZONTAL mode 184 #define DC_IDX 1 // index for intra DC mode 185 #define NUM_CHROMA_MODE 5 // total number of chroma modes 186 #define DM_CHROMA_IDX 36 // chroma mode index for derived from luma intra mode 187 #define INVALID_MODE_IDX (NUM_INTRA_MODE+1) // value used to indicate an invalid intra mode 188 #define STOPCHROMASEARCH_MODE_IDX (INVALID_MODE_IDX+1) // value used to signal the end of a chroma mode search 189 190 #define MDCS_ANGLE_LIMIT 4 ///< (default 4) 0 = Horizontal/vertical only, 1 = Horizontal/vertical +/- 1, 2 = Horizontal/vertical +/- 2 etc... 191 #define MDCS_MAXIMUM_WIDTH 8 ///< (default 8) (measured in pixels) TUs with width greater than this can only use diagonal scan 192 #define MDCS_MAXIMUM_HEIGHT 8 ///< (default 8) (measured in pixels) TUs with height greater than this can only use diagonal scan 193 194 #define FAST_UDI_USE_MPM 1 195 196 #define RDO_WITHOUT_DQP_BITS 0 ///< Disable counting dQP bits in RDO-based mode decision 197 198 #define LOG2_MAX_NUM_COLUMNS_MINUS1 7 199 #define LOG2_MAX_NUM_ROWS_MINUS1 7 200 #define LOG2_MAX_COLUMN_WIDTH 13 201 #define LOG2_MAX_ROW_HEIGHT 13 202 203 #define MATRIX_MULT 0 // Brute force matrix multiplication instead of partial butterfly 204 205 #define AMP_SAD 1 ///< dedicated SAD functions for AMP 206 #define AMP_ENC_SPEEDUP 1 ///< encoder only speed-up by AMP mode skipping 207 #if AMP_ENC_SPEEDUP 208 #define AMP_MRG 1 ///< encoder only force merge for AMP partition (no motion search for AMP) 209 #endif 210 211 #define CABAC_INIT_PRESENT_FLAG 1 212 213 #define LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS 4 214 #define CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS 8 215 216 #define MAX_NUM_LONG_TERM_REF_PICS 33 217 218 #define DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES 1 219 220 #define RD_TEST_SAO_DISABLE_AT_PICTURE_LEVEL 0 ///< 1 = tests whether SAO should be disabled at the picture level, 0 (default) = does not apply this additional test 221 222 #define O0043_BEST_EFFORT_DECODING 0 ///< 0 (default) = disable code related to best effort decoding, 1 = enable code relating to best effort decoding [ decode-side only ]. 223 224 // Cost mode support 225 226 #define LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP 0 ///< QP to use for lossless coding. 227 #define LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME 4 ///< QP' to use for mixed_lossy_lossless coding. 228 229 // Debug support 230 231 #define ENVIRONMENT_VARIABLE_DEBUG_AND_TEST 0 ///< When enabled, allows control of debug modifications via environment variables 232 233 #define PRINT_MACRO_VALUES 1 ///< When enabled, the encoder prints out a list of the non-environment-variable controlled macros and their values on startup 234 235 // TODO: rename this macro to DECODER_DEBUG_BIT_STATISTICS (may currently cause merge issues with other branches) 236 // This can be enabled by the makefile 237 #ifndef RExt__DECODER_DEBUG_BIT_STATISTICS 238 #define RExt__DECODER_DEBUG_BIT_STATISTICS 0 ///< 0 (default) = decoder reports as normal, 1 = decoder produces bit usage statistics (will impact decoder run time by up to ~10%) 239 #endif 240 241 // This can be enabled by the makefile 242 #ifndef RExt__HIGH_BIT_DEPTH_SUPPORT 243 #define RExt__HIGH_BIT_DEPTH_SUPPORT 0 ///< 0 (default) use data type definitions for 8-10 bit video, 1 = use larger data types to allow for up to 16-bit video (originally developed as part of N0188) 244 #endif 245 246 #define RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS 4 247 #define RExt__GOLOMB_RICE_INCREMENT_DIVISOR 4 248 249 #define 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. 250 251 #define MAX_TIMECODE_SEI_SETS 3 ///< Maximum number of time sets 252 253 254 //------------------------------------------------ 255 // Derived macros 256 //------------------------------------------------ 257 258 #if RExt__HIGH_BIT_DEPTH_SUPPORT 259 #define FULL_NBIT 1 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion 260 #define RExt__HIGH_PRECISION_FORWARD_TRANSFORM 1 ///< 0 use original 6-bit transform matrices for both forward and inverse transform, 1 (default) = use original matrices for inverse transform and high precision matrices for forward transform 261 #else 262 #define FULL_NBIT 0 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion 263 #define RExt__HIGH_PRECISION_FORWARD_TRANSFORM 0 ///< 0 (default) use original 6-bit transform matrices for both forward and inverse transform, 1 = use original matrices for inverse transform and high precision matrices for forward transform 264 #endif 265 266 #if FULL_NBIT 267 # define DISTORTION_PRECISION_ADJUSTMENT(x) 0 268 #else 269 # define DISTORTION_PRECISION_ADJUSTMENT(x) (x) 270 #endif 271 272 273 //------------------------------------------------ 274 // Error checks 275 //------------------------------------------------ 276 277 #if ((RExt__HIGH_PRECISION_FORWARD_TRANSFORM != 0) && (RExt__HIGH_BIT_DEPTH_SUPPORT == 0)) 278 #error ERROR: cannot enable RExt__HIGH_PRECISION_FORWARD_TRANSFORM without RExt__HIGH_BIT_DEPTH_SUPPORT 279 #endif 280 281 // ==================================================================================================================== 282 // Basic type redefinition 283 // ==================================================================================================================== 284 285 typedef void Void; 286 typedef bool Bool; 287 288 #ifdef __arm__ 289 typedef signed char Char; 290 #else 291 typedef char Char; 292 #endif 293 typedef unsigned char UChar; 294 typedef short Short; 295 typedef unsigned short UShort; 296 typedef int Int; 297 typedef unsigned int UInt; 298 typedef double Double; 299 typedef float Float; 300 301 302 // ==================================================================================================================== 303 // 64-bit integer type 304 // ==================================================================================================================== 305 306 #ifdef _MSC_VER 307 typedef __int64 Int64; 308 309 #if _MSC_VER <= 1200 // MS VC6 310 typedef __int64 UInt64; // MS VC6 does not support unsigned __int64 to double conversion 311 #else 312 typedef unsigned __int64 UInt64; 313 #endif 314 315 #else 316 317 typedef long long Int64; 318 typedef unsigned long long UInt64; 319 320 #endif 321 322 323 // ==================================================================================================================== 324 // Enumeration 325 // ==================================================================================================================== 326 327 enum RDPCMMode 328 { 329 RDPCM_OFF = 0, 330 RDPCM_HOR = 1, 331 RDPCM_VER = 2, 332 NUMBER_OF_RDPCM_MODES = 3 333 }; 334 335 enum RDPCMSignallingMode 336 { 337 RDPCM_SIGNAL_IMPLICIT = 0, 338 RDPCM_SIGNAL_EXPLICIT = 1, 339 NUMBER_OF_RDPCM_SIGNALLING_MODES = 2 340 }; 341 342 /// supported slice type 343 enum SliceType 344 { 345 B_SLICE = 0, 346 P_SLICE = 1, 347 I_SLICE = 2, 348 NUMBER_OF_SLICE_TYPES = 3 349 }; 350 351 /// chroma formats (according to semantics of chroma_format_idc) 352 enum ChromaFormat 353 { 354 CHROMA_400 = 0, 355 CHROMA_420 = 1, 356 CHROMA_422 = 2, 357 CHROMA_444 = 3, 358 NUM_CHROMA_FORMAT = 4 359 }; 360 361 enum ChannelType 362 { 363 CHANNEL_TYPE_LUMA = 0, 364 CHANNEL_TYPE_CHROMA = 1, 365 MAX_NUM_CHANNEL_TYPE = 2 366 }; 367 368 enum ComponentID 369 { 370 COMPONENT_Y = 0, 371 COMPONENT_Cb = 1, 372 COMPONENT_Cr = 2, 373 MAX_NUM_COMPONENT = 3 374 }; 375 376 enum InputColourSpaceConversion // defined in terms of conversion prior to input of encoder. 377 { 378 IPCOLOURSPACE_UNCHANGED = 0, 379 IPCOLOURSPACE_YCbCrtoYCrCb = 1, // Mainly used for debug! 380 IPCOLOURSPACE_YCbCrtoYYY = 2, // Mainly used for debug! 381 IPCOLOURSPACE_RGBtoGBR = 3, 382 NUMBER_INPUT_COLOUR_SPACE_CONVERSIONS = 4 383 }; 384 385 enum DeblockEdgeDir 386 { 387 EDGE_VER = 0, 388 EDGE_HOR = 1, 389 NUM_EDGE_DIR = 2 390 }; 391 392 /// supported partition shape 393 enum PartSize 394 { 395 SIZE_2Nx2N = 0, ///< symmetric motion partition, 2Nx2N 396 SIZE_2NxN = 1, ///< symmetric motion partition, 2Nx N 397 SIZE_Nx2N = 2, ///< symmetric motion partition, Nx2N 398 SIZE_NxN = 3, ///< symmetric motion partition, Nx N 399 SIZE_2NxnU = 4, ///< asymmetric motion partition, 2Nx( N/2) + 2Nx(3N/2) 400 SIZE_2NxnD = 5, ///< asymmetric motion partition, 2Nx(3N/2) + 2Nx( N/2) 401 SIZE_nLx2N = 6, ///< asymmetric motion partition, ( N/2)x2N + (3N/2)x2N 402 SIZE_nRx2N = 7, ///< asymmetric motion partition, (3N/2)x2N + ( N/2)x2N 403 NUMBER_OF_PART_SIZES = 8 404 }; 405 406 /// supported prediction type 407 enum PredMode 408 { 409 MODE_INTER = 0, ///< inter-prediction mode 410 MODE_INTRA = 1, ///< intra-prediction mode 411 NUMBER_OF_PREDICTION_MODES = 2, 412 }; 413 414 /// reference list index 415 enum RefPicList 416 { 417 REF_PIC_LIST_0 = 0, ///< reference list 0 418 REF_PIC_LIST_1 = 1, ///< reference list 1 419 NUM_REF_PIC_LIST_01 = 2, 420 REF_PIC_LIST_X = 100 ///< special mark 421 }; 422 423 /// distortion function index 424 enum DFunc 425 { 426 DF_DEFAULT = 0, 427 DF_SSE = 1, ///< general size SSE 428 DF_SSE4 = 2, ///< 4xM SSE 429 DF_SSE8 = 3, ///< 8xM SSE 430 DF_SSE16 = 4, ///< 16xM SSE 431 DF_SSE32 = 5, ///< 32xM SSE 432 DF_SSE64 = 6, ///< 64xM SSE 433 DF_SSE16N = 7, ///< 16NxM SSE 434 435 DF_SAD = 8, ///< general size SAD 436 DF_SAD4 = 9, ///< 4xM SAD 437 DF_SAD8 = 10, ///< 8xM SAD 438 DF_SAD16 = 11, ///< 16xM SAD 439 DF_SAD32 = 12, ///< 32xM SAD 440 DF_SAD64 = 13, ///< 64xM SAD 441 DF_SAD16N = 14, ///< 16NxM SAD 442 443 DF_SADS = 15, ///< general size SAD with step 444 DF_SADS4 = 16, ///< 4xM SAD with step 445 DF_SADS8 = 17, ///< 8xM SAD with step 446 DF_SADS16 = 18, ///< 16xM SAD with step 447 DF_SADS32 = 19, ///< 32xM SAD with step 448 DF_SADS64 = 20, ///< 64xM SAD with step 449 DF_SADS16N = 21, ///< 16NxM SAD with step 450 451 DF_HADS = 22, ///< general size Hadamard with step 452 DF_HADS4 = 23, ///< 4xM HAD with step 453 DF_HADS8 = 24, ///< 8xM HAD with step 454 DF_HADS16 = 25, ///< 16xM HAD with step 455 DF_HADS32 = 26, ///< 32xM HAD with step 456 DF_HADS64 = 27, ///< 64xM HAD with step 457 DF_HADS16N = 28, ///< 16NxM HAD with step 458 459 #if AMP_SAD 460 DF_SAD12 = 43, 461 DF_SAD24 = 44, 462 DF_SAD48 = 45, 463 464 DF_SADS12 = 46, 465 DF_SADS24 = 47, 466 DF_SADS48 = 48, 467 468 DF_SSE_FRAME = 50, ///< Frame-based SSE 469 DF_TOTAL_FUNCTIONS = 64 470 #else 471 DF_SSE_FRAME = 32, ///< Frame-based SSE 472 DF_TOTAL_FUNCTIONS = 33 473 #endif 474 }; 475 476 /// index for SBAC based RD optimization 477 enum CI_IDX 478 { 479 CI_CURR_BEST = 0, ///< best mode index 480 CI_NEXT_BEST, ///< next best index 481 CI_TEMP_BEST, ///< temporal index 482 CI_CHROMA_INTRA, ///< chroma intra index 483 CI_QT_TRAFO_TEST, 484 CI_QT_TRAFO_ROOT, 485 CI_NUM, ///< total number 486 }; 487 488 /// motion vector predictor direction used in AMVP 489 enum MVP_DIR 490 { 491 MD_LEFT = 0, ///< MVP of left block 492 MD_ABOVE, ///< MVP of above block 493 MD_ABOVE_RIGHT, ///< MVP of above right block 494 MD_BELOW_LEFT, ///< MVP of below left block 495 MD_ABOVE_LEFT ///< MVP of above left block 496 }; 497 498 enum StoredResidualType 499 { 500 RESIDUAL_RECONSTRUCTED = 0, 501 RESIDUAL_ENCODER_SIDE = 1, 502 NUMBER_OF_STORED_RESIDUAL_TYPES = 2 503 }; 504 505 enum TransformDirection 506 { 507 TRANSFORM_FORWARD = 0, 508 TRANSFORM_INVERSE = 1, 509 TRANSFORM_NUMBER_OF_DIRECTIONS = 2 510 }; 511 512 /// supported ME search methods 513 enum MESearchMethod 514 { 515 FULL_SEARCH = 0, ///< Full search 516 DIAMOND = 1, ///< Fast search 517 SELECTIVE = 2 ///< Selective search 518 }; 519 520 /// coefficient scanning type used in ACS 521 enum COEFF_SCAN_TYPE 522 { 523 SCAN_DIAG = 0, ///< up-right diagonal scan 524 SCAN_HOR = 1, ///< horizontal first scan 525 SCAN_VER = 2, ///< vertical first scan 526 SCAN_NUMBER_OF_TYPES = 3 527 }; 528 529 enum COEFF_SCAN_GROUP_TYPE 530 { 531 SCAN_UNGROUPED = 0, 532 SCAN_GROUPED_4x4 = 1, 533 SCAN_NUMBER_OF_GROUP_TYPES = 2 534 }; 535 536 enum SignificanceMapContextType 537 { 538 CONTEXT_TYPE_4x4 = 0, 539 CONTEXT_TYPE_8x8 = 1, 540 CONTEXT_TYPE_NxN = 2, 541 CONTEXT_TYPE_SINGLE = 3, 542 CONTEXT_NUMBER_OF_TYPES = 4 543 }; 544 545 enum ScalingListMode 546 { 547 SCALING_LIST_OFF, 548 SCALING_LIST_DEFAULT, 549 SCALING_LIST_FILE_READ 550 }; 551 552 enum ScalingListSize 553 { 554 SCALING_LIST_4x4 = 0, 555 SCALING_LIST_8x8, 556 SCALING_LIST_16x16, 557 SCALING_LIST_32x32, 558 SCALING_LIST_SIZE_NUM 559 }; 560 561 // Slice / Slice segment encoding modes 562 enum SliceConstraint 563 { 564 NO_SLICES = 0, ///< don't use slices / slice segments 565 FIXED_NUMBER_OF_CTU = 1, ///< Limit maximum number of largest coding tree units in a slice / slice segments 566 FIXED_NUMBER_OF_BYTES = 2, ///< Limit maximum number of bytes in a slice / slice segment 567 FIXED_NUMBER_OF_TILES = 3, ///< slices / slice segments span an integer number of tiles 568 }; 569 570 enum SAOMode //mode 571 { 572 SAO_MODE_OFF = 0, 573 SAO_MODE_NEW, 574 SAO_MODE_MERGE, 575 NUM_SAO_MODES 576 }; 577 578 enum SAOModeMergeTypes 579 { 580 SAO_MERGE_LEFT =0, 581 SAO_MERGE_ABOVE, 582 NUM_SAO_MERGE_TYPES 583 }; 584 585 586 enum SAOModeNewTypes 587 { 588 SAO_TYPE_START_EO =0, 589 SAO_TYPE_EO_0 = SAO_TYPE_START_EO, 590 SAO_TYPE_EO_90, 591 SAO_TYPE_EO_135, 592 SAO_TYPE_EO_45, 593 594 SAO_TYPE_START_BO, 595 SAO_TYPE_BO = SAO_TYPE_START_BO, 596 597 NUM_SAO_NEW_TYPES 598 }; 599 #define NUM_SAO_EO_TYPES_LOG2 2 600 601 enum SAOEOClasses 602 { 603 SAO_CLASS_EO_FULL_VALLEY = 0, 604 SAO_CLASS_EO_HALF_VALLEY = 1, 605 SAO_CLASS_EO_PLAIN = 2, 606 SAO_CLASS_EO_HALF_PEAK = 3, 607 SAO_CLASS_EO_FULL_PEAK = 4, 608 NUM_SAO_EO_CLASSES, 609 }; 610 611 #define NUM_SAO_BO_CLASSES_LOG2 5 612 #define NUM_SAO_BO_CLASSES (1<<NUM_SAO_BO_CLASSES_LOG2) 613 614 namespace Profile 615 { 616 enum Name 617 { 618 NONE = 0, 619 MAIN = 1, 620 MAIN10 = 2, 621 MAINSTILLPICTURE = 3, 622 MAINREXT = 4, 623 HIGHTHROUGHPUTREXT = 5 624 }; 625 } 626 627 namespace Level 628 { 629 enum Tier 630 { 631 MAIN = 0, 632 HIGH = 1, 633 }; 634 635 enum Name 636 { 637 // code = (level * 30) 638 NONE = 0, 639 LEVEL1 = 30, 640 LEVEL2 = 60, 641 LEVEL2_1 = 63, 642 LEVEL3 = 90, 643 LEVEL3_1 = 93, 644 LEVEL4 = 120, 645 LEVEL4_1 = 123, 646 LEVEL5 = 150, 647 LEVEL5_1 = 153, 648 LEVEL5_2 = 156, 649 LEVEL6 = 180, 650 LEVEL6_1 = 183, 651 LEVEL6_2 = 186, 652 LEVEL8_5 = 255, 653 }; 654 } 655 656 enum CostMode 657 { 658 COST_STANDARD_LOSSY = 0, 659 COST_SEQUENCE_LEVEL_LOSSLESS = 1, 660 COST_LOSSLESS_CODING = 2, 661 COST_MIXED_LOSSLESS_LOSSY_CODING = 3 662 }; 663 664 enum SPSExtensionFlagIndex 665 { 666 SPS_EXT__REXT = 0, 667 //SPS_EXT__MVHEVC = 1, //for use in future versions 668 //SPS_EXT__SHVC = 2, //for use in future versions 669 NUM_SPS_EXTENSION_FLAGS = 8 670 }; 671 672 enum PPSExtensionFlagIndex 673 { 674 PPS_EXT__REXT = 0, 675 //PPS_EXT__MVHEVC = 1, //for use in future versions 676 //PPS_EXT__SHVC = 2, //for use in future versions 677 NUM_PPS_EXTENSION_FLAGS = 8 678 }; 679 680 // ==================================================================================================================== 681 // Type definition 682 // ==================================================================================================================== 683 684 #if RExt__HIGH_BIT_DEPTH_SUPPORT 685 typedef Int Pel; ///< pixel type 686 typedef Int64 TCoeff; ///< transform coefficient 687 typedef Int TMatrixCoeff; ///< transform matrix coefficient 688 typedef Short TFilterCoeff; ///< filter coefficient 689 typedef Int64 Intermediate_Int; ///< used as intermediate value in calculations 690 typedef UInt64 Intermediate_UInt; ///< used as intermediate value in calculations 691 #else 692 typedef Short Pel; ///< pixel type 693 typedef Int TCoeff; ///< transform coefficient 694 typedef Short TMatrixCoeff; ///< transform matrix coefficient 695 typedef Short TFilterCoeff; ///< filter coefficient 696 typedef Int Intermediate_Int; ///< used as intermediate value in calculations 697 typedef UInt Intermediate_UInt; ///< used as intermediate value in calculations 698 #endif 699 700 #if FULL_NBIT 701 typedef UInt64 Distortion; ///< distortion measurement 702 #else 703 typedef UInt Distortion; ///< distortion measurement 704 #endif 705 706 /// parameters for adaptive loop filter 707 class TComPicSym; 708 709 #define MAX_NUM_SAO_CLASSES 32 //(NUM_SAO_EO_GROUPS > NUM_SAO_BO_GROUPS)?NUM_SAO_EO_GROUPS:NUM_SAO_BO_GROUPS 710 711 struct SAOOffset 712 { 713 SAOMode modeIdc; // NEW, MERGE, OFF 714 Int typeIdc; // union of SAOModeMergeTypes and SAOModeNewTypes, depending on modeIdc. 715 Int typeAuxInfo; // BO: starting band index 716 Int offset[MAX_NUM_SAO_CLASSES]; 717 718 SAOOffset(); 719 ~SAOOffset(); 720 Void reset(); 721 722 const SAOOffset& operator= (const SAOOffset& src); 723 }; 724 725 struct SAOBlkParam 726 { 727 728 SAOBlkParam(); 729 ~SAOBlkParam(); 730 Void reset(); 731 const SAOBlkParam& operator= (const SAOBlkParam& src); 732 SAOOffset& operator[](Int compIdx){ return offsetParam[compIdx];} 733 private: 734 SAOOffset offsetParam[MAX_NUM_COMPONENT]; 735 736 }; 737 738 739 /// parameters for deblocking filter 740 typedef struct _LFCUParam 741 { 742 Bool bInternalEdge; ///< indicates internal edge 743 Bool bLeftEdge; ///< indicates left edge 744 Bool bTopEdge; ///< indicates top edge 745 } LFCUParam; 746 747 748 749 //TU settings for entropy encoding 750 struct TUEntropyCodingParameters 751 { 752 const UInt *scan; 753 const UInt *scanCG; 754 COEFF_SCAN_TYPE scanType; 755 UInt widthInGroups; 756 UInt heightInGroups; 757 UInt firstSignificanceMapContext; 758 }; 759 760 761 struct TComDigest 762 { 763 std::vector<UChar> hash; 764 765 Bool operator==(const TComDigest &other) const 766 { 767 if (other.hash.size() != hash.size()) return false; 768 for(UInt i=0; i<UInt(hash.size()); i++) 769 if (other.hash[i] != hash[i]) return false; 770 return true; 771 } 772 773 Bool operator!=(const TComDigest &other) const 774 { 775 return !(*this == other); 776 } 777 }; 778 779 struct TComSEITimeSet 780 { TComSEITimeSetTComSEITimeSet781 TComSEITimeSet() : clockTimeStampFlag(false), 782 numUnitFieldBasedFlag(false), 783 countingType(0), 784 fullTimeStampFlag(false), 785 discontinuityFlag(false), 786 cntDroppedFlag(false), 787 numberOfFrames(0), 788 secondsValue(0), 789 minutesValue(0), 790 hoursValue(0), 791 secondsFlag(false), 792 minutesFlag(false), 793 hoursFlag(false), 794 timeOffsetLength(0), 795 timeOffsetValue(0) 796 { } 797 Bool clockTimeStampFlag; 798 Bool numUnitFieldBasedFlag; 799 Int countingType; 800 Bool fullTimeStampFlag; 801 Bool discontinuityFlag; 802 Bool cntDroppedFlag; 803 Int numberOfFrames; 804 Int secondsValue; 805 Int minutesValue; 806 Int hoursValue; 807 Bool secondsFlag; 808 Bool minutesFlag; 809 Bool hoursFlag; 810 Int timeOffsetLength; 811 Int timeOffsetValue; 812 }; 813 814 struct TComSEIMasteringDisplay 815 { 816 Bool colourVolumeSEIEnabled; 817 UInt maxLuminance; 818 UInt minLuminance; 819 UShort primaries[3][2]; 820 UShort whitePoint[2]; 821 }; 822 //! \} 823 824 #endif 825 826 827