AOMedia AV1 Codec
speed_features.h
Go to the documentation of this file.
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 
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);
156 typedef enum {
165  CDEF_PICK_METHODS
167 
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 } UENUM1BYTE(MULTI_WINNER_MODE_TYPE);
224 
225 enum {
226  PRUNE_NEARMV_OFF = 0, // Turn off nearmv pruning
227  PRUNE_NEARMV_LEVEL1 = 1, // Prune nearmv for qindex (0-85)
228  PRUNE_NEARMV_LEVEL2 = 2, // Prune nearmv for qindex (0-170)
229  PRUNE_NEARMV_LEVEL3 = 3, // Prune nearmv more aggressively for qindex (0-170)
230  PRUNE_NEARMV_MAX = PRUNE_NEARMV_LEVEL3,
231 } UENUM1BYTE(PRUNE_NEARMV_LEVEL);
232 
233 typedef struct {
234  TX_TYPE_PRUNE_MODE prune_2d_txfm_mode;
235  int fast_intra_tx_type_search;
236 
237  // INT_MAX: Disable fast search.
238  // 1 - 1024: Probability threshold used for conditionally forcing tx type,
239  // during mode search.
240  // 0: Force tx type to be DCT_DCT unconditionally, during
241  // mode search.
242  int fast_inter_tx_type_prob_thresh;
243 
244  // Prune less likely chosen transforms for each intra mode. The speed
245  // feature ranges from 0 to 2, for different speed / compression trade offs.
246  int use_reduced_intra_txset;
247 
248  // Use a skip flag prediction model to detect blocks with skip = 1 early
249  // and avoid doing full TX type search for such blocks.
250  int use_skip_flag_prediction;
251 
252  // Threshold used by the ML based method to predict TX block split decisions.
253  int ml_tx_split_thresh;
254 
255  // skip remaining transform type search when we found the rdcost of skip is
256  // better than applying transform
257  int skip_tx_search;
258 
259  // Prune tx type search using previous frame stats.
260  int prune_tx_type_using_stats;
261  // Prune tx type search using estimated RDcost
262  int prune_tx_type_est_rd;
263 
264  // Flag used to control the winner mode processing for tx type pruning for
265  // inter blocks. It enables further tx type mode pruning based on ML model for
266  // mode evaluation and disables tx type mode pruning for winner mode
267  // processing.
268  int winner_mode_tx_type_pruning;
269 } TX_TYPE_SEARCH;
270 
271 enum {
272  // Search partitions using RD criterion
273  SEARCH_PARTITION,
274 
275  // Always use a fixed size partition
276  FIXED_PARTITION,
277 
278  // Partition using source variance
279  VAR_BASED_PARTITION,
280 
281 #if CONFIG_RT_ML_PARTITIONING
282  // Partition using ML model
283  ML_BASED_PARTITION
284 #endif
285 } UENUM1BYTE(PARTITION_SEARCH_TYPE);
286 
287 enum {
288  NOT_IN_USE,
289  DIRECT_PRED,
290  RELAXED_PRED,
291  ADAPT_PRED
292 } UENUM1BYTE(MAX_PART_PRED_MODE);
293 
294 enum {
295  LAST_MV_DATA,
296  CURRENT_Q,
297  QTR_ONLY,
298 } UENUM1BYTE(MV_PREC_LOGIC);
299 
300 enum {
301  SUPERRES_AUTO_ALL, // Tries all possible superres ratios
302  SUPERRES_AUTO_DUAL, // Tries no superres and q-based superres ratios
303  SUPERRES_AUTO_SOLO, // Only apply the q-based superres ratio
304 } UENUM1BYTE(SUPERRES_AUTO_SEARCH_TYPE);
315 typedef enum {
321 
326 typedef enum {
327  NO_PRUNING = -1,
344 
351 
355  RECODE_LOOP_TYPE recode_loop;
356 
362 
369  MV_PREC_LOGIC high_precision_mv_usage;
370 
379 
383  SUPERRES_AUTO_SEARCH_TYPE superres_auto_search_type;
384 
389 
395 
407 
412 
417 
423 
425 typedef struct TPL_SPEED_FEATURES {
426  // GOP length adaptive decision.
427  // If set to 0, tpl model decides whether a shorter gf interval is better.
428  // If set to 1, tpl stats of ARFs from base layer, (base+1) layer and
429  // (base+2) layer decide whether a shorter gf interval is better.
430  // If set to 2, tpl stats of ARFs from base layer, (base+1) layer and GF boost
431  // decide whether a shorter gf interval is better.
432  // If set to 3, gop length adaptive decision is disabled.
433  int gop_length_decision_method;
434  // Prune the intra modes search by tpl.
435  // If set to 0, we will search all intra modes from DC_PRED to PAETH_PRED.
436  // If set to 1, we only search DC_PRED, V_PRED, and H_PRED.
437  int prune_intra_modes;
438  // This parameter controls which step in the n-step process we start at.
439  int reduce_first_step_size;
440  // Skip motion estimation based on the precision of center MVs and the
441  // difference between center MVs.
442  // If set to 0, motion estimation is skipped for duplicate center MVs
443  // (default). If set to 1, motion estimation is skipped for duplicate
444  // full-pixel center MVs. If set to 2, motion estimation is skipped if the
445  // difference between center MVs is less than the threshold.
446  int skip_alike_starting_mv;
447 
448  // When to stop subpel search.
449  SUBPEL_FORCE_STOP subpel_force_stop;
450 
451  // Which search method to use.
452  SEARCH_METHODS search_method;
453 
454  // Prune starting mvs in TPL based on sad scores.
455  int prune_starting_mv;
456 
457  // Not run TPL for filtered Key frame.
458  int disable_filtered_key_tpl;
459 
460  // Prune reference frames in TPL.
461  int prune_ref_frames_in_tpl;
462 
463  // Support compound predictions.
464  int allow_compound_pred;
465 
466  // Calculate rate and distortion based on Y plane only.
467  int use_y_only_rate_distortion;
468 } TPL_SPEED_FEATURES;
469 
470 typedef struct GLOBAL_MOTION_SPEED_FEATURES {
471  GM_SEARCH_TYPE gm_search_type;
472 
473  // During global motion estimation, prune remaining reference frames in a
474  // given direction(past/future), if the evaluated ref_frame in that direction
475  // yields gm_type as INVALID/TRANSLATION/IDENTITY
476  int prune_ref_frame_for_gm_search;
477 
478  // When the current GM type is set to ZEROMV, prune ZEROMV if its performance
479  // is worse than NEWMV under SSE metric.
480  // 0 : no pruning
481  // 1 : conservative pruning
482  // 2 : aggressive pruning
484 
485  // Disable global motion estimation based on stats of previous frames in the
486  // GF group
487  int disable_gm_search_based_on_stats;
488 } GLOBAL_MOTION_SPEED_FEATURES;
489 
490 typedef struct PARTITION_SPEED_FEATURES {
491  PARTITION_SEARCH_TYPE partition_search_type;
492 
493  // Used if partition_search_type = FIXED_PARTITION
494  BLOCK_SIZE fixed_partition_size;
495 
496  // Prune extended partition types search
497  // Can take values 0 - 2, 0 referring to no pruning, and 1 - 2 increasing
498  // aggressiveness of pruning in order.
499  int prune_ext_partition_types_search_level;
500 
501  // Prune part4 based on block size
502  int prune_part4_search;
503 
504  // Use a ML model to prune rectangular, ab and 4-way horz
505  // and vert partitions
506  int ml_prune_partition;
507 
508  // Use a ML model to adaptively terminate partition search after trying
509  // PARTITION_SPLIT. Can take values 0 - 2, 0 meaning not being enabled, and
510  // 1 - 2 increasing aggressiveness in order.
511  int ml_early_term_after_part_split_level;
512 
513  // Skip rectangular partition test when partition type none gives better
514  // rd than partition type split. Can take values 0 - 2, 0 referring to no
515  // skipping, and 1 - 2 increasing aggressiveness of skipping in order.
516  int less_rectangular_check_level;
517 
518  // Use square partition only beyond this block size.
519  BLOCK_SIZE use_square_partition_only_threshold;
520 
521  // Sets max square partition levels for this superblock based on
522  // motion vector and prediction error distribution produced from 16x16
523  // simple motion search
524  MAX_PART_PRED_MODE auto_max_partition_based_on_simple_motion;
525 
526  // Min and max square partition size we enable (block_size) as per auto
527  // min max, but also used by adjust partitioning, and pick_partitioning.
528  BLOCK_SIZE default_min_partition_size;
529  BLOCK_SIZE default_max_partition_size;
530 
531  // Sets level of adjustment of variance-based partitioning during
532  // rd_use_partition 0 - no partition adjustment, 1 - try to merge partitions
533  // for small blocks and high QP, 2 - try to merge partitions, 3 - always try
534  // to merge leaf partitions for small blocks, 4 - try to merge and split leaf
535  // partitions and 0 - 4 decreasing aggressiveness in order.
536  int adjust_var_based_rd_partitioning;
537 
538  // Partition search early breakout thresholds.
539  int64_t partition_search_breakout_dist_thr;
540  int partition_search_breakout_rate_thr;
541 
542  // Thresholds for ML based partition search breakout.
543  int ml_partition_search_breakout_thresh[PARTITION_BLOCK_SIZES];
544 
545  // Aggressiveness levels for pruning split and rectangular partitions based on
546  // simple_motion_search. SIMPLE_AGG_LVL0 to SIMPLE_AGG_LVL3 correspond to
547  // simple motion search based pruning. QIDX_BASED_AGG_LVL1 corresponds to
548  // qindex based and simple motion search based pruning.
549  int simple_motion_search_prune_agg;
550 
551  // Perform simple_motion_search on each possible subblock and use it to prune
552  // PARTITION_HORZ and PARTITION_VERT.
553  int simple_motion_search_prune_rect;
554 
555  // Perform simple motion search before none_partition to decide if we
556  // want to remove all partitions other than PARTITION_SPLIT. If set to 0, this
557  // model is disabled. If set to 1, the model attempts to perform
558  // PARTITION_SPLIT only. If set to 2, the model also attempts to prune
559  // PARTITION_SPLIT.
560  int simple_motion_search_split;
561 
562  // Use features from simple_motion_search to terminate prediction block
563  // partition after PARTITION_NONE
564  int simple_motion_search_early_term_none;
565 
566  // Controls whether to reduce the number of motion search steps. If this is 0,
567  // then simple_motion_search has the same number of steps as
568  // single_motion_search (assuming no other speed features). Otherwise, reduce
569  // the number of steps by the value contained in this variable.
570  int simple_motion_search_reduce_search_steps;
571 
572  // This variable controls the maximum block size where intra blocks can be
573  // used in inter frames.
574  // TODO(aconverse): Fold this into one of the other many mode skips
575  BLOCK_SIZE max_intra_bsize;
576 
577  // Use CNN with luma pixels on source frame on each of the 64x64 subblock to
578  // perform partition pruning in intra frames.
579  // 0: No Pruning
580  // 1: Prune split and rectangular partitions only
581  // 2: Prune none, split and rectangular partitions
582  int intra_cnn_based_part_prune_level;
583 
584  // Disable extended partition search for lower block sizes.
585  int ext_partition_eval_thresh;
586 
587  // Disable rectangular partitions for larger block sizes.
588  int rect_partition_eval_thresh;
589 
590  // prune extended partition search
591  // 0 : no pruning
592  // 1 : prune 1:4 partition search using winner info from split partitions
593  // 2 : prune 1:4 and AB partition search using split and HORZ/VERT info
594  int prune_ext_part_using_split_info;
595 
596  // Prunt rectangular, AB and 4-way partition based on q index and block size
597  // 0 : no pruning
598  // 1 : prune sub_8x8 at very low quantizers
599  // 2 : prune all block size based on qindex
600  int prune_rectangular_split_based_on_qidx;
601 
602  // Terminate partition search for child partition,
603  // when NONE and SPLIT partition rd_costs are INT64_MAX.
604  int early_term_after_none_split;
605 
606  // Level used to adjust threshold for av1_ml_predict_breakout(). At lower
607  // levels, more conservative threshold is used, and value of 0 indicates
608  // av1_ml_predict_breakout() is disabled. Value of 3 corresponds to default
609  // case with no adjustment to lbd thresholds.
610  int ml_predict_breakout_level;
611 
612  // Prune sub_8x8 (BLOCK_4X4, BLOCK_4X8 and BLOCK_8X4) partitions.
613  // 0 : no pruning
614  // 1 : pruning based on neighbour block information
615  // 2 : prune always
616  int prune_sub_8x8_partition_level;
617 
618  // Prune rectangular split based on simple motion search split/no_split score.
619  // 0: disable pruning, 1: enable pruning
620  int simple_motion_search_rect_split;
621 
622  // The current encoder adopts a DFS search for block partitions.
623  // Therefore the mode selection and associated rdcost is ready for smaller
624  // blocks before the mode selection for some partition types.
625  // AB partition could use previous rd information and skip mode search.
626  // An example is:
627  //
628  // current block
629  // +---+---+
630  // | |
631  // + +
632  // | |
633  // +-------+
634  //
635  // SPLIT partition has been searched first before trying HORZ_A
636  // +---+---+
637  // | R | R |
638  // +---+---+
639  // | R | R |
640  // +---+---+
641  //
642  // HORZ_A
643  // +---+---+
644  // | | |
645  // +---+---+
646  // | |
647  // +-------+
648  //
649  // With this speed feature, the top two sub blocks can directly use rdcost
650  // searched in split partition, and the mode info is also copied from
651  // saved info. Similarly, the bottom rectangular block can also use
652  // the available information from previous rectangular search.
653  int reuse_prev_rd_results_for_part_ab;
654 
655  // Reuse the best prediction modes found in PARTITION_SPLIT and PARTITION_RECT
656  // when encoding PARTITION_AB.
657  int reuse_best_prediction_for_part_ab;
658 
659  // The current partition search records the best rdcost so far and uses it
660  // in mode search and transform search to early skip when some criteria is
661  // met. For example, when the current rdcost is larger than the best rdcost,
662  // or the model rdcost is larger than the best rdcost times some thresholds.
663  // By default, this feature is turned on to speed up the encoder partition
664  // search.
665  // If disabling it, at speed 0, 30 frames, we could get
666  // about -0.25% quality gain (psnr, ssim, vmaf), with about 13% slowdown.
667  int use_best_rd_for_pruning;
668 
669  // Skip evaluation of non-square partitions based on the corresponding NONE
670  // partition.
671  // 0: no pruning
672  // 1: prune extended partitions if NONE is skippable
673  // 2: on top of 1, prune rectangular partitions if NONE is inter, not a newmv
674  // mode and skippable
675  int skip_non_sq_part_based_on_none;
676 } PARTITION_SPEED_FEATURES;
677 
678 typedef struct MV_SPEED_FEATURES {
679  // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc).
680  SEARCH_METHODS search_method;
681 
682  // Enable the use of faster, less accurate mv search method on bsize >=
683  // BLOCK_32X32.
684  // TODO(chiyotsai@google.com): Take the clip's resolution and mv activity into
685  // account.
686  int use_bsize_dependent_search_method;
687 
688  // If this is set to 1, we limit the motion search range to 2 times the
689  // largest motion vector found in the last frame.
690  int auto_mv_step_size;
691 
692  // Subpel_search_method can only be subpel_tree which does a subpixel
693  // logarithmic search that keeps stepping at 1/2 pixel units until
694  // you stop getting a gain, and then goes on to 1/4 and repeats
695  // the same process. Along the way it skips many diagonals.
696  SUBPEL_SEARCH_METHODS subpel_search_method;
697 
698  // Maximum number of steps in logarithmic subpel search before giving up.
699  int subpel_iters_per_step;
700 
701  // When to stop subpel search.
702  SUBPEL_FORCE_STOP subpel_force_stop;
703 
704  // When to stop subpel search in simple motion search.
705  SUBPEL_FORCE_STOP simple_motion_subpel_force_stop;
706 
707  // If true, sub-pixel search uses the exact convolve function used for final
708  // encoding and decoding; otherwise, it uses bilinear interpolation.
709  SUBPEL_SEARCH_TYPE use_accurate_subpel_search;
710 
711  // Threshold for allowing exhaustive motion search.
712  int exhaustive_searches_thresh;
713 
714  // Pattern to be used for any exhaustive mesh searches (except intraBC ME).
715  MESH_PATTERN mesh_patterns[MAX_MESH_STEP];
716 
717  // Pattern to be used for exhaustive mesh searches of intraBC ME.
718  MESH_PATTERN intrabc_mesh_patterns[MAX_MESH_STEP];
719 
720  // Reduce single motion search range based on MV result of prior ref_mv_idx.
721  int reduce_search_range;
722 
723  // Prune mesh search.
724  int prune_mesh_search;
725 
726  // Use the rd cost around the best FULLPEL_MV to speed up subpel search
727  int use_fullpel_costlist;
728 
729  // Set the full pixel search level of obmc
730  // 0: obmc_full_pixel_diamond
731  // 1: obmc_refining_search_sad (faster)
732  int obmc_full_pixel_search_level;
733 
734  // Accurate full pixel motion search based on TPL stats.
735  int full_pixel_search_level;
736 
737  // Whether to downsample the rows in sad calculation during motion search.
738  // This is only active when there are at least 16 rows.
739  int use_downsampled_sad;
740 
741  // Enable/disable extensive joint motion search.
742  int disable_extensive_joint_motion_search;
743 
744  // Enable second best mv check in joint mv search.
745  // 0: allow second MV (use rd cost as the metric)
746  // 1: use var as the metric
747  // 2: disable second MV
748  int disable_second_mv;
749 } MV_SPEED_FEATURES;
750 
751 typedef struct INTER_MODE_SPEED_FEATURES {
752  // 2-pass inter mode model estimation where the preliminary pass skips
753  // transform search and uses a model to estimate rd, while the final pass
754  // computes the full transform search. Two types of models are supported:
755  // 0: not used
756  // 1: used with online dynamic rd model
757  // 2: used with static rd model
758  int inter_mode_rd_model_estimation;
759 
760  // Bypass transform search based on skip rd
761  int txfm_rd_gate_level;
762 
763  // Limit the inter mode tested in the RD loop
764  int reduce_inter_modes;
765 
766  // This variable is used to cap the maximum number of times we skip testing a
767  // mode to be evaluated. A high value means we will be faster.
768  int adaptive_rd_thresh;
769 
770  // Aggressively prune inter modes when best mode is skippable.
771  int prune_inter_modes_if_skippable;
772 
773  // Drop less likely to be picked reference frames in the RD search.
774  // Has seven levels for now: 0, 1, 2, 3, 4, 5 and 6 where higher levels prune
775  // more aggressively than lower ones. (0 means no pruning).
776  int selective_ref_frame;
777 
778  // Prune reference frames for rectangular partitions.
779  // 0 implies no pruning
780  // 1 implies prune for extended partition
781  // 2 implies prune horiz, vert and extended partition
782  int prune_ref_frame_for_rect_partitions;
783 
784  // Prune inter modes w.r.t past reference frames
785  // 0 no pruning
786  // 1 prune inter modes w.r.t ALTREF2 and ALTREF reference frames
787  // 2 prune inter modes w.r.t BWDREF, ALTREF2 and ALTREF reference frames
788  int alt_ref_search_fp;
789 
790  // Skip the current ref_mv in NEW_MV mode based on mv, rate cost, etc.
791  // This speed feature equaling 0 means no skipping.
792  // If the speed feature equals 1 or 2, skip the current ref_mv in NEW_MV mode
793  // if we have already encountered ref_mv in the drl such that:
794  // 1. The other drl has the same mv during the SIMPLE_TRANSLATION search
795  // process as the current mv.
796  // 2. The rate needed to encode the current mv is larger than that for the
797  // other ref_mv.
798  // The speed feature equaling 1 means using subpel mv in the comparison.
799  // The speed feature equaling 2 means using fullpel mv in the comparison.
800  // If the speed feature >= 3, skip the current ref_mv in NEW_MV mode based on
801  // known full_mv bestsme and drl cost.
802  int skip_newmv_in_drl;
803 
804  // This speed feature checks duplicate ref MVs among NEARESTMV, NEARMV,
805  // GLOBALMV and skips NEARMV or GLOBALMV (in order) if a duplicate is found
806  // TODO(any): Instead of skipping repeated ref mv, use the recalculated
807  // rd-cost based on mode rate and skip the mode evaluation
808  int skip_repeated_ref_mv;
809 
810  // Flag used to control the ref_best_rd based gating for chroma
811  int perform_best_rd_based_gating_for_chroma;
812 
813  // Reuse the inter_intra_mode search result from NEARESTMV mode to other
814  // single ref modes
815  int reuse_inter_intra_mode;
816 
817  // prune wedge and compound segment approximate rd evaluation based on
818  // compound average modeled rd
819  int prune_comp_type_by_model_rd;
820 
821  // prune wedge and compound segment approximate rd evaluation based on
822  // compound average rd/ref_best_rd
823  int prune_comp_type_by_comp_avg;
824 
825  // Skip some ref frames in compound motion search by single motion search
826  // result. Has three levels for now: 0 referring to no skipping, and 1 - 3
827  // increasing aggressiveness of skipping in order.
828  // Note: The search order might affect the result. It assumes that the single
829  // reference modes are searched before compound modes. It is better to search
830  // same single inter mode as a group.
831  int prune_comp_search_by_single_result;
832 
833  // Instead of performing a full MV search, do a simple translation first
834  // and only perform a full MV search on the motion vectors that performed
835  // well.
836  int prune_mode_search_simple_translation;
837 
838  // Only search compound modes with at least one "good" reference frame.
839  // A reference frame is good if, after looking at its performance among
840  // the single reference modes, it is one of the two best performers.
841  int prune_compound_using_single_ref;
842 
843  // Skip extended compound mode (NEAREST_NEWMV, NEW_NEARESTMV, NEAR_NEWMV,
844  // NEW_NEARMV) using ref frames of above and left neighbor
845  // blocks.
846  // 0 : no pruning
847  // 1 : prune ext compound modes using neighbor blocks (less aggressiveness)
848  // 2 : prune ext compound modes using neighbor blocks (high aggressiveness)
849  // 3 : prune ext compound modes unconditionally (highest aggressiveness)
850  int prune_ext_comp_using_neighbors;
851 
852  // Skip NEW_NEARMV and NEAR_NEWMV extended compound modes
853  int skip_ext_comp_nearmv_mode;
854 
855  // Skip extended compound mode when ref frame corresponding to NEWMV does not
856  // have NEWMV as single mode winner.
857  // 0 : no pruning
858  // 1 : prune extended compound mode (less aggressiveness)
859  // 2 : prune extended compound mode (high aggressiveness)
860  int prune_comp_using_best_single_mode_ref;
861 
862  // Skip NEARESTMV and NEARMV using weight computed in ref mv list population
863  int prune_nearest_near_mv_using_refmv_weight;
864 
865  // Based on previous ref_mv_idx search result, prune the following search.
866  int prune_ref_mv_idx_search;
867 
868  // Disable one sided compound modes.
869  int disable_onesided_comp;
870 
871  // Prune obmc search using previous frame stats.
872  // INT_MAX : disable obmc search
873  int prune_obmc_prob_thresh;
874 
875  // Prune warped motion search using previous frame stats.
876  int prune_warped_prob_thresh;
877 
878  // Variance threshold to enable/disable Interintra wedge search
879  unsigned int disable_interintra_wedge_var_thresh;
880 
881  // Variance threshold to enable/disable Interinter wedge search
882  unsigned int disable_interinter_wedge_var_thresh;
883 
884  // De-couple wedge and mode search during interintra RDO.
885  int fast_interintra_wedge_search;
886 
887  // Whether fast wedge sign estimate is used
888  int fast_wedge_sign_estimate;
889 
890  // Enable/disable ME for interinter wedge search.
891  int disable_interinter_wedge_newmv_search;
892 
893  // Decide when and how to use joint_comp.
894  DIST_WTD_COMP_FLAG use_dist_wtd_comp_flag;
895 
896  // Clip the frequency of updating the mv cost.
897  INTERNAL_COST_UPDATE_TYPE mv_cost_upd_level;
898 
899  // Clip the frequency of updating the coeff cost.
900  INTERNAL_COST_UPDATE_TYPE coeff_cost_upd_level;
901 
902  // Clip the frequency of updating the mode cost.
903  INTERNAL_COST_UPDATE_TYPE mode_cost_upd_level;
904 
905  // Prune inter modes based on tpl stats
906  // 0 : no pruning
907  // 1 - 3 indicate increasing aggressiveness in order.
908  int prune_inter_modes_based_on_tpl;
909 
910  // Skip NEARMV and NEAR_NEARMV modes using ref frames of above and left
911  // neighbor blocks and qindex.
912  PRUNE_NEARMV_LEVEL prune_nearmv_using_neighbors;
913 
914  // Model based breakout after interpolation filter search
915  // 0: no breakout
916  // 1: use model based rd breakout
917  int model_based_post_interp_filter_breakout;
918 
919  // Reuse compound type rd decision when exact match is found
920  // 0: No reuse
921  // 1: Reuse the compound type decision
922  int reuse_compound_type_decision;
923 
924  // Enable/disable masked compound.
925  int disable_masked_comp;
926 
927  // Enable/disable the fast compound mode search.
928  int enable_fast_compound_mode_search;
929 
930  // Reuse masked compound type search results
931  int reuse_mask_search_results;
932 
933  // Enable/disable fast search for wedge masks
934  int enable_fast_wedge_mask_search;
935 
936  // Early breakout from transform search of inter modes
937  int inter_mode_txfm_breakout;
938 
939  // Limit number of inter modes for txfm search if a newmv mode gets
940  // evaluated among the top modes.
941  // 0: no pruning
942  // 1 to 3 indicate increasing order of aggressiveness
943  int limit_inter_mode_cands;
944 
945  // Cap the no. of txfm searches for a given prediction mode.
946  // 0: no cap, 1: cap beyond first 4 searches, 2: cap beyond first 3 searches.
947  int limit_txfm_eval_per_mode;
948 
949  // Prune warped motion search based on block size.
950  int extra_prune_warped;
951 
952  // Do not search compound modes for ARF.
953  // The intuition is that ARF is predicted by frames far away from it,
954  // whose temporal correlations with the ARF are likely low.
955  // It is therefore likely that compound modes do not work as well for ARF
956  // as other inter frames.
957  // Speed/quality impact:
958  // Speed 1: 12% faster, 0.1% psnr loss.
959  // Speed 2: 2% faster, 0.05% psnr loss.
960  // No change for speed 3 and up, because |disable_onesided_comp| is true.
961  int skip_arf_compound;
962 } INTER_MODE_SPEED_FEATURES;
963 
964 typedef struct INTERP_FILTER_SPEED_FEATURES {
965  // Do limited interpolation filter search for dual filters, since best choice
966  // usually includes EIGHTTAP_REGULAR.
967  int use_fast_interpolation_filter_search;
968 
969  // Disable dual filter
970  int disable_dual_filter;
971 
972  // Save results of av1_interpolation_filter_search for a block
973  // Check mv and ref_frames before search, if they are very close with previous
974  // saved results, filter search can be skipped.
975  int use_interp_filter;
976 
977  // skip sharp_filter evaluation based on regular and smooth filter rd for
978  // dual_filter=0 case
979  int skip_sharp_interp_filter_search;
980 
981  int cb_pred_filter_search;
982 
983  // adaptive interp_filter search to allow skip of certain filter types.
984  int adaptive_interp_filter_search;
985 } INTERP_FILTER_SPEED_FEATURES;
986 
987 typedef struct INTRA_MODE_SPEED_FEATURES {
988  // These bit masks allow you to enable or disable intra modes for each
989  // transform size separately.
990  int intra_y_mode_mask[TX_SIZES];
991  int intra_uv_mode_mask[TX_SIZES];
992 
993  // flag to allow skipping intra mode for inter frame prediction
994  int skip_intra_in_interframe;
995 
996  // Prune intra mode candidates based on source block histogram of gradient.
997  // Applies to luma plane only.
998  // Feasible values are 0..4. The feature is disabled for 0. An increasing
999  // value indicates more aggressive pruning threshold.
1000  int intra_pruning_with_hog;
1001 
1002  // Prune intra mode candidates based on source block histogram of gradient.
1003  // Applies to chroma plane only.
1004  // Feasible values are 0..4. The feature is disabled for 0. An increasing
1005  // value indicates more aggressive pruning threshold.
1006  int chroma_intra_pruning_with_hog;
1007 
1008  // Enable/disable smooth intra modes.
1009  int disable_smooth_intra;
1010 
1011  // Prune filter intra modes in intra frames.
1012  // 0 : No pruning
1013  // 1 : Evaluate applicable filter intra modes based on best intra mode so far
1014  // 2 : Do not evaluate filter intra modes
1015  int prune_filter_intra_level;
1016 
1017  // prune palette search
1018  // 0: No pruning
1019  // 1: Perform coarse search to prune the palette colors. For winner colors,
1020  // neighbors are also evaluated using a finer search.
1021  // 2: Perform 2 way palette search from max colors to min colors (and min
1022  // colors to remaining colors) and terminate the search if current number of
1023  // palette colors is not the winner.
1024  int prune_palette_search_level;
1025 
1026  // Terminate early in luma palette_size search. Speed feature values indicate
1027  // increasing level of pruning.
1028  // 0: No early termination
1029  // 1: Terminate early for higher luma palette_size, if header rd cost of lower
1030  // palette_size is more than 2 * best_rd. This level of pruning is more
1031  // conservative when compared to sf level 2 as the cases which will get pruned
1032  // with sf level 1 is a subset of the cases which will get pruned with sf
1033  // level 2.
1034  // 2: Terminate early for higher luma palette_size, if header rd cost of lower
1035  // palette_size is more than best_rd.
1036  // For allintra encode, this sf reduces instruction count by 2.49%, 1.07%,
1037  // 2.76%, 2.30%, 1.84%, 2.69%, 2.04%, 2.05% and 1.44% for speed 0, 1, 2, 3, 4,
1038  // 5, 6, 7 and 8 on screen content set with coding performance change less
1039  // than 0.01% for speed <= 2 and less than 0.03% for speed >= 3. For AVIF
1040  // image encode, this sf reduces instruction count by 1.94%, 1.13%, 1.29%,
1041  // 0.93%, 0.89%, 1.03%, 1.07%, 1.20% and 0.18% for speed 0, 1, 2, 3, 4, 5, 6,
1042  // 7 and 8 on a typical image dataset with coding performance change less than
1043  // 0.01%.
1044  int prune_luma_palette_size_search_level;
1045 
1046  // Prune chroma intra modes based on luma intra mode winner.
1047  // 0: No pruning
1048  // 1: Prune chroma intra modes other than UV_DC_PRED, UV_SMOOTH_PRED,
1049  // UV_CFL_PRED and the mode that corresponds to luma intra mode winner.
1050  int prune_chroma_modes_using_luma_winner;
1051 
1052  // Clip the frequency of updating the mv cost for intrabc.
1053  INTERNAL_COST_UPDATE_TYPE dv_cost_upd_level;
1054 
1055  // We use DCT_DCT transform followed by computing SATD (Sum of Absolute
1056  // Transformed Differences) as an estimation of RD score to quickly find the
1057  // best possible Chroma from Luma (CFL) parameter. Then we do a full RD search
1058  // near the best possible parameter. The search range is set here.
1059  // The range of cfl_searh_range should be [1, 33], and the following are the
1060  // recommended values.
1061  // 1: Fastest mode.
1062  // 3: Default mode that provides good speedup without losing compression
1063  // performance at speed 0.
1064  // 33: Exhaustive rd search (33 == CFL_MAGS_SIZE). This mode should only
1065  // be used for debugging purpose.
1066  int cfl_search_range;
1067 
1068  // TOP_INTRA_MODEL_COUNT is 4 that is the number of top model rd to store in
1069  // intra mode decision. Here, add a speed feature to reduce this number for
1070  // higher speeds.
1071  int top_intra_model_count_allowed;
1072 
1073  // Adapt top_intra_model_count_allowed locally to prune luma intra modes using
1074  // neighbor block and quantizer information.
1075  int adapt_top_model_rd_count_using_neighbors;
1076 
1077  // Terminate early in chroma palette_size search.
1078  // 0: No early termination
1079  // 1: Terminate early for higher palette_size, if header rd cost of lower
1080  // palette_size is more than best_rd.
1081  // For allintra encode, this sf reduces instruction count by 0.45%,
1082  // 0.62%, 1.73%, 2.50%, 2.89%, 3.09% and 3.86% for speed 0 to 6 on screen
1083  // content set with coding performance change less than 0.01%.
1084  // For AVIF image encode, this sf reduces instruction count by 0.45%, 0.81%,
1085  // 0.85%, 1.05%, 1.45%, 1.66% and 1.95% for speed 0 to 6 on a typical image
1086  // dataset with no quality drop.
1087  int early_term_chroma_palette_size_search;
1088 
1089  // Skips the evaluation of filter intra modes in inter frames if rd evaluation
1090  // of luma intra dc mode results in invalid rd stats.
1091  int skip_filter_intra_in_inter_frames;
1092 } INTRA_MODE_SPEED_FEATURES;
1093 
1094 typedef struct TX_SPEED_FEATURES {
1095  // Init search depth for square and rectangular transform partitions.
1096  // Values:
1097  // 0 - search full tree, 1: search 1 level, 2: search the highest level only
1098  int inter_tx_size_search_init_depth_sqr;
1099  int inter_tx_size_search_init_depth_rect;
1100  int intra_tx_size_search_init_depth_sqr;
1101  int intra_tx_size_search_init_depth_rect;
1102 
1103  // If any dimension of a coding block size above 64, always search the
1104  // largest transform only, since the largest transform block size is 64x64.
1105  int tx_size_search_lgr_block;
1106 
1107  TX_TYPE_SEARCH tx_type_search;
1108 
1109  // Skip split transform block partition when the collocated bigger block
1110  // is selected as all zero coefficients.
1111  int txb_split_cap;
1112 
1113  // Shortcut the transform block partition and type search when the target
1114  // rdcost is relatively lower.
1115  // Values are 0 (not used) , or 1 - 2 with progressively increasing
1116  // aggressiveness
1117  int adaptive_txb_search_level;
1118 
1119  // Prune level for tx_size_type search for inter based on rd model
1120  // 0: no pruning
1121  // 1-2: progressively increasing aggressiveness of pruning
1122  int model_based_prune_tx_search_level;
1123 
1124  // Refine TX type after fast TX search.
1125  int refine_fast_tx_search_results;
1126 
1127  // Prune transform split/no_split eval based on residual properties. A value
1128  // of 0 indicates no pruning, and the aggressiveness of pruning progressively
1129  // increases from levels 1 to 3.
1130  int prune_tx_size_level;
1131 } TX_SPEED_FEATURES;
1132 
1133 typedef struct RD_CALC_SPEED_FEATURES {
1134  // Fast approximation of av1_model_rd_from_var_lapndz
1135  int simple_model_rd_from_var;
1136 
1137  // Whether to compute distortion in the image domain (slower but
1138  // more accurate), or in the transform domain (faster but less acurate).
1139  // 0: use image domain
1140  // 1: use transform domain in tx_type search, and use image domain for
1141  // RD_STATS
1142  // 2: use transform domain
1143  int tx_domain_dist_level;
1144 
1145  // Transform domain distortion threshold level
1146  int tx_domain_dist_thres_level;
1147 
1148  // Trellis (dynamic programming) optimization of quantized values
1149  TRELLIS_OPT_TYPE optimize_coefficients;
1150 
1151  // Use hash table to store macroblock RD search results
1152  // to avoid repeated search on the same residue signal.
1153  int use_mb_rd_hash;
1154 
1155  // Flag used to control the extent of coeff R-D optimization
1156  int perform_coeff_opt;
1157 } RD_CALC_SPEED_FEATURES;
1158 
1159 typedef struct WINNER_MODE_SPEED_FEATURES {
1160  // Flag used to control the winner mode processing for better R-D optimization
1161  // of quantized coeffs
1162  int enable_winner_mode_for_coeff_opt;
1163 
1164  // Flag used to control the winner mode processing for transform size
1165  // search method
1166  int enable_winner_mode_for_tx_size_srch;
1167 
1168  // Control transform size search level
1169  // Eval type: Default Mode Winner
1170  // Level 0 : FULL RD LARGEST ALL FULL RD
1171  // Level 1 : FAST RD LARGEST ALL FULL RD
1172  // Level 2 : LARGEST ALL LARGEST ALL FULL RD
1173  // Level 3 : LARGEST ALL LARGEST ALL LARGEST ALL
1174  int tx_size_search_level;
1175 
1176  // Flag used to control the winner mode processing for use transform
1177  // domain distortion
1178  int enable_winner_mode_for_use_tx_domain_dist;
1179 
1180  // Flag used to enable processing of multiple winner modes
1181  MULTI_WINNER_MODE_TYPE multi_winner_mode_type;
1182 
1183  // Motion mode for winner candidates:
1184  // 0: speed feature OFF
1185  // 1 / 2 : Use configured number of winner candidates
1186  int motion_mode_for_winner_cand;
1187 
1188  // Early DC only txfm block prediction
1189  // 0: speed feature OFF
1190  // 1 / 2 : Use the configured level for different modes
1191  int dc_blk_pred_level;
1192 
1193  // If on, disables interpolation filter search in handle_inter_mode loop, and
1194  // performs it during winner mode processing by \ref
1195  // tx_search_best_inter_candidates.
1196  int winner_mode_ifs;
1197 } WINNER_MODE_SPEED_FEATURES;
1198 
1199 typedef struct LOOP_FILTER_SPEED_FEATURES {
1200  // This feature controls how the loop filter level is determined.
1201  LPF_PICK_METHOD lpf_pick;
1202 
1203  // Skip some final iterations in the determination of the best loop filter
1204  // level.
1205  int use_coarse_filter_level_search;
1206 
1207  // Control how the CDEF strength is determined.
1208  CDEF_PICK_METHOD cdef_pick_method;
1209 
1210  // Decoder side speed feature to add penalty for use of dual-sgr filters.
1211  // Takes values 0 - 10, 0 indicating no penalty and each additional level
1212  // adding a penalty of 1%
1213  int dual_sgr_penalty_level;
1214 
1215  // prune sgr ep using binary search like mechanism
1216  int enable_sgr_ep_pruning;
1217 
1218  // Disable loop restoration for Chroma plane
1219  int disable_loop_restoration_chroma;
1220 
1221  // Disable loop restoration for luma plane
1222  int disable_loop_restoration_luma;
1223 
1224  // Prune RESTORE_WIENER evaluation based on source variance
1225  // 0 : no pruning
1226  // 1 : conservative pruning
1227  // 2 : aggressive pruning
1228  int prune_wiener_based_on_src_var;
1229 
1230  // Prune self-guided loop restoration based on wiener search results
1231  // 0 : no pruning
1232  // 1 : pruning based on rdcost ratio of RESTORE_WIENER and RESTORE_NONE
1233  // 2 : pruning based on winner restoration type among RESTORE_WIENER and
1234  // RESTORE_NONE
1235  int prune_sgr_based_on_wiener;
1236 
1237  // Reduce the wiener filter win size for luma
1238  int reduce_wiener_window_size;
1239 
1240  // Disable loop restoration filter
1241  int disable_lr_filter;
1242 } LOOP_FILTER_SPEED_FEATURES;
1243 
1244 typedef struct REAL_TIME_SPEED_FEATURES {
1245  // check intra prediction for non-RD mode.
1246  int check_intra_pred_nonrd;
1247 
1248  // skip checking intra prediction if TX is skipped
1249  int skip_intra_pred_if_tx_skip;
1250 
1251  // Perform coarse ME before calculating variance in variance-based partition
1252  int estimate_motion_for_var_based_partition;
1253 
1254  // For nonrd_use_partition: mode of extra check of leaf partition
1255  // 0 - don't check merge
1256  // 1 - always check merge
1257  // 2 - check merge and prune checking final split
1258  int nonrd_check_partition_merge_mode;
1259 
1260  // For nonrd_use_partition: check of leaf partition extra split
1261  int nonrd_check_partition_split;
1262 
1263  // Implements various heuristics to skip searching modes
1264  // The heuristics selected are based on flags
1265  // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
1266  unsigned int mode_search_skip_flags;
1267 
1268  // For nonrd: Reduces ref frame search.
1269  // 0 - low level of search prune in non last frames
1270  // 1 - pruned search in non last frames
1271  // 2 - more pruned search in non last frames
1272  int nonrd_prune_ref_frame_search;
1273 
1274  // This flag controls the use of non-RD mode decision.
1275  int use_nonrd_pick_mode;
1276 
1277  // Use ALTREF frame in non-RD mode decision.
1278  int use_nonrd_altref_frame;
1279 
1280  // Use compound reference for non-RD mode.
1281  int use_comp_ref_nonrd;
1282 
1283  // Reference frames for compound prediction for nonrd pickmode:
1284  // LAST_GOLDEN (0), LAST_LAST2 (1), or LAST_ALTREF (2).
1285  int ref_frame_comp_nonrd[3];
1286 
1287  // use reduced ref set for real-time mode
1288  int use_real_time_ref_set;
1289 
1290  // Skip a number of expensive mode evaluations for blocks with very low
1291  // temporal variance.
1292  int short_circuit_low_temp_var;
1293 
1294  // Use modeled (currently CurvFit model) RDCost for fast non-RD mode
1295  int use_modeled_non_rd_cost;
1296 
1297  // Reuse inter prediction in fast non-rd mode.
1298  int reuse_inter_pred_nonrd;
1299 
1300  // Number of best inter modes to search transform. INT_MAX - search all.
1301  int num_inter_modes_for_tx_search;
1302 
1303  // Forces TX search off for RDCost calulation.
1304  int force_tx_search_off;
1305 
1306  // Use interpolation filter search in non-RD mode decision.
1307  int use_nonrd_filter_search;
1308 
1309  // Use simplified RD model for interpolation search and Intra
1310  int use_simple_rd_model;
1311 
1312  // If set forces interpolation filter to EIGHTTAP_REGULAR
1313  int skip_interp_filter_search;
1314 
1315  // For nonrd mode: use hybrid (rd for bsize < 16x16, otherwise nonrd)
1316  // intra mode search for intra only frames. If set to 0 then nonrd pick
1317  // intra is used for all blocks.
1318  int hybrid_intra_pickmode;
1319 
1320  // Compute variance/sse on source difference, prior to encoding superblock.
1321  int source_metrics_sb_nonrd;
1322 
1323  // Flag to indicate process for handling overshoot on slide/scene change,
1324  // for real-time CBR mode.
1325  OVERSHOOT_DETECTION_CBR overshoot_detection_cbr;
1326 
1327  // Check for scene/content change detection on every frame before encoding.
1328  int check_scene_detection;
1329 
1330  // Forces larger partition blocks in variance based partitioning
1331  int force_large_partition_blocks;
1332 
1333  // uses results of temporal noise estimate
1334  int use_temporal_noise_estimate;
1335 
1336  // Parameter indicating initial search window to be used in full-pixel search
1337  // for nonrd_pickmode. Range [0, MAX_MVSEARCH_STEPS - 1]. Lower value
1338  // indicates larger window. If set to 0, step_param is set based on internal
1339  // logic in set_mv_search_params().
1340  int fullpel_search_step_param;
1341 
1342  // Bit mask to enable or disable intra modes for each prediction block size
1343  // separately, for nonrd pickmode.
1344  int intra_y_mode_bsize_mask_nrd[BLOCK_SIZES];
1345 
1346  // Skips mode checks more agressively in nonRD mode
1347  int nonrd_agressive_skip;
1348 
1349  // Skip cdef on 64x64 blocks when NEWMV or INTRA is not picked or color
1350  // sensitivity is off. When color sensitivity is on for a superblock, all
1351  // 64x64 blocks within will not skip.
1352  int skip_cdef_sb;
1353 
1354  // Forces larger partition blocks in variance based partitioning for intra
1355  // frames
1356  int force_large_partition_blocks_intra;
1357 
1358  // Skip evaluation of no split in tx size selection for merge partition
1359  int skip_tx_no_split_var_based_partition;
1360 
1361  // Intermediate termination of newMV mode evaluation based on so far best mode
1362  // sse
1363  int skip_newmv_mode_based_on_sse;
1364 
1365  // Define gf length multiplier.
1366  // Level 0: use large multiplier, level 1: use medium multiplier.
1367  int gf_length_lvl;
1368 
1369  // Prune inter modes with golden frame as reference for NEARMV and NEWMV modes
1370  int prune_inter_modes_with_golden_ref;
1371 
1372  // Prune inter modes w.r.t golden or alt-ref frame based on sad
1373  int prune_inter_modes_wrt_gf_arf_based_on_sad;
1374 
1375  // Prune inter mode search in rd path based on current block's temporal
1376  // variance wrt LAST reference.
1377  int prune_inter_modes_using_temp_var;
1378 
1379  // Force half_pel at block level.
1380  int force_half_pel_block;
1381 } REAL_TIME_SPEED_FEATURES;
1382 
1388 typedef struct SPEED_FEATURES {
1393 
1398 
1402  TPL_SPEED_FEATURES tpl_sf;
1403 
1407  GLOBAL_MOTION_SPEED_FEATURES gm_sf;
1408 
1412  PARTITION_SPEED_FEATURES part_sf;
1413 
1417  MV_SPEED_FEATURES mv_sf;
1418 
1422  INTER_MODE_SPEED_FEATURES inter_sf;
1423 
1427  INTERP_FILTER_SPEED_FEATURES interp_sf;
1428 
1432  INTRA_MODE_SPEED_FEATURES intra_sf;
1433 
1437  TX_SPEED_FEATURES tx_sf;
1438 
1442  RD_CALC_SPEED_FEATURES rd_sf;
1443 
1447  WINNER_MODE_SPEED_FEATURES winner_mode_sf;
1448 
1452  LOOP_FILTER_SPEED_FEATURES lpf_sf;
1453 
1457  REAL_TIME_SPEED_FEATURES rt_sf;
1461 struct AV1_COMP;
1462 
1476  int speed);
1477 
1490  int speed);
1503 
1504 #ifdef __cplusplus
1505 } // extern "C"
1506 #endif
1507 
1508 #endif // AOM_AV1_ENCODER_SPEED_FEATURES_H_
static int prune_zero_mv_with_sse(const aom_variance_fn_ptr_t *fn_ptr, const MACROBLOCK *x, BLOCK_SIZE bsize, const HandleInterModeArgs *args, int prune_zero_mv_with_sse)
Prunes ZeroMV Search Using Best NEWMV's SSE.
Definition: rdopt.c:2475
void av1_set_speed_features_framesize_independent(struct AV1_COMP *cpi, int speed)
Frame size independent speed vs quality trade off flags.
void av1_set_speed_features_qindex_dependent(struct AV1_COMP *cpi, int speed)
Q index dependent speed vs quality trade off flags.
void av1_set_speed_features_framesize_dependent(struct AV1_COMP *cpi, int speed)
Frame size dependent speed vs quality trade off flags.
INTERNAL_COST_UPDATE_TYPE
This enum decides internally how often to update the entropy costs.
Definition: speed_features.h:315
@ INTERNAL_COST_UPD_OFF
Definition: speed_features.h:316
@ INTERNAL_COST_UPD_SBROW_SET
Definition: speed_features.h:317
@ INTERNAL_COST_UPD_SBROW
Definition: speed_features.h:318
@ INTERNAL_COST_UPD_SB
Definition: speed_features.h:319
SIMPLE_MOTION_SEARCH_PRUNE_LEVEL
This enumeration defines a variety of simple motion search based partition prune levels.
Definition: speed_features.h:326
@ QIDX_BASED_AGG_LVL1
Definition: speed_features.h:332
@ SIMPLE_AGG_LVL3
Definition: speed_features.h:331
@ TOTAL_SIMPLE_AGG_LVLS
Definition: speed_features.h:335
@ SIMPLE_AGG_LVL1
Definition: speed_features.h:329
@ SIMPLE_AGG_LVL0
Definition: speed_features.h:328
@ TOTAL_AGG_LVLS
Definition: speed_features.h:341
@ SIMPLE_AGG_LVL2
Definition: speed_features.h:330
@ TOTAL_QINDEX_BASED_AGG_LVLS
Definition: speed_features.h:337
struct SPEED_FEATURES SPEED_FEATURES
Top level speed vs quality trade off data struture.
struct HIGH_LEVEL_SPEED_FEATURES HIGH_LEVEL_SPEED_FEATURES
Sequence/frame level speed vs quality features.
struct FIRST_PASS_SPEED_FEATURES FIRST_PASS_SPEED_FEATURES
CDEF_PICK_METHOD
This enumeration defines a variety of CDEF pick methods.
Definition: speed_features.h:156
@ CDEF_FAST_SEARCH_LVL2
Definition: speed_features.h:159
@ CDEF_FAST_SEARCH_LVL5
Definition: speed_features.h:163
@ CDEF_FAST_SEARCH_LVL1
Definition: speed_features.h:158
@ CDEF_FULL_SEARCH
Definition: speed_features.h:157
@ CDEF_PICK_FROM_Q
Definition: speed_features.h:164
@ CDEF_FAST_SEARCH_LVL4
Definition: speed_features.h:162
@ CDEF_FAST_SEARCH_LVL3
Definition: speed_features.h:160
Top level encoder structure.
Definition: encoder.h:2632
int speed
Definition: encoder.h:2828
Definition: speed_features.h:399
int disable_recon
Skips reconstruction by using source buffers for prediction.
Definition: speed_features.h:416
int reduce_mv_step_param
Reduces the mv search window. By default, the initial search window is around MIN(MIN(dims),...
Definition: speed_features.h:406
int skip_zeromv_motion_search
Skips the motion search centered on 0,0 mv.
Definition: speed_features.h:421
int skip_motion_search_threshold
Skips the motion search when the zero mv has small sse.
Definition: speed_features.h:411
Sequence/frame level speed vs quality features.
Definition: speed_features.h:348
int second_alt_ref_filtering
Definition: speed_features.h:393
int frame_parameter_update
Definition: speed_features.h:350
MV_PREC_LOGIC high_precision_mv_usage
Definition: speed_features.h:369
int disable_extra_sc_testing
Definition: speed_features.h:388
int recode_tolerance
Definition: speed_features.h:361
SUPERRES_AUTO_SEARCH_TYPE superres_auto_search_type
Definition: speed_features.h:383
int static_segmentation
Definition: speed_features.h:378
RECODE_LOOP_TYPE recode_loop
Definition: speed_features.h:355
Top level speed vs quality trade off data struture.
Definition: speed_features.h:1388
MV_SPEED_FEATURES mv_sf
Definition: speed_features.h:1417
TPL_SPEED_FEATURES tpl_sf
Definition: speed_features.h:1402
LOOP_FILTER_SPEED_FEATURES lpf_sf
Definition: speed_features.h:1452
TX_SPEED_FEATURES tx_sf
Definition: speed_features.h:1437
INTER_MODE_SPEED_FEATURES inter_sf
Definition: speed_features.h:1422
RD_CALC_SPEED_FEATURES rd_sf
Definition: speed_features.h:1442
PARTITION_SPEED_FEATURES part_sf
Definition: speed_features.h:1412
GLOBAL_MOTION_SPEED_FEATURES gm_sf
Definition: speed_features.h:1407
INTERP_FILTER_SPEED_FEATURES interp_sf
Definition: speed_features.h:1427
FIRST_PASS_SPEED_FEATURES fp_sf
Definition: speed_features.h:1397
INTRA_MODE_SPEED_FEATURES intra_sf
Definition: speed_features.h:1432
WINNER_MODE_SPEED_FEATURES winner_mode_sf
Definition: speed_features.h:1447
REAL_TIME_SPEED_FEATURES rt_sf
Definition: speed_features.h:1457
HIGH_LEVEL_SPEED_FEATURES hl_sf
Definition: speed_features.h:1392