1 /* 2 * Copyright (c) 2016, Alliance for Open Media. All rights reserved 3 * 4 * This source code is subject to the terms of the BSD 2 Clause License and 5 * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License 6 * was not distributed with this source code in the LICENSE file, you can 7 * obtain it at www.aomedia.org/license/software. If the Alliance for Open 8 * Media Patent License 1.0 was not distributed with this source code in the 9 * PATENTS file, you can obtain it at www.aomedia.org/license/patent. 10 */ 11 12 #ifndef AOM_AV1_ENCODER_SPEED_FEATURES_H_ 13 #define AOM_AV1_ENCODER_SPEED_FEATURES_H_ 14 15 #include "av1/common/enums.h" 16 #include "av1/encoder/enc_enums.h" 17 #include "av1/encoder/mcomp.h" 18 #include "av1/encoder/encodemb.h" 19 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 /*! @file */ 25 26 /*!\cond */ 27 #define MAX_MESH_STEP 4 28 29 typedef struct MESH_PATTERN { 30 int range; 31 int interval; 32 } MESH_PATTERN; 33 34 enum { 35 GM_FULL_SEARCH, 36 GM_REDUCED_REF_SEARCH_SKIP_L2_L3, 37 GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2, 38 GM_DISABLE_SEARCH 39 } UENUM1BYTE(GM_SEARCH_TYPE); 40 41 enum { 42 DIST_WTD_COMP_ENABLED, 43 DIST_WTD_COMP_SKIP_MV_SEARCH, 44 DIST_WTD_COMP_DISABLED, 45 } UENUM1BYTE(DIST_WTD_COMP_FLAG); 46 47 enum { 48 INTRA_ALL = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << D45_PRED) | 49 (1 << D135_PRED) | (1 << D113_PRED) | (1 << D157_PRED) | 50 (1 << D203_PRED) | (1 << D67_PRED) | (1 << SMOOTH_PRED) | 51 (1 << SMOOTH_V_PRED) | (1 << SMOOTH_H_PRED) | (1 << PAETH_PRED), 52 UV_INTRA_ALL = 53 (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED) | 54 (1 << UV_D45_PRED) | (1 << UV_D135_PRED) | (1 << UV_D113_PRED) | 55 (1 << UV_D157_PRED) | (1 << UV_D203_PRED) | (1 << UV_D67_PRED) | 56 (1 << UV_SMOOTH_PRED) | (1 << UV_SMOOTH_V_PRED) | 57 (1 << UV_SMOOTH_H_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED), 58 UV_INTRA_DC = (1 << UV_DC_PRED), 59 UV_INTRA_DC_CFL = (1 << UV_DC_PRED) | (1 << UV_CFL_PRED), 60 UV_INTRA_DC_TM = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED), 61 UV_INTRA_DC_PAETH_CFL = 62 (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED), 63 UV_INTRA_DC_H_V = (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED), 64 UV_INTRA_DC_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_V_PRED) | 65 (1 << UV_H_PRED) | (1 << UV_CFL_PRED), 66 UV_INTRA_DC_PAETH_H_V = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | 67 (1 << UV_V_PRED) | (1 << UV_H_PRED), 68 UV_INTRA_DC_PAETH_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | 69 (1 << UV_V_PRED) | (1 << UV_H_PRED) | 70 (1 << UV_CFL_PRED), 71 INTRA_DC = (1 << DC_PRED), 72 INTRA_DC_TM = (1 << DC_PRED) | (1 << PAETH_PRED), 73 INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED), 74 INTRA_DC_H_V_SMOOTH = 75 (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << SMOOTH_PRED), 76 INTRA_DC_PAETH_H_V = 77 (1 << DC_PRED) | (1 << PAETH_PRED) | (1 << V_PRED) | (1 << H_PRED) 78 }; 79 80 enum { 81 INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) | 82 (1 << NEWMV) | (1 << NEAREST_NEARESTMV) | (1 << NEAR_NEARMV) | 83 (1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) | (1 << NEAR_NEWMV) | 84 (1 << NEW_NEARMV) | (1 << NEW_NEARESTMV) | (1 << GLOBAL_GLOBALMV), 85 INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) | 86 (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) | 87 (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) | 88 (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) | 89 (1 << NEAR_NEARMV), 90 }; 91 92 enum { 93 DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) | 94 (1 << THR_ALTR) | (1 << THR_GOLD) | (1 << THR_LAST), 95 96 DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT, 97 98 DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA), 99 100 LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) | 101 (1 << THR_ALTR) | (1 << THR_GOLD) 102 }; 103 104 enum { 105 TXFM_CODING_SF = 1, 106 INTER_PRED_SF = 2, 107 INTRA_PRED_SF = 4, 108 PARTITION_SF = 8, 109 LOOP_FILTER_SF = 16, 110 RD_SKIP_SF = 32, 111 RESERVE_2_SF = 64, 112 RESERVE_3_SF = 128, 113 } UENUM1BYTE(DEV_SPEED_FEATURES); 114 115 /* This enumeration defines when the rate control recode loop will be 116 * enabled. 117 */ 118 enum { 119 /* 120 * No recodes allowed 121 */ 122 DISALLOW_RECODE = 0, 123 /* 124 * Allow recode only for KF/ARF/GF frames 125 */ 126 ALLOW_RECODE_KFARFGF = 1, 127 /* 128 * Allow recode for all frame types based on bitrate constraints. 129 */ 130 ALLOW_RECODE = 2, 131 } UENUM1BYTE(RECODE_LOOP_TYPE); 132 133 enum { 134 SUBPEL_TREE = 0, 135 SUBPEL_TREE_PRUNED = 1, // Prunes 1/2-pel searches 136 SUBPEL_TREE_PRUNED_MORE = 2, // Prunes 1/2-pel searches more aggressively 137 } UENUM1BYTE(SUBPEL_SEARCH_METHODS); 138 139 enum { 140 // Try the full image with different values. 141 LPF_PICK_FROM_FULL_IMAGE, 142 // Try the full image filter search with non-dual filter only. 143 LPF_PICK_FROM_FULL_IMAGE_NON_DUAL, 144 // Try a small portion of the image with different values. 145 LPF_PICK_FROM_SUBIMAGE, 146 // Estimate the level based on quantizer and frame type 147 LPF_PICK_FROM_Q, 148 // Pick 0 to disable LPF if LPF was enabled last frame 149 LPF_PICK_MINIMAL_LPF 150 } UENUM1BYTE(LPF_PICK_METHOD); 151 /*!\endcond */ 152 153 /*!\enum CDEF_PICK_METHOD 154 * \brief This enumeration defines a variety of CDEF pick methods 155 */ 156 typedef enum { 157 CDEF_FULL_SEARCH, /**< Full search */ 158 CDEF_FAST_SEARCH_LVL1, /**< Search among a subset of all possible filters. */ 159 CDEF_FAST_SEARCH_LVL2, /**< Search reduced subset of filters than Level 1. */ 160 CDEF_FAST_SEARCH_LVL3, /**< Search reduced subset of secondary filters than 161 Level 2. */ 162 CDEF_FAST_SEARCH_LVL4, /**< Search reduced subset of filters than Level 3. */ 163 CDEF_FAST_SEARCH_LVL5, /**< Search reduced subset of filters than Level 4. */ 164 CDEF_PICK_FROM_Q, /**< Estimate filter strength based on quantizer. */ 165 CDEF_PICK_METHODS 166 } CDEF_PICK_METHOD; 167 168 /*!\cond */ 169 enum { 170 // Terminate search early based on distortion so far compared to 171 // qp step, distortion in the neighborhood of the frame, etc. 172 FLAG_EARLY_TERMINATE = 1 << 0, 173 174 // Skips comp inter modes if the best so far is an intra mode. 175 FLAG_SKIP_COMP_BESTINTRA = 1 << 1, 176 177 // Skips oblique intra modes if the best so far is an inter mode. 178 FLAG_SKIP_INTRA_BESTINTER = 1 << 3, 179 180 // Skips oblique intra modes at angles 27, 63, 117, 153 if the best 181 // intra so far is not one of the neighboring directions. 182 FLAG_SKIP_INTRA_DIRMISMATCH = 1 << 4, 183 184 // Skips intra modes other than DC_PRED if the source variance is small 185 FLAG_SKIP_INTRA_LOWVAR = 1 << 5, 186 } UENUM1BYTE(MODE_SEARCH_SKIP_LOGIC); 187 188 enum { 189 // No tx type pruning 190 TX_TYPE_PRUNE_0 = 0, 191 // adaptively prunes the least perspective tx types out of all 16 192 // (tuned to provide negligible quality loss) 193 TX_TYPE_PRUNE_1 = 1, 194 // similar, but applies much more aggressive pruning to get better speed-up 195 TX_TYPE_PRUNE_2 = 2, 196 TX_TYPE_PRUNE_3 = 3, 197 // More aggressive pruning based on tx type score and allowed tx count 198 TX_TYPE_PRUNE_4 = 4, 199 TX_TYPE_PRUNE_5 = 5, 200 } UENUM1BYTE(TX_TYPE_PRUNE_MODE); 201 202 enum { 203 // No reaction to rate control on a detected slide/scene change. 204 NO_DETECTION = 0, 205 206 // Set to larger Q based only on the detected slide/scene change and 207 // current/past Q. 208 FAST_DETECTION_MAXQ = 1, 209 } UENUM1BYTE(OVERSHOOT_DETECTION_CBR); 210 211 enum { 212 // Turns off multi-winner mode. So we will do txfm search on either all modes 213 // if winner mode is off, or we will only on txfm search on a single winner 214 // mode. 215 MULTI_WINNER_MODE_OFF = 0, 216 217 // Limits the number of winner modes to at most 2 218 MULTI_WINNER_MODE_FAST = 1, 219 220 // Uses the default number of winner modes, which is 3 for intra mode, and 1 221 // for inter mode. 222 MULTI_WINNER_MODE_DEFAULT = 2, 223 224 // Maximum number of winner modes allowed. 225 MULTI_WINNER_MODE_LEVELS, 226 } UENUM1BYTE(MULTI_WINNER_MODE_TYPE); 227 228 enum { 229 PRUNE_NEARMV_OFF = 0, // Turn off nearmv pruning 230 PRUNE_NEARMV_LEVEL1 = 1, // Prune nearmv for qindex (0-85) 231 PRUNE_NEARMV_LEVEL2 = 2, // Prune nearmv for qindex (0-170) 232 PRUNE_NEARMV_LEVEL3 = 3, // Prune nearmv more aggressively for qindex (0-170) 233 PRUNE_NEARMV_MAX = PRUNE_NEARMV_LEVEL3, 234 } UENUM1BYTE(PRUNE_NEARMV_LEVEL); 235 236 typedef struct { 237 TX_TYPE_PRUNE_MODE prune_2d_txfm_mode; 238 int fast_intra_tx_type_search; 239 240 // INT_MAX: Disable fast search. 241 // 1 - 1024: Probability threshold used for conditionally forcing tx type, 242 // during mode search. 243 // 0: Force tx type to be DCT_DCT unconditionally, during 244 // mode search. 245 int fast_inter_tx_type_prob_thresh; 246 247 // Prune less likely chosen transforms for each intra mode. The speed 248 // feature ranges from 0 to 2, for different speed / compression trade offs. 249 int use_reduced_intra_txset; 250 251 // Use a skip flag prediction model to detect blocks with skip = 1 early 252 // and avoid doing full TX type search for such blocks. 253 int use_skip_flag_prediction; 254 255 // Threshold used by the ML based method to predict TX block split decisions. 256 int ml_tx_split_thresh; 257 258 // skip remaining transform type search when we found the rdcost of skip is 259 // better than applying transform 260 int skip_tx_search; 261 262 // Prune tx type search using previous frame stats. 263 int prune_tx_type_using_stats; 264 // Prune tx type search using estimated RDcost 265 int prune_tx_type_est_rd; 266 267 // Flag used to control the winner mode processing for tx type pruning for 268 // inter blocks. It enables further tx type mode pruning based on ML model for 269 // mode evaluation and disables tx type mode pruning for winner mode 270 // processing. 271 int winner_mode_tx_type_pruning; 272 } TX_TYPE_SEARCH; 273 274 enum { 275 // Search partitions using RD criterion 276 SEARCH_PARTITION, 277 278 // Always use a fixed size partition 279 FIXED_PARTITION, 280 281 // Partition using source variance 282 VAR_BASED_PARTITION, 283 284 #if CONFIG_RT_ML_PARTITIONING 285 // Partition using ML model 286 ML_BASED_PARTITION 287 #endif 288 } UENUM1BYTE(PARTITION_SEARCH_TYPE); 289 290 enum { 291 NOT_IN_USE, 292 DIRECT_PRED, 293 RELAXED_PRED, 294 ADAPT_PRED 295 } UENUM1BYTE(MAX_PART_PRED_MODE); 296 297 enum { 298 LAST_MV_DATA, 299 CURRENT_Q, 300 QTR_ONLY, 301 } UENUM1BYTE(MV_PREC_LOGIC); 302 303 enum { 304 SUPERRES_AUTO_ALL, // Tries all possible superres ratios 305 SUPERRES_AUTO_DUAL, // Tries no superres and q-based superres ratios 306 SUPERRES_AUTO_SOLO, // Only apply the q-based superres ratio 307 } UENUM1BYTE(SUPERRES_AUTO_SEARCH_TYPE); 308 /*!\endcond */ 309 310 /*!\enum INTERNAL_COST_UPDATE_TYPE 311 * \brief This enum decides internally how often to update the entropy costs 312 * 313 * INTERNAL_COST_UPD_TYPE is similar to \ref COST_UPDATE_TYPE but has slightly 314 * more flexibility in update frequency. This enum is separate from \ref 315 * COST_UPDATE_TYPE because although \ref COST_UPDATE_TYPE is not exposed, its 316 * values are public so it cannot be modified without breaking public API. 317 * Due to the use of AOMMIN() in populate_unified_cost_update_freq() to 318 * compute the unified cost update frequencies (out of COST_UPDATE_TYPE and 319 * INTERNAL_COST_UPDATE_TYPE), the values of this enum type must be listed in 320 * the order of increasing frequencies. 321 * 322 * \warning In case of any updates/modifications to the enum COST_UPDATE_TYPE, 323 * update the enum INTERNAL_COST_UPDATE_TYPE as well. 324 */ 325 typedef enum { 326 INTERNAL_COST_UPD_OFF, /*!< Turn off cost updates. */ 327 INTERNAL_COST_UPD_TILE, /*!< Update every tile. */ 328 INTERNAL_COST_UPD_SBROW_SET, /*!< Update every row_set of height 256 pixs. */ 329 INTERNAL_COST_UPD_SBROW, /*!< Update every sb rows inside a tile. */ 330 INTERNAL_COST_UPD_SB, /*!< Update every sb. */ 331 } INTERNAL_COST_UPDATE_TYPE; 332 333 /*!\enum SIMPLE_MOTION_SEARCH_PRUNE_LEVEL 334 * \brief This enumeration defines a variety of simple motion search based 335 * partition prune levels 336 */ 337 typedef enum { 338 NO_PRUNING = -1, 339 SIMPLE_AGG_LVL0, /*!< Simple prune aggressiveness level 0. */ 340 SIMPLE_AGG_LVL1, /*!< Simple prune aggressiveness level 1. */ 341 SIMPLE_AGG_LVL2, /*!< Simple prune aggressiveness level 2. */ 342 SIMPLE_AGG_LVL3, /*!< Simple prune aggressiveness level 3. */ 343 QIDX_BASED_AGG_LVL1, /*!< Qindex based prune aggressiveness level, aggressive 344 level maps to simple agg level 1 or 2 based on qindex. 345 */ 346 TOTAL_SIMPLE_AGG_LVLS = QIDX_BASED_AGG_LVL1, /*!< Total number of simple prune 347 aggressiveness levels. */ 348 TOTAL_QINDEX_BASED_AGG_LVLS = 349 QIDX_BASED_AGG_LVL1 - 350 SIMPLE_AGG_LVL3, /*!< Total number of qindex based simple prune 351 aggressiveness levels. */ 352 TOTAL_AGG_LVLS = TOTAL_SIMPLE_AGG_LVLS + 353 TOTAL_QINDEX_BASED_AGG_LVLS, /*!< Total number of levels. */ 354 } SIMPLE_MOTION_SEARCH_PRUNE_LEVEL; 355 356 /*!\enum PRUNE_MESH_SEARCH_LEVEL 357 * \brief This enumeration defines a variety of mesh search prune levels. 358 */ 359 typedef enum { 360 PRUNE_MESH_SEARCH_DISABLED = 0, /*!< Prune mesh search level 0. */ 361 PRUNE_MESH_SEARCH_LVL_1 = 1, /*!< Prune mesh search level 1. */ 362 PRUNE_MESH_SEARCH_LVL_2 = 2, /*!< Prune mesh search level 2. */ 363 } PRUNE_MESH_SEARCH_LEVEL; 364 365 /*!\enum INTER_SEARCH_EARLY_TERM_IDX 366 * \brief This enumeration defines inter search early termination index in 367 * non-rd path based on sse value. 368 */ 369 typedef enum { 370 EARLY_TERM_DISABLED = 371 0, /*!< Early terminate inter mode search based on sse disabled. */ 372 EARLY_TERM_IDX_1 = 373 1, /*!< Early terminate inter mode search based on sse, index 1. */ 374 EARLY_TERM_IDX_2 = 375 2, /*!< Early terminate inter mode search based on sse, index 2. */ 376 EARLY_TERM_IDX_3 = 377 3, /*!< Early terminate inter mode search based on sse, index 3. */ 378 EARLY_TERM_IDX_4 = 379 4, /*!< Early terminate inter mode search based on sse, index 4. */ 380 EARLY_TERM_INDICES, /*!< Total number of early terminate indices */ 381 } INTER_SEARCH_EARLY_TERM_IDX; 382 383 /*! 384 * \brief Sequence/frame level speed vs quality features 385 */ 386 typedef struct HIGH_LEVEL_SPEED_FEATURES { 387 /*! Frame level coding parameter update. */ 388 int frame_parameter_update; 389 390 /*! 391 * Cases and frame types for which the recode loop is enabled. 392 */ 393 RECODE_LOOP_TYPE recode_loop; 394 395 /*! 396 * Controls the tolerance vs target rate used in deciding whether to 397 * recode a frame. It has no meaning if recode is disabled. 398 */ 399 int recode_tolerance; 400 401 /*! 402 * Determine how motion vector precision is chosen. The possibilities are: 403 * LAST_MV_DATA: use the mv data from the last coded frame 404 * CURRENT_Q: use the current q as a threshold 405 * QTR_ONLY: use quarter pel precision only. 406 */ 407 MV_PREC_LOGIC high_precision_mv_usage; 408 409 /*! 410 * Always set to 0. If on it enables 0 cost background transmission 411 * (except for the initial transmission of the segmentation). The feature is 412 * disabled because the addition of very large block sizes make the 413 * backgrounds very to cheap to encode, and the segmentation we have 414 * adds overhead. 415 */ 416 int static_segmentation; 417 418 /*! 419 * Superres-auto mode search type: 420 */ 421 SUPERRES_AUTO_SEARCH_TYPE superres_auto_search_type; 422 423 /*! 424 * Enable/disable extra screen content test by encoding key frame twice. 425 */ 426 int disable_extra_sc_testing; 427 428 /*! 429 * Enable/disable second_alt_ref temporal filtering. 430 */ 431 int second_alt_ref_filtering; 432 433 /*! 434 * Number of frames to be used in temporal filtering controlled based on noise 435 * levels and arf-q. 436 */ 437 int num_frames_used_in_tf; 438 439 /*! 440 * Decide the bit estimation approach used in qindex decision. 441 * 0: estimate bits based on a constant value; 442 * 1: estimate bits more accurately based on the frame complexity. 443 */ 444 int accurate_bit_estimate; 445 } HIGH_LEVEL_SPEED_FEATURES; 446 447 /*! 448 * Speed features for the first pass. 449 */ 450 typedef struct FIRST_PASS_SPEED_FEATURES { 451 /*! 452 * \brief Reduces the mv search window. 453 * By default, the initial search window is around 454 * MIN(MIN(dims), MAX_FULL_PEL_VAL) = MIN(MIN(dims), 1023). 455 * Each step reduction decrease the window size by about a factor of 2. 456 */ 457 int reduce_mv_step_param; 458 459 /*! 460 * \brief Skips the motion search when the zero mv has small sse. 461 */ 462 int skip_motion_search_threshold; 463 464 /*! 465 * \brief Skips reconstruction by using source buffers for prediction 466 */ 467 int disable_recon; 468 469 /*! 470 * \brief Skips the motion search centered on 0,0 mv. 471 */ 472 int skip_zeromv_motion_search; 473 } FIRST_PASS_SPEED_FEATURES; 474 475 /*!\cond */ 476 typedef struct TPL_SPEED_FEATURES { 477 // GOP length adaptive decision. 478 // If set to 0, tpl model decides whether a shorter gf interval is better. 479 // If set to 1, tpl stats of ARFs from base layer, (base+1) layer and 480 // (base+2) layer decide whether a shorter gf interval is better. 481 // If set to 2, tpl stats of ARFs from base layer, (base+1) layer and GF boost 482 // decide whether a shorter gf interval is better. 483 // If set to 3, gop length adaptive decision is disabled. 484 int gop_length_decision_method; 485 // Prune the intra modes search by tpl. 486 // If set to 0, we will search all intra modes from DC_PRED to PAETH_PRED. 487 // If set to 1, we only search DC_PRED, V_PRED, and H_PRED. 488 int prune_intra_modes; 489 // This parameter controls which step in the n-step process we start at. 490 int reduce_first_step_size; 491 // Skip motion estimation based on the precision of center MVs and the 492 // difference between center MVs. 493 // If set to 0, motion estimation is skipped for duplicate center MVs 494 // (default). If set to 1, motion estimation is skipped for duplicate 495 // full-pixel center MVs. If set to 2, motion estimation is skipped if the 496 // difference between center MVs is less than the threshold. 497 int skip_alike_starting_mv; 498 499 // When to stop subpel search. 500 SUBPEL_FORCE_STOP subpel_force_stop; 501 502 // Which search method to use. 503 SEARCH_METHODS search_method; 504 505 // Prune starting mvs in TPL based on sad scores. 506 int prune_starting_mv; 507 508 // Not run TPL for filtered Key frame. 509 int disable_filtered_key_tpl; 510 511 // Prune reference frames in TPL. 512 int prune_ref_frames_in_tpl; 513 514 // Support compound predictions. 515 int allow_compound_pred; 516 517 // Calculate rate and distortion based on Y plane only. 518 int use_y_only_rate_distortion; 519 } TPL_SPEED_FEATURES; 520 521 typedef struct GLOBAL_MOTION_SPEED_FEATURES { 522 GM_SEARCH_TYPE gm_search_type; 523 524 // During global motion estimation, prune remaining reference frames in a 525 // given direction(past/future), if the evaluated ref_frame in that direction 526 // yields gm_type as INVALID/TRANSLATION/IDENTITY 527 int prune_ref_frame_for_gm_search; 528 529 // When the current GM type is set to ZEROMV, prune ZEROMV if its performance 530 // is worse than NEWMV under SSE metric. 531 // 0 : no pruning 532 // 1 : conservative pruning 533 // 2 : aggressive pruning 534 int prune_zero_mv_with_sse; 535 536 // Disable global motion estimation based on stats of previous frames in the 537 // GF group 538 int disable_gm_search_based_on_stats; 539 } GLOBAL_MOTION_SPEED_FEATURES; 540 541 typedef struct PARTITION_SPEED_FEATURES { 542 PARTITION_SEARCH_TYPE partition_search_type; 543 544 // Used if partition_search_type = FIXED_PARTITION 545 BLOCK_SIZE fixed_partition_size; 546 547 // Prune extended partition types search 548 // Can take values 0 - 2, 0 referring to no pruning, and 1 - 2 increasing 549 // aggressiveness of pruning in order. 550 int prune_ext_partition_types_search_level; 551 552 // Prune part4 based on block size 553 int prune_part4_search; 554 555 // Use a ML model to prune rectangular, ab and 4-way horz 556 // and vert partitions 557 int ml_prune_partition; 558 559 // Use a ML model to adaptively terminate partition search after trying 560 // PARTITION_SPLIT. Can take values 0 - 2, 0 meaning not being enabled, and 561 // 1 - 2 increasing aggressiveness in order. 562 int ml_early_term_after_part_split_level; 563 564 // Skip rectangular partition test when partition type none gives better 565 // rd than partition type split. Can take values 0 - 2, 0 referring to no 566 // skipping, and 1 - 2 increasing aggressiveness of skipping in order. 567 int less_rectangular_check_level; 568 569 // Use square partition only beyond this block size. 570 BLOCK_SIZE use_square_partition_only_threshold; 571 572 // Sets max square partition levels for this superblock based on 573 // motion vector and prediction error distribution produced from 16x16 574 // simple motion search 575 MAX_PART_PRED_MODE auto_max_partition_based_on_simple_motion; 576 577 // Min and max square partition size we enable (block_size) as per auto 578 // min max, but also used by adjust partitioning, and pick_partitioning. 579 BLOCK_SIZE default_min_partition_size; 580 BLOCK_SIZE default_max_partition_size; 581 582 // Sets level of adjustment of variance-based partitioning during 583 // rd_use_partition 0 - no partition adjustment, 1 - try to merge partitions 584 // for small blocks and high QP, 2 - try to merge partitions, 3 - try to merge 585 // and split leaf partitions and 0 - 3 decreasing aggressiveness in order. 586 int adjust_var_based_rd_partitioning; 587 588 // Partition search early breakout thresholds. 589 int64_t partition_search_breakout_dist_thr; 590 int partition_search_breakout_rate_thr; 591 592 // Thresholds for ML based partition search breakout. 593 int ml_partition_search_breakout_thresh[PARTITION_BLOCK_SIZES]; 594 595 // Aggressiveness levels for pruning split and rectangular partitions based on 596 // simple_motion_search. SIMPLE_AGG_LVL0 to SIMPLE_AGG_LVL3 correspond to 597 // simple motion search based pruning. QIDX_BASED_AGG_LVL1 corresponds to 598 // qindex based and simple motion search based pruning. 599 int simple_motion_search_prune_agg; 600 601 // Perform simple_motion_search on each possible subblock and use it to prune 602 // PARTITION_HORZ and PARTITION_VERT. 603 int simple_motion_search_prune_rect; 604 605 // Perform simple motion search before none_partition to decide if we 606 // want to remove all partitions other than PARTITION_SPLIT. If set to 0, this 607 // model is disabled. If set to 1, the model attempts to perform 608 // PARTITION_SPLIT only. If set to 2, the model also attempts to prune 609 // PARTITION_SPLIT. 610 int simple_motion_search_split; 611 612 // Use features from simple_motion_search to terminate prediction block 613 // partition after PARTITION_NONE 614 int simple_motion_search_early_term_none; 615 616 // Controls whether to reduce the number of motion search steps. If this is 0, 617 // then simple_motion_search has the same number of steps as 618 // single_motion_search (assuming no other speed features). Otherwise, reduce 619 // the number of steps by the value contained in this variable. 620 int simple_motion_search_reduce_search_steps; 621 622 // This variable controls the maximum block size where intra blocks can be 623 // used in inter frames. 624 // TODO(aconverse): Fold this into one of the other many mode skips 625 BLOCK_SIZE max_intra_bsize; 626 627 // Use CNN with luma pixels on source frame on each of the 64x64 subblock to 628 // perform partition pruning in intra frames. 629 // 0: No Pruning 630 // 1: Prune split and rectangular partitions only 631 // 2: Prune none, split and rectangular partitions 632 int intra_cnn_based_part_prune_level; 633 634 // Disable extended partition search for lower block sizes. 635 int ext_partition_eval_thresh; 636 637 // Disable rectangular partitions for larger block sizes. 638 int rect_partition_eval_thresh; 639 640 // prune extended partition search 641 // 0 : no pruning 642 // 1 : prune 1:4 partition search using winner info from split partitions 643 // 2 : prune 1:4 and AB partition search using split and HORZ/VERT info 644 int prune_ext_part_using_split_info; 645 646 // Prunt rectangular, AB and 4-way partition based on q index and block size 647 // 0 : no pruning 648 // 1 : prune sub_8x8 at very low quantizers 649 // 2 : prune all block size based on qindex 650 int prune_rectangular_split_based_on_qidx; 651 652 // Terminate partition search for child partition, 653 // when NONE and SPLIT partition rd_costs are INT64_MAX. 654 int early_term_after_none_split; 655 656 // Level used to adjust threshold for av1_ml_predict_breakout(). At lower 657 // levels, more conservative threshold is used, and value of 0 indicates 658 // av1_ml_predict_breakout() is disabled. Value of 3 corresponds to default 659 // case with no adjustment to lbd thresholds. 660 int ml_predict_breakout_level; 661 662 // Prune sub_8x8 (BLOCK_4X4, BLOCK_4X8 and BLOCK_8X4) partitions. 663 // 0 : no pruning 664 // 1 : pruning based on neighbour block information 665 // 2 : prune always 666 int prune_sub_8x8_partition_level; 667 668 // Prune rectangular split based on simple motion search split/no_split score. 669 // 0: disable pruning, 1: enable pruning 670 int simple_motion_search_rect_split; 671 672 // The current encoder adopts a DFS search for block partitions. 673 // Therefore the mode selection and associated rdcost is ready for smaller 674 // blocks before the mode selection for some partition types. 675 // AB partition could use previous rd information and skip mode search. 676 // An example is: 677 // 678 // current block 679 // +---+---+ 680 // | | 681 // + + 682 // | | 683 // +-------+ 684 // 685 // SPLIT partition has been searched first before trying HORZ_A 686 // +---+---+ 687 // | R | R | 688 // +---+---+ 689 // | R | R | 690 // +---+---+ 691 // 692 // HORZ_A 693 // +---+---+ 694 // | | | 695 // +---+---+ 696 // | | 697 // +-------+ 698 // 699 // With this speed feature, the top two sub blocks can directly use rdcost 700 // searched in split partition, and the mode info is also copied from 701 // saved info. Similarly, the bottom rectangular block can also use 702 // the available information from previous rectangular search. 703 int reuse_prev_rd_results_for_part_ab; 704 705 // Reuse the best prediction modes found in PARTITION_SPLIT and PARTITION_RECT 706 // when encoding PARTITION_AB. 707 int reuse_best_prediction_for_part_ab; 708 709 // The current partition search records the best rdcost so far and uses it 710 // in mode search and transform search to early skip when some criteria is 711 // met. For example, when the current rdcost is larger than the best rdcost, 712 // or the model rdcost is larger than the best rdcost times some thresholds. 713 // By default, this feature is turned on to speed up the encoder partition 714 // search. 715 // If disabling it, at speed 0, 30 frames, we could get 716 // about -0.25% quality gain (psnr, ssim, vmaf), with about 13% slowdown. 717 int use_best_rd_for_pruning; 718 719 // Skip evaluation of non-square partitions based on the corresponding NONE 720 // partition. 721 // 0: no pruning 722 // 1: prune extended partitions if NONE is skippable 723 // 2: on top of 1, prune rectangular partitions if NONE is inter, not a newmv 724 // mode and skippable 725 int skip_non_sq_part_based_on_none; 726 727 // Disables 8x8 and below partitions for low quantizers. 728 int disable_8x8_part_based_on_qidx; 729 } PARTITION_SPEED_FEATURES; 730 731 typedef struct MV_SPEED_FEATURES { 732 // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc). 733 SEARCH_METHODS search_method; 734 735 // Enable the use of faster, less accurate mv search method 736 // 0: disable, 1: if bsize >= BLOCK_32X32, 2: based on bsize, SAD and qp 737 // TODO(chiyotsai@google.com): Take the clip's resolution and mv activity into 738 // account. 739 int use_bsize_dependent_search_method; 740 741 // If this is set to 1, we limit the motion search range to 2 times the 742 // largest motion vector found in the last frame. 743 int auto_mv_step_size; 744 745 // Subpel_search_method can only be subpel_tree which does a subpixel 746 // logarithmic search that keeps stepping at 1/2 pixel units until 747 // you stop getting a gain, and then goes on to 1/4 and repeats 748 // the same process. Along the way it skips many diagonals. 749 SUBPEL_SEARCH_METHODS subpel_search_method; 750 751 // Maximum number of steps in logarithmic subpel search before giving up. 752 int subpel_iters_per_step; 753 754 // When to stop subpel search. 755 SUBPEL_FORCE_STOP subpel_force_stop; 756 757 // When to stop subpel search in simple motion search. 758 SUBPEL_FORCE_STOP simple_motion_subpel_force_stop; 759 760 // If true, sub-pixel search uses the exact convolve function used for final 761 // encoding and decoding; otherwise, it uses bilinear interpolation. 762 SUBPEL_SEARCH_TYPE use_accurate_subpel_search; 763 764 // Threshold for allowing exhaustive motion search. 765 int exhaustive_searches_thresh; 766 767 // Pattern to be used for any exhaustive mesh searches (except intraBC ME). 768 MESH_PATTERN mesh_patterns[MAX_MESH_STEP]; 769 770 // Pattern to be used for exhaustive mesh searches of intraBC ME. 771 MESH_PATTERN intrabc_mesh_patterns[MAX_MESH_STEP]; 772 773 // Reduce single motion search range based on MV result of prior ref_mv_idx. 774 int reduce_search_range; 775 776 // Prune mesh search. 777 PRUNE_MESH_SEARCH_LEVEL prune_mesh_search; 778 779 // Use the rd cost around the best FULLPEL_MV to speed up subpel search 780 int use_fullpel_costlist; 781 782 // Set the full pixel search level of obmc 783 // 0: obmc_full_pixel_diamond 784 // 1: obmc_refining_search_sad (faster) 785 int obmc_full_pixel_search_level; 786 787 // Accurate full pixel motion search based on TPL stats. 788 int full_pixel_search_level; 789 790 // Whether to downsample the rows in sad calculation during motion search. 791 // This is only active when there are at least 16 rows. 792 int use_downsampled_sad; 793 794 // Enable/disable extensive joint motion search. 795 int disable_extensive_joint_motion_search; 796 797 // Enable second best mv check in joint mv search. 798 // 0: allow second MV (use rd cost as the metric) 799 // 1: use var as the metric 800 // 2: disable second MV 801 int disable_second_mv; 802 803 // Skips full pixel search based on start mv of prior ref_mv_idx. 804 int skip_fullpel_search_using_startmv; 805 } MV_SPEED_FEATURES; 806 807 typedef struct INTER_MODE_SPEED_FEATURES { 808 // 2-pass inter mode model estimation where the preliminary pass skips 809 // transform search and uses a model to estimate rd, while the final pass 810 // computes the full transform search. Two types of models are supported: 811 // 0: not used 812 // 1: used with online dynamic rd model 813 // 2: used with static rd model 814 int inter_mode_rd_model_estimation; 815 816 // Bypass transform search based on skip rd 817 int txfm_rd_gate_level; 818 819 // Limit the inter mode tested in the RD loop 820 int reduce_inter_modes; 821 822 // This variable is used to cap the maximum number of times we skip testing a 823 // mode to be evaluated. A high value means we will be faster. 824 int adaptive_rd_thresh; 825 826 // Aggressively prune inter modes when best mode is skippable. 827 int prune_inter_modes_if_skippable; 828 829 // Drop less likely to be picked reference frames in the RD search. 830 // Has seven levels for now: 0, 1, 2, 3, 4, 5 and 6 where higher levels prune 831 // more aggressively than lower ones. (0 means no pruning). 832 int selective_ref_frame; 833 834 // Prune reference frames for rectangular partitions. 835 // 0 implies no pruning 836 // 1 implies prune for extended partition 837 // 2 implies prune horiz, vert and extended partition 838 int prune_ref_frame_for_rect_partitions; 839 840 // Prune inter modes w.r.t past reference frames 841 // 0 no pruning 842 // 1 prune inter modes w.r.t ALTREF2 and ALTREF reference frames 843 // 2 prune inter modes w.r.t BWDREF, ALTREF2 and ALTREF reference frames 844 int alt_ref_search_fp; 845 846 // Prune compound reference frames 847 // 0 no pruning 848 // 1 prune compound references which do not satisfy the two conditions: 849 // a) The references are at a nearest distance from the current frame in 850 // both past and future direction. 851 // b) The references have minimum pred_mv_sad in both past and future 852 // direction. 853 // 2 prune compound references except the one with nearest distance from the 854 // current frame in both past and future direction. 855 int prune_comp_ref_frames; 856 857 // Skip the current ref_mv in NEW_MV mode based on mv, rate cost, etc. 858 // This speed feature equaling 0 means no skipping. 859 // If the speed feature equals 1 or 2, skip the current ref_mv in NEW_MV mode 860 // if we have already encountered ref_mv in the drl such that: 861 // 1. The other drl has the same mv during the SIMPLE_TRANSLATION search 862 // process as the current mv. 863 // 2. The rate needed to encode the current mv is larger than that for the 864 // other ref_mv. 865 // The speed feature equaling 1 means using subpel mv in the comparison. 866 // The speed feature equaling 2 means using fullpel mv in the comparison. 867 // If the speed feature >= 3, skip the current ref_mv in NEW_MV mode based on 868 // known full_mv bestsme and drl cost. 869 int skip_newmv_in_drl; 870 871 // This speed feature checks duplicate ref MVs among NEARESTMV, NEARMV, 872 // GLOBALMV and skips NEARMV or GLOBALMV (in order) if a duplicate is found 873 // TODO(any): Instead of skipping repeated ref mv, use the recalculated 874 // rd-cost based on mode rate and skip the mode evaluation 875 int skip_repeated_ref_mv; 876 877 // Flag used to control the ref_best_rd based gating for chroma 878 int perform_best_rd_based_gating_for_chroma; 879 880 // Reuse the inter_intra_mode search result from NEARESTMV mode to other 881 // single ref modes 882 int reuse_inter_intra_mode; 883 884 // prune wedge and compound segment approximate rd evaluation based on 885 // compound average modeled rd 886 int prune_comp_type_by_model_rd; 887 888 // prune wedge and compound segment approximate rd evaluation based on 889 // compound average rd/ref_best_rd 890 int prune_comp_type_by_comp_avg; 891 892 // Skip some ref frames in compound motion search by single motion search 893 // result. Has three levels for now: 0 referring to no skipping, and 1 - 3 894 // increasing aggressiveness of skipping in order. 895 // Note: The search order might affect the result. It assumes that the single 896 // reference modes are searched before compound modes. It is better to search 897 // same single inter mode as a group. 898 int prune_comp_search_by_single_result; 899 900 // Instead of performing a full MV search, do a simple translation first 901 // and only perform a full MV search on the motion vectors that performed 902 // well. 903 int prune_mode_search_simple_translation; 904 905 // Only search compound modes with at least one "good" reference frame. 906 // A reference frame is good if, after looking at its performance among 907 // the single reference modes, it is one of the two best performers. 908 int prune_compound_using_single_ref; 909 910 // Skip extended compound mode (NEAREST_NEWMV, NEW_NEARESTMV, NEAR_NEWMV, 911 // NEW_NEARMV) using ref frames of above and left neighbor 912 // blocks. 913 // 0 : no pruning 914 // 1 : prune ext compound modes using neighbor blocks (less aggressiveness) 915 // 2 : prune ext compound modes using neighbor blocks (high aggressiveness) 916 // 3 : prune ext compound modes unconditionally (highest aggressiveness) 917 int prune_ext_comp_using_neighbors; 918 919 // Skip NEW_NEARMV and NEAR_NEWMV extended compound modes 920 int skip_ext_comp_nearmv_mode; 921 922 // Skip extended compound mode when ref frame corresponding to NEWMV does not 923 // have NEWMV as single mode winner. 924 // 0 : no pruning 925 // 1 : prune extended compound mode (less aggressiveness) 926 // 2 : prune extended compound mode (high aggressiveness) 927 int prune_comp_using_best_single_mode_ref; 928 929 // Skip NEARESTMV and NEARMV using weight computed in ref mv list population 930 // This speed feature sometimes leads to severe visual artifacts for 931 // the overlay frame. It makes inter RD mode search skip NEARESTMV 932 // and NEARMV, and no valid inter mode is evaluated when the NEWMV mode 933 // is also early terminated due to the constraint that it does not handle 934 // zero mv difference. In this cases, intra modes will be chosen, leading 935 // to bad prediction and flickering artifacts. 936 // Turn off this feature for now. Be careful to check visual quality if 937 // anyone is going to turn it on. 938 int prune_nearest_near_mv_using_refmv_weight; 939 940 // Based on previous ref_mv_idx search result, prune the following search. 941 int prune_ref_mv_idx_search; 942 943 // Disable one sided compound modes. 944 int disable_onesided_comp; 945 946 // Prune obmc search using previous frame stats. 947 // INT_MAX : disable obmc search 948 int prune_obmc_prob_thresh; 949 950 // Prune warped motion search using previous frame stats. 951 int prune_warped_prob_thresh; 952 953 // Variance threshold to enable/disable Interintra wedge search 954 unsigned int disable_interintra_wedge_var_thresh; 955 956 // Variance threshold to enable/disable Interinter wedge search 957 unsigned int disable_interinter_wedge_var_thresh; 958 959 // De-couple wedge and mode search during interintra RDO. 960 int fast_interintra_wedge_search; 961 962 // Whether fast wedge sign estimate is used 963 int fast_wedge_sign_estimate; 964 965 // Enable/disable ME for interinter wedge search. 966 int disable_interinter_wedge_newmv_search; 967 968 // Decide when and how to use joint_comp. 969 DIST_WTD_COMP_FLAG use_dist_wtd_comp_flag; 970 971 // Clip the frequency of updating the mv cost. 972 INTERNAL_COST_UPDATE_TYPE mv_cost_upd_level; 973 974 // Clip the frequency of updating the coeff cost. 975 INTERNAL_COST_UPDATE_TYPE coeff_cost_upd_level; 976 977 // Clip the frequency of updating the mode cost. 978 INTERNAL_COST_UPDATE_TYPE mode_cost_upd_level; 979 980 // Prune inter modes based on tpl stats 981 // 0 : no pruning 982 // 1 - 3 indicate increasing aggressiveness in order. 983 int prune_inter_modes_based_on_tpl; 984 985 // Skip NEARMV and NEAR_NEARMV modes using ref frames of above and left 986 // neighbor blocks and qindex. 987 PRUNE_NEARMV_LEVEL prune_nearmv_using_neighbors; 988 989 // Model based breakout after interpolation filter search 990 // 0: no breakout 991 // 1: use model based rd breakout 992 int model_based_post_interp_filter_breakout; 993 994 // Reuse compound type rd decision when exact match is found 995 // 0: No reuse 996 // 1: Reuse the compound type decision 997 int reuse_compound_type_decision; 998 999 // Enable/disable masked compound. 1000 int disable_masked_comp; 1001 1002 // Enable/disable the fast compound mode search. 1003 int enable_fast_compound_mode_search; 1004 1005 // Reuse masked compound type search results 1006 int reuse_mask_search_results; 1007 1008 // Enable/disable fast search for wedge masks 1009 int enable_fast_wedge_mask_search; 1010 1011 // Early breakout from transform search of inter modes 1012 int inter_mode_txfm_breakout; 1013 1014 // Limit number of inter modes for txfm search if a newmv mode gets 1015 // evaluated among the top modes. 1016 // 0: no pruning 1017 // 1 to 3 indicate increasing order of aggressiveness 1018 int limit_inter_mode_cands; 1019 1020 // Cap the no. of txfm searches for a given prediction mode. 1021 // 0: no cap, 1: cap beyond first 4 searches, 2: cap beyond first 3 searches. 1022 int limit_txfm_eval_per_mode; 1023 1024 // Prune warped motion search based on block size. 1025 int extra_prune_warped; 1026 1027 // Do not search compound modes for ARF. 1028 // The intuition is that ARF is predicted by frames far away from it, 1029 // whose temporal correlations with the ARF are likely low. 1030 // It is therefore likely that compound modes do not work as well for ARF 1031 // as other inter frames. 1032 // Speed/quality impact: 1033 // Speed 1: 12% faster, 0.1% psnr loss. 1034 // Speed 2: 2% faster, 0.05% psnr loss. 1035 // No change for speed 3 and up, because |disable_onesided_comp| is true. 1036 int skip_arf_compound; 1037 } INTER_MODE_SPEED_FEATURES; 1038 1039 typedef struct INTERP_FILTER_SPEED_FEATURES { 1040 // Do limited interpolation filter search for dual filters, since best choice 1041 // usually includes EIGHTTAP_REGULAR. 1042 int use_fast_interpolation_filter_search; 1043 1044 // Disable dual filter 1045 int disable_dual_filter; 1046 1047 // Save results of av1_interpolation_filter_search for a block 1048 // Check mv and ref_frames before search, if they are very close with previous 1049 // saved results, filter search can be skipped. 1050 int use_interp_filter; 1051 1052 // skip sharp_filter evaluation based on regular and smooth filter rd for 1053 // dual_filter=0 case 1054 int skip_sharp_interp_filter_search; 1055 1056 // skip interpolation filter search for a block in chessboard pattern 1057 int cb_pred_filter_search; 1058 1059 // adaptive interp_filter search to allow skip of certain filter types. 1060 int adaptive_interp_filter_search; 1061 } INTERP_FILTER_SPEED_FEATURES; 1062 1063 typedef struct INTRA_MODE_SPEED_FEATURES { 1064 // These bit masks allow you to enable or disable intra modes for each 1065 // transform size separately. 1066 int intra_y_mode_mask[TX_SIZES]; 1067 int intra_uv_mode_mask[TX_SIZES]; 1068 1069 // flag to allow skipping intra mode for inter frame prediction 1070 int skip_intra_in_interframe; 1071 1072 // Prune intra mode candidates based on source block histogram of gradient. 1073 // Applies to luma plane only. 1074 // Feasible values are 0..4. The feature is disabled for 0. An increasing 1075 // value indicates more aggressive pruning threshold. 1076 int intra_pruning_with_hog; 1077 1078 // Prune intra mode candidates based on source block histogram of gradient. 1079 // Applies to chroma plane only. 1080 // Feasible values are 0..4. The feature is disabled for 0. An increasing 1081 // value indicates more aggressive pruning threshold. 1082 int chroma_intra_pruning_with_hog; 1083 1084 // Enable/disable smooth intra modes. 1085 int disable_smooth_intra; 1086 1087 // Prune UV_SMOOTH_PRED mode for chroma based on chroma source variance. 1088 // false : No pruning 1089 // true : Prune UV_SMOOTH_PRED mode based on chroma source variance 1090 // 1091 // For allintra encode, this speed feature reduces instruction count 1092 // by 1.90%, 2.21% and 1.97% for speed 6, 7 and 8 with coding performance 1093 // change less than 0.04%. For AVIF image encode, this speed feature reduces 1094 // encode time by 1.56%, 2.14% and 0.90% for speed 6, 7 and 8 on a typical 1095 // image dataset with coding performance change less than 0.05%. 1096 bool prune_smooth_intra_mode_for_chroma; 1097 1098 // Prune filter intra modes in intra frames. 1099 // 0 : No pruning 1100 // 1 : Evaluate applicable filter intra modes based on best intra mode so far 1101 // 2 : Do not evaluate filter intra modes 1102 int prune_filter_intra_level; 1103 1104 // prune palette search 1105 // 0: No pruning 1106 // 1: Perform coarse search to prune the palette colors. For winner colors, 1107 // neighbors are also evaluated using a finer search. 1108 // 2: Perform 2 way palette search from max colors to min colors (and min 1109 // colors to remaining colors) and terminate the search if current number of 1110 // palette colors is not the winner. 1111 int prune_palette_search_level; 1112 1113 // Terminate early in luma palette_size search. Speed feature values indicate 1114 // increasing level of pruning. 1115 // 0: No early termination 1116 // 1: Terminate early for higher luma palette_size, if header rd cost of lower 1117 // palette_size is more than 2 * best_rd. This level of pruning is more 1118 // conservative when compared to sf level 2 as the cases which will get pruned 1119 // with sf level 1 is a subset of the cases which will get pruned with sf 1120 // level 2. 1121 // 2: Terminate early for higher luma palette_size, if header rd cost of lower 1122 // palette_size is more than best_rd. 1123 // For allintra encode, this sf reduces instruction count by 2.49%, 1.07%, 1124 // 2.76%, 2.30%, 1.84%, 2.69%, 2.04%, 2.05% and 1.44% for speed 0, 1, 2, 3, 4, 1125 // 5, 6, 7 and 8 on screen content set with coding performance change less 1126 // than 0.01% for speed <= 2 and less than 0.03% for speed >= 3. For AVIF 1127 // image encode, this sf reduces instruction count by 1.94%, 1.13%, 1.29%, 1128 // 0.93%, 0.89%, 1.03%, 1.07%, 1.20% and 0.18% for speed 0, 1, 2, 3, 4, 5, 6, 1129 // 7 and 8 on a typical image dataset with coding performance change less than 1130 // 0.01%. 1131 int prune_luma_palette_size_search_level; 1132 1133 // Prune chroma intra modes based on luma intra mode winner. 1134 // 0: No pruning 1135 // 1: Prune chroma intra modes other than UV_DC_PRED, UV_SMOOTH_PRED, 1136 // UV_CFL_PRED and the mode that corresponds to luma intra mode winner. 1137 int prune_chroma_modes_using_luma_winner; 1138 1139 // Clip the frequency of updating the mv cost for intrabc. 1140 INTERNAL_COST_UPDATE_TYPE dv_cost_upd_level; 1141 1142 // We use DCT_DCT transform followed by computing SATD (Sum of Absolute 1143 // Transformed Differences) as an estimation of RD score to quickly find the 1144 // best possible Chroma from Luma (CFL) parameter. Then we do a full RD search 1145 // near the best possible parameter. The search range is set here. 1146 // The range of cfl_searh_range should be [1, 33], and the following are the 1147 // recommended values. 1148 // 1: Fastest mode. 1149 // 3: Default mode that provides good speedup without losing compression 1150 // performance at speed 0. 1151 // 33: Exhaustive rd search (33 == CFL_MAGS_SIZE). This mode should only 1152 // be used for debugging purpose. 1153 int cfl_search_range; 1154 1155 // TOP_INTRA_MODEL_COUNT is 4 that is the number of top model rd to store in 1156 // intra mode decision. Here, add a speed feature to reduce this number for 1157 // higher speeds. 1158 int top_intra_model_count_allowed; 1159 1160 // Adapt top_intra_model_count_allowed locally to prune luma intra modes using 1161 // neighbor block and quantizer information. 1162 int adapt_top_model_rd_count_using_neighbors; 1163 1164 // Prune the evaluation of odd delta angles of directional luma intra modes by 1165 // using the rdcosts of neighbouring delta angles. 1166 // For allintra encode, this speed feature reduces instruction count 1167 // by 4.461%, 3.699% and 3.536% for speed 6, 7 and 8 on a typical video 1168 // dataset with coding performance change less than 0.26%. For AVIF image 1169 // encode, this speed feature reduces encode time by 2.849%, 2.471%, 1170 // and 2.051% for speed 6, 7 and 8 on a typical image dataset with coding 1171 // performance change less than 0.27%. 1172 int prune_luma_odd_delta_angles_in_intra; 1173 1174 // Terminate early in chroma palette_size search. 1175 // 0: No early termination 1176 // 1: Terminate early for higher palette_size, if header rd cost of lower 1177 // palette_size is more than best_rd. 1178 // For allintra encode, this sf reduces instruction count by 0.45%, 1179 // 0.62%, 1.73%, 2.50%, 2.89%, 3.09% and 3.86% for speed 0 to 6 on screen 1180 // content set with coding performance change less than 0.01%. 1181 // For AVIF image encode, this sf reduces instruction count by 0.45%, 0.81%, 1182 // 0.85%, 1.05%, 1.45%, 1.66% and 1.95% for speed 0 to 6 on a typical image 1183 // dataset with no quality drop. 1184 int early_term_chroma_palette_size_search; 1185 1186 // Skips the evaluation of filter intra modes in inter frames if rd evaluation 1187 // of luma intra dc mode results in invalid rd stats. 1188 int skip_filter_intra_in_inter_frames; 1189 } INTRA_MODE_SPEED_FEATURES; 1190 1191 typedef struct TX_SPEED_FEATURES { 1192 // Init search depth for square and rectangular transform partitions. 1193 // Values: 1194 // 0 - search full tree, 1: search 1 level, 2: search the highest level only 1195 int inter_tx_size_search_init_depth_sqr; 1196 int inter_tx_size_search_init_depth_rect; 1197 int intra_tx_size_search_init_depth_sqr; 1198 int intra_tx_size_search_init_depth_rect; 1199 1200 // If any dimension of a coding block size above 64, always search the 1201 // largest transform only, since the largest transform block size is 64x64. 1202 int tx_size_search_lgr_block; 1203 1204 TX_TYPE_SEARCH tx_type_search; 1205 1206 // Skip split transform block partition when the collocated bigger block 1207 // is selected as all zero coefficients. 1208 int txb_split_cap; 1209 1210 // Shortcut the transform block partition and type search when the target 1211 // rdcost is relatively lower. 1212 // Values are 0 (not used) , or 1 - 2 with progressively increasing 1213 // aggressiveness 1214 int adaptive_txb_search_level; 1215 1216 // Prune level for tx_size_type search for inter based on rd model 1217 // 0: no pruning 1218 // 1-2: progressively increasing aggressiveness of pruning 1219 int model_based_prune_tx_search_level; 1220 1221 // Refine TX type after fast TX search. 1222 int refine_fast_tx_search_results; 1223 1224 // Prune transform split/no_split eval based on residual properties. A value 1225 // of 0 indicates no pruning, and the aggressiveness of pruning progressively 1226 // increases from levels 1 to 3. 1227 int prune_tx_size_level; 1228 1229 // Prune the evaluation of transform depths as decided by the NN model. 1230 // false: No pruning. 1231 // true : Avoid the evaluation of specific transform depths using NN model. 1232 // 1233 // For allintra encode, this speed feature reduces instruction count 1234 // by 4.76%, 8.92% and 11.28% for speed 6, 7 and 8 with coding performance 1235 // change less than 0.32%. For AVIF image encode, this speed feature reduces 1236 // encode time by 4.65%, 9.16% and 10.45% for speed 6, 7 and 8 on a typical 1237 // image dataset with coding performance change less than 0.19%. 1238 bool prune_intra_tx_depths_using_nn; 1239 } TX_SPEED_FEATURES; 1240 1241 typedef struct RD_CALC_SPEED_FEATURES { 1242 // Fast approximation of av1_model_rd_from_var_lapndz 1243 int simple_model_rd_from_var; 1244 1245 // Perform faster distortion computation during the R-D evaluation by trying 1246 // to approximate the prediction error with transform coefficients (faster but 1247 // less accurate) rather than computing distortion in the pixel domain (slower 1248 // but more accurate). The following methods are used for distortion 1249 // computation: 1250 // Method 0: Always compute distortion in the pixel domain 1251 // Method 1: Based on block error, try using transform domain distortion for 1252 // tx_type search and compute distortion in pixel domain for final RD_STATS 1253 // Method 2: Based on block error, try to compute distortion in transform 1254 // domain 1255 // Methods 1 and 2 may fallback to computing distortion in the pixel domain in 1256 // case the block error is less than the threshold, which is controlled by the 1257 // speed feature tx_domain_dist_thres_level. 1258 // 1259 // The speed feature tx_domain_dist_level decides which of the above methods 1260 // needs to be used across different mode evaluation stages as described 1261 // below: 1262 // Eval type: Default Mode Winner 1263 // Level 0 : Method 0 Method 2 Method 0 1264 // Level 1 : Method 1 Method 2 Method 0 1265 // Level 2 : Method 2 Method 2 Method 0 1266 // Level 3 : Method 2 Method 2 Method 2 1267 int tx_domain_dist_level; 1268 1269 // Transform domain distortion threshold level 1270 int tx_domain_dist_thres_level; 1271 1272 // Trellis (dynamic programming) optimization of quantized values 1273 TRELLIS_OPT_TYPE optimize_coefficients; 1274 1275 // Use hash table to store macroblock RD search results 1276 // to avoid repeated search on the same residue signal. 1277 int use_mb_rd_hash; 1278 1279 // Flag used to control the extent of coeff R-D optimization 1280 int perform_coeff_opt; 1281 } RD_CALC_SPEED_FEATURES; 1282 1283 typedef struct WINNER_MODE_SPEED_FEATURES { 1284 // Flag used to control the winner mode processing for better R-D optimization 1285 // of quantized coeffs 1286 int enable_winner_mode_for_coeff_opt; 1287 1288 // Flag used to control the winner mode processing for transform size 1289 // search method 1290 int enable_winner_mode_for_tx_size_srch; 1291 1292 // Control transform size search level 1293 // Eval type: Default Mode Winner 1294 // Level 0 : FULL RD LARGEST ALL FULL RD 1295 // Level 1 : FAST RD LARGEST ALL FULL RD 1296 // Level 2 : LARGEST ALL LARGEST ALL FULL RD 1297 // Level 3 : LARGEST ALL LARGEST ALL LARGEST ALL 1298 int tx_size_search_level; 1299 1300 // Flag used to control the winner mode processing for use transform 1301 // domain distortion 1302 int enable_winner_mode_for_use_tx_domain_dist; 1303 1304 // Flag used to enable processing of multiple winner modes 1305 MULTI_WINNER_MODE_TYPE multi_winner_mode_type; 1306 1307 // Motion mode for winner candidates: 1308 // 0: speed feature OFF 1309 // 1 / 2 : Use configured number of winner candidates 1310 int motion_mode_for_winner_cand; 1311 1312 // Controls the prediction of transform skip block or DC only block. 1313 // 1314 // Different speed feature values (0 to 3) decide the aggressiveness of 1315 // prediction (refer to predict_dc_levels[][] in speed_features.c) to be used 1316 // during different mode evaluation stages. 1317 int dc_blk_pred_level; 1318 1319 // If on, disables interpolation filter search in handle_inter_mode loop, and 1320 // performs it during winner mode processing by \ref 1321 // tx_search_best_inter_candidates. 1322 int winner_mode_ifs; 1323 1324 // Controls the disabling of winner mode processing. Speed feature levels 1325 // are ordered in increasing aggressiveness of pruning. The method considered 1326 // for disabling, depends on the sf level value and it is described as below. 1327 // 0: Do not disable 1328 // 1: Disable for blocks with low source variance. 1329 // 2: Disable for blocks which turn out to be transform skip (skipped based on 1330 // eob) during MODE_EVAL stage except NEWMV mode. 1331 // 3: Disable for blocks which turn out to be transform skip during MODE_EVAL 1332 // stage except NEWMV mode. For high quantizers, prune conservatively based on 1333 // transform skip (skipped based on eob) except for NEWMV mode. 1334 // 4: Disable for blocks which turn out to be transform skip during MODE_EVAL 1335 // stage. 1336 int prune_winner_mode_eval_level; 1337 } WINNER_MODE_SPEED_FEATURES; 1338 1339 typedef struct LOOP_FILTER_SPEED_FEATURES { 1340 // This feature controls how the loop filter level is determined. 1341 LPF_PICK_METHOD lpf_pick; 1342 1343 // Skip some final iterations in the determination of the best loop filter 1344 // level. 1345 int use_coarse_filter_level_search; 1346 1347 // Control how the CDEF strength is determined. 1348 CDEF_PICK_METHOD cdef_pick_method; 1349 1350 // Decoder side speed feature to add penalty for use of dual-sgr filters. 1351 // Takes values 0 - 10, 0 indicating no penalty and each additional level 1352 // adding a penalty of 1% 1353 int dual_sgr_penalty_level; 1354 1355 // prune sgr ep using binary search like mechanism 1356 int enable_sgr_ep_pruning; 1357 1358 // Disable loop restoration for Chroma plane 1359 int disable_loop_restoration_chroma; 1360 1361 // Disable loop restoration for luma plane 1362 int disable_loop_restoration_luma; 1363 1364 // Prune RESTORE_WIENER evaluation based on source variance 1365 // 0 : no pruning 1366 // 1 : conservative pruning 1367 // 2 : aggressive pruning 1368 int prune_wiener_based_on_src_var; 1369 1370 // Prune self-guided loop restoration based on wiener search results 1371 // 0 : no pruning 1372 // 1 : pruning based on rdcost ratio of RESTORE_WIENER and RESTORE_NONE 1373 // 2 : pruning based on winner restoration type among RESTORE_WIENER and 1374 // RESTORE_NONE 1375 int prune_sgr_based_on_wiener; 1376 1377 // Reduce the wiener filter win size for luma 1378 int reduce_wiener_window_size; 1379 1380 // Disable loop restoration filter 1381 int disable_lr_filter; 1382 1383 // Whether to downsample the rows in computation of wiener stats. 1384 int use_downsampled_wiener_stats; 1385 } LOOP_FILTER_SPEED_FEATURES; 1386 1387 typedef struct REAL_TIME_SPEED_FEATURES { 1388 // check intra prediction for non-RD mode. 1389 int check_intra_pred_nonrd; 1390 1391 // Skip checking intra prediction. 1392 // 0 - don't skip 1393 // 1 - skip if TX is skipped and best mode is not NEWMV 1394 // 2 - skip if TX is skipped 1395 // Skipping aggressiveness increases from level 1 to 2. 1396 int skip_intra_pred; 1397 1398 // Perform coarse ME before calculating variance in variance-based partition 1399 int estimate_motion_for_var_based_partition; 1400 1401 // For nonrd_use_partition: mode of extra check of leaf partition 1402 // 0 - don't check merge 1403 // 1 - always check merge 1404 // 2 - check merge and prune checking final split 1405 // 3 - check merge and prune checking final split based on bsize and qindex 1406 int nonrd_check_partition_merge_mode; 1407 1408 // For nonrd_use_partition: check of leaf partition extra split 1409 int nonrd_check_partition_split; 1410 1411 // Implements various heuristics to skip searching modes 1412 // The heuristics selected are based on flags 1413 // defined in the MODE_SEARCH_SKIP_HEURISTICS enum 1414 unsigned int mode_search_skip_flags; 1415 1416 // For nonrd: Reduces ref frame search. 1417 // 0 - low level of search prune in non last frames 1418 // 1 - pruned search in non last frames 1419 // 2 - more pruned search in non last frames 1420 int nonrd_prune_ref_frame_search; 1421 1422 // This flag controls the use of non-RD mode decision. 1423 int use_nonrd_pick_mode; 1424 1425 // Use ALTREF frame in non-RD mode decision. 1426 int use_nonrd_altref_frame; 1427 1428 // Use compound reference for non-RD mode. 1429 int use_comp_ref_nonrd; 1430 1431 // Reference frames for compound prediction for nonrd pickmode: 1432 // LAST_GOLDEN (0), LAST_LAST2 (1), or LAST_ALTREF (2). 1433 int ref_frame_comp_nonrd[3]; 1434 1435 // use reduced ref set for real-time mode 1436 int use_real_time_ref_set; 1437 1438 // Skip a number of expensive mode evaluations for blocks with very low 1439 // temporal variance. 1440 int short_circuit_low_temp_var; 1441 1442 // Reuse inter prediction in fast non-rd mode. 1443 int reuse_inter_pred_nonrd; 1444 1445 // Number of best inter modes to search transform. INT_MAX - search all. 1446 int num_inter_modes_for_tx_search; 1447 1448 // Use interpolation filter search in non-RD mode decision. 1449 int use_nonrd_filter_search; 1450 1451 // Use simplified RD model for interpolation search and Intra 1452 int use_simple_rd_model; 1453 1454 // If set forces interpolation filter to EIGHTTAP_REGULAR 1455 int skip_interp_filter_search; 1456 1457 // For nonrd mode: use hybrid intra mode search for intra only frames based on 1458 // block properties. 1459 // 0 : use nonrd pick intra for all blocks 1460 // 1 : use rd for bsize < 16x16, nonrd otherwise 1461 // 2 : use rd for bsize < 16x16 and src var >= 101, nonrd otherwise 1462 int hybrid_intra_pickmode; 1463 1464 // Compute variance/sse on source difference, prior to encoding superblock. 1465 int source_metrics_sb_nonrd; 1466 1467 // Flag to indicate process for handling overshoot on slide/scene change, 1468 // for real-time CBR mode. 1469 OVERSHOOT_DETECTION_CBR overshoot_detection_cbr; 1470 1471 // Check for scene/content change detection on every frame before encoding. 1472 int check_scene_detection; 1473 1474 // For nonrd mode: Prefer larger partition blks in variance based partitioning 1475 // 0: disabled, 1-3: increasing aggressiveness 1476 int prefer_large_partition_blocks; 1477 1478 // uses results of temporal noise estimate 1479 int use_temporal_noise_estimate; 1480 1481 // Parameter indicating initial search window to be used in full-pixel search 1482 // for nonrd_pickmode. Range [0, MAX_MVSEARCH_STEPS - 1]. Lower value 1483 // indicates larger window. If set to 0, step_param is set based on internal 1484 // logic in set_mv_search_params(). 1485 int fullpel_search_step_param; 1486 1487 // Bit mask to enable or disable intra modes for each prediction block size 1488 // separately, for nonrd_pickmode. Currently, the sf is not respected when 1489 // 'force_intra_check' is true in 'estimate_intra_mode()' function. Also, H 1490 // and V pred modes allowed through this sf can be further pruned when 1491 //'prune_hv_pred_modes_using_src_sad' sf is true. 1492 int intra_y_mode_bsize_mask_nrd[BLOCK_SIZES]; 1493 1494 // Prune H and V intra predition modes evalution in inter frame. 1495 // The sf does not have any impact. 1496 // i. when frame_source_sad is 1.1 times greater than avg_source_sad 1497 // ii. when cyclic_refresh_segment_id_boosted is enabled 1498 // iii. when SB level source sad is greater than kMedSad 1499 // iv. when color sensitivity is non zero for both the chroma channels 1500 bool prune_hv_pred_modes_using_src_sad; 1501 1502 // Skips mode checks more aggressively in nonRD mode 1503 int nonrd_aggressive_skip; 1504 1505 // Skip cdef on 64x64 blocks when NEWMV or INTRA is not picked or color 1506 // sensitivity is off. When color sensitivity is on for a superblock, all 1507 // 64x64 blocks within will not skip. 1508 int skip_cdef_sb; 1509 1510 // Forces larger partition blocks in variance based partitioning for intra 1511 // frames 1512 int force_large_partition_blocks_intra; 1513 1514 // Skip evaluation of no split in tx size selection for merge partition 1515 int skip_tx_no_split_var_based_partition; 1516 1517 // Intermediate termination of newMV mode evaluation based on so far best mode 1518 // sse 1519 int skip_newmv_mode_based_on_sse; 1520 1521 // Define gf length multiplier. 1522 // Level 0: use large multiplier, level 1: use medium multiplier. 1523 int gf_length_lvl; 1524 1525 // Prune inter modes with golden frame as reference for NEARMV and NEWMV modes 1526 int prune_inter_modes_with_golden_ref; 1527 1528 // Prune inter modes w.r.t golden or alt-ref frame based on sad 1529 int prune_inter_modes_wrt_gf_arf_based_on_sad; 1530 1531 // Prune inter mode search in rd path based on current block's temporal 1532 // variance wrt LAST reference. 1533 int prune_inter_modes_using_temp_var; 1534 1535 // Reduce MV precision to halfpel for higher int MV value & frame-level motion 1536 // 0: disabled 1537 // 1-2: Reduce precision to halfpel, fullpel based on conservative 1538 // thresholds, aggressiveness increases with increase in level 1539 // 3: Reduce precision to halfpel using more aggressive thresholds 1540 int reduce_mv_pel_precision_highmotion; 1541 1542 // Reduce MV precision for low complexity blocks 1543 // 0: disabled 1544 // 1: Reduce the mv resolution for zero mv if the variance is low 1545 // 2: Switch to halfpel, fullpel based on low block spatial-temporal 1546 // complexity. 1547 int reduce_mv_pel_precision_lowcomplex; 1548 1549 // Prune intra mode evaluation in inter frames based on mv range. 1550 BLOCK_SIZE prune_intra_mode_based_on_mv_range; 1551 // The number of times to left shift the splitting thresholds in variance 1552 // based partitioning. The minimum values should be 7 to avoid left shifting 1553 // by a negative number. 1554 int var_part_split_threshold_shift; 1555 1556 // Qindex based variance partition threshold index, which determines 1557 // the aggressiveness of partition pruning 1558 // 0: disabled for speeds 9,10 1559 // 1,2: (rd-path) lowers qindex thresholds conditionally (for low SAD sb) 1560 // 3,4: (non-rd path) uses pre-tuned qindex thresholds 1561 int var_part_based_on_qidx; 1562 1563 // Enable GF refresh based on Q value. 1564 int gf_refresh_based_on_qp; 1565 1566 // Temporal filtering 1567 // The value can be 1 or 2, which indicates the threshold to use. 1568 int use_rtc_tf; 1569 1570 // Prune the use of the identity transform in nonrd_pickmode, 1571 // used for screen content mode: only for smaller blocks 1572 // and higher spatial variance, and when skip_txfm is not 1573 // already set. 1574 int prune_idtx_nonrd; 1575 1576 // Skip loopfilter, for static content after slide change 1577 // or key frame, once quality has ramped up. 1578 int skip_lf_screen; 1579 1580 // For nonrd: early exit out of variance partition that sets the 1581 // block size to superblock size, and sets mode to zeromv-last skip. 1582 // 0: disabled 1583 // 1: zeromv-skip is enabled at SB level only 1584 // 2: zeromv-skip is enabled at SB level and coding block level 1585 int part_early_exit_zeromv; 1586 1587 // Early terminate inter mode search based on sse in non-rd path. 1588 INTER_SEARCH_EARLY_TERM_IDX sse_early_term_inter_search; 1589 1590 // SAD based adaptive altref selection 1591 int sad_based_adp_altref_lag; 1592 1593 // Enable/disable partition direct merging. 1594 int partition_direct_merging; 1595 1596 // Level of aggressiveness for obtaining tx size based on qstep 1597 int tx_size_level_based_on_qstep; 1598 1599 // Avoid the partitioning of a 16x16 block in variance based partitioning 1600 // (VBP) by making use of minimum and maximum sub-block variances. 1601 // For allintra encode, this speed feature reduces instruction count by 5.39% 1602 // for speed 9 on a typical video dataset with coding performance gain 1603 // of 1.44%. 1604 // For AVIF image encode, this speed feature reduces encode time 1605 // by 8.44% for speed 9 on a typical image dataset with coding performance 1606 // gain of 0.78%. 1607 bool vbp_prune_16x16_split_using_min_max_sub_blk_var; 1608 1609 // A qindex threshold that determines whether to use qindex based CDEF filter 1610 // strength estimation for screen content types. The strength estimation model 1611 // used for screen contents prefers to allow cdef filtering for more frames. 1612 // This sf is used to limit the frames which go through cdef filtering and 1613 // following explains the setting of the same. 1614 // MAXQ (255): This disables the usage of this sf. Here, frame does not use a 1615 // screen content model thus reduces the number of frames that go through cdef 1616 // filtering. 1617 // MINQ (0): Frames always use screen content model thus increasing the number 1618 // of frames that go through cdef filtering. 1619 // This speed feature has a substantial gain on coding metrics, with moderate 1620 // increase encoding time. Select threshold based on speed vs quality 1621 // trade-off. 1622 int screen_content_cdef_filter_qindex_thresh; 1623 1624 // Prune compound mode if its variance is higher than the variance of single 1625 // modes. 1626 bool prune_compoundmode_with_singlecompound_var; 1627 1628 // Allow mode cost update at frame level every couple frames. This 1629 // overrides the command line setting --mode-cost-upd-freq=3 (never update 1630 // except on key frame and first delta). 1631 bool frame_level_mode_cost_update; 1632 1633 // Prune H_PRED during intra mode evaluation in the nonrd path based on best 1634 // mode so far. 1635 // 1636 // For allintra encode, this speed feature reduces instruction count by 1.10% 1637 // for speed 9 with coding performance change less than 0.04%. 1638 // For AVIF image encode, this speed feature reduces encode time by 1.03% for 1639 // speed 9 on a typical image dataset with coding performance change less than 1640 // 0.08%. 1641 bool prune_h_pred_using_best_mode_so_far; 1642 1643 // If compound is enabled, and the current block size is \geq BLOCK_16X16, 1644 // limit the compound modes to GLOBAL_GLOBALMV. This does not apply to the 1645 // base layer of svc. 1646 bool check_only_zero_zeromv_on_large_blocks; 1647 1648 // Allow for disabling cdf update for non reference frames in svc mode. 1649 bool disable_cdf_update_non_reference_frame; 1650 1651 // Prune compound modes if the single modes variances do not perform well. 1652 bool prune_compoundmode_with_singlemode_var; 1653 1654 // Skip searching all compound mode if the variance of single_mode residue is 1655 // sufficiently low. 1656 bool skip_compound_based_on_var; 1657 1658 // Sets force_zeromv_skip based on the source sad available. Aggressiveness 1659 // increases with increase in the level set for speed feature. 1660 // 0: No setting 1661 // 1: If source sad is kZeroSad 1662 // 2: If source sad <= kVeryLowSad 1663 int set_zeromv_skip_based_on_source_sad; 1664 1665 // Downgrades the block-level subpel motion search to 1666 // av1_find_best_sub_pixel_tree_pruned_more for higher QP and when fullpel 1667 // search performed well, zeromv has low sad or low source_var 1668 bool use_adaptive_subpel_search; 1669 1670 // A flag used in RTC case to control frame_refs_short_signaling. Note that 1671 // the final decision is made in check_frame_refs_short_signaling(). The flag 1672 // can only be turned on when res < 360p and speed >= 9, in which case only 1673 // LAST and GOLDEN ref frames are used now. 1674 bool enable_ref_short_signaling; 1675 1676 // A flag that controls if we check or bypass GLOBALMV in rtc single ref frame 1677 // case. 1678 bool check_globalmv_on_single_ref; 1679 } REAL_TIME_SPEED_FEATURES; 1680 1681 /*!\endcond */ 1682 1683 /*! 1684 * \brief Top level speed vs quality trade off data struture. 1685 */ 1686 typedef struct SPEED_FEATURES { 1687 /*! 1688 * Sequence/frame level speed features: 1689 */ 1690 HIGH_LEVEL_SPEED_FEATURES hl_sf; 1691 1692 /*! 1693 * Speed features for the first pass. 1694 */ 1695 FIRST_PASS_SPEED_FEATURES fp_sf; 1696 1697 /*! 1698 * Speed features related to how tpl's searches are done. 1699 */ 1700 TPL_SPEED_FEATURES tpl_sf; 1701 1702 /*! 1703 * Global motion speed features: 1704 */ 1705 GLOBAL_MOTION_SPEED_FEATURES gm_sf; 1706 1707 /*! 1708 * Partition search speed features: 1709 */ 1710 PARTITION_SPEED_FEATURES part_sf; 1711 1712 /*! 1713 * Motion search speed features: 1714 */ 1715 MV_SPEED_FEATURES mv_sf; 1716 1717 /*! 1718 * Inter mode search speed features: 1719 */ 1720 INTER_MODE_SPEED_FEATURES inter_sf; 1721 1722 /*! 1723 * Interpolation filter search speed features: 1724 */ 1725 INTERP_FILTER_SPEED_FEATURES interp_sf; 1726 1727 /*! 1728 * Intra mode search speed features: 1729 */ 1730 INTRA_MODE_SPEED_FEATURES intra_sf; 1731 1732 /*! 1733 * Transform size/type search speed features: 1734 */ 1735 TX_SPEED_FEATURES tx_sf; 1736 1737 /*! 1738 * RD calculation speed features: 1739 */ 1740 RD_CALC_SPEED_FEATURES rd_sf; 1741 1742 /*! 1743 * Two-pass mode evaluation features: 1744 */ 1745 WINNER_MODE_SPEED_FEATURES winner_mode_sf; 1746 1747 /*! 1748 * In-loop filter speed features: 1749 */ 1750 LOOP_FILTER_SPEED_FEATURES lpf_sf; 1751 1752 /*! 1753 * Real-time mode speed features: 1754 */ 1755 REAL_TIME_SPEED_FEATURES rt_sf; 1756 } SPEED_FEATURES; 1757 /*!\cond */ 1758 1759 struct AV1_COMP; 1760 1761 /*!\endcond */ 1762 /*!\brief Frame size independent speed vs quality trade off flags 1763 * 1764 *\ingroup speed_features 1765 * 1766 * \param[in] cpi Top - level encoder instance structure 1767 * \param[in] speed Speed setting passed in from the command line 1768 * 1769 * \remark No return value but configures the various speed trade off flags 1770 * based on the passed in speed setting. (Higher speed gives lower 1771 * quality) 1772 */ 1773 void av1_set_speed_features_framesize_independent(struct AV1_COMP *cpi, 1774 int speed); 1775 1776 /*!\brief Frame size dependent speed vs quality trade off flags 1777 * 1778 *\ingroup speed_features 1779 * 1780 * \param[in] cpi Top - level encoder instance structure 1781 * \param[in] speed Speed setting passed in from the command line 1782 * 1783 * \remark No return value but configures the various speed trade off flags 1784 * based on the passed in speed setting and frame size. (Higher speed 1785 * corresponds to lower quality) 1786 */ 1787 void av1_set_speed_features_framesize_dependent(struct AV1_COMP *cpi, 1788 int speed); 1789 /*!\brief Q index dependent speed vs quality trade off flags 1790 * 1791 *\ingroup speed_features 1792 * 1793 * \param[in] cpi Top - level encoder instance structure 1794 * \param[in] speed Speed setting passed in from the command line 1795 * 1796 * \remark No return value but configures the various speed trade off flags 1797 * based on the passed in speed setting and current frame's Q index. 1798 * (Higher speed corresponds to lower quality) 1799 */ 1800 void av1_set_speed_features_qindex_dependent(struct AV1_COMP *cpi, int speed); 1801 1802 #ifdef __cplusplus 1803 } // extern "C" 1804 #endif 1805 1806 #endif // AOM_AV1_ENCODER_SPEED_FEATURES_H_ 1807