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