Home | History | Annotate | Download | only in encoder
      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 
     17 #ifdef __cplusplus
     18 extern "C" {
     19 #endif
     20 
     21 enum {
     22   INTRA_ALL = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED) | (1 << D45_PRED) |
     23               (1 << D135_PRED) | (1 << D113_PRED) | (1 << D157_PRED) |
     24               (1 << D203_PRED) | (1 << D67_PRED) | (1 << SMOOTH_PRED) |
     25               (1 << SMOOTH_V_PRED) | (1 << SMOOTH_H_PRED) | (1 << PAETH_PRED),
     26   UV_INTRA_ALL =
     27       (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED) |
     28       (1 << UV_D45_PRED) | (1 << UV_D135_PRED) | (1 << UV_D113_PRED) |
     29       (1 << UV_D157_PRED) | (1 << UV_D203_PRED) | (1 << UV_D67_PRED) |
     30       (1 << UV_SMOOTH_PRED) | (1 << UV_SMOOTH_V_PRED) |
     31       (1 << UV_SMOOTH_H_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED),
     32   UV_INTRA_DC = (1 << UV_DC_PRED),
     33   UV_INTRA_DC_CFL = (1 << UV_DC_PRED) | (1 << UV_CFL_PRED),
     34   UV_INTRA_DC_TM = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED),
     35   UV_INTRA_DC_PAETH_CFL =
     36       (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) | (1 << UV_CFL_PRED),
     37   UV_INTRA_DC_H_V = (1 << UV_DC_PRED) | (1 << UV_V_PRED) | (1 << UV_H_PRED),
     38   UV_INTRA_DC_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_V_PRED) |
     39                         (1 << UV_H_PRED) | (1 << UV_CFL_PRED),
     40   UV_INTRA_DC_PAETH_H_V = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) |
     41                           (1 << UV_V_PRED) | (1 << UV_H_PRED),
     42   UV_INTRA_DC_PAETH_H_V_CFL = (1 << UV_DC_PRED) | (1 << UV_PAETH_PRED) |
     43                               (1 << UV_V_PRED) | (1 << UV_H_PRED) |
     44                               (1 << UV_CFL_PRED),
     45   INTRA_DC = (1 << DC_PRED),
     46   INTRA_DC_TM = (1 << DC_PRED) | (1 << PAETH_PRED),
     47   INTRA_DC_H_V = (1 << DC_PRED) | (1 << V_PRED) | (1 << H_PRED),
     48   INTRA_DC_PAETH_H_V =
     49       (1 << DC_PRED) | (1 << PAETH_PRED) | (1 << V_PRED) | (1 << H_PRED)
     50 };
     51 
     52 enum {
     53   INTER_ALL = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) |
     54               (1 << NEWMV) | (1 << NEAREST_NEARESTMV) | (1 << NEAR_NEARMV) |
     55               (1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) | (1 << NEAR_NEWMV) |
     56               (1 << NEW_NEARMV) | (1 << NEW_NEARESTMV) | (1 << GLOBAL_GLOBALMV),
     57   INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) |
     58                             (1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
     59                             (1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) |
     60                             (1 << NEW_NEARMV) | (1 << NEAR_NEWMV) |
     61                             (1 << NEAR_NEARMV),
     62 };
     63 
     64 enum {
     65   DISABLE_ALL_INTER_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) |
     66                             (1 << THR_ALTR) | (1 << THR_GOLD) | (1 << THR_LAST),
     67 
     68   DISABLE_ALL_SPLIT = (1 << THR_INTRA) | DISABLE_ALL_INTER_SPLIT,
     69 
     70   DISABLE_COMPOUND_SPLIT = (1 << THR_COMP_GA) | (1 << THR_COMP_LA),
     71 
     72   LAST_AND_INTRA_SPLIT_ONLY = (1 << THR_COMP_GA) | (1 << THR_COMP_LA) |
     73                               (1 << THR_ALTR) | (1 << THR_GOLD)
     74 };
     75 
     76 enum {
     77   TXFM_CODING_SF = 1,
     78   INTER_PRED_SF = 2,
     79   INTRA_PRED_SF = 4,
     80   PARTITION_SF = 8,
     81   LOOP_FILTER_SF = 16,
     82   RD_SKIP_SF = 32,
     83   RESERVE_2_SF = 64,
     84   RESERVE_3_SF = 128,
     85 } UENUM1BYTE(DEV_SPEED_FEATURES);
     86 
     87 enum {
     88   DIAMOND = 0,
     89   NSTEP = 1,
     90   HEX = 2,
     91   BIGDIA = 3,
     92   SQUARE = 4,
     93   FAST_HEX = 5,
     94   FAST_DIAMOND = 6
     95 } UENUM1BYTE(SEARCH_METHODS);
     96 
     97 enum {
     98   // No recode.
     99   DISALLOW_RECODE = 0,
    100   // Allow recode for KF and exceeding maximum frame bandwidth.
    101   ALLOW_RECODE_KFMAXBW = 1,
    102   // Allow recode only for KF/ARF/GF frames.
    103   ALLOW_RECODE_KFARFGF = 2,
    104   // Allow recode for all frames based on bitrate constraints.
    105   ALLOW_RECODE = 3,
    106 } UENUM1BYTE(RECODE_LOOP_TYPE);
    107 
    108 enum {
    109   SUBPEL_TREE = 0,
    110   SUBPEL_TREE_PRUNED = 1,           // Prunes 1/2-pel searches
    111   SUBPEL_TREE_PRUNED_MORE = 2,      // Prunes 1/2-pel searches more aggressively
    112   SUBPEL_TREE_PRUNED_EVENMORE = 3,  // Prunes 1/2- and 1/4-pel searches
    113   // Other methods to come
    114 } UENUM1BYTE(SUBPEL_SEARCH_METHODS);
    115 
    116 enum {
    117   USE_FULL_RD = 0,
    118   USE_FAST_RD,
    119   USE_LARGESTALL,
    120 } UENUM1BYTE(TX_SIZE_SEARCH_METHOD);
    121 
    122 enum {
    123   // Try the full image with different values.
    124   LPF_PICK_FROM_FULL_IMAGE,
    125   // Try a small portion of the image with different values.
    126   LPF_PICK_FROM_SUBIMAGE,
    127   // Estimate the level based on quantizer and frame type
    128   LPF_PICK_FROM_Q,
    129   // Pick 0 to disable LPF if LPF was enabled last frame
    130   LPF_PICK_MINIMAL_LPF
    131 } UENUM1BYTE(LPF_PICK_METHOD);
    132 
    133 enum {
    134   // Terminate search early based on distortion so far compared to
    135   // qp step, distortion in the neighborhood of the frame, etc.
    136   FLAG_EARLY_TERMINATE = 1 << 0,
    137 
    138   // Skips comp inter modes if the best so far is an intra mode.
    139   FLAG_SKIP_COMP_BESTINTRA = 1 << 1,
    140 
    141   // Skips oblique intra modes if the best so far is an inter mode.
    142   FLAG_SKIP_INTRA_BESTINTER = 1 << 3,
    143 
    144   // Skips oblique intra modes  at angles 27, 63, 117, 153 if the best
    145   // intra so far is not one of the neighboring directions.
    146   FLAG_SKIP_INTRA_DIRMISMATCH = 1 << 4,
    147 
    148   // Skips intra modes other than DC_PRED if the source variance is small
    149   FLAG_SKIP_INTRA_LOWVAR = 1 << 5,
    150 } UENUM1BYTE(MODE_SEARCH_SKIP_LOGIC);
    151 
    152 enum {
    153   NO_PRUNE = 0,
    154   // eliminates one tx type in vertical and horizontal direction
    155   PRUNE_ONE = 1,
    156   // eliminates two tx types in each direction
    157   PRUNE_TWO = 2,
    158   // adaptively prunes the least perspective tx types out of all 16
    159   // (tuned to provide negligible quality loss)
    160   PRUNE_2D_ACCURATE = 3,
    161   // similar, but applies much more aggressive pruning to get better speed-up
    162   PRUNE_2D_FAST = 4,
    163 } UENUM1BYTE(TX_TYPE_PRUNE_MODE);
    164 
    165 typedef struct {
    166   TX_TYPE_PRUNE_MODE prune_mode;
    167   int fast_intra_tx_type_search;
    168   int fast_inter_tx_type_search;
    169 
    170   // Use a skip flag prediction model to detect blocks with skip = 1 early
    171   // and avoid doing full TX type search for such blocks.
    172   int use_skip_flag_prediction;
    173 
    174   // Threshold used by the ML based method to predict TX block split decisions.
    175   int ml_tx_split_thresh;
    176 
    177   // skip remaining transform type search when we found the rdcost of skip is
    178   // better than applying transform
    179   int skip_tx_search;
    180 } TX_TYPE_SEARCH;
    181 
    182 enum {
    183   // Search partitions using RD criterion
    184   SEARCH_PARTITION,
    185 
    186   // Always use a fixed size partition
    187   FIXED_PARTITION,
    188 
    189   REFERENCE_PARTITION,
    190 
    191   VAR_BASED_PARTITION
    192 } UENUM1BYTE(PARTITION_SEARCH_TYPE);
    193 
    194 enum {
    195   EIGHTH_PEL,
    196   QUARTER_PEL,
    197   HALF_PEL,
    198   FULL_PEL
    199 } UENUM1BYTE(SUBPEL_FORCE_STOP);
    200 
    201 enum {
    202   NOT_IN_USE,
    203   DIRECT_PRED,
    204   RELAXED_PRED,
    205   ADAPT_PRED
    206 } UENUM1BYTE(MAX_PART_PRED_MODE);
    207 
    208 typedef struct MV_SPEED_FEATURES {
    209   // Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc).
    210   SEARCH_METHODS search_method;
    211 
    212   // This parameter controls which step in the n-step process we start at.
    213   // It's changed adaptively based on circumstances.
    214   int reduce_first_step_size;
    215 
    216   // If this is set to 1, we limit the motion search range to 2 times the
    217   // largest motion vector found in the last frame.
    218   int auto_mv_step_size;
    219 
    220   // Subpel_search_method can only be subpel_tree which does a subpixel
    221   // logarithmic search that keeps stepping at 1/2 pixel units until
    222   // you stop getting a gain, and then goes on to 1/4 and repeats
    223   // the same process. Along the way it skips many diagonals.
    224   SUBPEL_SEARCH_METHODS subpel_search_method;
    225 
    226   // Maximum number of steps in logarithmic subpel search before giving up.
    227   int subpel_iters_per_step;
    228 
    229   // When to stop subpel search.
    230   SUBPEL_FORCE_STOP subpel_force_stop;
    231 } MV_SPEED_FEATURES;
    232 
    233 #define MAX_MESH_STEP 4
    234 
    235 typedef struct MESH_PATTERN {
    236   int range;
    237   int interval;
    238 } MESH_PATTERN;
    239 
    240 enum {
    241   GM_FULL_SEARCH,
    242   GM_REDUCED_REF_SEARCH_SKIP_L2_L3,
    243   GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2,
    244   GM_DISABLE_SEARCH
    245 } UENUM1BYTE(GM_SEARCH_TYPE);
    246 
    247 enum {
    248   GM_ERRORADV_TR_0,
    249   GM_ERRORADV_TR_1,
    250   GM_ERRORADV_TR_2,
    251   GM_ERRORADV_TR_TYPES,
    252 } UENUM1BYTE(GM_ERRORADV_TYPE);
    253 
    254 enum {
    255   NO_TRELLIS_OPT,          // No trellis optimization
    256   FULL_TRELLIS_OPT,        // Trellis optimization in all stages
    257   FINAL_PASS_TRELLIS_OPT,  // Trellis optimization in only the final encode pass
    258   NO_ESTIMATE_YRD_TRELLIS_OPT  // Disable trellis in estimate_yrd_for_sb
    259 } UENUM1BYTE(TRELLIS_OPT_TYPE);
    260 
    261 enum {
    262   FULL_TXFM_RD,
    263   LOW_TXFM_RD,
    264 } UENUM1BYTE(TXFM_RD_MODEL);
    265 
    266 enum {
    267   DIST_WTD_COMP_ENABLED,
    268   DIST_WTD_COMP_SKIP_MV_SEARCH,
    269   DIST_WTD_COMP_DISABLED,
    270 } UENUM1BYTE(DIST_WTD_COMP_FLAG);
    271 
    272 typedef enum {
    273   FLAG_SKIP_EIGHTTAP = 1 << EIGHTTAP_REGULAR,
    274   FLAG_SKIP_EIGHTTAP_SMOOTH = 1 << EIGHTTAP_SMOOTH,
    275   FLAG_SKIP_EIGHTTAP_SHARP = 1 << MULTITAP_SHARP,
    276 } INTERP_FILTER_MASK;
    277 
    278 typedef struct SPEED_FEATURES {
    279   MV_SPEED_FEATURES mv;
    280 
    281   // Frame level coding parameter update
    282   int frame_parameter_update;
    283 
    284   RECODE_LOOP_TYPE recode_loop;
    285 
    286   // Trellis (dynamic programming) optimization of quantized values
    287   TRELLIS_OPT_TYPE optimize_coefficients;
    288 
    289   // Global motion warp error threshold
    290   GM_ERRORADV_TYPE gm_erroradv_type;
    291 
    292   // Always set to 0. If on it enables 0 cost background transmission
    293   // (except for the initial transmission of the segmentation). The feature is
    294   // disabled because the addition of very large block sizes make the
    295   // backgrounds very to cheap to encode, and the segmentation we have
    296   // adds overhead.
    297   int static_segmentation;
    298 
    299   // Limit the inter mode tested in the RD loop
    300   int reduce_inter_modes;
    301 
    302   // Do not compute the global motion parameters for a LAST2_FRAME or
    303   // LAST3_FRAME if the GOLDEN_FRAME is closer and it has a non identity
    304   // global model.
    305   int selective_ref_gm;
    306 
    307   // If 1 we iterate finding a best reference for 2 ref frames together - via
    308   // a log search that iterates 4 times (check around mv for last for best
    309   // error of combined predictor then check around mv for alt). If 0 we
    310   // we just use the best motion vector found for each frame by itself.
    311   BLOCK_SIZE comp_inter_joint_search_thresh;
    312 
    313   // This variable is used to cap the maximum number of times we skip testing a
    314   // mode to be evaluated. A high value means we will be faster.
    315   int adaptive_rd_thresh;
    316 
    317   // Determine which method we use to determine transform size. We can choose
    318   // between options like full rd, largest for prediction size, largest
    319   // for intra and model coefs for the rest.
    320   TX_SIZE_SEARCH_METHOD tx_size_search_method;
    321 
    322   // Init search depth for square and rectangular transform partitions.
    323   // Values:
    324   // 0 - search full tree, 1: search 1 level, 2: search the highest level only
    325   int inter_tx_size_search_init_depth_sqr;
    326   int inter_tx_size_search_init_depth_rect;
    327   int intra_tx_size_search_init_depth_sqr;
    328   int intra_tx_size_search_init_depth_rect;
    329   // If any dimension of a coding block size above 64, always search the
    330   // largest transform only, since the largest transform block size is 64x64.
    331   int tx_size_search_lgr_block;
    332 
    333   PARTITION_SEARCH_TYPE partition_search_type;
    334 
    335   TX_TYPE_SEARCH tx_type_search;
    336 
    337   // Skip split transform block partition when the collocated bigger block
    338   // is selected as all zero coefficients.
    339   int txb_split_cap;
    340 
    341   // Shortcut the transform block partition and type search when the target
    342   // rdcost is relatively lower.
    343   // Values are 0 (not used) , or 1 - 2 with progressively increasing
    344   // aggressiveness
    345   int adaptive_txb_search_level;
    346 
    347   // Prune level for tx_size_type search for inter based on rd model
    348   // 0: no pruning
    349   // 1-2: progressively increasing aggressiveness of pruning
    350   int model_based_prune_tx_search_level;
    351 
    352   // Model based breakout after interpolation filter search
    353   // 0: no breakout
    354   // 1: use model based rd breakout
    355   int model_based_post_interp_filter_breakout;
    356 
    357   // Model based breakout in motion_mode_rd
    358   // 0: no breakout
    359   // 1: use model based rd breakout
    360   int model_based_motion_mode_rd_breakout;
    361 
    362   // Used if partition_search_type = FIXED_SIZE_PARTITION
    363   BLOCK_SIZE always_this_block_size;
    364 
    365   // Drop less likely to be picked reference frames in the RD search.
    366   // Has five levels for now: 0, 1, 2, 3 and 4, where higher levels prune more
    367   // aggressively than lower ones. (0 means no pruning).
    368   int selective_ref_frame;
    369 
    370   // Prune extended partition types search
    371   // Can take values 0 - 2, 0 referring to no pruning, and 1 - 2 increasing
    372   // aggressiveness of pruning in order.
    373   int prune_ext_partition_types_search_level;
    374 
    375   // Use a ML model to prune horz and vert partitions
    376   int ml_prune_rect_partition;
    377 
    378   // Disable/Enable interintra motion mode based on stats collected during
    379   // first_partition_search_pass
    380   int use_first_partition_pass_interintra_stats;
    381 
    382   // Use a ML model to prune horz_a, horz_b, vert_a and vert_b partitions.
    383   int ml_prune_ab_partition;
    384 
    385   // Use a ML model to prune horz4 and vert4 partitions.
    386   int ml_prune_4_partition;
    387 
    388   int fast_cdef_search;
    389 
    390   // 2-pass coding block partition search, and also use the mode decisions made
    391   // in the initial partition search to prune mode candidates, e.g. ref frames.
    392   int two_pass_partition_search;
    393 
    394   // Terminate early in firstpass of two_pass partition search for faster
    395   // firstpass.
    396   int firstpass_simple_motion_search_early_term;
    397 
    398   // Skip rectangular partition test when partition type none gives better
    399   // rd than partition type split. Can take values 0 - 2, 0 referring to no
    400   // skipping, and 1 - 2 increasing aggressiveness of skipping in order.
    401   int less_rectangular_check_level;
    402 
    403   // Use square partition only beyond this block size.
    404   BLOCK_SIZE use_square_partition_only_threshold;
    405 
    406   // Prune reference frames for rectangular partitions.
    407   // 0 implies no pruning
    408   // 1 implies prune for extended partition
    409   // 2 implies prune horiz, vert and extended partition
    410   int prune_ref_frame_for_rect_partitions;
    411 
    412   // Sets min and max square partition levels for this superblock based on
    413   // motion vector and prediction error distribution produced from 16x16
    414   // simple motion search
    415   MAX_PART_PRED_MODE auto_max_partition_based_on_simple_motion;
    416   int auto_min_partition_based_on_simple_motion;
    417 
    418   // Ensures the rd based auto partition search will always
    419   // go down at least to the specified level.
    420   BLOCK_SIZE rd_auto_partition_min_limit;
    421 
    422   // Min and max partition size we enable (block_size) as per auto
    423   // min max, but also used by adjust partitioning, and pick_partitioning.
    424   BLOCK_SIZE default_min_partition_size;
    425   BLOCK_SIZE default_max_partition_size;
    426 
    427   // Whether or not we allow partitions one smaller or one greater than the last
    428   // frame's partitioning. Only used if use_lastframe_partitioning is set.
    429   int adjust_partitioning_from_last_frame;
    430 
    431   // TODO(jingning): combine the related motion search speed features
    432   // This allows us to use motion search at other sizes as a starting
    433   // point for this motion search and limits the search range around it.
    434   int adaptive_motion_search;
    435 
    436   // Flag for allowing some use of exhaustive searches;
    437   int allow_exhaustive_searches;
    438 
    439   // Threshold for allowing exhaistive motion search.
    440   int exhaustive_searches_thresh;
    441 
    442   // Maximum number of exhaustive searches for a frame.
    443   int max_exaustive_pct;
    444 
    445   // Pattern to be used for any exhaustive mesh searches.
    446   MESH_PATTERN mesh_patterns[MAX_MESH_STEP];
    447 
    448   // Allows sub 8x8 modes to use the prediction filter that was determined
    449   // best for 8x8 mode. If set to 0 we always re check all the filters for
    450   // sizes less than 8x8, 1 means we check all filter modes if no 8x8 filter
    451   // was selected, and 2 means we use 8 tap if no 8x8 filter mode was selected.
    452   int adaptive_pred_interp_filter;
    453 
    454   // Adaptive prediction mode search
    455   int adaptive_mode_search;
    456 
    457   int alt_ref_search_fp;
    458 
    459   // Implements various heuristics to skip searching modes
    460   // The heuristics selected are based on  flags
    461   // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
    462   unsigned int mode_search_skip_flags;
    463 
    464   // A source variance threshold below which filter search is disabled
    465   // Choose a very large value (UINT_MAX) to use 8-tap always
    466   unsigned int disable_filter_search_var_thresh;
    467 
    468   // Only enable wedge search if the edge strength is greater than
    469   // this threshold. A value of 0 signals that this check is disabled.
    470   unsigned int disable_wedge_search_edge_thresh;
    471 
    472   // Only enable wedge search if the variance is above this threshold.
    473   unsigned int disable_wedge_search_var_thresh;
    474 
    475   // Whether fast wedge sign estimate is used
    476   int fast_wedge_sign_estimate;
    477 
    478   // Whether to prune wedge search based on predictor difference
    479   int prune_wedge_pred_diff_based;
    480 
    481   // These bit masks allow you to enable or disable intra modes for each
    482   // transform size separately.
    483   int intra_y_mode_mask[TX_SIZES];
    484   int intra_uv_mode_mask[TX_SIZES];
    485 
    486   // This feature controls how the loop filter level is determined.
    487   LPF_PICK_METHOD lpf_pick;
    488 
    489   // This feature controls whether we do the expensive context update and
    490   // calculation in the rd coefficient costing loop.
    491   int use_fast_coef_costing;
    492 
    493   // This feature controls the tolerence vs target used in deciding whether to
    494   // recode a frame. It has no meaning if recode is disabled.
    495   int recode_tolerance;
    496 
    497   // This variable controls the maximum block size where intra blocks can be
    498   // used in inter frames.
    499   // TODO(aconverse): Fold this into one of the other many mode skips
    500   BLOCK_SIZE max_intra_bsize;
    501 
    502   // Partition search early breakout thresholds.
    503   int64_t partition_search_breakout_dist_thr;
    504   int partition_search_breakout_rate_thr;
    505 
    506   // Thresholds for ML based partition search breakout.
    507   int ml_partition_search_breakout_thresh[PARTITION_BLOCK_SIZES];
    508 
    509   // Allow skipping partition search for still image frame
    510   int allow_partition_search_skip;
    511 
    512   // Fast approximation of av1_model_rd_from_var_lapndz
    513   int simple_model_rd_from_var;
    514 
    515   // If true, sub-pixel search uses the exact convolve function used for final
    516   // encoding and decoding; otherwise, it uses bilinear interpolation.
    517   SUBPEL_SEARCH_TYPE use_accurate_subpel_search;
    518 
    519   // Whether to compute distortion in the image domain (slower but
    520   // more accurate), or in the transform domain (faster but less acurate).
    521   // 0: use image domain
    522   // 1: use transform domain in tx_type search, and use image domain for
    523   // RD_STATS
    524   // 2: use transform domain
    525   int use_transform_domain_distortion;
    526 
    527   GM_SEARCH_TYPE gm_search_type;
    528 
    529   // whether to disable the global motion recode loop
    530   int gm_disable_recode;
    531 
    532   // Do limited interpolation filter search for dual filters, since best choice
    533   // usually includes EIGHTTAP_REGULAR.
    534   int use_fast_interpolation_filter_search;
    535 
    536   // Disable dual filter
    537   int disable_dual_filter;
    538 
    539   // Save results of interpolation_filter_search for a block
    540   // Check mv and ref_frames before search, if they are same with previous
    541   // saved results, it can be skipped.
    542   int skip_repeat_interpolation_filter_search;
    543 
    544   // Use a hash table to store previously computed optimized qcoeffs from
    545   // expensive calls to optimize_txb.
    546   int use_hash_based_trellis;
    547 
    548   // flag to drop some ref frames in compound motion search
    549   int drop_ref;
    550 
    551   // flag to allow skipping intra mode for inter frame prediction
    552   int skip_intra_in_interframe;
    553 
    554   // Use hash table to store intra(keyframe only) txb transform search results
    555   // to avoid repeated search on the same residue signal.
    556   int use_intra_txb_hash;
    557 
    558   // Use hash table to store inter txb transform search results
    559   // to avoid repeated search on the same residue signal.
    560   int use_inter_txb_hash;
    561 
    562   // Use hash table to store macroblock RD search results
    563   // to avoid repeated search on the same residue signal.
    564   int use_mb_rd_hash;
    565 
    566   // Calculate RD cost before doing optimize_b, and skip if the cost is large.
    567   int optimize_b_precheck;
    568 
    569   // Use two-loop compound search
    570   int two_loop_comp_search;
    571 
    572   // Use model rd instead of transform search in second loop of compound search
    573   int second_loop_comp_fast_tx_search;
    574 
    575   // Decide when and how to use joint_comp.
    576   DIST_WTD_COMP_FLAG use_dist_wtd_comp_flag;
    577 
    578   // Decoder side speed feature to add penalty for use of dual-sgr filters.
    579   // Takes values 0 - 10, 0 indicating no penalty and each additional level
    580   // adding a penalty of 1%
    581   int dual_sgr_penalty_level;
    582 
    583   // 2-pass inter mode model estimation where the preliminary pass skips
    584   // transform search and uses a model to estimate rd, while the final pass
    585   // computes the full transform search. Two types of models are supported:
    586   // 0: not used
    587   // 1: used with online dynamic rd model
    588   // 2: used with static rd model
    589   int inter_mode_rd_model_estimation;
    590 
    591   // Skip some ref frames in compound motion search by single motion search
    592   // result. Has three levels for now: 0 referring to no skipping, and 1 - 3
    593   // increasing aggressiveness of skipping in order.
    594   // Note: The search order might affect the result. It is better to search same
    595   // single inter mode as a group.
    596   int prune_comp_search_by_single_result;
    597 
    598   // Skip certain motion modes (OBMC, warped, interintra) for single reference
    599   // motion search, using the results of single ref SIMPLE_TRANSLATION
    600   int prune_single_motion_modes_by_simple_trans;
    601 
    602   // Reuse the inter_intra_mode search result from NEARESTMV mode to other
    603   // single ref modes
    604   int reuse_inter_intra_mode;
    605 
    606   // Set the full pixel search level of obmc
    607   // 0: obmc_full_pixel_diamond
    608   // 1: obmc_refining_search_sad (faster)
    609   int obmc_full_pixel_search_level;
    610 
    611   // flag to skip NEWMV mode in drl if the motion search result is the same
    612   int skip_repeated_newmv;
    613 
    614   // Prune intra mode candidates based on source block gradient stats.
    615   int intra_angle_estimation;
    616 
    617   // Skip obmc or warped motion mode when neighborhood motion field is
    618   // identical
    619   int skip_obmc_in_uniform_mv_field;
    620   int skip_wm_in_uniform_mv_field;
    621 
    622   // Enable/disable ME for interinter wedge search.
    623   int disable_interinter_wedge_newmv_search;
    624 
    625   // Enable/disable smooth inter-intra mode
    626   int disable_smooth_interintra;
    627 
    628   // skip sharp_filter evaluation based on regular and smooth filter rd for
    629   // dual_filter=0 case
    630   int skip_sharp_interp_filter_search;
    631 
    632   // prune wedge and compound segment approximate rd evaluation based on
    633   // compound average rd/ref_best_rd
    634   int prune_comp_type_by_comp_avg;
    635 
    636   // Prune/gate motion mode evaluation based on token based rd
    637   // during transform search for inter blocks
    638   // Values are 0 (not used) , 1 - 3 with progressively increasing
    639   // aggressiveness
    640   int prune_motion_mode_level;
    641 
    642   // Gate warp evaluation for motions of type IDENTITY,
    643   // TRANSLATION and AFFINE(based on number of warp neighbors)
    644   int prune_warp_using_wmtype;
    645 
    646   // Perform simple_motion_search on each possible subblock and use it to prune
    647   // PARTITION_HORZ and PARTITION_VERT.
    648   int simple_motion_search_prune_rect;
    649 
    650   // Perform simple motion search before none_partition to decide if we
    651   // want to split directly without trying other partition types.
    652   int simple_motion_search_split_only;
    653 
    654   // Use features from simple_motion_search to terminate prediction block
    655   // partition after PARTITION_NONE
    656   int simple_motion_search_early_term_none;
    657 
    658   int cb_pred_filter_search;
    659 
    660   // adaptive interp_filter search to allow skip of certain filter types.
    661   int adaptive_interp_filter_search;
    662 
    663   // mask for skip evaluation of certain interp_filter type.
    664   INTERP_FILTER_MASK interp_filter_search_mask;
    665 
    666   // Flag used to control the ref_best_rd based gating for chroma
    667   int perform_best_rd_based_gating_for_chroma;
    668 
    669   // Enable/disable interintra wedge search.
    670   int disable_wedge_interintra_search;
    671 
    672   // Disable loop restoration for Chroma plane
    673   int disable_loop_restoration_chroma;
    674 
    675   // Flag used to control the extent of coeff R-D optimization
    676   int perform_coeff_opt;
    677 
    678   // Flag used to control the speed of the eob selection in trellis.
    679   int trellis_eob_fast;
    680 
    681   // This flag controls the use of non-RD mode decision.
    682   int use_nonrd_pick_mode;
    683 
    684   // prune wedge and compound segment approximate rd evaluation based on
    685   // compound average modeled rd
    686   int prune_comp_type_by_model_rd;
    687 
    688   // Enable/disable smooth intra modes.
    689   int disable_smooth_intra;
    690 
    691   // use reduced ref set for real-time mode
    692   int use_real_time_ref_set;
    693 
    694   // Perform a full TX search on some modes while using the
    695   // inter-mode RD model for others. Only enabled when
    696   // inter_mode_rd_model_estimation != 0
    697   int inter_mode_rd_model_estimation_adaptive;
    698 } SPEED_FEATURES;
    699 
    700 struct AV1_COMP;
    701 
    702 void av1_set_speed_features_framesize_independent(struct AV1_COMP *cpi,
    703                                                   int speed);
    704 void av1_set_speed_features_framesize_dependent(struct AV1_COMP *cpi,
    705                                                 int speed);
    706 
    707 #ifdef __cplusplus
    708 }  // extern "C"
    709 #endif
    710 
    711 #endif  // AOM_AV1_ENCODER_SPEED_FEATURES_H_
    712