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 CBP_VCL_FACTOR 1000 348 349 #define ENABLE_REFINED_QP_MOD 1 350 351 #if ENABLE_REFINED_QP_MOD 352 /* to find the uncovered region (or new region) which will be used for reference for the upcoming pictures 353 will be coded well to enhance coding efficiency*/ 354 #define ENABLE_TEMPORAL_WEIGHING 0 355 356 /* to enable modulation factor based on spatial variance when we calculate activity factor using 357 the following equaltion 358 act_factor = (m * c + a )/(c + m * a)*/ 359 // SATD_NOISE_FLOOR_THRESHOLD was earlier controlled using this 360 #define ENABLE_QP_MOD_BASED_ON_SPATIAL_VARIANCE 0 361 362 /* To enable the trace for delta Qp bits */ 363 #define QP_DELTA_BITS_TRACE 364 365 /* to enable modulation based LAP2 average satd*/ 366 #define MODULATION_OVER_LAP 1 367 368 /* 0 - Lamda and Qp are decoupled, 369 1 - Lamda and Qp are coupled*/ 370 #define LAMDA_BASED_ON_QUANT 0 371 372 /* 373 0 - act_factor = (m * c + a )/(c + m * a) 374 m = modulation factor 375 c = cur satd 376 a = average satd 377 ---------------------------------------- 378 1 - act_factor = (c/a) ^ (s/3) 379 s = strength 380 c = cur satd 381 a = average satd 382 */ 383 #define LOGARITHMIC_MODULATION 1 384 385 #define MEDIAN_ENABLE 1 386 #define MIN_ENABLE 0 387 388 /* well compensatable regions are not considered for 389 QP modulation*/ 390 #define DISABLE_COMPENSATION 1 391 392 #define CST_NOISE_THRSHLD 0 393 394 /*decrease intra cu qp by 1 in Inter Pictures*/ 395 #define DECREASE_QP 0 396 397 /*strength calculation based on deviation*/ 398 #define STRENGTH_BASED_ON_DEVIATION 1 399 400 /*enable allow cliping of qctivity factor such that 401 deviation of qp in modulation is controlled*/ 402 #define ALLOW_ACT_FACTOR_CLIP_IN_QP_MOD 1 403 404 /*instead of avg activity use sqrt(avg of satd square)*/ 405 #define USE_SQRT_AVG_OF_SATD_SQR 1 406 407 /*use sum of squared transform coeff*/ 408 #define USE_SQR_SATD_COEFF 0 409 410 /*instead of L1 IPE SATD, use L1 CUR SATD*/ 411 #define USE_CUR_SATD 0 // else it will use satd of cur - pred 412 413 /*use L0 CUR SATD */ 414 #define USE_CUR_L0_SATD 0 415 416 /* strength based on only curr frame deviation else it is based on average over lap2 */ 417 #define STRENGTH_BASED_ON_CURR_FRM 0 418 419 #define POW_OPT 1 420 421 #else /*INITIAL QP MOD*/ 422 /*Same as 11_0 Mod version */ 423 // SATD_NOISE_FLOOR_THRESHOLD was earlier controlled using this 424 #define ENABLE_QP_MOD_BASED_ON_SPATIAL_VARIANCE 0 425 #define ENABLE_TEMPORAL_WEIGHING 0 426 #define MODULATION_OVER_LAP 0 427 #define LAMDA_BASED_ON_QUANT 1 428 #define LOGARITHMIC_MODULATION 0 429 #define MIN_ENABLE 1 430 #define DISABLE_COMPENSATION 1 431 #define CST_NOISE_THRSHLD 1 432 #define DECREASE_QP 0 433 #endif 434 435 #define MASK_4AC 0xFFFFFFFEFEFEFCE0 436 #define MASK_3AC 0xFFFFFFFFFEFEFCF0 437 #define MASK_2AC 0xFFFFFFFFFFFEFCF8 438 #define MASK_DC 0xFFFFFFFFFFFFFFFE 439 #define I_PIC_LAMDA_MODIFIER 0.5 440 #define CONST_LAMDA_MODIFIER 1 441 #define NO_EXTRA_MULTIPLIER 1 442 #define NEW_LAMDA_MODIFIER (!CONST_LAMDA_MODIFIER) 443 #define LAMDA_MODIFIER(QP, Tid) \ 444 (0.85 * pow(2.0, (Tid * (CLIP3(((QP + 5.0) / 25.0), 1.0, 2.0) - 1.0)) / 3.0)) 445 #define CONST_LAMDA_MOD_VAL (0.85) 446 #define MEAN_BASED_QP_MOD 0 447 448 #if MEDIAN_ENABLE 449 #define MEDIAN_CU_TU 1 450 #define MEDIAN_CU_TU_BY_2 3 451 #define MEDIAN_CU_TU_BY_4 10 452 #endif 453 454 #if MIN_ENABLE 455 #define MEDIAN_CU_TU 0 456 #define MEDIAN_CU_TU_BY_2 0 457 #define MEDIAN_CU_TU_BY_4 0 458 #endif 459 460 #define COMP_RATIO_NORM 5 461 #define COMP_RATIO_MIN 0 462 #define COMP_RATIO_MAX 3 463 #define NOISE_THRE_MAP_TO_8 3 464 465 #define REF_MOD_VARIANCE (0.6696) 466 467 #define REF_MOD_DEVIATION (473.0) //(0.6696) // 468 #define NO_MOD_DEVIATION (220.0) 469 #define BELOW_REF_DEVIATION (0.0) 470 #define ABOVE_REF_DEVIATION (220.0) 471 472 #define MIN_BITRATE 4000 473 #define MIN_QP_MOD_OFFSET -10 474 #define MAX_QP_MOD_OFFSET 3 475 #define TOT_QP_MOD_OFFSET (MAX_QP_MOD_OFFSET - MIN_QP_MOD_OFFSET + 1) 476 477 #define ENABLE_UNIFORM_CU_SIZE_16x16 0 478 479 #define ENABLE_UNIFORM_CU_SIZE_8x8 0 480 481 #define MAX_QP_BD_OFFSET 24 482 483 // chroma mode index for derived from luma intra mode 484 #define DM_CHROMA_IDX 36 485 486 #define DISABLE_RDOQ 0 487 488 #define DISABLE_SKIP_AND_MERGE_EVAL 0 489 490 #define ENABLE_PICKING_4_BEST_IN_B_PIC_IN_ME 0 491 492 #define ENABLE_TU_TREE_DETERMINATION_IN_RDOPT 0 493 494 #define MAX_NUM_MIXED_MODE_INTER_RDO_CANDS (MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_PQ_AND_HQ * 2) 495 496 #define MAX_NUM_CU_MERGE_SKIP_CAND (MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_PQ_AND_HQ + 1) 497 498 #define NUM_MODE_COMBINATIONS_IN_INTER_CU_WITH_2_PUS 4 499 500 /* +1 for skip candidate */ 501 #define MAX_NUM_INTER_RDO_CANDS \ 502 (NUM_MODE_COMBINATIONS_IN_INTER_CU_WITH_2_PUS * MAX_NUMBER_OF_INTER_RDOPT_CANDS_IN_PQ_AND_HQ + \ 503 1) 504 505 #define UNI_SATD_SCALE 1 506 507 #define ENABLE_MIXED_INTER_MODE_EVAL 1 508 509 #define DISABLE_SAO 0 510 511 #define DISABLE_LUMA_SAO (0 || (DISABLE_SAO)) 512 513 #define DISABLE_CHROMA_SAO (0 || (DISABLE_SAO)) 514 515 #define MAX_NUM_INTER_CANDS_PQ 4 /*MAX_NUM_INTER_RDO_CANDS*/ 516 517 #define MAX_NUM_INTER_CANDS_HQ 4 /*MAX_NUM_INTER_RDO_CANDS*/ 518 519 #define MAX_NUM_INTER_CANDS_MS 3 520 521 #define MAX_NUM_INTER_CANDS_HS 2 522 523 #define MAX_NUM_INTER_CANDS_ES 2 524 525 #define RESTRICT_NUM_INTER_CANDS_PER_PART_TYPE 0 526 527 #define MAX_NUM_INTER_CANDS_PER_PART_TYPE 3 528 529 #define PICK_ONLY_BEST_CAND_PER_PART_TYPE 0 530 531 #define REUSE_ME_COMPUTED_ERROR_FOR_INTER_CAND_SIFTING 0 532 533 #define DISABLE_SBH 0 534 535 #define DISABLE_TMVP 0 536 537 #define DISABLE_QUANT_ROUNDING 0 538 539 #define ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE 1 540 541 #define FORCE_INTRA_TU_DEPTH_TO_0 0 542 543 #define WEIGH_CHROMA_COST 1 544 545 #define ENABLE_ZERO_CBF_IN_INTRA 0 546 547 #define DISABLE_ZERO_ZBF_IN_INTER 0 548 549 #define ENABLE_INTER_ZCU_COST 1 550 551 #define ADAPT_COLOCATED_FROM_L0_FLAG 1 552 553 #define CHROMA_COST_WEIGHING_FACTOR_Q_SHIFT 10 554 555 #define ENABLE_SSD_CALC_RC 0 556 557 #define SRC_PADDING_FOR_TRAQO 1 558 559 #define ENABLE_CU_SPLIT_FLAG_RATE_ESTIMATION 1 560 561 #define ZCBF_SKIP_DISTORTION_THRESHOLD (1.2) 562 563 #define ENABLE_CHROMA_RDOPT_EVAL_IN_PQ 1 564 565 #define ENABLE_CHROMA_RDOPT_EVAL_IN_HQ 1 566 567 #define ENABLE_CHROMA_RDOPT_EVAL_IN_MS 1 568 569 #define ENABLE_CHROMA_RDOPT_EVAL_IN_HS 0 570 571 #define ENABLE_CHROMA_RDOPT_EVAL_IN_XS 0 572 573 #define ENABLE_CHROMA_RDOPT_EVAL_IN_XS6 0 574 575 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_PQ \ 576 (1 && (ENABLE_CHROMA_RDOPT_EVAL_IN_PQ) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 577 578 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_HQ \ 579 (1 && (ENABLE_CHROMA_RDOPT_EVAL_IN_HQ) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 580 581 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_MS \ 582 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_MS) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 583 584 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_HS \ 585 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_HS) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 586 587 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_XS \ 588 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_XS) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 589 590 #define ENABLE_ADDITIONAL_CHROMA_MODES_EVAL_IN_XS6 \ 591 (0 && (ENABLE_CHROMA_RDOPT_EVAL_IN_XS6) && (ENABLE_SEPARATE_LUMA_CHROMA_INTRA_MODE)) 592 593 #define RC_BUFFER_INFO 0 594 595 #define DISABLE_SMP_IN_XS25 1 596 597 #define DISABLE_64X64_BLOCK_MERGE_IN_ME_IN_XS25 1 598 599 #define MAX_NUM_TU_RECUR_CANDS_IN_XS25 1 600 601 #define MAX_NUM_CANDS_FOR_FPEL_REFINE_IN_XS25 1 602 603 #define MAX_NUM_CONSTITUENT_MVS_TO_ENABLE_32MERGE_IN_XS25 4 604 605 #define NUM_INIT_SEARCH_CANDS_IN_L1_AND_L2_ME_IN_XS25 2 606 607 #define DISABLE_TOP_SYNC 0 608 609 #define ENABLE_MULTI_THREAD_FILE_WRITES 0 610 611 #define DISABLE_EARLY_ZCBF 0 612 613 #define EARLY_CBF_ON 1 614 615 #define DUMP_CBF_HIST_DATA 0 616 617 #define ENABLE_INTRA_MODE_FILTERING_IN_XS25 1 618 619 #define MAX_NUM_INTRA_MODES_PER_TU_DISTRIBUTION_IN_XS25 2 620 621 #define MAX_NUM_REFS_IN_PPICS_IN_XS25 1 622 623 #define USE_CONSTANT_LAMBDA_MODIFIER 0 624 625 /* Actual Lambda in ME -> (100 - ME_LAMBDA_DISCOUNT) * lambda / 100 */ 626 #define ME_LAMBDA_DISCOUNT 0 627 628 #define FORCE_AT_LEAST_1_UNICAND_IN_BPICS 0 629 630 #define MULTI_REF_ENABLE 1 631 632 #define PROHIBIT_INTRA_QUANT_ROUNDING_FACTOR_TO_DROP_BELOW_1BY3 0 633 634 #define ENABLE_INTRA_GATING_FOR_HQ 0 635 636 #define ADD_NOISE_TERM_TO_COST 1 637 638 #define ALPHA_Q_FORMAT 4 639 #define ALPHA_FOR_NOISE_TERM_IN_ME_P (1 << ((ALPHA_Q_FORMAT)-2)) //0.25 640 #define ALPHA_FOR_NOISE_TERM_IN_ME_BREF (1 << ((ALPHA_Q_FORMAT)-2)) //0.25 641 #define ALPHA_FOR_NOISE_TERM_IN_RDOPT_P (1 << ((ALPHA_Q_FORMAT)-2)) 642 643 #define ALPHA_FOR_NOISE_TERM (1 << ((ALPHA_Q_FORMAT)-2)) 644 645 #define ALPHA_FOR_NOISE_TERM_IN_ME (ALPHA_FOR_NOISE_TERM) 646 647 #define ALPHA_FOR_NOISE_TERM_IN_RDOPT (ALPHA_FOR_NOISE_TERM) 648 649 #define ALPHA_DISCOUNT_IN_REF_PICS_IN_RDOPT 50 650 651 #define ALPHA_FOR_ZERO_CODING_DECISIONS (ALPHA_FOR_NOISE_TERM_IN_RDOPT) 652 653 #define STIM_Q_FORMAT 8 654 655 #define USE_NOISE_TERM_IN_L0_ME (1 && (ADD_NOISE_TERM_TO_COST)) 656 657 #define USE_NOISE_TERM_IN_ENC_LOOP (1 && (ADD_NOISE_TERM_TO_COST)) 658 659 #define COMPUTE_NOISE_TERM_AT_THE_TU_LEVEL (1 && (USE_NOISE_TERM_IN_ENC_LOOP)) 660 661 #define DISABLE_SUBPEL_REFINEMENT_WHEN_SRC_IS_NOISY (0 && (USE_NOISE_TERM_IN_L0_ME)) 662 663 #define USE_NOISE_TERM_DURING_BICAND_SEARCH (1 && (USE_NOISE_TERM_IN_L0_ME)) 664 665 #define DISABLE_BLK_MERGE_WHEN_NOISY (0 && (USE_NOISE_TERM_IN_L0_ME)) 666 667 /* Macros for Noise detection implmentation */ 668 #define NOISE_DETECT (ADD_NOISE_TERM_TO_COST) 669 670 #define PSY_RD_DEBUG_CTBX 2048 671 #define PSY_RD_DEBUG_CTBY 1600 672 #define DEBUG_POC_NO 0 673 674 #define DISABLE_LARGE_INTRA_PQ 1 675 676 #define EVERYWHERE_NOISY 0 677 678 #define DEBUG_PRINT_NOISE_SPATIAL 0 679 680 #define DEBUG_PRINT_NOISE_TEMPORAL 0 681 682 #define TEMPORAL_NOISE_DETECT (1 && (USE_NOISE_TERM_IN_L0_ME) && !(EVERYWHERE_NOISY)) 683 684 #define MIN_NOISY_BLOCKS_CNT_16x16 7 685 686 #define ALTERNATE_METRIC 0 687 688 #define PSY_STRENGTH_CHROMA 2 // 0.5 in Q2 689 690 #define Q_PSY_STRENGTH_CHROMA 2 691 692 #define PSY_STRENGTH 4 // 0.5 in Q2 693 694 #define Q_PSY_STRENGTH 2 695 696 /* between 0 and 100 */ 697 #define MIN_ENERGY_FOR_NOISE_PERCENT_16x16 20 698 699 /* normalised value between 0 and 1 */ 700 #define MIN_VARIANCE_FOR_NOISE_16x16 0.6 701 702 /* HAD size is restricted to square blocks only. so we specify only one dimension */ 703 #define HAD_BLOCK_SIZE_16x16 16 704 705 #define MIN_NUM_COEFFS_ABOVE_AVG_16x16 41 706 707 #define MIN_COEFF_AVG_ENERGY_16x16 0 708 709 #define MIN_NOISY_BLOCKS_CNT_8x8 30 710 711 /* between 0 and 100 */ 712 #define MIN_ENERGY_FOR_NOISE_PERCENT_8x8 20 713 714 /* normalised value between 0 and 1 */ 715 #define MIN_VARIANCE_FOR_NOISE_8x8 0.6 716 717 /* HAD size is restricted to square blocks only. so we specify only one dimension */ 718 #define HAD_BLOCK_SIZE_8x8 8 719 720 #define MIN_NUM_COEFFS_ABOVE_AVG_8x8 17 721 722 #define MIN_COEFF_AVG_ENERGY_8x8 0 723 724 #define SATD_NOISE_FLOOR_THRESHOLD 16 725 726 #define ENABLE_DEBUG_PRINTS_IN_ME 0 727 728 #define RC_DEBUG_LEVEL_1 0 729 730 #define RC_2PASS_GOP_DEBUG 0 731 732 #define DUMP_NOISE_MAP 0 733 734 #define DISABLE_SKIP 0 735 736 #define DISABLE_NOISE_DETECTION_IN_P_PICS (0 && (NOISE_DETECT)) 737 738 #define MAX_LAYER_ID_OF_B_PICS_WITHOUT_NOISE_DETECTION \ 739 ((1 == (DISABLE_NOISE_DETECTION_IN_P_PICS)) ? 0 : 0) 740 741 #define DISABLE_INTRA_WHEN_NOISY (0 && (NOISE_DETECT)) 742 743 #define DISABLE_BIPRED_MODES_WHEN_NOISY (0 && (ADD_NOISE_TERM_TO_COST)) 744 745 #define TEMPORAL_VARIANCE_FACTOR 3 // in Q2 746 747 #define Q_TEMPORAL_VARIANCE_FACTOR 2 748 749 /* Actual Lambda -> (100 - ME_LAMBDA_DISCOUNT_WHEN_NOISY) * lambda / 100 */ 750 /*(((100 * (ALPHA_FOR_NOISE_TERM_IN_ME) + (1 << ((ALPHA_Q_FORMAT) - 1)))) >> (ALPHA_Q_FORMAT))*/ 751 #define ME_LAMBDA_DISCOUNT_WHEN_NOISY 50 752 753 /*(((100 * (ALPHA_FOR_NOISE_TERM_IN_RDOPT) + (1 << ((ALPHA_Q_FORMAT) - 1)))) >> (ALPHA_Q_FORMAT))*/ 754 #define RDOPT_LAMBDA_DISCOUNT_WHEN_NOISY 25 755 756 #define DISABLE_SKIP_AND_MERGE_WHEN_NOISY (0 && (USE_NOISE_TERM_IN_ENC_LOOP)) 757 758 #define NO_QP_OFFSET 0 759 760 #define CONVERT_SSDS_TO_SPATIAL_DOMAIN (1 || (USE_NOISE_TERM_IN_ENC_LOOP)) 761 762 #define MAX_QP_WHERE_SPATIAL_SSD_ENABLED 18 763 764 #define USE_RECON_TO_EVALUATE_STIM_IN_RDOPT (1 && (USE_NOISE_TERM_IN_ENC_LOOP)) 765 766 #define DISABLE_SAO_WHEN_NOISY (1 && (USE_NOISE_TERM_IN_ENC_LOOP)) 767 768 #define MAX_TU_SIZE_WHEN_NOISY 64 769 770 #define RANDOMIZE_MERGE_IDX_WHEN_NOISY (0 && (USE_NOISE_TERM_IN_ENC_LOOP)) 771 772 #define MAX_CU_SIZE_WHERE_MERGE_AND_SKIPS_ENABLED_AND_WHEN_NOISY 64 773 774 #define NUM_ELEMENTS_IN_RANDOMIZED_MERGE_IDX_LIST 113 775 776 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX4 \ 777 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 2) 778 779 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX3 \ 780 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 2) 781 782 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX2 \ 783 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 1) 784 785 #define NUM_MERGE_INDICES_TO_PICK_WHEN_LIST_RANDOMIZED_MAXIDX1 \ 786 ((DISABLE_SKIP_AND_MERGE_WHEN_NOISY) ? 0 : 1) 787 788 #define USE_NOISE_TERM_IN_ZERO_CODING_DECISION_ALGORITHMS \ 789 (1 && (COMPUTE_NOISE_TERM_AT_THE_TU_LEVEL)) 790 791 #define BITPOS_IN_VQ_TOGGLE_FOR_CONTROL_TOGGLER 0 792 793 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_NOISE_PRESERVATION 29 794 795 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_PSYRDOPT_1 5 796 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_PSYRDOPT_2 6 797 #define BITPOS_IN_VQ_TOGGLE_FOR_ENABLING_PSYRDOPT_3 7 798 799 #define MODULATE_LAMDA_WHEN_SPATIAL_MOD_ON 1 800 801 #define MODULATE_LAMDA_WHEN_TRAQO_MOD_ON 1 802 803 #define ENABLE_RUNTIME_ARCH_SWITCH 1 804 805 #define DISABLE_8X8CUS_IN_NREFBPICS_IN_P6 1 806 807 #define DISABLE_8X8CUS_IN_REFBPICS_IN_P6 (0 && (DISABLE_8X8CUS_IN_NREFBPICS_IN_P6)) 808 809 #define DISABLE_8X8CUS_IN_PPICS_IN_P6 (0 && (DISABLE_8X8CUS_IN_REFBPICS_IN_P6)) 810 811 #define L0ME_IN_OPENLOOP_MODE 0 812 813 #define DISABLE_INTRAS_IN_BPIC 0 814 815 #define MAX_RE_ENC 1 816 817 #define ENABLE_RDO_BASED_TU_RECURSION 1 818 819 #define ENABLE_TOP_DOWN_TU_RECURSION 1 820 821 #define INCLUDE_CHROMA_DURING_TU_RECURSION (0 && (ENABLE_RDO_BASED_TU_RECURSION)) 822 823 #define PROCESS_GT_1CTB_VIA_CU_RECUR_IN_FAST_PRESETS (0) 824 825 #define PROCESS_INTRA_AND_INTER_CU_TREES_SEPARATELY \ 826 (0 && (PROCESS_GT_1CTB_VIA_CU_RECUR_IN_FAST_PRESETS)) 827 828 #define RESTRICT_NUM_PARTITION_LEVEL_L0ME_RESULTS_TO_1 1 829 830 #define RESTRICT_NUM_PARTITION_LEVEL_L1ME_RESULTS_TO_1 1 831 832 #define RESTRICT_NUM_PARTITION_LEVEL_L2ME_RESULTS_TO_1 1 833 834 #define RESTRICT_NUM_SEARCH_CANDS_PER_SEARCH_CAND_LOC 1 835 836 #define RESTRICT_NUM_2NX2N_TU_RECUR_CANDS 1 837 838 /*****************************************************************************/ 839 /* Function Macros */ 840 /*****************************************************************************/ 841 842 #define CREATE_SUBBLOCK2CSBFID_MAP(map, numMapElements, transSize, csbfBufStride) \ 843 { \ 844 WORD32 i, j; \ 845 \ 846 WORD32 i4NumSubBlocksPerRow = transSize / 4; \ 847 WORD32 i4NumSubBlocksPerColumn = i4NumSubBlocksPerRow; \ 848 \ 849 ASSERT(numMapElements >= i4NumSubBlocksPerRow * i4NumSubBlocksPerColumn); \ 850 \ 851 for(i = 0; i < i4NumSubBlocksPerColumn; i++) \ 852 { \ 853 for(j = 0; j < i4NumSubBlocksPerRow; j++) \ 854 { \ 855 map[j + i * i4NumSubBlocksPerRow] = j + i * csbfBufStride; \ 856 } \ 857 } \ 858 } 859 860 #define COPY_CABAC_STATES(dest, src, size) \ 861 { \ 862 memcpy(dest, src, size); \ 863 } 864 865 #define COPY_CABAC_STATES_FRM_CAB_COEFFX_PREFIX(dest, src, size) \ 866 { \ 867 memcpy(dest, src, size); \ 868 } 869 870 #define PAD_BUF(pu1_start, stride, wd, ht, p_x, p_y, plane, function_pointer1, function_pointer2) \ 871 { \ 872 function_pointer1(pu1_start, stride, ht, wd, p_x); \ 873 function_pointer2((pu1_start) - (p_x), stride, ht, wd + ((p_x) << 1), p_y); \ 874 } 875 876 #define PAD_BUF_HOR(pu1_start, stride, ht, p_x, p_y, function_pointer) \ 877 { \ 878 function_pointer(pu1_start, stride, ht, p_x); \ 879 } 880 881 #define PAD_BUF_VER(pu1_start, stride, wd, p_x, p_y, function_pointer) \ 882 { \ 883 function_pointer(pu1_start, stride, wd, p_y); \ 884 } 885 886 #define POPULATE_PART_RESULTS(ps_part_results, ps_search_node) \ 887 { \ 888 ps_part_results->i1_ref_idx = ps_search_node->i1_ref_idx; \ 889 ps_part_results->i2_mv_x = ps_search_node->i2_mv_x; \ 890 ps_part_results->i2_mv_y = ps_search_node->i2_mv_y; \ 891 ps_part_results->i4_sad = ps_search_node->i4_sad; \ 892 } 893 894 #define GET_IDX_CIRCULAR_BUF(idx, increment, size) \ 895 { \ 896 if(increment < 0) \ 897 { \ 898 idx += increment; \ 899 if(idx < 0) \ 900 { \ 901 idx += size; \ 902 } \ 903 } \ 904 else \ 905 { \ 906 idx += increment; \ 907 if(idx >= size) \ 908 { \ 909 idx %= size; \ 910 } \ 911 } \ 912 } 913 914 #define CLIPUCHAR(x) CLIP3((x), 0, 255) 915 916 #define CLIPUCHAR10BIT(x) CLIP3((x), 0, 1023) 917 918 #define CEIL4(x) (((x + 3) >> 2) << 2) 919 920 #define CEIL8(x) (((x + 7) >> 3) << 3) 921 922 #define CEIL2(x) (((x + 1) >> 1) << 1) 923 924 #define CEIL16(x) (((x) + 15) & (~15)) 925 926 #define CEIL_POW2(x, align) (((x) + (align)-1) & (~((align)-1))) 927 928 #define PAD_SUBPEL PAD_BUF 929 #define PAD_FPEL PAD_BUF 930 #define PAD_FPEL_HOR PAD_BUF_HOR 931 #define PAD_FPEL_VER PAD_BUF_VER 932 933 /* Defining a printf macro: To disable all prints inside codec in release mode */ 934 #ifdef _DEBUG 935 #define DBG_PRINTF(...) printf(__VA_ARGS__) 936 #else 937 #define DBG_PRINTF(...) 938 #endif 939 940 /*****************************************************************************/ 941 /* Enumerations */ 942 /*****************************************************************************/ 943 944 typedef enum 945 { 946 LEVEL1 = 30, 947 LEVEL2 = 60, 948 LEVEL2_1 = 63, 949 LEVEL3 = 90, 950 LEVEL3_1 = 93, 951 LEVEL4 = 120, 952 LEVEL4_1 = 123, 953 LEVEL5 = 150, 954 LEVEL5_1 = 153, 955 LEVEL5_2 = 156, 956 LEVEL6 = 180, 957 LEVEL6_1 = 183, 958 LEVEL6_2 = 186 959 } LEVEL_T; 960 961 typedef enum 962 { 963 LIST_0, 964 LIST_1, 965 966 NUM_REF_LISTS 967 968 } REF_LISTS_t; 969 970 typedef enum SSD_TYPE_T 971 { 972 NULL_TYPE = -1, 973 SPATIAL_DOMAIN_SSD, 974 FREQUENCY_DOMAIN_SSD 975 976 } SSD_TYPE_T; 977 978 #endif 979