xref: /aosp_15_r20/external/libvpx/vp9/encoder/vp9_speed_features.h (revision fb1b10ab9aebc7c7068eedab379b749d7e3900be)
1 /*
2  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef VPX_VP9_ENCODER_VP9_SPEED_FEATURES_H_
12 #define VPX_VP9_ENCODER_VP9_SPEED_FEATURES_H_
13 
14 #include "vp9/common/vp9_enums.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 enum {
21   INTRA_ALL = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << D45_PRED) |
22               (1 << D135_PRED) | (1 << D117_PRED) | (1 << D153_PRED) |
23               (1 << D207_PRED) | (1 << D63_PRED) | (1 << TM_PRED),
24   INTRA_DC = (1 << DC_PRED),
25   INTRA_DC_TM = (1 << DC_PRED) | (1 << TM_PRED),
26   INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED),
27   INTRA_DC_TM_H_V =
28       (1 << DC_PRED) | (1 << TM_PRED) | (1 << V_PRED) | (1 << H_PRED)
29 };
30 
31 enum {
32   INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV) | (1 << NEWMV),
33   INTER_NEAREST = (1 << NEARESTMV),
34   INTER_NEAREST_NEW = (1 << NEARESTMV) | (1 << NEWMV),
35   INTER_NEAREST_ZERO = (1 << NEARESTMV) | (1 << ZEROMV),
36   INTER_NEAREST_NEW_ZERO = (1 << NEARESTMV) | (1 << ZEROMV) | (1 << NEWMV),
37   INTER_NEAREST_NEAR_NEW = (1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV),
38   INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << ZEROMV),
39 };
40 
41 enum {
42   DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) |
43                             (1 << THR_ALTR) | (1 << THR_GOLD) | (1 << THR_LAST),
44 
45   DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT,
46 
47   DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA),
48 
49   LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) |
50                               (1 << THR_ALTR) | (1 << THR_GOLD)
51 };
52 
53 typedef enum {
54   DIAMOND = 0,
55   NSTEP = 1,
56   HEX = 2,
57   BIGDIA = 3,
58   SQUARE = 4,
59   FAST_HEX = 5,
60   FAST_DIAMOND = 6,
61   MESH = 7
62 } SEARCH_METHODS;
63 
64 typedef enum {
65   // No recode.
66   DISALLOW_RECODE = 0,
67   // Allow recode for KF and exceeding maximum frame bandwidth.
68   ALLOW_RECODE_KFMAXBW = 1,
69   // Allow recode only for KF/ARF/GF frames.
70   ALLOW_RECODE_KFARFGF = 2,
71   // Allow recode for ARF/GF/KF and first normal frame in each group.
72   ALLOW_RECODE_FIRST = 3,
73   // Allow recode for all frames based on bitrate constraints.
74   ALLOW_RECODE = 4,
75 } RECODE_LOOP_TYPE;
76 
77 typedef enum {
78   SUBPEL_TREE = 0,
79   SUBPEL_TREE_PRUNED = 1,           // Prunes 1/2-pel searches
80   SUBPEL_TREE_PRUNED_MORE = 2,      // Prunes 1/2-pel searches more aggressively
81   SUBPEL_TREE_PRUNED_EVENMORE = 3,  // Prunes 1/2- and 1/4-pel searches
82   // Other methods to come
83 } SUBPEL_SEARCH_METHODS;
84 
85 typedef enum {
86   NO_MOTION_THRESHOLD = 0,
87   LOW_MOTION_THRESHOLD = 7
88 } MOTION_THRESHOLD;
89 
90 typedef enum {
91   USE_FULL_RD = 0,
92   USE_LARGESTALL,
93   USE_TX_8X8
94 } TX_SIZE_SEARCH_METHOD;
95 
96 typedef enum {
97   NOT_IN_USE = 0,
98   RELAXED_NEIGHBORING_MIN_MAX = 1,
99   STRICT_NEIGHBORING_MIN_MAX = 2
100 } AUTO_MIN_MAX_MODE;
101 
102 typedef enum {
103   // Try the full image with different values.
104   LPF_PICK_FROM_FULL_IMAGE,
105   // Try a small portion of the image with different values.
106   LPF_PICK_FROM_SUBIMAGE,
107   // Estimate the level based on quantizer and frame type
108   LPF_PICK_FROM_Q,
109   // Pick 0 to disable LPF if LPF was enabled last frame
110   LPF_PICK_MINIMAL_LPF
111 } LPF_PICK_METHOD;
112 
113 typedef enum {
114   // Terminate search early based on distortion so far compared to
115   // qp step, distortion in the neighborhood of the frame, etc.
116   FLAG_EARLY_TERMINATE = 1 << 0,
117 
118   // Skips comp inter modes if the best so far is an intra mode.
119   FLAG_SKIP_COMP_BESTINTRA = 1 << 1,
120 
121   // Skips oblique intra modes if the best so far is an inter mode.
122   FLAG_SKIP_INTRA_BESTINTER = 1 << 3,
123 
124   // Skips oblique intra modes  at angles 27, 63, 117, 153 if the best
125   // intra so far is not one of the neighboring directions.
126   FLAG_SKIP_INTRA_DIRMISMATCH = 1 << 4,
127 
128   // Skips intra modes other than DC_PRED if the source variance is small
129   FLAG_SKIP_INTRA_LOWVAR = 1 << 5,
130 } MODE_SEARCH_SKIP_LOGIC;
131 
132 typedef enum {
133   FLAG_SKIP_EIGHTTAP = 1 << EIGHTTAP,
134   FLAG_SKIP_EIGHTTAP_SMOOTH = 1 << EIGHTTAP_SMOOTH,
135   FLAG_SKIP_EIGHTTAP_SHARP = 1 << EIGHTTAP_SHARP,
136 } INTERP_FILTER_MASK;
137 
138 typedef enum {
139   // Search partitions using RD/NONRD criterion.
140   SEARCH_PARTITION,
141 
142   // Always use a fixed size partition.
143   FIXED_PARTITION,
144 
145   REFERENCE_PARTITION,
146 
147   // Use an arbitrary partitioning scheme based on source variance within
148   // a 64X64 SB.
149   VAR_BASED_PARTITION,
150 
151   // Use non-fixed partitions based on source variance.
152   SOURCE_VAR_BASED_PARTITION,
153 
154   // Make partition decisions with machine learning models.
155   ML_BASED_PARTITION
156 } PARTITION_SEARCH_TYPE;
157 
158 typedef enum {
159   // Does a dry run to see if any of the contexts need to be updated or not,
160   // before the final run.
161   TWO_LOOP = 0,
162 
163   // No dry run, also only half the coef contexts and bands are updated.
164   // The rest are not updated at all.
165   ONE_LOOP_REDUCED = 1
166 } FAST_COEFF_UPDATE;
167 
168 typedef enum { EIGHTH_PEL, QUARTER_PEL, HALF_PEL, FULL_PEL } SUBPEL_FORCE_STOP;
169 
170 typedef struct ADAPT_SUBPEL_FORCE_STOP {
171   // Threshold for full pixel motion vector;
172   int mv_thresh;
173 
174   // subpel_force_stop if full pixel MV is below the threshold.
175   SUBPEL_FORCE_STOP force_stop_below;
176 
177   // subpel_force_stop if full pixel MV is equal to or above the threshold.
178   SUBPEL_FORCE_STOP force_stop_above;
179 } ADAPT_SUBPEL_FORCE_STOP;
180 
181 typedef struct MV_SPEED_FEATURES {
182   // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc).
183   SEARCH_METHODS search_method;
184 
185   // This parameter controls which step in the n-step process we start at.
186   // It's changed adaptively based on circumstances.
187   int reduce_first_step_size;
188 
189   // If this is set to 1, we limit the motion search range to 2 times the
190   // largest motion vector found in the last frame.
191   int auto_mv_step_size;
192 
193   // Subpel_search_method can only be subpel_tree which does a subpixel
194   // logarithmic search that keeps stepping at 1/2 pixel units until
195   // you stop getting a gain, and then goes on to 1/4 and repeats
196   // the same process. Along the way it skips many diagonals.
197   SUBPEL_SEARCH_METHODS subpel_search_method;
198 
199   // Subpel MV search level. Can take values 0 - 2. Higher values mean more
200   // extensive subpel search.
201   int subpel_search_level;
202 
203   // When to stop subpel motion search.
204   SUBPEL_FORCE_STOP subpel_force_stop;
205 
206   // If it's enabled, different subpel_force_stop will be used for different MV.
207   int enable_adaptive_subpel_force_stop;
208 
209   ADAPT_SUBPEL_FORCE_STOP adapt_subpel_force_stop;
210 
211   // This variable sets the step_param used in full pel motion search.
212   int fullpel_search_step_param;
213 
214   // Whether to downsample the rows in sad calculation during motion search.
215   // This is only active when there are at least 8 rows.
216   int use_downsampled_sad;
217 } MV_SPEED_FEATURES;
218 
219 typedef struct PARTITION_SEARCH_BREAKOUT_THR {
220   int64_t dist;
221   int rate;
222 } PARTITION_SEARCH_BREAKOUT_THR;
223 
224 #define MAX_MESH_STEP 4
225 
226 typedef struct MESH_PATTERN {
227   int range;
228   int interval;
229 } MESH_PATTERN;
230 
231 typedef enum {
232   // No reaction to rate control on a detected slide/scene change.
233   NO_DETECTION = 0,
234 
235   // Set to larger Q (max_q set by user) based only on the
236   // detected slide/scene change and current/past Q.
237   FAST_DETECTION_MAXQ = 1,
238 
239   // Based on (first pass) encoded frame, if large frame size is detected
240   // then set to higher Q for the second re-encode. This involves 2 pass
241   // encoding on slide change, so slower than 1, but more accurate for
242   // detecting overshoot.
243   RE_ENCODE_MAXQ = 2
244 } OVERSHOOT_DETECTION_CBR_RT;
245 
246 typedef enum {
247   USE_2_TAPS = 0,
248   USE_4_TAPS,
249   USE_8_TAPS,
250   USE_8_TAPS_SHARP,
251 } SUBPEL_SEARCH_TYPE;
252 
253 typedef enum {
254   // Disable trellis coefficient optimization
255   DISABLE_TRELLIS_OPT,
256   // Enable trellis coefficient optimization
257   ENABLE_TRELLIS_OPT,
258   // Enable trellis coefficient optimization based on source variance of the
259   // prediction block during transform RD
260   ENABLE_TRELLIS_OPT_TX_RD_SRC_VAR,
261   // Enable trellis coefficient optimization based on residual mse of the
262   // transform block during transform RD
263   ENABLE_TRELLIS_OPT_TX_RD_RESIDUAL_MSE,
264 } ENABLE_TRELLIS_OPT_METHOD;
265 
266 typedef struct TRELLIS_OPT_CONTROL {
267   ENABLE_TRELLIS_OPT_METHOD method;
268   double thresh;
269 } TRELLIS_OPT_CONTROL;
270 
271 typedef struct SPEED_FEATURES {
272   MV_SPEED_FEATURES mv;
273 
274   // Frame level coding parameter update
275   int frame_parameter_update;
276 
277   RECODE_LOOP_TYPE recode_loop;
278 
279   // Trellis (dynamic programming) optimization of quantized values (+1, 0).
280   int optimize_coefficients;
281 
282   // Always set to 0. If on it enables 0 cost background transmission
283   // (except for the initial transmission of the segmentation). The feature is
284   // disabled because the addition of very large block sizes make the
285   // backgrounds very to cheap to encode, and the segmentation we have
286   // adds overhead.
287   int static_segmentation;
288 
289   // The best compound predictor is found using an iterative log search process
290   // that searches for best ref0 mv using error of combined predictor and then
291   // searches for best ref1 mv. This sf determines the number of iterations of
292   // this process based on block size. The sf becomes more aggressive from level
293   // 0 to 2. The following table indicates the number of iterations w.r.t bsize:
294   //  -----------------------------------------------
295   // |sf (level)|bsize < 8X8| [8X8, 16X16] | > 16X16 |
296   // |    0     |     4     |      4       |    4    |
297   // |    1     |     0     |      2       |    4    |
298   // |    2     |     0     |      0       |    0    |
299   //  -----------------------------------------------
300   // Here, 0 iterations indicate using the best single motion vector selected
301   // for each ref frame without any iterative refinement.
302   int comp_inter_joint_search_iter_level;
303 
304   // This variable is used to cap the maximum number of times we skip testing a
305   // mode to be evaluated. A high value means we will be faster.
306   // Turned off when (row_mt_bit_exact == 1 && adaptive_rd_thresh_row_mt == 0).
307   int adaptive_rd_thresh;
308 
309   // Flag to use adaptive_rd_thresh when row-mt is enabled, only for non-rd
310   // pickmode.
311   int adaptive_rd_thresh_row_mt;
312 
313   // Enables skipping the reconstruction step (idct, recon) in the
314   // intermediate steps assuming the last frame didn't have too many intra
315   // blocks and the q is less than a threshold.
316   int skip_encode_sb;
317   int skip_encode_frame;
318   // Speed feature to allow or disallow skipping of recode at block
319   // level within a frame.
320   int allow_skip_recode;
321 
322   // Coefficient probability model approximation step size
323   int coeff_prob_appx_step;
324 
325   // Enable uniform quantizer followed by trellis coefficient optimization
326   // during transform RD
327   TRELLIS_OPT_CONTROL trellis_opt_tx_rd;
328 
329   // Enable asymptotic closed-loop encoding decision for key frame and
330   // alternate reference frames.
331   int allow_acl;
332 
333   // Temporal dependency model based encoding mode optimization
334   int enable_tpl_model;
335 
336   // Use transform domain distortion. Use pixel domain distortion in speed 0
337   // and certain situations in higher speed to improve the RD model precision.
338   int allow_txfm_domain_distortion;
339   double tx_domain_thresh;
340 
341   // The threshold is to determine how slow the motino is, it is used when
342   // use_lastframe_partitioning is set to LAST_FRAME_PARTITION_LOW_MOTION
343   MOTION_THRESHOLD lf_motion_threshold;
344 
345   // Determine which method we use to determine transform size. We can choose
346   // between options like full rd, largest for prediction size, largest
347   // for intra and model coefs for the rest.
348   TX_SIZE_SEARCH_METHOD tx_size_search_method;
349 
350   // How many levels of tx size to search, starting from the largest.
351   int tx_size_search_depth;
352 
353   // Low precision 32x32 fdct keeps everything in 16 bits and thus is less
354   // precise but significantly faster than the non lp version.
355   int use_lp32x32fdct;
356 
357   // After looking at the first set of modes (set by index here), skip
358   // checking modes for reference frames that don't match the reference frame
359   // of the best so far.
360   int mode_skip_start;
361 
362   // TODO(JBB): Remove this.
363   int reference_masking;
364 
365   PARTITION_SEARCH_TYPE partition_search_type;
366 
367   // Used if partition_search_type = FIXED_PARTITION
368   BLOCK_SIZE always_this_block_size;
369 
370   // Skip rectangular partition test when partition type none gives better
371   // rd than partition type split.
372   int less_rectangular_check;
373 
374   // Disable testing non square partitions(eg 16x32) for block sizes larger than
375   // use_square_only_thresh_high or smaller than use_square_only_thresh_low.
376   int use_square_partition_only;
377   BLOCK_SIZE use_square_only_thresh_high;
378   BLOCK_SIZE use_square_only_thresh_low;
379 
380   // Prune reference frames for rectangular partitions.
381   int prune_ref_frame_for_rect_partitions;
382 
383   // Sets min and max partition sizes for this 64x64 region based on the
384   // same 64x64 in last encoded frame, and the left and above neighbor.
385   AUTO_MIN_MAX_MODE auto_min_max_partition_size;
386   // Ensures the rd based auto partition search will always
387   // go down at least to the specified level.
388   BLOCK_SIZE rd_auto_partition_min_limit;
389 
390   // Min and max partition size we enable (block_size) as per auto
391   // min max, but also used by adjust partitioning, and pick_partitioning.
392   BLOCK_SIZE default_min_partition_size;
393   BLOCK_SIZE default_max_partition_size;
394 
395   // Whether or not we allow partitions one smaller or one greater than the last
396   // frame's partitioning. Only used if use_lastframe_partitioning is set.
397   int adjust_partitioning_from_last_frame;
398 
399   // How frequently we re do the partitioning from scratch. Only used if
400   // use_lastframe_partitioning is set.
401   int last_partitioning_redo_frequency;
402 
403   // Disables sub 8x8 blocksizes in different scenarios: Choices are to disable
404   // it always, to allow it for only Last frame and Intra, disable it for all
405   // inter modes or to enable it always.
406   int disable_split_mask;
407 
408   // TODO(jingning): combine the related motion search speed features
409   // This allows us to use motion search at other sizes as a starting
410   // point for this motion search and limits the search range around it.
411   int adaptive_motion_search;
412 
413   // Do extra full pixel motion search to obtain better motion vector.
414   int enhanced_full_pixel_motion_search;
415 
416   // Threshold for allowing exhaistive motion search.
417   int exhaustive_searches_thresh;
418 
419   // Pattern to be used for any exhaustive mesh searches.
420   MESH_PATTERN mesh_patterns[MAX_MESH_STEP];
421 
422   int schedule_mode_search;
423 
424   // Allows sub 8x8 modes to use the prediction filter that was determined
425   // best for 8x8 mode. If set to 0 we always re check all the filters for
426   // sizes less than 8x8, 1 means we check all filter modes if no 8x8 filter
427   // was selected, and 2 means we use 8 tap if no 8x8 filter mode was selected.
428   int adaptive_pred_interp_filter;
429 
430   // Adaptive prediction mode search
431   int adaptive_mode_search;
432 
433   // Prune NEAREST and ZEROMV single reference modes based on motion vector
434   // difference and mode rate
435   int prune_single_mode_based_on_mv_diff_mode_rate;
436 
437   // Chessboard pattern prediction for interp filter. Aggressiveness increases
438   // with levels.
439   // 0: disable
440   // 1: cb pattern in eval when filter is not switchable
441   // 2: cb pattern prediction for filter search
442   int cb_pred_filter_search;
443 
444   // This variable enables an early termination of interpolation filter eval
445   // based on the current rd cost after processing each plane
446   int early_term_interp_search_plane_rd;
447 
448   int cb_partition_search;
449 
450   int motion_field_mode_search;
451 
452   int alt_ref_search_fp;
453 
454   // Fast quantization process path
455   int use_quant_fp;
456 
457   // Use finer quantizer in every other few frames that run variable block
458   // partition type search.
459   int force_frame_boost;
460 
461   // Maximally allowed base quantization index fluctuation.
462   int max_delta_qindex;
463 
464   // Implements various heuristics to skip searching modes
465   // The heuristics selected are based on  flags
466   // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
467   unsigned int mode_search_skip_flags;
468 
469   // A source variance threshold below which filter search is disabled
470   // Choose a very large value (UINT_MAX) to use 8-tap always
471   unsigned int disable_filter_search_var_thresh;
472 
473   // These bit masks allow you to enable or disable intra modes for each
474   // transform size separately.
475   int intra_y_mode_mask[TX_SIZES];
476   int intra_uv_mode_mask[TX_SIZES];
477 
478   // These bit masks allow you to enable or disable intra modes for each
479   // prediction block size separately.
480   int intra_y_mode_bsize_mask[BLOCK_SIZES];
481 
482   // This variable enables an early break out of mode testing if the model for
483   // rd built from the prediction signal indicates a value that's much
484   // higher than the best rd we've seen so far.
485   int use_rd_breakout;
486 
487   // This enables us to use an estimate for intra rd based on dc mode rather
488   // than choosing an actual uv mode in the stage of encoding before the actual
489   // final encode.
490   int use_uv_intra_rd_estimate;
491 
492   // This feature controls how the loop filter level is determined.
493   LPF_PICK_METHOD lpf_pick;
494 
495   // This feature limits the number of coefficients updates we actually do
496   // by only looking at counts from 1/2 the bands.
497   FAST_COEFF_UPDATE use_fast_coef_updates;
498 
499   // This flag controls the use of non-RD mode decision.
500   int use_nonrd_pick_mode;
501 
502   // A binary mask indicating if NEARESTMV, NEARMV, ZEROMV, NEWMV
503   // modes are used in order from LSB to MSB for each BLOCK_SIZE.
504   int inter_mode_mask[BLOCK_SIZES];
505 
506   // This feature controls whether we do the expensive context update and
507   // calculation in the rd coefficient costing loop.
508   int use_fast_coef_costing;
509 
510   // This feature controls the tolerence vs target used in deciding whether to
511   // recode a frame. It has no meaning if recode is disabled.
512   int recode_tolerance_low;
513   int recode_tolerance_high;
514 
515   // This variable controls the maximum block size where intra blocks can be
516   // used in inter frames.
517   // TODO(aconverse): Fold this into one of the other many mode skips
518   BLOCK_SIZE max_intra_bsize;
519 
520   // The frequency that we check if SOURCE_VAR_BASED_PARTITION or
521   // FIXED_PARTITION search type should be used.
522   int search_type_check_frequency;
523 
524   // When partition is pre-set, the inter prediction result from pick_inter_mode
525   // can be reused in final block encoding process. It is enabled only for real-
526   // time mode speed 6.
527   int reuse_inter_pred_sby;
528 
529   // This variable sets the encode_breakout threshold. Currently, it is only
530   // enabled in real time mode.
531   int encode_breakout_thresh;
532 
533   // default interp filter choice
534   INTERP_FILTER default_interp_filter;
535 
536   // Early termination in transform size search, which only applies while
537   // tx_size_search_method is USE_FULL_RD.
538   int tx_size_search_breakout;
539 
540   // adaptive interp_filter search to allow skip of certain filter types.
541   int adaptive_interp_filter_search;
542 
543   // mask for skip evaluation of certain interp_filter type.
544   INTERP_FILTER_MASK interp_filter_search_mask;
545 
546   // Partition search early breakout thresholds.
547   PARTITION_SEARCH_BREAKOUT_THR partition_search_breakout_thr;
548 
549   struct {
550     // Use ML-based partition search early breakout.
551     int search_breakout;
552     // Higher values mean more aggressiveness for partition search breakout that
553     // results in better encoding  speed but worse compression performance.
554     float search_breakout_thresh[3];
555 
556     // Machine-learning based partition search early termination
557     int search_early_termination;
558 
559     // Machine-learning based partition search pruning using prediction residue
560     // variance.
561     int var_pruning;
562 
563     // Threshold values used for ML based rectangular partition search pruning.
564     // If < 0, the feature is turned off.
565     // Higher values mean more aggressiveness to skip rectangular partition
566     // search that results in better encoding speed but worse coding
567     // performance.
568     int prune_rect_thresh[4];
569   } rd_ml_partition;
570 
571   // Fast approximation of vp9_model_rd_from_var_lapndz
572   int simple_model_rd_from_var;
573 
574   // Skip a number of expensive mode evaluations for blocks with zero source
575   // variance.
576   int short_circuit_flat_blocks;
577 
578   // Skip a number of expensive mode evaluations for blocks with very low
579   // temporal variance. If the low temporal variance flag is set for a block,
580   // do the following:
581   // 1: Skip all golden modes and ALL INTRA for bsize >= 32x32.
582   // 2: Skip golden non-zeromv and newmv-last for bsize >= 16x16, skip ALL
583   // INTRA for bsize >= 32x32 and vert/horz INTRA for bsize 16x16, 16x32 and
584   // 32x16.
585   // 3: Same as (2), but also skip golden zeromv.
586   int short_circuit_low_temp_var;
587 
588   // Limits the rd-threshold update for early exit for the newmv-last mode,
589   // for non-rd mode.
590   int limit_newmv_early_exit;
591 
592   // Adds a bias against golden reference, for non-rd mode.
593   int bias_golden;
594 
595   // Bias to use base mv and skip 1/4 subpel search when use base mv in
596   // enhancement layer.
597   int base_mv_aggressive;
598 
599   // Global flag to enable partition copy from the previous frame.
600   int copy_partition_flag;
601 
602   // Compute the source sad for every superblock of the frame,
603   // prior to encoding the frame, to be used to bypass some encoder decisions.
604   int use_source_sad;
605 
606   int use_simple_block_yrd;
607 
608   // If source sad of superblock is high (> adapt_partition_thresh), will switch
609   // from VARIANCE_PARTITION to REFERENCE_PARTITION (which selects partition
610   // based on the nonrd-pickmode).
611   int adapt_partition_source_sad;
612   int adapt_partition_thresh;
613 
614   // Enable use of alt-refs in 1 pass VBR.
615   int use_altref_onepass;
616 
617   // Enable use of compound prediction, for nonrd_pickmode with nonzero lag.
618   int use_compound_nonrd_pickmode;
619 
620   // Always use nonrd_pick_intra for all block sizes on keyframes.
621   int nonrd_keyframe;
622 
623   // For SVC: enables use of partition from lower spatial resolution.
624   int svc_use_lowres_part;
625 
626   // Flag to indicate process for handling overshoot on slide/scene change,
627   // for real-time CBR mode.
628   OVERSHOOT_DETECTION_CBR_RT overshoot_detection_cbr_rt;
629 
630   // Disable partitioning of 16x16 blocks.
631   int disable_16x16part_nonkey;
632 
633   // Allow for disabling golden reference.
634   int disable_golden_ref;
635 
636   // Allow sub-pixel search to use interpolation filters with different taps in
637   // order to achieve accurate motion search result.
638   SUBPEL_SEARCH_TYPE use_accurate_subpel_search;
639 
640   // Search method used by temporal filtering in full_pixel_motion_search.
641   SEARCH_METHODS temporal_filter_search_method;
642 
643   // Use machine learning based partition search.
644   int nonrd_use_ml_partition;
645 
646   // Multiplier for base threshold for variance partitioning.
647   int variance_part_thresh_mult;
648 
649   // Force subpel motion filter to always use SMOOTH_FILTER.
650   int force_smooth_interpol;
651 
652   // For real-time mode: force DC only under intra search when content
653   // does not have high souce SAD.
654   int rt_intra_dc_only_low_content;
655 
656   // The encoder has a feature that skips forward transform and quantization
657   // based on a model rd estimation to reduce encoding time.
658   // However, this feature is dangerous since it could lead to bad perceptual
659   // quality. This flag is added to guard the feature.
660   int allow_skip_txfm_ac_dc;
661 } SPEED_FEATURES;
662 
663 struct VP9_COMP;
664 
665 void vp9_set_speed_features_framesize_independent(struct VP9_COMP *cpi,
666                                                   int speed);
667 void vp9_set_speed_features_framesize_dependent(struct VP9_COMP *cpi,
668                                                 int speed);
669 
670 #ifdef __cplusplus
671 }  // extern "C"
672 #endif
673 
674 #endif  // VPX_VP9_ENCODER_VP9_SPEED_FEATURES_H_
675