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
21extern "C" {
22#endif
23
27#define MAX_MESH_STEP 4
28
29typedef struct MESH_PATTERN {
30 int range;
31 int interval;
32} MESH_PATTERN;
33
34enum {
35 GM_FULL_SEARCH,
36 GM_REDUCED_REF_SEARCH_SKIP_L2_L3,
37 GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2,
38 GM_DISABLE_SEARCH
39} UENUM1BYTE(GM_SEARCH_TYPE);
40
41enum {
42 DIST_WTD_COMP_ENABLED,
43 DIST_WTD_COMP_SKIP_MV_SEARCH,
44 DIST_WTD_COMP_DISABLED,
45} UENUM1BYTE(DIST_WTD_COMP_FLAG);
46
47enum {
48 INTRA_ALL = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << D45_PRED) |
49 (1 << D135_PRED) | (1 << D113_PRED) | (1 << D157_PRED) |
50 (1 << D203_PRED) | (1 << D67_PRED) | (1 << SMOOTH_PRED) |
51 (1 << SMOOTH_V_PRED) | (1 << SMOOTH_H_PRED) | (1 << PAETH_PRED),
52 UV_INTRA_ALL =
53 (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED) |
54 (1 << UV_D45_PRED) | (1 << UV_D135_PRED) | (1 << UV_D113_PRED) |
55 (1 << UV_D157_PRED) | (1 << UV_D203_PRED) | (1 << UV_D67_PRED) |
56 (1 << UV_SMOOTH_PRED) | (1 << UV_SMOOTH_V_PRED) |
57 (1 << UV_SMOOTH_H_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED),
58 UV_INTRA_DC = (1 << UV_DC_PRED),
59 UV_INTRA_DC_CFL = (1 << UV_DC_PRED) | (1 << UV_CFL_PRED),
60 UV_INTRA_DC_TM = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED),
61 UV_INTRA_DC_PAETH_CFL =
62 (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED),
63 UV_INTRA_DC_H_V = (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED),
64 UV_INTRA_DC_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_V_PRED) |
65 (1 << UV_H_PRED) | (1 << UV_CFL_PRED),
66 UV_INTRA_DC_PAETH_H_V = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) |
67 (1 << UV_V_PRED) | (1 << UV_H_PRED),
68 UV_INTRA_DC_PAETH_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) |
69 (1 << UV_V_PRED) | (1 << UV_H_PRED) |
70 (1 << UV_CFL_PRED),
71 INTRA_DC = (1 << DC_PRED),
72 INTRA_DC_TM = (1 << DC_PRED) | (1 << PAETH_PRED),
73 INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED),
74 INTRA_DC_H_V_SMOOTH =
75 (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << SMOOTH_PRED),
76 INTRA_DC_PAETH_H_V =
77 (1 << DC_PRED) | (1 << PAETH_PRED) | (1 << V_PRED) | (1 << H_PRED)
78};
79
80enum {
81 INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) |
82 (1 << NEWMV) | (1 << NEAREST_NEARESTMV) | (1 << NEAR_NEARMV) |
83 (1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) | (1 << NEAR_NEWMV) |
84 (1 << NEW_NEARMV) | (1 << NEW_NEARESTMV) | (1 << GLOBAL_GLOBALMV),
85 INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) |
86 (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
87 (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) |
88 (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) |
89 (1 << NEAR_NEARMV),
90};
91
92enum {
93 DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) |
94 (1 << THR_ALTR) | (1 << THR_GOLD) | (1 << THR_LAST),
95
96 DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT,
97
98 DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA),
99
100 LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) |
101 (1 << THR_ALTR) | (1 << THR_GOLD)
102};
103
104enum {
105 TXFM_CODING_SF = 1,
106 INTER_PRED_SF = 2,
107 INTRA_PRED_SF = 4,
108 PARTITION_SF = 8,
109 LOOP_FILTER_SF = 16,
110 RD_SKIP_SF = 32,
111 RESERVE_2_SF = 64,
112 RESERVE_3_SF = 128,
113} UENUM1BYTE(DEV_SPEED_FEATURES);
114
115/* This enumeration defines when the rate control recode loop will be
116 * enabled.
117 */
118enum {
119 /*
120 * No recodes allowed
121 */
122 DISALLOW_RECODE = 0,
123 /*
124 * Allow recode only for KF/ARF/GF frames
125 */
126 ALLOW_RECODE_KFARFGF = 1,
127 /*
128 * Allow recode for all frame types based on bitrate constraints.
129 */
130 ALLOW_RECODE = 2,
131} UENUM1BYTE(RECODE_LOOP_TYPE);
132
133enum {
134 SUBPEL_TREE = 0,
135 SUBPEL_TREE_PRUNED = 1, // Prunes 1/2-pel searches
136 SUBPEL_TREE_PRUNED_MORE = 2, // Prunes 1/2-pel searches more aggressively
137} UENUM1BYTE(SUBPEL_SEARCH_METHODS);
138
139enum {
140 // Try the full image with different values.
141 LPF_PICK_FROM_FULL_IMAGE,
142 // Try the full image filter search with non-dual filter only.
143 LPF_PICK_FROM_FULL_IMAGE_NON_DUAL,
144 // Try a small portion of the image with different values.
145 LPF_PICK_FROM_SUBIMAGE,
146 // Estimate the level based on quantizer and frame type
147 LPF_PICK_FROM_Q,
148 // Pick 0 to disable LPF if LPF was enabled last frame
149 LPF_PICK_MINIMAL_LPF
150} UENUM1BYTE(LPF_PICK_METHOD);
156typedef enum {
164 CDEF_PICK_METHODS
166
168enum {
169 // Terminate search early based on distortion so far compared to
170 // qp step, distortion in the neighborhood of the frame, etc.
171 FLAG_EARLY_TERMINATE = 1 << 0,
172
173 // Skips comp inter modes if the best so far is an intra mode.
174 FLAG_SKIP_COMP_BESTINTRA = 1 << 1,
175
176 // Skips oblique intra modes if the best so far is an inter mode.
177 FLAG_SKIP_INTRA_BESTINTER = 1 << 3,
178
179 // Skips oblique intra modes at angles 27, 63, 117, 153 if the best
180 // intra so far is not one of the neighboring directions.
181 FLAG_SKIP_INTRA_DIRMISMATCH = 1 << 4,
182
183 // Skips intra modes other than DC_PRED if the source variance is small
184 FLAG_SKIP_INTRA_LOWVAR = 1 << 5,
185} UENUM1BYTE(MODE_SEARCH_SKIP_LOGIC);
186
187enum {
188 // No tx type pruning
189 TX_TYPE_PRUNE_0 = 0,
190 // adaptively prunes the least perspective tx types out of all 16
191 // (tuned to provide negligible quality loss)
192 TX_TYPE_PRUNE_1 = 1,
193 // similar, but applies much more aggressive pruning to get better speed-up
194 TX_TYPE_PRUNE_2 = 2,
195 TX_TYPE_PRUNE_3 = 3,
196 // More aggressive pruning based on tx type score and allowed tx count
197 TX_TYPE_PRUNE_4 = 4,
198 TX_TYPE_PRUNE_5 = 5,
199} UENUM1BYTE(TX_TYPE_PRUNE_MODE);
200
201enum {
202 // No reaction to rate control on a detected slide/scene change.
203 NO_DETECTION = 0,
204
205 // Set to larger Q based only on the detected slide/scene change and
206 // current/past Q.
207 FAST_DETECTION_MAXQ = 1,
208} UENUM1BYTE(OVERSHOOT_DETECTION_CBR);
209
210enum {
211 // Turns off multi-winner mode. So we will do txfm search on either all modes
212 // if winner mode is off, or we will only on txfm search on a single winner
213 // mode.
214 MULTI_WINNER_MODE_OFF = 0,
215
216 // Limits the number of winner modes to at most 2
217 MULTI_WINNER_MODE_FAST = 1,
218
219 // Uses the default number of winner modes, which is 3 for intra mode, and 1
220 // for inter mode.
221 MULTI_WINNER_MODE_DEFAULT = 2,
222} UENUM1BYTE(MULTI_WINNER_MODE_TYPE);
223
224typedef struct {
225 TX_TYPE_PRUNE_MODE prune_2d_txfm_mode;
226 int fast_intra_tx_type_search;
227 int fast_inter_tx_type_search;
228
229 // Prune less likely chosen transforms for each intra mode. The speed
230 // feature ranges from 0 to 2, for different speed / compression trade offs.
231 int use_reduced_intra_txset;
232
233 // Use a skip flag prediction model to detect blocks with skip = 1 early
234 // and avoid doing full TX type search for such blocks.
235 int use_skip_flag_prediction;
236
237 // Threshold used by the ML based method to predict TX block split decisions.
238 int ml_tx_split_thresh;
239
240 // skip remaining transform type search when we found the rdcost of skip is
241 // better than applying transform
242 int skip_tx_search;
243
244 // Prune tx type search using previous frame stats.
245 int prune_tx_type_using_stats;
246 // Prune tx type search using estimated RDcost
247 int prune_tx_type_est_rd;
248
249 // Flag used to control the winner mode processing for tx type pruning for
250 // inter blocks. It enables further tx type mode pruning based on ML model for
251 // mode evaluation and disables tx type mode pruning for winner mode
252 // processing.
253 int winner_mode_tx_type_pruning;
254} TX_TYPE_SEARCH;
255
256enum {
257 // Search partitions using RD criterion
258 SEARCH_PARTITION,
259
260 // Always use a fixed size partition
261 FIXED_PARTITION,
262
263 // Partition using source variance
264 VAR_BASED_PARTITION,
265
266#if CONFIG_RT_ML_PARTITIONING
267 // Partition using ML model
268 ML_BASED_PARTITION
269#endif
270} UENUM1BYTE(PARTITION_SEARCH_TYPE);
271
272enum {
273 NOT_IN_USE,
274 DIRECT_PRED,
275 RELAXED_PRED,
276 ADAPT_PRED
277} UENUM1BYTE(MAX_PART_PRED_MODE);
278
279enum {
280 LAST_MV_DATA,
281 CURRENT_Q,
282 QTR_ONLY,
283} UENUM1BYTE(MV_PREC_LOGIC);
284
285enum {
286 SUPERRES_AUTO_ALL, // Tries all possible superres ratios
287 SUPERRES_AUTO_DUAL, // Tries no superres and q-based superres ratios
288 SUPERRES_AUTO_SOLO, // Only apply the q-based superres ratio
289} UENUM1BYTE(SUPERRES_AUTO_SEARCH_TYPE);
300typedef enum {
306
312 // Frame level coding parameter update
313 int frame_parameter_update;
314
319 RECODE_LOOP_TYPE recode_loop;
320
326
328 // Determine how motion vector precision is chosen. The possibilities are:
329 // LAST_MV_DATA: use the mv data from the last coded frame
330 // CURRENT_Q: use the current q as a threshold
331 // QTR_ONLY: use quarter pel precision only.
332 MV_PREC_LOGIC high_precision_mv_usage;
333
334 // Always set to 0. If on it enables 0 cost background transmission
335 // (except for the initial transmission of the segmentation). The feature is
336 // disabled because the addition of very large block sizes make the
337 // backgrounds very to cheap to encode, and the segmentation we have
338 // adds overhead.
339 int static_segmentation;
340
344 SUPERRES_AUTO_SEARCH_TYPE superres_auto_search_type;
351
357
359typedef struct TPL_SPEED_FEATURES {
360 // Enable/disable GOP length adaptive decision.
361 int disable_gop_length_decision;
362 // Prune the intra modes search by tpl.
363 // If set to 0, we will search all intra modes from DC_PRED to PAETH_PRED.
364 // If set to 1, we only search DC_PRED, V_PRED, and H_PRED.
365 int prune_intra_modes;
366 // This parameter controls which step in the n-step process we start at.
367 int reduce_first_step_size;
368 // Skip motion estimation based on the precision of center MVs and the
369 // difference between center MVs.
370 // If set to 0, motion estimation is skipped for duplicate center MVs
371 // (default). If set to 1, motion estimation is skipped for duplicate
372 // full-pixel center MVs. If set to 2, motion estimation is skipped if the
373 // difference between center MVs is less than the threshold.
374 int skip_alike_starting_mv;
375
376 // When to stop subpel search.
377 SUBPEL_FORCE_STOP subpel_force_stop;
378
379 // Which search method to use.
380 SEARCH_METHODS search_method;
381
382 // Prune starting mvs in TPL based on sad scores.
383 int prune_starting_mv;
384
385 // Not run TPL for filtered Key frame.
386 int disable_filtered_key_tpl;
387
388 // Prune reference frames in TPL.
389 int prune_ref_frames_in_tpl;
390
391 // Support compound predictions.
392 int allow_compound_pred;
393
394 // Calculate rate and distortion based on Y plane only.
395 int use_y_only_rate_distortion;
396} TPL_SPEED_FEATURES;
397
398typedef struct GLOBAL_MOTION_SPEED_FEATURES {
399 GM_SEARCH_TYPE gm_search_type;
400
401 // During global motion estimation, prune remaining reference frames in a
402 // given direction(past/future), if the evaluated ref_frame in that direction
403 // yields gm_type as INVALID/TRANSLATION/IDENTITY
404 int prune_ref_frame_for_gm_search;
405} GLOBAL_MOTION_SPEED_FEATURES;
406
407typedef struct PARTITION_SPEED_FEATURES {
408 PARTITION_SEARCH_TYPE partition_search_type;
409
410 // Used if partition_search_type = FIXED_PARTITION
411 BLOCK_SIZE fixed_partition_size;
412
413 // Prune extended partition types search
414 // Can take values 0 - 2, 0 referring to no pruning, and 1 - 2 increasing
415 // aggressiveness of pruning in order.
416 int prune_ext_partition_types_search_level;
417
418 // Prune part4 based on block size
419 int prune_part4_search;
420
421 // Use a ML model to prune rectangular, ab and 4-way horz
422 // and vert partitions
423 int ml_prune_partition;
424
425 // Use a ML model to adaptively terminate partition search after trying
426 // PARTITION_SPLIT. Can take values 0 - 2, 0 meaning not being enabled, and
427 // 1 - 2 increasing aggressiveness in order.
428 int ml_early_term_after_part_split_level;
429
430 // Skip rectangular partition test when partition type none gives better
431 // rd than partition type split. Can take values 0 - 2, 0 referring to no
432 // skipping, and 1 - 2 increasing aggressiveness of skipping in order.
433 int less_rectangular_check_level;
434
435 // Use square partition only beyond this block size.
436 BLOCK_SIZE use_square_partition_only_threshold;
437
438 // Sets max square partition levels for this superblock based on
439 // motion vector and prediction error distribution produced from 16x16
440 // simple motion search
441 MAX_PART_PRED_MODE auto_max_partition_based_on_simple_motion;
442
443 // Min and max square partition size we enable (block_size) as per auto
444 // min max, but also used by adjust partitioning, and pick_partitioning.
445 BLOCK_SIZE default_min_partition_size;
446 BLOCK_SIZE default_max_partition_size;
447
448 // Sets level of adjustment of variance-based partitioning during
449 // rd_use_partition 0 - no partition adjustment, 1 - try to merge partitions
450 // for small blocks and high QP, 2 - always try to merge leaf partitions, 3 -
451 // try to merge and split leaf partitions
452 int adjust_var_based_rd_partitioning;
453
454 // Partition search early breakout thresholds.
455 int64_t partition_search_breakout_dist_thr;
456 int partition_search_breakout_rate_thr;
457
458 // Thresholds for ML based partition search breakout.
459 int ml_partition_search_breakout_thresh[PARTITION_BLOCK_SIZES];
460
461 // Allow skipping partition search for still image frame
462 int allow_partition_search_skip;
463
464 // The aggressiveness of pruning with simple_motion_search.
465 // Currently 0 is the lowest, and 2 the highest.
466 int simple_motion_search_prune_agg;
467
468 // Perform simple_motion_search on each possible subblock and use it to prune
469 // PARTITION_HORZ and PARTITION_VERT.
470 int simple_motion_search_prune_rect;
471
472 // Perform simple motion search before none_partition to decide if we
473 // want to remove all partitions other than PARTITION_SPLIT. If set to 0, this
474 // model is disabled. If set to 1, the model attempts to perform
475 // PARTITION_SPLIT only. If set to 2, the model also attempts to prune
476 // PARTITION_SPLIT.
477 int simple_motion_search_split;
478
479 // Use features from simple_motion_search to terminate prediction block
480 // partition after PARTITION_NONE
481 int simple_motion_search_early_term_none;
482
483 // Controls whether to reduce the number of motion search steps. If this is 0,
484 // then simple_motion_search has the same number of steps as
485 // single_motion_search (assuming no other speed features). Otherwise, reduce
486 // the number of steps by the value contained in this variable.
487 int simple_motion_search_reduce_search_steps;
488
489 // This variable controls the maximum block size where intra blocks can be
490 // used in inter frames.
491 // TODO(aconverse): Fold this into one of the other many mode skips
492 BLOCK_SIZE max_intra_bsize;
493
494 // Use CNN with luma pixels on source frame on each of the 64x64 subblock to
495 // perform split/no_split decision on intra-frames.
496 int intra_cnn_split;
497
498 // Disable extended partition search for lower block sizes.
499 int ext_partition_eval_thresh;
500
501 // prune extended partition search
502 // 0 : no pruning
503 // 1 : prune 1:4 partition search using winner info from split partitions
504 // 2 : prune 1:4 and AB partition search using split and HORZ/VERT info
505 int prune_ext_part_using_split_info;
506
507 // Prunt rectangular, AB and 4-way partition based on q index and block size
508 int prune_rectangular_split_based_on_qidx;
509
510 // Terminate partition search for child partition,
511 // when NONE and SPLIT partition rd_costs are INT64_MAX.
512 int early_term_after_none_split;
513
514 // Level used to adjust threshold for av1_ml_predict_breakout(). At lower
515 // levels, more conservative threshold is used, and value of 0 indicates
516 // av1_ml_predict_breakout() is disabled. Value of 3 corresponds to default
517 // case with no adjustment to lbd thresholds.
518 int ml_predict_breakout_level;
519
520 // Prune sub_8x8 (BLOCK_4X4, BLOCK_4X8 and BLOCK_8X4) partitions.
521 // 0 : no pruning
522 // 1 : pruning based on neighbour block information
523 // 2 : prune always
524 int prune_sub_8x8_partition_level;
525
526 // Prune rectangular split based on simple motion search split/no_split score.
527 // 0: disable pruning, 1: enable pruning
528 int simple_motion_search_rect_split;
529
530 // Reuse the best prediction modes found in PARTITION_SPLIT and PARTITION_RECT
531 // when encoding PARTITION_AB.
532 int reuse_best_prediction_for_part_ab;
533} PARTITION_SPEED_FEATURES;
534
535typedef struct MV_SPEED_FEATURES {
536 // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc).
537 SEARCH_METHODS search_method;
538
539 // Enable the use of faster, less accurate mv search method on bsize >=
540 // BLOCK_32X32.
541 // TODO(chiyotsai@google.com): Take the clip's resolution and mv activity into
542 // account.
543 int use_bsize_dependent_search_method;
544
545 // If this is set to 1, we limit the motion search range to 2 times the
546 // largest motion vector found in the last frame.
547 int auto_mv_step_size;
548
549 // Subpel_search_method can only be subpel_tree which does a subpixel
550 // logarithmic search that keeps stepping at 1/2 pixel units until
551 // you stop getting a gain, and then goes on to 1/4 and repeats
552 // the same process. Along the way it skips many diagonals.
553 SUBPEL_SEARCH_METHODS subpel_search_method;
554
555 // Maximum number of steps in logarithmic subpel search before giving up.
556 int subpel_iters_per_step;
557
558 // When to stop subpel search.
559 SUBPEL_FORCE_STOP subpel_force_stop;
560
561 // When to stop subpel search in simple motion search.
562 SUBPEL_FORCE_STOP simple_motion_subpel_force_stop;
563
564 // If true, sub-pixel search uses the exact convolve function used for final
565 // encoding and decoding; otherwise, it uses bilinear interpolation.
566 SUBPEL_SEARCH_TYPE use_accurate_subpel_search;
567
568 // Threshold for allowing exhaustive motion search.
569 int exhaustive_searches_thresh;
570
571 // Pattern to be used for any exhaustive mesh searches (except intraBC ME).
572 MESH_PATTERN mesh_patterns[MAX_MESH_STEP];
573
574 // Pattern to be used for exhaustive mesh searches of intraBC ME.
575 MESH_PATTERN intrabc_mesh_patterns[MAX_MESH_STEP];
576
577 // Reduce single motion search range based on MV result of prior ref_mv_idx.
578 int reduce_search_range;
579
580 // Prune mesh search.
581 int prune_mesh_search;
582
583 // Use the rd cost around the best FULLPEL_MV to speed up subpel search
584 int use_fullpel_costlist;
585
586 // Set the full pixel search level of obmc
587 // 0: obmc_full_pixel_diamond
588 // 1: obmc_refining_search_sad (faster)
589 int obmc_full_pixel_search_level;
590
591 // Accurate full pixel motion search based on TPL stats.
592 int full_pixel_search_level;
593
594 // Whether to downsample the rows in sad calculation during motion search.
595 // This is only active when there are at least 16 rows.
596 int use_downsampled_sad;
597
598 // Enable/disable extensive joint motion search.
599 int disable_extensive_joint_motion_search;
600
601 // Enable second best mv check in joint mv search.
602 // 0: allow second MV (use rd cost as the metric)
603 // 1: use var as the metric
604 // 2: disable second MV
605 int disable_second_mv;
606} MV_SPEED_FEATURES;
607
608typedef struct INTER_MODE_SPEED_FEATURES {
609 // 2-pass inter mode model estimation where the preliminary pass skips
610 // transform search and uses a model to estimate rd, while the final pass
611 // computes the full transform search. Two types of models are supported:
612 // 0: not used
613 // 1: used with online dynamic rd model
614 // 2: used with static rd model
615 int inter_mode_rd_model_estimation;
616
617 // Bypass transform search based on skip rd
618 int txfm_rd_gate_level;
619
620 // Limit the inter mode tested in the RD loop
621 int reduce_inter_modes;
622
623 // This variable is used to cap the maximum number of times we skip testing a
624 // mode to be evaluated. A high value means we will be faster.
625 int adaptive_rd_thresh;
626
627 // Aggressively prune inter modes when best mode is skippable.
628 int prune_inter_modes_if_skippable;
629
630 // Drop less likely to be picked reference frames in the RD search.
631 // Has seven levels for now: 0, 1, 2, 3, 4, 5 and 6 where higher levels prune
632 // more aggressively than lower ones. (0 means no pruning).
633 int selective_ref_frame;
634
635 // Prune reference frames for rectangular partitions.
636 // 0 implies no pruning
637 // 1 implies prune for extended partition
638 // 2 implies prune horiz, vert and extended partition
639 int prune_ref_frame_for_rect_partitions;
640
641 int alt_ref_search_fp;
642
643 // flag to skip NEWMV mode in drl if the motion search result is the same
644 int skip_repeated_newmv;
645
646 // Skip the current ref_mv in NEW_MV mode if we have already encountered
647 // another ref_mv in the drl such that:
648 // 1. The other drl has the same fullpel_mv during the SIMPLE_TRANSLATION
649 // search process as the current fullpel_mv.
650 // 2. The rate needed to encode the current fullpel_mv is larger than that
651 // for the other ref_mv.
652 int skip_repeated_full_newmv;
653
654 // This speed feature checks duplicate ref MVs among NEARESTMV, NEARMV,
655 // GLOBALMV and skips NEARMV or GLOBALMV (in order) if a duplicate is found
656 // TODO(any): Instead of skipping repeated ref mv, use the recalculated
657 // rd-cost based on mode rate and skip the mode evaluation
658 int skip_repeated_ref_mv;
659
660 // Flag used to control the ref_best_rd based gating for chroma
661 int perform_best_rd_based_gating_for_chroma;
662
663 // Reuse the inter_intra_mode search result from NEARESTMV mode to other
664 // single ref modes
665 int reuse_inter_intra_mode;
666
667 // prune wedge and compound segment approximate rd evaluation based on
668 // compound average modeled rd
669 int prune_comp_type_by_model_rd;
670
671 // prune wedge and compound segment approximate rd evaluation based on
672 // compound average rd/ref_best_rd
673 int prune_comp_type_by_comp_avg;
674
675 // Skip some ref frames in compound motion search by single motion search
676 // result. Has three levels for now: 0 referring to no skipping, and 1 - 3
677 // increasing aggressiveness of skipping in order.
678 // Note: The search order might affect the result. It assumes that the single
679 // reference modes are searched before compound modes. It is better to search
680 // same single inter mode as a group.
681 int prune_comp_search_by_single_result;
682
683 // If 1 we iterate finding a best reference for 2 ref frames together - via
684 // a log search that iterates 4 times (check around mv for last for best
685 // error of combined predictor then check around mv for alt). If 0 we
686 // we just use the best motion vector found for each frame by itself.
687 BLOCK_SIZE comp_inter_joint_search_thresh;
688
689 // Instead of performing a full MV search, do a simple translation first
690 // and only perform a full MV search on the motion vectors that performed
691 // well.
692 int prune_mode_search_simple_translation;
693
694 // Only search compound modes with at least one "good" reference frame.
695 // A reference frame is good if, after looking at its performance among
696 // the single reference modes, it is one of the two best performers.
697 int prune_compound_using_single_ref;
698
699 // Skip extended compound mode using ref frames of above and left neighbor
700 // blocks.
701 // 0 : no pruning
702 // 1 : prune extended compound mode (less aggressiveness)
703 // 2 : prune extended compound mode (high aggressiveness)
704 int prune_compound_using_neighbors;
705
706 // Skip extended compound mode when ref frame corresponding to NEWMV does not
707 // have NEWMV as single mode winner.
708 // 0 : no pruning
709 // 1 : prune extended compound mode (less aggressiveness)
710 // 2 : prune extended compound mode (high aggressiveness)
711 int prune_comp_using_best_single_mode_ref;
712
713 // Based on previous ref_mv_idx search result, prune the following search.
714 int prune_ref_mv_idx_search;
715
716 // Disable one sided compound modes.
717 int disable_onesided_comp;
718
719 // Prune obmc search using previous frame stats.
720 // INT_MAX : disable obmc search
721 int prune_obmc_prob_thresh;
722
723 // Prune warped motion search using previous frame stats.
724 int prune_warped_prob_thresh;
725
726 // Variance threshold to enable/disable Interintra wedge search
727 unsigned int disable_interintra_wedge_var_thresh;
728
729 // Variance threshold to enable/disable Interinter wedge search
730 unsigned int disable_interinter_wedge_var_thresh;
731
732 // De-couple wedge and mode search during interintra RDO.
733 int fast_interintra_wedge_search;
734
735 // Whether fast wedge sign estimate is used
736 int fast_wedge_sign_estimate;
737
738 // Enable/disable ME for interinter wedge search.
739 int disable_interinter_wedge_newmv_search;
740
741 // Decide when and how to use joint_comp.
742 DIST_WTD_COMP_FLAG use_dist_wtd_comp_flag;
743
744 // Clip the frequency of updating the mv cost.
745 INTERNAL_COST_UPDATE_TYPE mv_cost_upd_level;
746
747 // Prune inter modes based on tpl stats
748 // 0 : no pruning
749 // 1 - 3 indicate increasing aggressiveness in order.
750 int prune_inter_modes_based_on_tpl;
751
752 // Skip NEARMV and NEAR_NEARMV modes using ref frames of above and left
753 // neighbor blocks and qindex.
754 int prune_nearmv_using_neighbors;
755
756 // Model based breakout after interpolation filter search
757 // 0: no breakout
758 // 1: use model based rd breakout
759 int model_based_post_interp_filter_breakout;
760
761 // Reuse compound type rd decision when exact match is found
762 // 0: No reuse
763 // 1: Reuse the compound type decision
764 int reuse_compound_type_decision;
765
766 // Enable/disable masked compound.
767 int disable_masked_comp;
768
769 // Enable/disable the fast compound mode search.
770 int enable_fast_compound_mode_search;
771
772 // Reuse masked compound type search results
773 int reuse_mask_search_results;
774} INTER_MODE_SPEED_FEATURES;
775
776typedef struct INTERP_FILTER_SPEED_FEATURES {
777 // Do limited interpolation filter search for dual filters, since best choice
778 // usually includes EIGHTTAP_REGULAR.
779 int use_fast_interpolation_filter_search;
780
781 // Disable dual filter
782 int disable_dual_filter;
783
784 // Save results of av1_interpolation_filter_search for a block
785 // Check mv and ref_frames before search, if they are very close with previous
786 // saved results, filter search can be skipped.
787 int use_interp_filter;
788
789 // skip sharp_filter evaluation based on regular and smooth filter rd for
790 // dual_filter=0 case
791 int skip_sharp_interp_filter_search;
792
793 int cb_pred_filter_search;
794
795 // adaptive interp_filter search to allow skip of certain filter types.
796 int adaptive_interp_filter_search;
797} INTERP_FILTER_SPEED_FEATURES;
798
799typedef struct INTRA_MODE_SPEED_FEATURES {
800 // These bit masks allow you to enable or disable intra modes for each
801 // transform size separately.
802 int intra_y_mode_mask[TX_SIZES];
803 int intra_uv_mode_mask[TX_SIZES];
804
805 // flag to allow skipping intra mode for inter frame prediction
806 int skip_intra_in_interframe;
807
808 // Prune intra mode candidates based on source block histogram of gradient.
809 // Applies to luma plane only.
810 // Feasible values are 0..4. The feature is disabled for 0. An increasing
811 // value indicates more aggressive pruning threshold.
812 int intra_pruning_with_hog;
813
814 // Prune intra mode candidates based on source block histogram of gradient.
815 // Applies to chroma plane only.
816 // Feasible values are 0..4. The feature is disabled for 0. An increasing
817 // value indicates more aggressive pruning threshold.
818 int chroma_intra_pruning_with_hog;
819
820 // Enable/disable smooth intra modes.
821 int disable_smooth_intra;
822
823 // Enable/disable filter intra modes.
824 int disable_filter_intra;
825
826 // prune palette search
827 // 0: No pruning
828 // 1: Perform coarse search to prune the palette colors. For winner colors,
829 // neighbors are also evaluated using a finer search.
830 // 2: Perform 2 way palette search from max colors to min colors (and min
831 // colors to remaining colors) and terminate the search if current number of
832 // palette colors is not the winner.
833 int prune_palette_search_level;
834
835 // Prune chroma intra modes based on luma intra mode winner.
836 // 0: No pruning
837 // 1: Prune chroma intra modes other than UV_DC_PRED, UV_SMOOTH_PRED,
838 // UV_CFL_PRED and the mode that corresponds to luma intra mode winner.
839 int prune_chroma_modes_using_luma_winner;
840
841 // Clip the frequency of updating the mv cost for intrabc.
842 INTERNAL_COST_UPDATE_TYPE dv_cost_upd_level;
843
844 // We use DCT_DCT transform followed by computing SATD (Sum of Absolute
845 // Transformed Differences) as an estimation of RD score to quickly find the
846 // best possible Chroma from Luma (CFL) parameter. Then we do a full RD search
847 // near the best possible parameter. The search range is set here.
848 // The range of cfl_searh_range should be [1, 33], and the following are the
849 // recommended values.
850 // 1: Fastest mode.
851 // 3: Default mode that provides good speedup without losing compression
852 // performance at speed 0.
853 // 33: Exhaustive rd search (33 == CFL_MAGS_SIZE). This mode should only
854 // be used for debugging purpose.
855 int cfl_search_range;
856} INTRA_MODE_SPEED_FEATURES;
857
858typedef struct TX_SPEED_FEATURES {
859 // Init search depth for square and rectangular transform partitions.
860 // Values:
861 // 0 - search full tree, 1: search 1 level, 2: search the highest level only
862 int inter_tx_size_search_init_depth_sqr;
863 int inter_tx_size_search_init_depth_rect;
864 int intra_tx_size_search_init_depth_sqr;
865 int intra_tx_size_search_init_depth_rect;
866
867 // If any dimension of a coding block size above 64, always search the
868 // largest transform only, since the largest transform block size is 64x64.
869 int tx_size_search_lgr_block;
870
871 TX_TYPE_SEARCH tx_type_search;
872
873 // Skip split transform block partition when the collocated bigger block
874 // is selected as all zero coefficients.
875 int txb_split_cap;
876
877 // Shortcut the transform block partition and type search when the target
878 // rdcost is relatively lower.
879 // Values are 0 (not used) , or 1 - 2 with progressively increasing
880 // aggressiveness
881 int adaptive_txb_search_level;
882
883 // Prune level for tx_size_type search for inter based on rd model
884 // 0: no pruning
885 // 1-2: progressively increasing aggressiveness of pruning
886 int model_based_prune_tx_search_level;
887
888 // Use hash table to store intra(keyframe only) txb transform search results
889 // to avoid repeated search on the same residue signal. This is currently not
890 // compatible with multi-winner mode as the hash states are reset during
891 // winner mode processing.
892 int use_intra_txb_hash;
893
894 // Use hash table to store inter txb transform search results
895 // to avoid repeated search on the same residue signal.
896 int use_inter_txb_hash;
897
898 // Refine TX type after fast TX search.
899 int refine_fast_tx_search_results;
900
901 // Prune transform split/no_split eval based on residual properties. A value
902 // of 0 indicates no pruning, and the aggressiveness of pruning progressively
903 // increases from levels 1 to 3.
904 int prune_tx_size_level;
905} TX_SPEED_FEATURES;
906
907typedef struct RD_CALC_SPEED_FEATURES {
908 // Fast approximation of av1_model_rd_from_var_lapndz
909 int simple_model_rd_from_var;
910
911 // Whether to compute distortion in the image domain (slower but
912 // more accurate), or in the transform domain (faster but less acurate).
913 // 0: use image domain
914 // 1: use transform domain in tx_type search, and use image domain for
915 // RD_STATS
916 // 2: use transform domain
917 int tx_domain_dist_level;
918
919 // Transform domain distortion threshold level
920 int tx_domain_dist_thres_level;
921
922 // Trellis (dynamic programming) optimization of quantized values
923 TRELLIS_OPT_TYPE optimize_coefficients;
924
925 // Use hash table to store macroblock RD search results
926 // to avoid repeated search on the same residue signal.
927 int use_mb_rd_hash;
928
929 // Flag used to control the extent of coeff R-D optimization
930 int perform_coeff_opt;
931} RD_CALC_SPEED_FEATURES;
932
933typedef struct WINNER_MODE_SPEED_FEATURES {
934 // Flag used to control the winner mode processing for better R-D optimization
935 // of quantized coeffs
936 int enable_winner_mode_for_coeff_opt;
937
938 // Flag used to control the winner mode processing for transform size
939 // search method
940 int enable_winner_mode_for_tx_size_srch;
941
942 // Control transform size search level
943 // Eval type: Default Mode Winner
944 // Level 0 : FULL RD LARGEST ALL FULL RD
945 // Level 1 : FAST RD LARGEST ALL FULL RD
946 // Level 2 : LARGEST ALL LARGEST ALL FULL RD
947 int tx_size_search_level;
948
949 // Flag used to control the winner mode processing for use transform
950 // domain distortion
951 int enable_winner_mode_for_use_tx_domain_dist;
952
953 // Flag used to enable processing of multiple winner modes
954 MULTI_WINNER_MODE_TYPE multi_winner_mode_type;
955
956 // Motion mode for winner candidates:
957 // 0: speed feature OFF
958 // 1 / 2 : Use configured number of winner candidates
959 int motion_mode_for_winner_cand;
960
961 // Early DC only txfm block prediction
962 // 0: speed feature OFF
963 // 1 / 2 : Use the configured level for different modes
964 int dc_blk_pred_level;
965} WINNER_MODE_SPEED_FEATURES;
966
967typedef struct LOOP_FILTER_SPEED_FEATURES {
968 // This feature controls how the loop filter level is determined.
969 LPF_PICK_METHOD lpf_pick;
970
971 // Skip some final iterations in the determination of the best loop filter
972 // level.
973 int use_coarse_filter_level_search;
974
975 // Control how the CDEF strength is determined.
976 CDEF_PICK_METHOD cdef_pick_method;
977
978 // Decoder side speed feature to add penalty for use of dual-sgr filters.
979 // Takes values 0 - 10, 0 indicating no penalty and each additional level
980 // adding a penalty of 1%
981 int dual_sgr_penalty_level;
982
983 // prune sgr ep using binary search like mechanism
984 int enable_sgr_ep_pruning;
985
986 // Disable loop restoration for Chroma plane
987 int disable_loop_restoration_chroma;
988
989 // Prune RESTORE_WIENER evaluation based on source variance
990 // 0 : no pruning
991 // 1 : conservative pruning
992 // 2 : aggressive pruning
993 int prune_wiener_based_on_src_var;
994
995 // Prune self-guided loop restoration based on wiener search results
996 // 0 : no pruning
997 // 1 : pruning based on rdcost ratio of RESTORE_WIENER and RESTORE_NONE
998 // 2 : pruning based on winner restoration type among RESTORE_WIENER and
999 // RESTORE_NONE
1000 int prune_sgr_based_on_wiener;
1001
1002 // Reduce the wiener filter win size for luma
1003 int reduce_wiener_window_size;
1004
1005 // Disable loop restoration filter
1006 int disable_lr_filter;
1007} LOOP_FILTER_SPEED_FEATURES;
1008
1009typedef struct REAL_TIME_SPEED_FEATURES {
1010 // check intra prediction for non-RD mode.
1011 int check_intra_pred_nonrd;
1012
1013 // skip checking intra prediction if TX is skipped
1014 int skip_intra_pred_if_tx_skip;
1015
1016 // Perform coarse ME before calculating variance in variance-based partition
1017 int estimate_motion_for_var_based_partition;
1018
1019 // For nonrd_use_partition: mode of extra check of leaf partition
1020 // 0 - don't check merge
1021 // 1 - always check merge
1022 // 2 - check merge and prune checking final split
1023 int nonrd_check_partition_merge_mode;
1024
1025 // For nonrd_use_partition: check of leaf partition extra split
1026 int nonrd_check_partition_split;
1027
1028 // Implements various heuristics to skip searching modes
1029 // The heuristics selected are based on flags
1030 // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
1031 unsigned int mode_search_skip_flags;
1032
1033 // For nonrd: Reduces ref frame search.
1034 // 0 - low level of search prune in non last frames
1035 // 1 - pruned search in non last frames
1036 // 2 - more pruned search in non last frames
1037 int nonrd_prune_ref_frame_search;
1038
1039 // This flag controls the use of non-RD mode decision.
1040 int use_nonrd_pick_mode;
1041
1042 // Use ALTREF frame in non-RD mode decision.
1043 int use_nonrd_altref_frame;
1044
1045 // Use compound reference for non-RD mode.
1046 int use_comp_ref_nonrd;
1047
1048 // use reduced ref set for real-time mode
1049 int use_real_time_ref_set;
1050
1051 // Skip a number of expensive mode evaluations for blocks with very low
1052 // temporal variance.
1053 int short_circuit_low_temp_var;
1054
1055 // Use modeled (currently CurvFit model) RDCost for fast non-RD mode
1056 int use_modeled_non_rd_cost;
1057
1058 // Reuse inter prediction in fast non-rd mode.
1059 int reuse_inter_pred_nonrd;
1060
1061 // Number of best inter modes to search transform. INT_MAX - search all.
1062 int num_inter_modes_for_tx_search;
1063
1064 // Forces TX search off for RDCost calulation.
1065 int force_tx_search_off;
1066
1067 // Use interpolation filter search in non-RD mode decision.
1068 int use_nonrd_filter_search;
1069
1070 // Use simplified RD model for interpolation search and Intra
1071 int use_simple_rd_model;
1072
1073 // If set forces interpolation filter to EIGHTTAP_REGULAR
1074 int skip_interp_filter_search;
1075
1076 // For nonrd mode: use hybrid (rd for bsize < 16x16, otherwise nonrd)
1077 // intra mode search for intra only frames. If set to 0 then nonrd pick
1078 // intra is used for all blocks.
1079 int hybrid_intra_pickmode;
1080
1081 // Compute variance/sse on source difference, prior to encoding superblock.
1082 int source_metrics_sb_nonrd;
1083
1084 // Flag to indicate process for handling overshoot on slide/scene change,
1085 // for real-time CBR mode.
1086 OVERSHOOT_DETECTION_CBR overshoot_detection_cbr;
1087
1088 // Check for scene/content change detection on every frame before encoding.
1089 int check_scene_detection;
1090
1091 // Forces larger partition blocks in variance based partitioning
1092 int force_large_partition_blocks;
1093
1094 // uses results of temporal noise estimate
1095 int use_temporal_noise_estimate;
1096
1097 // Parameter indicating initial search window to be used in full-pixel search
1098 // for nonrd_pickmode. Range [0, MAX_MVSEARCH_STEPS - 1]. Lower value
1099 // indicates larger window. If set to 0, step_param is set based on internal
1100 // logic in set_mv_search_params().
1101 int fullpel_search_step_param;
1102
1103 // Skip loopfilter (and cdef) in svc real-time mode for
1104 // non_reference/droppable frames.
1105 int skip_loopfilter_non_reference;
1106
1107 // Bit mask to enable or disable intra modes for each prediction block size
1108 // separately, for nonrd pickmode.
1109 int intra_y_mode_bsize_mask_nrd[BLOCK_SIZES];
1110
1111 // Skips mode checks more agressively in nonRD mode
1112 int nonrd_agressive_skip;
1113} REAL_TIME_SPEED_FEATURES;
1114
1120typedef struct SPEED_FEATURES {
1125
1129 TPL_SPEED_FEATURES tpl_sf;
1130
1134 GLOBAL_MOTION_SPEED_FEATURES gm_sf;
1135
1139 PARTITION_SPEED_FEATURES part_sf;
1140
1144 MV_SPEED_FEATURES mv_sf;
1145
1149 INTER_MODE_SPEED_FEATURES inter_sf;
1150
1154 INTERP_FILTER_SPEED_FEATURES interp_sf;
1155
1159 INTRA_MODE_SPEED_FEATURES intra_sf;
1160
1164 TX_SPEED_FEATURES tx_sf;
1165
1169 RD_CALC_SPEED_FEATURES rd_sf;
1170
1174 WINNER_MODE_SPEED_FEATURES winner_mode_sf;
1175
1179 LOOP_FILTER_SPEED_FEATURES lpf_sf;
1180
1184 REAL_TIME_SPEED_FEATURES rt_sf;
1188struct AV1_COMP;
1189
1203 int speed);
1204
1217 int speed);
1230
1231#ifdef __cplusplus
1232} // extern "C"
1233#endif
1234
1235#endif // AOM_AV1_ENCODER_SPEED_FEATURES_H_
void av1_set_speed_features_framesize_independent(struct AV1_COMP *cpi, int speed)
Frame size independent speed vs quality trade off flags.
void av1_set_speed_features_qindex_dependent(struct AV1_COMP *cpi, int speed)
Q index dependent speed vs quality trade off flags.
void av1_set_speed_features_framesize_dependent(struct AV1_COMP *cpi, int speed)
Frame size dependent speed vs quality trade off flags.
INTERNAL_COST_UPDATE_TYPE
This enum decides internally how often to update the entropy costs.
Definition: speed_features.h:300
@ INTERNAL_COST_UPD_OFF
Definition: speed_features.h:301
@ INTERNAL_COST_UPD_SBROW_SET
Definition: speed_features.h:302
@ INTERNAL_COST_UPD_SBROW
Definition: speed_features.h:303
@ INTERNAL_COST_UPD_SB
Definition: speed_features.h:304
struct SPEED_FEATURES SPEED_FEATURES
Top level speed vs quality trade off data struture.
struct HIGH_LEVEL_SPEED_FEATURES HIGH_LEVEL_SPEED_FEATURES
Sequence/frame level speed vs quality features.
CDEF_PICK_METHOD
This enumeration defines a variety of CDEF pick methods.
Definition: speed_features.h:156
@ CDEF_FAST_SEARCH_LVL2
Definition: speed_features.h:159
@ CDEF_FAST_SEARCH_LVL1
Definition: speed_features.h:158
@ CDEF_FULL_SEARCH
Definition: speed_features.h:157
@ CDEF_PICK_FROM_Q
Definition: speed_features.h:163
@ CDEF_FAST_SEARCH_LVL4
Definition: speed_features.h:162
@ CDEF_FAST_SEARCH_LVL3
Definition: speed_features.h:160
Top level encoder structure.
Definition: encoder.h:2095
int speed
Definition: encoder.h:2309
Sequence/frame level speed vs quality features.
Definition: speed_features.h:310
int second_alt_ref_filtering
Definition: speed_features.h:355
int disable_extra_sc_testing
Definition: speed_features.h:350
int recode_tolerance
Definition: speed_features.h:325
RECODE_LOOP_TYPE recode_loop
Definition: speed_features.h:319
Top level speed vs quality trade off data struture.
Definition: speed_features.h:1120
MV_SPEED_FEATURES mv_sf
Definition: speed_features.h:1144
TPL_SPEED_FEATURES tpl_sf
Definition: speed_features.h:1129
LOOP_FILTER_SPEED_FEATURES lpf_sf
Definition: speed_features.h:1179
TX_SPEED_FEATURES tx_sf
Definition: speed_features.h:1164
INTER_MODE_SPEED_FEATURES inter_sf
Definition: speed_features.h:1149
RD_CALC_SPEED_FEATURES rd_sf
Definition: speed_features.h:1169
PARTITION_SPEED_FEATURES part_sf
Definition: speed_features.h:1139
GLOBAL_MOTION_SPEED_FEATURES gm_sf
Definition: speed_features.h:1134
INTERP_FILTER_SPEED_FEATURES interp_sf
Definition: speed_features.h:1154
INTRA_MODE_SPEED_FEATURES intra_sf
Definition: speed_features.h:1159
WINNER_MODE_SPEED_FEATURES winner_mode_sf
Definition: speed_features.h:1174
REAL_TIME_SPEED_FEATURES rt_sf
Definition: speed_features.h:1184
HIGH_LEVEL_SPEED_FEATURES hl_sf
Definition: speed_features.h:1124