Group speed features

Code refactoring. Grouped speed features by encoding components.

Change-Id: Ica61829bb84cbb0f5af6bbec9fb45b7a133097c2
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index e650af8..8756443 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -287,21 +287,31 @@
 } UENUM1BYTE(DIST_WTD_COMP_FLAG);
 
 typedef struct SPEED_FEATURES {
-  MV_SPEED_FEATURES mv;
-
+  /*
+   * Sequence/frame level speed features:
+   */
   // Frame level coding parameter update
   int frame_parameter_update;
 
   RECODE_LOOP_TYPE recode_loop;
 
-  // Trellis (dynamic programming) optimization of quantized values
-  TRELLIS_OPT_TYPE optimize_coefficients;
+  // This feature controls the tolerence vs target used in deciding whether to
+  // recode a frame. It has no meaning if recode is disabled.
+  int recode_tolerance;
 
-  // Global motion warp error threshold
-  GM_ERRORADV_TYPE gm_erroradv_type;
+  // Use reduced 1/8th pel mv usage, in the range 0 - 2, where
+  // 0: maximizes quality and does not reduce mv precision
+  // 1: more aggressive reduced usage of high precision MV
+  // 2: use only quarter pel motion
+  int reduce_high_precision_mv_usage;
 
-  // Disable adaptive threshold for global motion warp error
-  int disable_adaptive_warp_error_thresh;
+  // Whether to disable overlay frames for filtered Altref frames,
+  // overiding oxcf->enable_overlay flag set as 1.
+  int disable_overlay_frames;
+
+  // Enable/disable adaptively deciding whether or not to encode ALTREF overlay
+  // frame.
+  int adaptive_overlay_encoding;
 
   // Always set to 0. If on it enables 0 cost background transmission
   // (except for the initial transmission of the segmentation). The feature is
@@ -310,67 +320,38 @@
   // adds overhead.
   int static_segmentation;
 
-  // Limit the inter mode tested in the RD loop
-  int reduce_inter_modes;
+  /*
+   * Global motion speed features:
+   */
+  // Global motion warp error threshold
+  GM_ERRORADV_TYPE gm_erroradv_type;
+
+  // Disable adaptive threshold for global motion warp error
+  int disable_adaptive_warp_error_thresh;
 
   // Do not compute the global motion parameters for a LAST2_FRAME or
   // LAST3_FRAME if the GOLDEN_FRAME is closer and it has a non identity
   // global model.
   int selective_ref_gm;
 
-  // If 1 we iterate finding a best reference for 2 ref frames together - via
-  // a log search that iterates 4 times (check around mv for last for best
-  // error of combined predictor then check around mv for alt). If 0 we
-  // we just use the best motion vector found for each frame by itself.
-  BLOCK_SIZE comp_inter_joint_search_thresh;
+  GM_SEARCH_TYPE gm_search_type;
 
-  // This variable is used to cap the maximum number of times we skip testing a
-  // mode to be evaluated. A high value means we will be faster.
-  int adaptive_rd_thresh;
+  // whether to disable the global motion recode loop
+  int gm_disable_recode;
 
-  // Init search depth for square and rectangular transform partitions.
-  // Values:
-  // 0 - search full tree, 1: search 1 level, 2: search the highest level only
-  int inter_tx_size_search_init_depth_sqr;
-  int inter_tx_size_search_init_depth_rect;
-  int intra_tx_size_search_init_depth_sqr;
-  int intra_tx_size_search_init_depth_rect;
-  // If any dimension of a coding block size above 64, always search the
-  // largest transform only, since the largest transform block size is 64x64.
-  int tx_size_search_lgr_block;
+  // During global motion estimation, prune remaining reference frames in a
+  // given direction(past/future), if the evaluated ref_frame in that direction
+  // yields gm_type as INVALID/TRANSLATION/IDENTITY
+  int prune_ref_frame_for_gm_search;
 
+  /*
+   * Partition search speed features:
+   */
   PARTITION_SEARCH_TYPE partition_search_type;
 
-  TX_TYPE_SEARCH tx_type_search;
-
-  // Skip split transform block partition when the collocated bigger block
-  // is selected as all zero coefficients.
-  int txb_split_cap;
-
-  // Shortcut the transform block partition and type search when the target
-  // rdcost is relatively lower.
-  // Values are 0 (not used) , or 1 - 2 with progressively increasing
-  // aggressiveness
-  int adaptive_txb_search_level;
-
-  // Prune level for tx_size_type search for inter based on rd model
-  // 0: no pruning
-  // 1-2: progressively increasing aggressiveness of pruning
-  int model_based_prune_tx_search_level;
-
-  // Model based breakout after interpolation filter search
-  // 0: no breakout
-  // 1: use model based rd breakout
-  int model_based_post_interp_filter_breakout;
-
   // Used if partition_search_type = FIXED_SIZE_PARTITION
   BLOCK_SIZE always_this_block_size;
 
-  // Drop less likely to be picked reference frames in the RD search.
-  // Has five levels for now: 0, 1, 2, 3 and 4, where higher levels prune more
-  // aggressively than lower ones. (0 means no pruning).
-  int selective_ref_frame;
-
   // Prune extended partition types search
   // Can take values 0 - 2, 0 referring to no pruning, and 1 - 2 increasing
   // aggressiveness of pruning in order.
@@ -398,12 +379,6 @@
   // Use square partition only beyond this block size.
   BLOCK_SIZE use_square_partition_only_threshold;
 
-  // Prune reference frames for rectangular partitions.
-  // 0 implies no pruning
-  // 1 implies prune for extended partition
-  // 2 implies prune horiz, vert and extended partition
-  int prune_ref_frame_for_rect_partitions;
-
   // Sets min and max square partition levels for this superblock based on
   // motion vector and prediction error distribution produced from 16x16
   // simple motion search
@@ -419,6 +394,44 @@
   // frame's partitioning. Only used if use_lastframe_partitioning is set.
   int adjust_partitioning_from_last_frame;
 
+  // Partition search early breakout thresholds.
+  int64_t partition_search_breakout_dist_thr;
+  int partition_search_breakout_rate_thr;
+
+  // Thresholds for ML based partition search breakout.
+  int ml_partition_search_breakout_thresh[PARTITION_BLOCK_SIZES];
+
+  // Allow skipping partition search for still image frame
+  int allow_partition_search_skip;
+
+  // The aggresiveness of pruning with simple_motion_search.
+  // Currently 0 is the lowest, and 2 the highest.
+  int simple_motion_search_prune_agg;
+
+  // Perform simple_motion_search on each possible subblock and use it to prune
+  // PARTITION_HORZ and PARTITION_VERT.
+  int simple_motion_search_prune_rect;
+
+  // Perform simple motion search before none_partition to decide if we
+  // want to remove all partitions other than PARTITION_SPLIT. If set to 0, this
+  // model is disabled. If set to 1, the model attempts to perform
+  // PARTITION_SPLIT only. If set to 2, the model also attempts to prune
+  // PARTITION_SPLIT.
+  int simple_motion_search_split;
+
+  // Use features from simple_motion_search to terminate prediction block
+  // partition after PARTITION_NONE
+  int simple_motion_search_early_term_none;
+
+  /*
+   * Motion search speed features:
+   */
+  MV_SPEED_FEATURES mv;
+
+  // If true, sub-pixel search uses the exact convolve function used for final
+  // encoding and decoding; otherwise, it uses bilinear interpolation.
+  SUBPEL_SEARCH_TYPE use_accurate_subpel_search;
+
   // TODO(jingning): combine the related motion search speed features
   // This allows us to use motion search at other sizes as a starting
   // point for this motion search and limits the search range around it.
@@ -442,19 +455,132 @@
   // Pattern to be used for exhaustive mesh searches of intraBC ME.
   MESH_PATTERN intrabc_mesh_patterns[MAX_MESH_STEP];
 
+  // Use to control hash generation and use of the same
+  // Applicable only for screen contents
+  int disable_hash_me;
+
+  /*
+   * Inter mode search speed features:
+   */
+  // 2-pass inter mode model estimation where the preliminary pass skips
+  // transform search and uses a model to estimate rd, while the final pass
+  // computes the full transform search. Two types of models are supported:
+  // 0: not used
+  // 1: used with online dynamic rd model
+  // 2: used with static rd model
+  int inter_mode_rd_model_estimation;
+
+  // Perform a full TX search on some modes while using the
+  // inter-mode RD model for others. Currently not in use.
+  // TODO(any): Find out when we can actually skip tx_search on some modes.
+  int inter_mode_rd_model_estimation_adaptive;
+
+  // Limit the inter mode tested in the RD loop
+  int reduce_inter_modes;
+
   // Adaptive prediction mode search
   int adaptive_mode_search;
 
+  // This variable is used to cap the maximum number of times we skip testing a
+  // mode to be evaluated. A high value means we will be faster.
+  int adaptive_rd_thresh;
+
+  // Drop less likely to be picked reference frames in the RD search.
+  // Has five levels for now: 0, 1, 2, 3 and 4, where higher levels prune more
+  // aggressively than lower ones. (0 means no pruning).
+  int selective_ref_frame;
+
+  // Prune reference frames for rectangular partitions.
+  // 0 implies no pruning
+  // 1 implies prune for extended partition
+  // 2 implies prune horiz, vert and extended partition
+  int prune_ref_frame_for_rect_partitions;
+
+  // flag to drop some ref frames in compound motion search
+  int drop_ref;
+
   int alt_ref_search_fp;
 
-  // Implements various heuristics to skip searching modes
-  // The heuristics selected are based on  flags
-  // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
-  unsigned int mode_search_skip_flags;
+  // flag to skip NEWMV mode in drl if the motion search result is the same
+  int skip_repeated_newmv;
 
-  // A source variance threshold below which filter search is disabled
-  // Choose a very large value (UINT_MAX) to use 8-tap always
-  unsigned int disable_filter_search_var_thresh;
+  // Flag used to control the ref_best_rd based gating for chroma
+  int perform_best_rd_based_gating_for_chroma;
+
+  // Skip certain motion modes (OBMC, warped, interintra) for single reference
+  // motion search, using the results of single ref SIMPLE_TRANSLATION
+  int prune_single_motion_modes_by_simple_trans;
+
+  // Reuse the inter_intra_mode search result from NEARESTMV mode to other
+  // single ref modes
+  int reuse_inter_intra_mode;
+
+  // prune wedge and compound segment approximate rd evaluation based on
+  // compound average modeled rd
+  int prune_comp_type_by_model_rd;
+
+  // prune wedge and compound segment approximate rd evaluation based on
+  // compound average rd/ref_best_rd
+  int prune_comp_type_by_comp_avg;
+
+  // Skip some ref frames in compound motion search by single motion search
+  // result. Has three levels for now: 0 referring to no skipping, and 1 - 3
+  // increasing aggressiveness of skipping in order.
+  // Note: The search order might affect the result. It assumes that the single
+  // reference modes are searched before compound modes. It is better to search
+  // same single inter mode as a group.
+  int prune_comp_search_by_single_result;
+
+  // If 1 we iterate finding a best reference for 2 ref frames together - via
+  // a log search that iterates 4 times (check around mv for last for best
+  // error of combined predictor then check around mv for alt). If 0 we
+  // we just use the best motion vector found for each frame by itself.
+  BLOCK_SIZE comp_inter_joint_search_thresh;
+
+  // Instead of performing a full MV search, do a simple translation first
+  // and only perform a full MV search on the motion vectors that performed
+  // well.
+  int prune_mode_search_simple_translation;
+
+  // Only search compound modes with at least one "good" reference frame.
+  // A reference frame is good if, after looking at its performance among
+  // the single reference modes, it is one of the two best performers.
+  int prune_compound_using_single_ref;
+
+  // Based on previous ref_mv_idx search result, prune the following search.
+  int prune_ref_mv_idx_search;
+
+  // Disable one sided compound modes.
+  int disable_onesided_comp;
+
+  // Skip obmc or warped motion mode when neighborhood motion field is
+  // identical
+  int skip_obmc_in_uniform_mv_field;
+  int skip_wm_in_uniform_mv_field;
+
+  // Prune/gate motion mode evaluation based on token based rd
+  // during transform search for inter blocks
+  // Values are 0 (not used) , 1 - 3 with progressively increasing
+  // aggressiveness
+  int prune_motion_mode_level;
+
+  // Set the full pixel search level of obmc
+  // 0: obmc_full_pixel_diamond
+  // 1: obmc_refining_search_sad (faster)
+  int obmc_full_pixel_search_level;
+
+  // Prune obmc search using previous frame stats.
+  int prune_obmc_prob_thresh;
+
+  // Disable obmc.
+  int disable_obmc;
+
+  // Gate warp evaluation for motions of type IDENTITY,
+  // TRANSLATION and AFFINE(based on number of warp neighbors)
+  int prune_warp_using_wmtype;
+
+  // Enable/disable interintra wedge search.
+  int disable_wedge_interintra_search;
 
   // Only enable wedge search if the edge strength is greater than
   // this threshold. A value of 0 signals that this check is disabled.
@@ -469,67 +595,41 @@
   // Whether to prune wedge search based on predictor difference
   int prune_wedge_pred_diff_based;
 
-  // These bit masks allow you to enable or disable intra modes for each
-  // transform size separately.
-  int intra_y_mode_mask[TX_SIZES];
-  int intra_uv_mode_mask[TX_SIZES];
+  // Enable/disable ME for interinter wedge search.
+  int disable_interinter_wedge_newmv_search;
 
-  // This feature controls how the loop filter level is determined.
-  LPF_PICK_METHOD lpf_pick;
+  // Enable/disable ME for interinter diffwtd search. PSNR BD-rate gain of
+  // ~0.1 on the lowres test set, but ~15% slower computation.
+  int enable_interinter_diffwtd_newmv_search;
 
-  // Control how the CDEF strength is determined.
-  CDEF_PICK_METHOD cdef_pick_method;
+  // Enable/disable smooth inter-intra mode
+  int disable_smooth_interintra;
 
-  // This feature controls whether we do the expensive context update and
-  // calculation in the rd coefficient costing loop.
-  int use_fast_coef_costing;
+  // Disable interinter_wedge
+  int disable_interinter_wedge;
 
-  // This feature controls the tolerence vs target used in deciding whether to
-  // recode a frame. It has no meaning if recode is disabled.
-  int recode_tolerance;
+  // Decide when and how to use joint_comp.
+  DIST_WTD_COMP_FLAG use_dist_wtd_comp_flag;
 
-  // This variable controls the maximum block size where intra blocks can be
-  // used in inter frames.
-  // TODO(aconverse): Fold this into one of the other many mode skips
-  BLOCK_SIZE max_intra_bsize;
+  // Whether to override and disable sb level coeff cost updates, if
+  // cpi->oxcf.coeff_cost_upd_freq = COST_UPD_SB (i.e. set at SB level)
+  int disable_sb_level_coeff_cost_upd;
 
-  // Partition search early breakout thresholds.
-  int64_t partition_search_breakout_dist_thr;
-  int partition_search_breakout_rate_thr;
+  // Whether to override and disable sb level mv cost updates, if
+  // cpi->oxcf.coeff_cost_upd_freq = COST_UPD_SB (i.e. set at SB level)
+  int disable_sb_level_mv_cost_upd;
 
-  // Thresholds for ML based partition search breakout.
-  int ml_partition_search_breakout_thresh[PARTITION_BLOCK_SIZES];
+  // Model based breakout after interpolation filter search
+  // 0: no breakout
+  // 1: use model based rd breakout
+  int model_based_post_interp_filter_breakout;
 
-  // Allow skipping partition search for still image frame
-  int allow_partition_search_skip;
-
-  // Fast approximation of av1_model_rd_from_var_lapndz
-  int simple_model_rd_from_var;
-
-  // If true, sub-pixel search uses the exact convolve function used for final
-  // encoding and decoding; otherwise, it uses bilinear interpolation.
-  SUBPEL_SEARCH_TYPE use_accurate_subpel_search;
-
-  // Whether to compute distortion in the image domain (slower but
-  // more accurate), or in the transform domain (faster but less acurate).
-  // 0: use image domain
-  // 1: use transform domain in tx_type search, and use image domain for
-  // RD_STATS
-  // 2: use transform domain
-  int tx_domain_dist_level;
-
-  // Transform domain distortion threshold level
-  int tx_domain_dist_thres_level;
-
-  GM_SEARCH_TYPE gm_search_type;
-
-  // whether to disable the global motion recode loop
-  int gm_disable_recode;
-
-  // During global motion estimation, prune remaining reference frames in a
-  // given direction(past/future), if the evaluated ref_frame in that direction
-  // yields gm_type as INVALID/TRANSLATION/IDENTITY
-  int prune_ref_frame_for_gm_search;
+  /*
+   * Interpolation filter search speed features:
+   */
+  // A source variance threshold below which filter search is disabled
+  // Choose a very large value (UINT_MAX) to use 8-tap always
+  unsigned int disable_filter_search_var_thresh;
 
   // Do limited interpolation filter search for dual filters, since best choice
   // usually includes EIGHTTAP_REGULAR.
@@ -543,12 +643,27 @@
   // saved results, filter search can be skipped.
   int use_interp_filter;
 
-  // Use a hash table to store previously computed optimized qcoeffs from
-  // expensive calls to optimize_txb.
-  int use_hash_based_trellis;
+  // skip sharp_filter evaluation based on regular and smooth filter rd for
+  // dual_filter=0 case
+  int skip_sharp_interp_filter_search;
 
-  // flag to drop some ref frames in compound motion search
-  int drop_ref;
+  int cb_pred_filter_search;
+
+  // adaptive interp_filter search to allow skip of certain filter types.
+  int adaptive_interp_filter_search;
+
+  /*
+   * Intra mode search speed features:
+   */
+  // These bit masks allow you to enable or disable intra modes for each
+  // transform size separately.
+  int intra_y_mode_mask[TX_SIZES];
+  int intra_uv_mode_mask[TX_SIZES];
+
+  // This variable controls the maximum block size where intra blocks can be
+  // used in inter frames.
+  // TODO(aconverse): Fold this into one of the other many mode skips
+  BLOCK_SIZE max_intra_bsize;
 
   // flag to allow skipping intra mode for inter frame prediction
   int skip_intra_in_interframe;
@@ -557,6 +672,51 @@
   // in inter frame prediction
   unsigned int src_var_thresh_intra_skip;
 
+  // Prune intra mode candidates based on source block histogram of gradient.
+  int intra_pruning_with_hog;
+
+  // TODO(anyone): tune intra_pruning_with_hog_thresh for various speeds.
+  float intra_pruning_with_hog_thresh;
+
+  // Use CNN with luma pixels on source frame on each of the 64x64 subblock to
+  // perform split/no_split decision on intra-frames.
+  int intra_cnn_split;
+
+  // Enable/disable smooth intra modes.
+  int disable_smooth_intra;
+
+  /*
+   * Transform size/type search speed features:
+   */
+  // Init search depth for square and rectangular transform partitions.
+  // Values:
+  // 0 - search full tree, 1: search 1 level, 2: search the highest level only
+  int inter_tx_size_search_init_depth_sqr;
+  int inter_tx_size_search_init_depth_rect;
+  int intra_tx_size_search_init_depth_sqr;
+  int intra_tx_size_search_init_depth_rect;
+
+  // If any dimension of a coding block size above 64, always search the
+  // largest transform only, since the largest transform block size is 64x64.
+  int tx_size_search_lgr_block;
+
+  TX_TYPE_SEARCH tx_type_search;
+
+  // Skip split transform block partition when the collocated bigger block
+  // is selected as all zero coefficients.
+  int txb_split_cap;
+
+  // Shortcut the transform block partition and type search when the target
+  // rdcost is relatively lower.
+  // Values are 0 (not used) , or 1 - 2 with progressively increasing
+  // aggressiveness
+  int adaptive_txb_search_level;
+
+  // Prune level for tx_size_type search for inter based on rd model
+  // 0: no pruning
+  // 1-2: progressively increasing aggressiveness of pruning
+  int model_based_prune_tx_search_level;
+
   // Use hash table to store intra(keyframe only) txb transform search results
   // to avoid repeated search on the same residue signal.
   int use_intra_txb_hash;
@@ -565,137 +725,50 @@
   // to avoid repeated search on the same residue signal.
   int use_inter_txb_hash;
 
+  /*
+   * RD calculation speed features:
+   */
+  // This feature controls whether we do the expensive context update and
+  // calculation in the rd coefficient costing loop.
+  int use_fast_coef_costing;
+
+  // Fast approximation of av1_model_rd_from_var_lapndz
+  int simple_model_rd_from_var;
+
+  // Whether to compute distortion in the image domain (slower but
+  // more accurate), or in the transform domain (faster but less acurate).
+  // 0: use image domain
+  // 1: use transform domain in tx_type search, and use image domain for
+  // RD_STATS
+  // 2: use transform domain
+  int tx_domain_dist_level;
+
+  // Transform domain distortion threshold level
+  int tx_domain_dist_thres_level;
+
+  // Trellis (dynamic programming) optimization of quantized values
+  TRELLIS_OPT_TYPE optimize_coefficients;
+
+  // Use a hash table to store previously computed optimized qcoeffs from
+  // expensive calls to optimize_txb.
+  int use_hash_based_trellis;
+
   // Use hash table to store macroblock RD search results
   // to avoid repeated search on the same residue signal.
   int use_mb_rd_hash;
 
-  // Use to control hash generation and use of the same
-  // Applicable only for screen contents
-  int disable_hash_me;
+  // Flag used to control the speed of the eob selection in trellis.
+  int trellis_eob_fast;
 
   // Calculate RD cost before doing optimize_b, and skip if the cost is large.
   int optimize_b_precheck;
 
-  // Decide when and how to use joint_comp.
-  DIST_WTD_COMP_FLAG use_dist_wtd_comp_flag;
-
-  // Decoder side speed feature to add penalty for use of dual-sgr filters.
-  // Takes values 0 - 10, 0 indicating no penalty and each additional level
-  // adding a penalty of 1%
-  int dual_sgr_penalty_level;
-
-  // 2-pass inter mode model estimation where the preliminary pass skips
-  // transform search and uses a model to estimate rd, while the final pass
-  // computes the full transform search. Two types of models are supported:
-  // 0: not used
-  // 1: used with online dynamic rd model
-  // 2: used with static rd model
-  int inter_mode_rd_model_estimation;
-
-  // Skip some ref frames in compound motion search by single motion search
-  // result. Has three levels for now: 0 referring to no skipping, and 1 - 3
-  // increasing aggressiveness of skipping in order.
-  // Note: The search order might affect the result. It assumes that the single
-  // reference modes are searched before compound modes. It is better to search
-  // same single inter mode as a group.
-  int prune_comp_search_by_single_result;
-
-  // Skip certain motion modes (OBMC, warped, interintra) for single reference
-  // motion search, using the results of single ref SIMPLE_TRANSLATION
-  int prune_single_motion_modes_by_simple_trans;
-
-  // Reuse the inter_intra_mode search result from NEARESTMV mode to other
-  // single ref modes
-  int reuse_inter_intra_mode;
-
-  // Set the full pixel search level of obmc
-  // 0: obmc_full_pixel_diamond
-  // 1: obmc_refining_search_sad (faster)
-  int obmc_full_pixel_search_level;
-
-  // flag to skip NEWMV mode in drl if the motion search result is the same
-  int skip_repeated_newmv;
-
-  // Prune intra mode candidates based on source block histogram of gradient.
-  int intra_pruning_with_hog;
-  // TODO(anyone): tune intra_pruning_with_hog_thresh for various speeds.
-  float intra_pruning_with_hog_thresh;
-
-  // Skip obmc or warped motion mode when neighborhood motion field is
-  // identical
-  int skip_obmc_in_uniform_mv_field;
-  int skip_wm_in_uniform_mv_field;
-
-  // Enable/disable ME for interinter wedge search.
-  int disable_interinter_wedge_newmv_search;
-
-  // Enable/disable ME for interinter diffwtd search. PSNR BD-rate gain of
-  // ~0.1 on the lowres test set, but ~15% slower computation.
-  int enable_interinter_diffwtd_newmv_search;
-
-  // Enable/disable smooth inter-intra mode
-  int disable_smooth_interintra;
-
-  // skip sharp_filter evaluation based on regular and smooth filter rd for
-  // dual_filter=0 case
-  int skip_sharp_interp_filter_search;
-
-  // prune wedge and compound segment approximate rd evaluation based on
-  // compound average rd/ref_best_rd
-  int prune_comp_type_by_comp_avg;
-
-  // Prune/gate motion mode evaluation based on token based rd
-  // during transform search for inter blocks
-  // Values are 0 (not used) , 1 - 3 with progressively increasing
-  // aggressiveness
-  int prune_motion_mode_level;
-
-  // prune sgr ep using binary search like mechanism
-  int enable_sgr_ep_pruning;
-
-  // Gate warp evaluation for motions of type IDENTITY,
-  // TRANSLATION and AFFINE(based on number of warp neighbors)
-  int prune_warp_using_wmtype;
-
-  // The aggresiveness of pruning with simple_motion_search.
-  // Currently 0 is the lowest, and 2 the highest.
-  int simple_motion_search_prune_agg;
-
-  // Perform simple_motion_search on each possible subblock and use it to prune
-  // PARTITION_HORZ and PARTITION_VERT.
-  int simple_motion_search_prune_rect;
-
-  // Perform simple motion search before none_partition to decide if we
-  // want to remove all partitions other than PARTITION_SPLIT. If set to 0, this
-  // model is disabled. If set to 1, the model attempts to perform
-  // PARTITION_SPLIT only. If set to 2, the model also attempts to prune
-  // PARTITION_SPLIT.
-  int simple_motion_search_split;
-
-  // Use features from simple_motion_search to terminate prediction block
-  // partition after PARTITION_NONE
-  int simple_motion_search_early_term_none;
-
-  int cb_pred_filter_search;
-
-  // adaptive interp_filter search to allow skip of certain filter types.
-  int adaptive_interp_filter_search;
-
-  // Flag used to control the ref_best_rd based gating for chroma
-  int perform_best_rd_based_gating_for_chroma;
-
-  // Enable/disable interintra wedge search.
-  int disable_wedge_interintra_search;
-
-  // Disable loop restoration for Chroma plane
-  int disable_loop_restoration_chroma;
-
-  // Reduce the wiener filter win size for luma
-  int reduce_wiener_window_size;
-
   // Flag used to control the extent of coeff R-D optimization
   int perform_coeff_opt;
 
+  /*
+   * Two-pass mode evaluation features:
+   */
   // Flag used to control the winner mode processing for better R-D optimization
   // of quantized coeffs
   int enable_winner_mode_for_coeff_opt;
@@ -718,127 +791,92 @@
   // Flag used to enable processing of multiple winner modes
   int enable_multiwinner_mode_process;
 
-  // Flag used to control the speed of the eob selection in trellis.
-  int trellis_eob_fast;
+  // Motion mode for winner candidates:
+  // 0: speed feature OFF
+  // 1 / 2 : Use configured number of winner candidates
+  int motion_mode_for_winner_cand;
 
-  // This flag controls the use of non-RD mode decision.
-  int use_nonrd_pick_mode;
+  /*
+   * In-loop filter speed features:
+   */
+  // This feature controls how the loop filter level is determined.
+  LPF_PICK_METHOD lpf_pick;
 
-  // prune wedge and compound segment approximate rd evaluation based on
-  // compound average modeled rd
-  int prune_comp_type_by_model_rd;
+  // Control how the CDEF strength is determined.
+  CDEF_PICK_METHOD cdef_pick_method;
 
-  // Enable/disable smooth intra modes.
-  int disable_smooth_intra;
+  // Decoder side speed feature to add penalty for use of dual-sgr filters.
+  // Takes values 0 - 10, 0 indicating no penalty and each additional level
+  // adding a penalty of 1%
+  int dual_sgr_penalty_level;
 
-  // use reduced ref set for real-time mode
-  int use_real_time_ref_set;
+  // prune sgr ep using binary search like mechanism
+  int enable_sgr_ep_pruning;
 
-  // Perform a full TX search on some modes while using the
-  // inter-mode RD model for others. Currently not in use.
-  // TODO(any): Find out when we can actually skip tx_search on some modes.
-  int inter_mode_rd_model_estimation_adaptive;
+  // Disable loop restoration for Chroma plane
+  int disable_loop_restoration_chroma;
 
-  // Reuse inter prediction in fast non-rd mode.
-  int reuse_inter_pred_nonrd;
+  // Reduce the wiener filter win size for luma
+  int reduce_wiener_window_size;
+
+  // Disable loop restoration filter
+  int disable_lr_filter;
+
+  /*
+   * Real-time mode speed features:
+   */
+  // check intra prediction for non-RD mode.
+  int check_intra_pred_nonrd;
 
   // Perform coarse ME before calculating variance in variance-based partition
   int estimate_motion_for_var_based_partition;
 
-  // Instead of performing a full MV search, do a simple translation first
-  // and only perform a full MV search on the motion vectors that performed
-  // well.
-  int prune_mode_search_simple_translation;
+  int nonrd_merge_partition;
+
+  // Implements various heuristics to skip searching modes
+  // The heuristics selected are based on  flags
+  // defined in the MODE_SEARCH_SKIP_HEURISTICS enum
+  unsigned int mode_search_skip_flags;
+
+  // For nonrd: Reduces golden mode search/testing in nonrd pickmode.
+  int nonrd_reduce_golden_mode_search;
+
+  // This flag controls the use of non-RD mode decision.
+  int use_nonrd_pick_mode;
+
+  // Use ALTREF frame in non-RD mode decision.
+  int use_nonrd_altref_frame;
 
   // Use compound reference for non-RD mode.
   int use_comp_ref_nonrd;
 
-  // check intra prediction for non-RD mode.
-  int check_intra_pred_nonrd;
-
-  // Only search compound modes with at least one "good" reference frame.
-  // A reference frame is good if, after looking at its performance among
-  // the single reference modes, it is one of the two best performers.
-  int prune_compound_using_single_ref;
-
-  // Disable one sided compound modes.
-  int disable_onesided_comp;
-
-  // Use CNN with luma pixels on source frame on each of the 64x64 subblock to
-  // perform split/no_split decision on intra-frames.
-  int intra_cnn_split;
-
-  // Use modeled (currently CurvFit model) RDCost for fast non-RD mode
-  int use_modeled_non_rd_cost;
+  // use reduced ref set for real-time mode
+  int use_real_time_ref_set;
 
   // Skip a number of expensive mode evaluations for blocks with very low
   // temporal variance.
   int short_circuit_low_temp_var;
 
-  // Use interpolation filter search in non-RD mode decision.
-  int use_nonrd_filter_search;
+  // Use modeled (currently CurvFit model) RDCost for fast non-RD mode
+  int use_modeled_non_rd_cost;
 
-  // Use reduced 1/8th pel mv usage, in the range 0 - 2, where
-  // 0: maximizes quality and does not reduce mv precision
-  // 1: more aggressive reduced usage of high precision MV
-  // 2: use only quarter pel motion
-  int reduce_high_precision_mv_usage;
-
-  // Whether to override and disable sb level coeff cost updates, if
-  // cpi->oxcf.coeff_cost_upd_freq = COST_UPD_SB (i.e. set at SB level)
-  int disable_sb_level_coeff_cost_upd;
-
-  // Whether to override and disable sb level mv cost updates, if
-  // cpi->oxcf.coeff_cost_upd_freq = COST_UPD_SB (i.e. set at SB level)
-  int disable_sb_level_mv_cost_upd;
-
-  // Whether to disable overlay frames for filtered Altref frames,
-  // overiding oxcf->enable_overlay flag set as 1.
-  int disable_overlay_frames;
-
-  // Enable/disable adaptively deciding whether or not to encode ALTREF overlay
-  // frame.
-  int adaptive_overlay_encoding;
-
-  // Prune obmc search using previous frame stats.
-  int prune_obmc_prob_thresh;
-
-  // Disable obmc.
-  int disable_obmc;
-
-  // Use ALTREF frame in non-RD mode decision.
-  int use_nonrd_altref_frame;
-
-  // If set forces interpolation filter to EIGHTTAP_REGULAR
-  int skip_interp_filter_search;
-
-  // Based on previous ref_mv_idx search result, prune the following search.
-  int prune_ref_mv_idx_search;
-
-  // For nonrd: use block_yrd for rd cost in interpolation filter search.
-  int nonrd_use_blockyrd_interp_filter;
-
-  // Forces TX search off for RDCost calulation.
-  int force_tx_search_off;
+  // Reuse inter prediction in fast non-rd mode.
+  int reuse_inter_pred_nonrd;
 
   // Number of best inter modes to search transform. INT_MAX - search all.
   int num_inter_modes_for_tx_search;
 
-  int nonrd_merge_partition;
+  // Forces TX search off for RDCost calulation.
+  int force_tx_search_off;
 
-  // For nonrd: Reduces golden mode search/testing in nonrd pickmode.
-  int nonrd_reduce_golden_mode_search;
+  // For nonrd: use block_yrd for rd cost in interpolation filter search.
+  int nonrd_use_blockyrd_interp_filter;
 
-  // Disable loop restoration filter
-  int disable_lr_filter;
+  // Use interpolation filter search in non-RD mode decision.
+  int use_nonrd_filter_search;
 
-  // Disable interinter_wedge
-  int disable_interinter_wedge;
-
-  // Motion mode for winner candidates:
-  // 0: speed feature OFF
-  // 1 / 2 : Use configured number of winner candidates
-  int motion_mode_for_winner_cand;
+  // If set forces interpolation filter to EIGHTTAP_REGULAR
+  int skip_interp_filter_search;
 } SPEED_FEATURES;
 
 struct AV1_COMP;