1 /****************************************************************************** 2 * 3 * Copyright (C) 2018 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19 */ 20 21 /** 22 ******************************************************************************* 23 * @file 24 * ihevce_defs.h 25 * 26 * @brief 27 * Definitions used in the codec 28 * 29 * @author 30 * Ittiam 31 * 32 * @remarks 33 * None 34 * 35 ******************************************************************************* 36 */ 37 #ifndef _IHEVCE_DEFS_H_ 38 #define _IHEVCE_DEFS_H_ 39 40 /*****************************************************************************/ 41 /* Constant Macros */ 42 /*****************************************************************************/ 43 44 #define SINGLE_THREAD_INTERFACE 0 45 46 #define DEFAULT_VPS_ID 0 47 48 #define DEFAULT_SPS_ID 0 49 50 #define DEFAULT_PPS_ID 0 51 52 #define DEFAULT_CHROMA_FORMAT_IDC 1 53 54 #define AMP_ENABLED 1 55 56 #define AMP_DISABLED 0 57 58 #define LISTS_MODIFICATION_ABSENT 0 59 60 #define LISTS_MODIFICATION_PRESENT 1 61 62 #define LONG_TERM_REF_PICS_PRESENT 1 63 64 #define LONG_TERM_REF_PICS_ABSENT 0 65 66 #define PCM_ENABLED 1 67 68 #define PCM_DISABLED 0 69 70 #define PCM_LOOP_FILTER_DISABLED 1 71 72 #define PCM_LOOP_FILTER_ENABLED 0 73 74 #define REF_PIC_LISTS_RESTRICTED 1 75 76 #define REF_PIC_LISTS_UNRESTRICTED 0 77 78 #define SCALING_LIST_DISABLED 0 79 80 #define SCALING_LIST_ENABLED 1 81 82 #define DEFAULT_SPS_MAX_SUB_LAYERS 1 83 84 #define VPS_SUB_LAYER_ORDERING_INFO_PRESENT 1 85 86 #define VPS_SUB_LAYER_ORDERING_INFO_ABSENT 0 87 88 #define SPS_SUB_LAYER_ORDERING_INFO_PRESENT 1 89 90 #define SPS_SUB_LAYER_ORDERING_INFO_ABSENT 0 91 92 #define SCALING_LIST_DATA_PRESENT 1 93 94 #define SCALING_LIST_DATA_ABSENT 0 95 96 #define SPS_TEMPORAL_ID_NESTING_DONE 1 97 98 #define NO_SPS_TEMPORAL_ID_NESTING_DONE 0 99 100 #define STRONG_INTRA_SMOOTHING_FLAG_DISABLE 0 101 102 #define STRONG_INTRA_SMOOTHING_FLAG_ENABLE 1 103 104 #define DEFAULT_LOG2_MAX_POC_LSB 10 105 106 #define DEFAULT_PIC_CROP_TOP_OFFSET 0 107 108 #define DEFAULT_PIC_CROP_LEFT_OFFSET 0 109 110 #define DEFAULT_PIC_CROP_RIGHT_OFFSET 0 111 112 #define DEFAULT_PIC_CROP_BOTTOM_OFFSET 0 113 114 #define DEFAULT_MAX_DEC_PIC_BUFFERING 8 115 116 #define DEFAULT_MAX_NUM_REORDER_PICS 8 117 118 #define DEFAULT_MAX_LATENCY_INCREASE 8 119 120 #define HIGH_TIER 1 121 122 #define MAIN_TIER 0 123 124 #define DEFAULT_BETA_OFFSET 0 125 126 #define CABAC_INIT_PRESENT 1 127 128 #define CABAC_INIT_ABSENT 0 129 130 #define CU_QP_DELTA_ENABLED 1 131 132 #define CU_QP_DELTA_DISABLED 0 133 134 #define MAX_MERGE_CANDIDATES 5 135 136 #define CONSTR_IPRED_ENABLED 1 137 138 #define CONSTR_IPRED_DISABLED 0 139 140 #define DISABLE_DEBLOCKING_FLAG 1 141 142 #define ENABLE_DEBLOCKING_FLAG 0 143 144 #define DEBLOCKING_FILTER_CONTROL_PRESENT 1 145 146 #define DEBLOCKING_FILTER_CONTROL_ABSENT 0 147 148 #define DEBLOCKING_FILTER_OVERRIDE_ENABLED 1 149 150 #define DEBLOCKING_FILTER_OVERRIDE_DISABLED 0 151 152 #define DEPENDENT_SLICE_ENABLED 1 153 154 #define DEPENDENT_SLICE_DISABLED 0 155 156 #define DEFAULT_DIFF_CU_QP_DELTA_DEPTH 0 157 158 #define ENTROPY_CODING_SYNC_ENABLED 1 159 160 #define ENTROPY_CODING_SYNC_DISABLED 0 161 162 #define ENTROPY_SLICE_ENABLED 1 163 164 #define ENTROPY_SLICE_DISABLED 0 165 166 #define DEFAULT_PARALLEL_MERGE_LEVEL 2 167 168 #define DEFAULT_NUM_REF_IDX_L0_DEFAULT_ACTIVE 6 169 170 #define DEFAULT_NUM_REF_IDX_L1_DEFAULT_ACTIVE 6 171 172 #define NUM_TILES_COLS 0 173 174 #define NUM_TILES_ROWS 0 175 176 #define OUTPUT_FLAG_PRESENT 1 177 178 #define OUTPUT_FLAG_ABSENT 0 179 180 #define DEFAULT_PIC_CB_QP_OFFSET 0 181 182 #define DEFAULT_PIC_CR_QP_OFFSET 0 183 184 #define SLICE_LEVEL_CHROMA_QP_OFFSETS_PRESENT 1 185 186 #define SLICE_LEVEL_CHROMA_QP_OFFSETS_ABSENT 0 187 188 #define DEBLOCKING_FILTER_DISABLED 1 189 190 #define DEBLOCKING_FILTER_ENABLED 0 191 192 #define LF_ACROSS_SLICES_ENABLED 1 193 194 #define LF_ACROSS_SLICES_DISABLED 0 195 196 #define SAO_ENABLED 1 197 198 #define SAO_DISABLED 0 199 200 #define SCALING_LIST_DATA_PRESENT 1 201 202 #define SCALING_LIST_DATA_ABSENT 0 203 204 #define SIGN_DATA_HIDDEN 1 205 206 #define SIGN_DATA_UNHIDDEN 0 207 208 #define SLICE_EXTENSION_PRESENT 1 209 210 #define SLICE_EXTENSION_ABSENT 0 211 212 #define SLICE_HEADER_EXTENSION_PRESENT 1 213 214 #define SLICE_HEADER_EXTENSION_ABSENT 0 215 216 #define DEFAULT_TC_OFFSET 0 217 218 #define TRANSFORM_SKIP_ENABLED 1 219 220 #define TRANSFORM_SKIP_DISABLED 0 221 222 #define TRANSFORM_BYPASS_ENABLED 1 223 224 #define TRANSFORM_BYPASS_DISABLED 0 225 226 #define SPACING_IS_UNIFORM 1 227 228 #define SPACING_IS_NONUNIFORM 0 229 230 #define TILES_ENABLED 1 231 232 #define TILES_DISABLED 0 233 234 #define TOTAL_NUM_TIERS 2 235 236 #define TOTAL_NUM_LEVELS 13 237 238 #define SET_CTB_ALIGN(x, y) ((((x) & ((y)-1)) == 0) ? 0 : (y) - ((x) & ((y)-1))) 239 240 /* Enables HM-8.1 compatible stream, setting to 0 will make it 8.2 compatible*/ 241 #define HM_8DOT1_SYNTAX 0 242 243 /* Enables cu level RD optimized encoding by computing cabac bits for the cu */ 244 #define RDOPT_ENABLE 1 245 246 /* Enables inclusion of chroma coding cost for RD opt decisions */ 247 #define CHROMA_RDOPT_ENABLE 1 248 249 /* Enables tu level zero cbf based RD optimized encoding */ 250 #define RDOPT_ZERO_CBF_ENABLE 1 251 252 /* Enables bit savings in tu tree of inter cus by merging not coded child nodes to parent node */ 253 #define SHRINK_INTER_TUTREE 1 254 255 /* q format for lamba used in the encoder */ 256 #define LAMBDA_Q_SHIFT 8 257 258 /* If 0, Allign PIC Wd/ht to Min CU size */ 259 /* If 1, Allign PIC Wd/ht to CTB size */ 260 #define PIC_ALIGN_CTB_SIZE 0 261 262 /** Enables DCT integer transform / Hadamard Transform based SATD evaluation 263 * 1 : DCT integer Transform, 0 : Hadamard Transform 264 */ 265 #define USE_EXACT_TFR 0 266 267 /** Enable colocated PU population */ 268 #define ENABLE_COL_PU_POPULATION 1 269 270 #define MAX_MVX_SUPPORTED_IN_COARSE_LAYER 128 271 272 #define MAX_MVY_SUPPORTED_IN_COARSE_LAYER 64 273 274 //ME_Experiments 275 276 #define USE_4x4_IN_L1 0 277 278 #define DIAMOND_GRID 1 279 280 #define SUBPEL_DEDUPLICATE_ENABLE 1 281 282 /** Enables CU delta QP population within a frame : Random for now */ 283 //#define RANDOM_CU_QP 0 284 285 /** 286 * @brief Mapping of Minimum HEVC qp to MPEG2 QP 287 */ 288 #define MIN_RC_QP (1) 289 /** 290 * @brief Mapping of Maximum HEVC qp to MPEG2 QP 291 */ 292 #define MAX_RC_QP (228) 293 /** 294 * @brief Total NUmber of MPEG2 QPs 295 */ 296 #define MPEG2_QP_ELEM (MAX_RC_QP + 1) 297 /** 298 * @brief Total NUmber of HEVC QPs 299 */ 300 #define HEVC_QP_ELEM (MAX_HEVC_QP_10bit + 1) 301 302 #define QP_LEVEL_MOD_ACT_FACTOR 10 303 304 #define TWO_POW_QP_LEVEL_MOD_ACT_FACTOR (1 << (QP_LEVEL_MOD_ACT_FACTOR)) 305 306 #define DEFAULT_NON_PACKED_CONSTRAINT_FLAG 1 307 308 #define DEFAULT_FRAME_ONLY_CONSTRAINT_FLAG 0 309 310 #define ENABLE_CU_TREE_CULLING (1 && ENABLE_4CTB_EVALUATION) 311 312 #define RATIONALISE_NUM_RDO_MODES_IN_PQ_AND_HQ 1 313 314 #define MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_PQ_AND_HQ 2 315 316 #define MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_MS 2 317 318 #define MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_HS_AND_XS 1 319 320 #define BUFFER_SIZE_MULTIPLIER_IF_HBD 3 321 322 /* If */ 323 /* qp_bdoffset = 6 * (bit_depth - 8) */ 324 /* and */ 325 /* lambda = pow(2.0, (((i4_cur_frame_qp + qp_bdoffset - 12)) / 3)), */ 326 /* Then 'Lambda Types' are - */ 327 /* 0, when bit_depth_in_module = 8 => qp_bdoffset = 0 always */ 328 /* 1, when bit_depth_in_module > 8, => qp_bdoffset = value derived above */ 329 /* 2, when both of the lambdas referred to in the previous cases are required */ 330 331 #define PRE_ENC_LAMBDA_TYPE 0 332 333 #define ENC_LAMBDA_TYPE 0 334 335 #define IPE_LAMBDA_TYPE 0 336 337 #define ME_LAMBDA_TYPE 0 338 339 #define ENC_LOOP_LAMBDA_TYPE 2 340 341 #define ENABLE_SSIM 0 342 343 #define VUI_BIT_RATE_SCALE 6 344 345 #define VUI_CPB_SIZE_SCALE 8 346 347 #define ENABLE_REFINED_QP_MOD 1 348 349 #if ENABLE_REFINED_QP_MOD 350 /* to find the uncovered region (or new region) which will be used for reference for the upcoming pictures 351 will be coded well to enhance coding efficiency*/ 352 #define ENABLE_TEMPORAL_WEIGHING 0 353 354 /* to enable modulation factor based on spatial variance when we calculate activity factor using 355 the following equaltion 356 act_factor = (m * c + a )/(c + m * a)*/ 357 // SATD_NOISE_FLOOR_THRESHOLD was earlier controlled using this 358 #define ENABLE_QP_MOD_BASED_ON_SPATIAL_VARIANCE 0 359 360 /* To enable the trace for delta Qp bits */ 361 #define QP_DELTA_BITS_TRACE 362 363 /* to enable modulation based LAP2 average satd*/ 364 #define MODULATION_OVER_LAP 1 365 366 /* 0 - Lamda and Qp are decoupled, 367 1 - Lamda and Qp are coupled*/ 368 #define LAMDA_BASED_ON_QUANT 0 369 370 /* 371 0 - act_factor = (m * c + a )/(c + m * a) 372 m = modulation factor 373 c = cur satd 374 a = average satd 375 ---------------------------------------- 376 1 - act_factor = (c/a) ^ (s/3) 377 s = strength 378 c = cur satd 379 a = average satd 380 */ 381 #define LOGARITHMIC_MODULATION 1 382 383 #define MEDIAN_ENABLE 1 384 #define MIN_ENABLE 0 385 386 /* well compensatable regions are not considered for 387 QP modulation*/ 388 #define DISABLE_COMPENSATION 1 389 390 #define CST_NOISE_THRSHLD 0 391 392 /*decrease intra cu qp by 1 in Inter Pictures*/ 393 #define DECREASE_QP 0 394 395 /*strength calculation based on deviation*/ 396 #define STRENGTH_BASED_ON_DEVIATION 1 397 398 /*enable allow cliping of qctivity factor such that 399 deviation of qp in modulation is controlled*/ 400 #define ALLOW_ACT_FACTOR_CLIP_IN_QP_MOD 1 401 402 /*instead of avg activity use sqrt(avg of satd square)*/ 403 #define USE_SQRT_AVG_OF_SATD_SQR 1 404 405 /*use sum of squared transform coeff*/ 406 #define USE_SQR_SATD_COEFF 0 407 408 /*instead of L1 IPE SATD, use L1 CUR SATD*/ 409 #define USE_CUR_SATD 0 // else it will use satd of cur - pred 410 411 /*use L0 CUR SATD */ 412 #define USE_CUR_L0_SATD 0 413 414 /* strength based on only curr frame deviation else it is based on average over lap2 */ 415 #define STRENGTH_BASED_ON_CURR_FRM 0 416 417 #define POW_OPT 1 418 419 #else /*INITIAL QP MOD*/ 420 /*Same as 11_0 Mod version */ 421 // SATD_NOISE_FLOOR_THRESHOLD was earlier controlled using this 422 #define ENABLE_QP_MOD_BASED_ON_SPATIAL_VARIANCE 0 423 #define ENABLE_TEMPORAL_WEIGHING 0 424 #define MODULATION_OVER_LAP 0 425 #define LAMDA_BASED_ON_QUANT 1 426 #define LOGARITHMIC_MODULATION 0 427 #define MIN_ENABLE 1 428 #define DISABLE_COMPENSATION 1 429 #define CST_NOISE_THRSHLD 1 430 #define DECREASE_QP 0 431 #endif 432 433 #define MASK_4AC 0xFFFFFFFEFEFEFCE0 434 #define MASK_3AC 0xFFFFFFFFFEFEFCF0 435 #define MASK_2AC 0xFFFFFFFFFFFEFCF8 436 #define MASK_DC 0xFFFFFFFFFFFFFFFE 437 #define I_PIC_LAMDA_MODIFIER 0.5 438 #define CONST_LAMDA_MODIFIER 1 439 #define NO_EXTRA_MULTIPLIER 1 440 #define NEW_LAMDA_MODIFIER (!CONST_LAMDA_MODIFIER) 441 #define LAMDA_MODIFIER(QP, Tid) \ 442 (0.85 * pow(2.0, (Tid * (CLIP3(((QP + 5.0) / 25.0), 1.0, 2.0) - 1.0)) / 3.0)) 443 #define CONST_LAMDA_MOD_VAL (0.85) 444 #define MEAN_BASED_QP_MOD 0 445 446 #if MEDIAN_ENABLE 447 #define MEDIAN_CU_TU 1 448 #define MEDIAN_CU_TU_BY_2 3 449 #define MEDIAN_CU_TU_BY_4 10 450 #endif 451 452 #if MIN_ENABLE 453 #define MEDIAN_CU_TU 0 454 #define MEDIAN_CU_TU_BY_2 0 455 #define MEDIAN_CU_TU_BY_4 0 456 #endif 457 458 #define COMP_RATIO_NORM 5 459 #define COMP_RATIO_MIN 0 460 #define COMP_RATIO_MAX 3 461 #define NOISE_THRE_MAP_TO_8 3 462 463 #define REF_MOD_VARIANCE (0.6696) 464 465 #define REF_MOD_DEVIATION (473.0) //(0.6696) // 466 #define NO_MOD_DEVIATION (220.0) 467 #define BELOW_REF_DEVIATION (0.0) 468 #define ABOVE_REF_DEVIATION (220.0) 469 470 #define MIN_QP_MOD_OFFSET -10 471 #define MAX_QP_MOD_OFFSET 3 472 #define TOT_QP_MOD_OFFSET (MAX_QP_MOD_OFFSET - MIN_QP_MOD_OFFSET + 1) 473 474 #define ENABLE_UNIFORM_CU_SIZE_16x16 0 475 476 #define ENABLE_UNIFORM_CU_SIZE_8x8 0 477 478 #define MAX_QP_BD_OFFSET 24 479 480 // chroma mode index for derived from luma intra mode 481 #define DM_CHROMA_IDX 36 482 483 #define DISABLE_RDOQ 0 484 485 #define DISABLE_SKIP_AND_MERGE_EVAL 0 486 487 #define ENABLE_PICKING_4_BEST_IN_B_PIC_IN_ME 0 488 489 #define ENABLE_TU_TREE_DETERMINATION_IN_RDOPT 0 490 491 #define MAX_NUM_MIXED_MODE_INTER_RDO_CANDS (MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_PQ_AND_HQ * 2) 492 493 #define MAX_NUM_CU_MERGE_SKIP_CAND (MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_PQ_AND_HQ + 1) 494 495 #define NUM_MODE_COMBINATIONS_IN_INTER_CU_WITH_2_PUS 4 496 497 /* +1 for skip candidate */ 498 #define MAX_NUM_INTER_RDO_CANDS \ 499 (NUM_MODE_COMBINATIONS_IN_INTER_CU_WITH_2_PUS * MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_PQ_AND_HQ + \ 500 1) 501 502 #define UNI_SATD_SCALE 1 503 504 #define ENABLE_MIXED_INTER_MODE_EVAL 1 505 506 #define DISABLE_SAO 0 507 508 #define DISABLE_LUMA_SAO (0 || (DISABLE_SAO)) 509 510 #define DISABLE_CHROMA_SAO (0 || (DISABLE_SAO)) 511 512 #define MAX_NUM_INTER_CANDS_PQ 4 /*MAX_NUM_INTER_RDO_CANDS*/ 513 514 #define MAX_NUM_INTER_CANDS_HQ 4 /*MAX_NUM_INTER_RDO_CANDS*/ 515 516 #define MAX_NUM_INTER_CANDS_MS 3 517 518 #define MAX_NUM_INTER_CANDS_HS 2 519 520 #define MAX_NUM_INTER_CANDS_ES 2 521 522 #define RESTRICT_NUM_INTER_CANDS_PER_PART_TYPE 0 523 524 #define MAX_NUM_INTER_CANDS_PER_PART_TYPE 3 525 526 #define PICK_ONLY_BEST_CAND_PER_PART_TYPE 0 527 528 #define REUSE_ME_COMPUTED_ERROR_FOR_INTER_CAND_SIFTING 0 529 530 #define DISABLE_SBH 0 531 532 #define DISABLE_TMVP 0 533 534 #define DISABLE_QUANT_ROUNDING 0 535 536 #define ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE 1 537 538 #define FORCE_INTRA_TU_DEPTH_TO_0 0 539 540 #define WEIGH_CHROMA_COST 1 541 542 #define ENABLE_ZERO_CBF_IN_INTRA 0 543 544 #define DISABLE_ZERO_ZBF_IN_INTER 0 545 546 #define ENABLE_INTER_ZCU_COST 1 547 548 #define ADAPT_COLOCATED_FROM_L0_FLAG 1 549 550 #define CHROMA_COST_WEIGHING_FACTOR_Q_SHIFT 10 551 552 #define ENABLE_SSD_CALC_RC 0 553 554 #define SRC_PADDING_FOR_TRAQO 1 555 556 #define ENABLE_CU_SPLIT_FLAG_RATE_ESTIMATION 1 557 558 #define ZCBF_SKIP_DISTORTION_THRESHOLD (1.2) 559 560 #define ENABLE_CHROMA_RDOPT_EVAL_IN_PQ 1 561 562 #define ENABLE_CHROMA_RDOPT_EVAL_IN_HQ 1 563 564 #define ENABLE_CHROMA_RDOPT_EVAL_IN_MS 1 565 566 #define ENABLE_CHROMA_RDOPT_EVAL_IN_HS 0 567 568 #define ENABLE_CHROMA_RDOPT_EVAL_IN_XS 0 569 570 #define ENABLE_CHROMA_RDOPT_EVAL_IN_XS6 0 571 572 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_PQ \ 573 (1 && (ENABLE_CHROMA_RDOPT_EVAL_IN_PQ) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 574 575 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_HQ \ 576 (1 && (ENABLE_CHROMA_RDOPT_EVAL_IN_HQ) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 577 578 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_MS \ 579 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_MS) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 580 581 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_HS \ 582 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_HS) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 583 584 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_XS \ 585 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_XS) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 586 587 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_XS6 \ 588 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_XS6) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 589 590 #define RC_BUFFER_INFO 0 591 592 #define DISABLE_SMP_IN_XS25 1 593 594 #define DISABLE_64X64_BLOCK_MERGE_IN_ME_IN_XS25 1 595 596 #define MAX_NUM_TU_RECUR_CANDS_IN_XS25 1 597 598 #define MAX_NUM_CANDS_FOR_FPEL_REFINE_IN_XS25 1 599 600 #define MAX_NUM_CONSTITUENT_MVS_TO_ENABLE_32MERGE_IN_XS25 4 601 602 #define NUM_INIT_SEARCH_CANDS_IN_L1_AND_L2_ME_IN_XS25 2 603 604 #define DISABLE_TOP_SYNC 0 605 606 #define ENABLE_MULTI_THREAD_FILE_WRITES 0 607 608 #define DISABLE_EARLY_ZCBF 0 609 610 #define EARLY_CBF_ON 1 611 612 #define DUMP_CBF_HIST_DATA 0 613 614 #define ENABLE_INTRA_MODE_FILTERING_IN_XS25 1 615 616 #define MAX_NUM_INTRA_MODES_PER_TU_DISTRIBUTION_IN_XS25 2 617 618 #define MAX_NUM_REFS_IN_PPICS_IN_XS25 1 619 620 #define USE_CONSTANT_LAMBDA_MODIFIER 0 621 622 /* Actual Lambda in ME -> (100 - ME_LAMBDA_DISCOUNT) * lambda / 100 */ 623 #define ME_LAMBDA_DISCOUNT 0 624 625 #define FORCE_AT_LEAST_1_UNICAND_IN_BPICS 0 626 627 #define MULTI_REF_ENABLE 1 628 629 #define PROHIBIT_INTRA_QUANT_ROUNDING_FACTOR_TO_DROP_BELOW_1BY3 0 630 631 #define ENABLE_INTRA_GATING_FOR_HQ 0 632 633 #define ADD_NOISE_TERM_TO_COST 1 634 635 #define ALPHA_Q_FORMAT 4 636 #define ALPHA_FOR_NOISE_TERM_IN_ME_P (1 << ((ALPHA_Q_FORMAT)-2)) //0.25 637 #define ALPHA_FOR_NOISE_TERM_IN_ME_BREF (1 << ((ALPHA_Q_FORMAT)-2)) //0.25 638 #define ALPHA_FOR_NOISE_TERM_IN_RDOPT_P (1 << ((ALPHA_Q_FORMAT)-2)) 639 640 #define ALPHA_FOR_NOISE_TERM (1 << ((ALPHA_Q_FORMAT)-2)) 641 642 #define ALPHA_FOR_NOISE_TERM_IN_ME (ALPHA_FOR_NOISE_TERM) 643 644 #define ALPHA_FOR_NOISE_TERM_IN_RDOPT (ALPHA_FOR_NOISE_TERM) 645 646 #define ALPHA_DISCOUNT_IN_REF_PICS_IN_RDOPT 50 647 648 #define ALPHA_FOR_ZERO_CODING_DECISIONS (ALPHA_FOR_NOISE_TERM_IN_RDOPT) 649 650 #define STIM_Q_FORMAT 8 651 652 #define USE_NOISE_TERM_IN_L0_ME (1 && (ADD_NOISE_TERM_TO_COST)) 653 654 #define USE_NOISE_TERM_IN_ENC_LOOP (1 && (ADD_NOISE_TERM_TO_COST)) 655 656 #define COMPUTE_NOISE_TERM_AT_THE_TU_LEVEL (1 && (USE_NOISE_TERM_IN_ENC_LOOP)) 657 658 #define DISABLE_SUBPEL_REFINEMENT_WHEN_SRC_IS_NOISY (0 && (USE_NOISE_TERM_IN_L0_ME)) 659 660 #define USE_NOISE_TERM_DURING_BICAND_SEARCH (1 && (USE_NOISE_TERM_IN_L0_ME)) 661 662 #define DISABLE_BLK_MERGE_WHEN_NOISY (0 && (USE_NOISE_TERM_IN_L0_ME)) 663 664 /* Macros for Noise detection implmentation */ 665 #define NOISE_DETECT (ADD_NOISE_TERM_TO_COST) 666 667 #define PSY_RD_DEBUG_CTBX 2048 668 #define PSY_RD_DEBUG_CTBY 1600 669 #define DEBUG_POC_NO 0 670 671 #define DISABLE_LARGE_INTRA_PQ 1 672 673 #define EVERYWHERE_NOISY 0 674 675 #define DEBUG_PRINT_NOISE_SPATIAL 0 676 677 #define DEBUG_PRINT_NOISE_TEMPORAL 0 678 679 #define TEMPORAL_NOISE_DETECT (1 && (USE_NOISE_TERM_IN_L0_ME) && !(EVERYWHERE_NOISY)) 680 681 #define MIN_NOISY_BLOCKS_CNT_16x16 7 682 683 #define ALTERNATE_METRIC 0 684 685 #define PSY_STRENGTH_CHROMA 2 // 0.5 in Q2 686 687 #define Q_PSY_STRENGTH_CHROMA 2 688 689 #define PSY_STRENGTH 4 // 0.5 in Q2 690 691 #define Q_PSY_STRENGTH 2 692 693 /* between 0 and 100 */ 694 #define MIN_ENERGY_FOR_NOISE_PERCENT_16x16 20 695 696 /* normalised value between 0 and 1 */ 697 #define MIN_VARIANCE_FOR_NOISE_16x16 0.6 698 699 /* HAD size is restricted to square blocks only. so we specify only one dimension */ 700 #define HAD_BLOCK_SIZE_16x16 16 701 702 #define MIN_NUM_COEFFS_ABOVE_AVG_16x16 41 703 704 #define MIN_COEFF_AVG_ENERGY_16x16 0 705 706 #define MIN_NOISY_BLOCKS_CNT_8x8 30 707 708 /* between 0 and 100 */ 709 #define MIN_ENERGY_FOR_NOISE_PERCENT_8x8 20 710 711 /* normalised value between 0 and 1 */ 712 #define MIN_VARIANCE_FOR_NOISE_8x8 0.6 713 714 /* HAD size is restricted to square blocks only. so we specify only one dimension */ 715 #define HAD_BLOCK_SIZE_8x8 8 716 717 #define MIN_NUM_COEFFS_ABOVE_AVG_8x8 17 718 719 #define MIN_COEFF_AVG_ENERGY_8x8 0 720 721 #define SATD_NOISE_FLOOR_THRESHOLD 16 722 723 #define ENABLE_DEBUG_PRINTS_IN_ME 0 724 725 #define RC_DEBUG_LEVEL_1 0 726 727 #define RC_2PASS_GOP_DEBUG 0 728 729 #define DUMP_NOISE_MAP 0 730 731 #define DISABLE_SKIP 0 732 733 #define DISABLE_NOISE_DETECTION_IN_P_PICS (0 && (NOISE_DETECT)) 734 735 #define MAX_LAYER_ID_OF_B_PICS_WITHOUT_NOISE_DETECTION \ 736 ((1 == (DISABLE_NOISE_DETECTION_IN_P_PICS)) ? 0 : 0) 737 738 #define DISABLE_INTRA_WHEN_NOISY (0 && (NOISE_DETECT)) 739 740 #define DISABLE_BIPRED_MODES_WHEN_NOISY (0 && (ADD_NOISE_TERM_TO_COST)) 741 742 #define TEMPORAL_VARIANCE_FACTOR 3 // in Q2 743 744 #define Q_TEMPORAL_VARIANCE_FACTOR 2 745 746 /* Actual Lambda -> (100 - ME_LAMBDA_DISCOUNT_WHEN_NOISY) * lambda / 100 */ 747 /*(((100 * (ALPHA_FOR_NOISE_TERM_IN_ME) + (1 << ((ALPHA_Q_FORMAT) - 1)))) >> (ALPHA_Q_FORMAT))*/ 748 #define ME_LAMBDA_DISCOUNT_WHEN_NOISY 50 749 750 /*(((100 * (ALPHA_FOR_NOISE_TERM_IN_RDOPT) + (1 << ((ALPHA_Q_FORMAT) - 1)))) >> (ALPHA_Q_FORMAT))*/ 751 #define RDOPT_LAMBDA_DISCOUNT_WHEN_NOISY 25 752 753 #define DISABLE_SKIP_AND_MERGE_WHEN_NOISY (0 && (USE_NOISE_TERM_IN_ENC_LOOP)) 754 755 #define NO_QP_OFFSET 0 756 757 #define CONVERT_SSDS_TO_SPATIAL_DOMAIN (1 || (USE_NOISE_TERM_IN_ENC_LOOP)) 758 759 #define MAX_QP_WHERE_SPATIAL_SSD_ENABLED 18 760 761 #define USE_RECON_TO_EVALUATE_STIM_IN_RDOPT (1 && (USE_NOISE_TERM_IN_ENC_LOOP)) 762 763 #define DISABLE_SAO_WHEN_NOISY (1 && (USE_NOISE_TERM_IN_ENC_LOOP)) 764 765 #define MAX_TU_SIZE_WHEN_NOISY 64 766 767 #define RANDOMIZE_MERGE_IDX_WHEN_NOISY (0 && (USE_NOISE_TERM_IN_ENC_LOOP)) 768 769 #define MAX_CU_SIZE_WHERE_MERGE_AND_SKIPS_ENABLED_AND_WHEN_NOISY 64 770 771 #define NUM_ELEMENTS_IN_RANDOMIZED_MERGE_IDX_LIST 113 772 773 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX4 \ 774 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 2) 775 776 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX3 \ 777 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 2) 778 779 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX2 \ 780 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 1) 781 782 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX1 \ 783 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 1) 784 785 #define USE_NOISE_TERM_IN_ZERO_CODING_DECISION_ALGORITHMS \ 786 (1 && (COMPUTE_NOISE_TERM_AT_THE_TU_LEVEL)) 787 788 #define BITPOS_IN_VQ_TOGGLE_FOR_CONTROL_TOGGLER 0 789 790 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_NOISE_PRESERVATION 29 791 792 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_PSYRDOPT_1 5 793 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_PSYRDOPT_2 6 794 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_PSYRDOPT_3 7 795 796 #define MODULATE_LAMDA_WHEN_SPATIAL_MOD_ON 1 797 798 #define MODULATE_LAMDA_WHEN_TRAQO_MOD_ON 1 799 800 #define ENABLE_RUNTIME_ARCH_SWITCH 1 801 802 #define DISABLE_8X8CUS_IN_NREFBPICS_IN_P6 1 803 804 #define DISABLE_8X8CUS_IN_REFBPICS_IN_P6 (0 && (DISABLE_8X8CUS_IN_NREFBPICS_IN_P6)) 805 806 #define DISABLE_8X8CUS_IN_PPICS_IN_P6 (0 && (DISABLE_8X8CUS_IN_REFBPICS_IN_P6)) 807 808 #define L0ME_IN_OPENLOOP_MODE 0 809 810 #define DISABLE_INTRAS_IN_BPIC 0 811 812 #define MAX_RE_ENC 1 813 814 #define ENABLE_RDO_BASED_TU_RECURSION 1 815 816 #define ENABLE_TOP_DOWN_TU_RECURSION 1 817 818 #define INCLUDE_CHROMA_DURING_TU_RECURSION (0 && (ENABLE_RDO_BASED_TU_RECURSION)) 819 820 #define PROCESS_GT_1CTB_VIA_CU_RECUR_IN_FAST_PRESETS (0) 821 822 #define PROCESS_INTRA_AND_INTER_CU_TREES_SEPARATELY \ 823 (0 && (PROCESS_GT_1CTB_VIA_CU_RECUR_IN_FAST_PRESETS)) 824 825 #define RESTRICT_NUM_PARTITION_LEVEL_L0ME_RESULTS_TO_1 1 826 827 #define RESTRICT_NUM_PARTITION_LEVEL_L1ME_RESULTS_TO_1 1 828 829 #define RESTRICT_NUM_PARTITION_LEVEL_L2ME_RESULTS_TO_1 1 830 831 #define RESTRICT_NUM_SEARCH_CANDS_PER_SEARCH_CAND_LOC 1 832 833 #define RESTRICT_NUM_2NX2N_TU_RECUR_CANDS 1 834 835 /*****************************************************************************/ 836 /* Function Macros */ 837 /*****************************************************************************/ 838 839 #define CREATE_SUBBLOCK2CSBFID_MAP(map, numMapElements, transSize, csbfBufStride) \ 840 { \ 841 WORD32 i, j; \ 842 \ 843 WORD32 i4NumSubBlocksPerRow = transSize / 4; \ 844 WORD32 i4NumSubBlocksPerColumn = i4NumSubBlocksPerRow; \ 845 \ 846 ASSERT(numMapElements >= i4NumSubBlocksPerRow * i4NumSubBlocksPerColumn); \ 847 \ 848 for(i = 0; i < i4NumSubBlocksPerColumn; i++) \ 849 { \ 850 for(j = 0; j < i4NumSubBlocksPerRow; j++) \ 851 { \ 852 map[j + i * i4NumSubBlocksPerRow] = j + i * csbfBufStride; \ 853 } \ 854 } \ 855 } 856 857 #define COPY_CABAC_STATES(dest, src, size) \ 858 { \ 859 memcpy(dest, src, size); \ 860 } 861 862 #define COPY_CABAC_STATES_FRM_CAB_COEFFX_PREFIX(dest, src, size) \ 863 { \ 864 memcpy(dest, src, size); \ 865 } 866 867 #define PAD_BUF(pu1_start, stride, wd, ht, p_x, p_y, plane, function_pointer1, function_pointer2) \ 868 { \ 869 function_pointer1(pu1_start, stride, ht, wd, p_x); \ 870 function_pointer2((pu1_start) - (p_x), stride, ht, wd + ((p_x) << 1), p_y); \ 871 } 872 873 #define PAD_BUF_HOR(pu1_start, stride, ht, p_x, p_y, function_pointer) \ 874 { \ 875 function_pointer(pu1_start, stride, ht, p_x); \ 876 } 877 878 #define PAD_BUF_VER(pu1_start, stride, wd, p_x, p_y, function_pointer) \ 879 { \ 880 function_pointer(pu1_start, stride, wd, p_y); \ 881 } 882 883 #define POPULATE_PART_RESULTS(ps_part_results, ps_search_node) \ 884 { \ 885 ps_part_results->i1_ref_idx = ps_search_node->i1_ref_idx; \ 886 ps_part_results->i2_mv_x = ps_search_node->i2_mv_x; \ 887 ps_part_results->i2_mv_y = ps_search_node->i2_mv_y; \ 888 ps_part_results->i4_sad = ps_search_node->i4_sad; \ 889 } 890 891 #define GET_IDX_CIRCULAR_BUF(idx, increment, size) \ 892 { \ 893 if(increment < 0) \ 894 { \ 895 idx += increment; \ 896 if(idx < 0) \ 897 { \ 898 idx += size; \ 899 } \ 900 } \ 901 else \ 902 { \ 903 idx += increment; \ 904 if(idx >= size) \ 905 { \ 906 idx %= size; \ 907 } \ 908 } \ 909 } 910 911 #define CLIPUCHAR(x) CLIP3((x), 0, 255) 912 913 #define CLIPUCHAR10BIT(x) CLIP3((x), 0, 1023) 914 915 #define CEIL4(x) (((x + 3) >> 2) << 2) 916 917 #define CEIL8(x) (((x + 7) >> 3) << 3) 918 919 #define CEIL2(x) (((x + 1) >> 1) << 1) 920 921 #define CEIL16(x) (((x) + 15) & (~15)) 922 923 #define CEIL_POW2(x, align) (((x) + (align)-1) & (~((align)-1))) 924 925 #define PAD_SUBPEL PAD_BUF 926 #define PAD_FPEL PAD_BUF 927 #define PAD_FPEL_HOR PAD_BUF_HOR 928 #define PAD_FPEL_VER PAD_BUF_VER 929 930 /* Defining a printf macro: To disable all prints inside codec in release mode */ 931 #ifdef _DEBUG 932 #define DBG_PRINTF(...) printf(__VA_ARGS__) 933 #else 934 #define DBG_PRINTF(...) 935 #endif 936 937 /*****************************************************************************/ 938 /* Enumerations */ 939 /*****************************************************************************/ 940 941 typedef enum 942 { 943 LEVEL1 = 30, 944 LEVEL2 = 60, 945 LEVEL2_1 = 63, 946 LEVEL3 = 90, 947 LEVEL3_1 = 93, 948 LEVEL4 = 120, 949 LEVEL4_1 = 123, 950 LEVEL5 = 150, 951 LEVEL5_1 = 153, 952 LEVEL5_2 = 156, 953 LEVEL6 = 180, 954 LEVEL6_1 = 183, 955 LEVEL6_2 = 186 956 } LEVEL_T; 957 958 typedef enum 959 { 960 LIST_0, 961 LIST_1, 962 963 NUM_REF_LISTS 964 965 } REF_LISTS_t; 966 967 typedef enum 968 { 969 NULL_PLANE = -1, 970 U_PLANE = 0, 971 V_PLANE = 1 972 } CHROMA_PLANE_ID_T; 973 974 typedef enum SSD_TYPE_T 975 { 976 NULL_TYPE = -1, 977 SPATIAL_DOMAIN_SSD, 978 FREQUENCY_DOMAIN_SSD 979 980 } SSD_TYPE_T; 981 982 #endif 983