Code cleanup related to winner mode speed feature

Initialization of speed features related to winner mode are unified based
on the lookup table.
Speed features considered for this patch,
- enable_winner_mode_for_tx_size_srch
- enable_winner_mode_for_use_tx_domain_dist
- enable_winner_mode_for_coeff_opt

Change-Id: I14192ed6bf82170ee5117517102fb298c52e9791
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 7e50dfa..f4aebd9 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -418,6 +418,7 @@
   int must_find_valid_partition;
   int recalc_luma_mc_data;  // Flag to indicate recalculation of MC data during
                             // interpolation filter search
+  uint32_t tx_domain_dist_threshold;
   int use_transform_domain_distortion;
   // The likelihood of an edge existing in the block (using partial Canny edge
   // detection). For reference, 556 is the value returned for a solid
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index e1fd083..9222c5f 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4823,7 +4823,7 @@
   cm->coded_lossless = is_coded_lossless(cm, xd);
   cm->all_lossless = cm->coded_lossless && !av1_superres_scaled(cm);
 
-  cm->tx_mode = select_tx_mode(cpi, cpi->sf.tx_size_search_method);
+  cm->tx_mode = get_eval_tx_mode(cpi, DEFAULT_EVAL);
 
   // Fix delta q resolution for the moment
   cm->delta_q_info.delta_q_res = 0;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 45f5dec..611c71e 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -998,14 +998,39 @@
   int max_comp_type_rd_threshold_mul;
   int max_comp_type_rd_threshold_div;
 
-  unsigned int tx_domain_dist_threshold;
+  // Threshold of transform domain distortion
+  // Index 0: Default mode evaluation, Winner mode processing is not applicable
+  // (Eg : IntraBc).
+  // Index 1: Mode evaluation.
+  // Index 2: Winner mode evaluation.
+  // Index 1 and 2 are applicable when enable_winner_mode_for_use_tx_domain_dist
+  // speed feature is ON
+  unsigned int tx_domain_dist_threshold[MODE_EVAL_TYPES];
 
   // Factor to control R-D optimization of coeffs based on block
   // mse.
-  // Index 0 corresponds to the modes where winner mode processing is not
-  // applicable (Eg : IntraBc). Index 1 corresponds to the mode evaluation and
-  // is applicable when enable_winner_mode_for_coeff_opt speed feature is ON
-  unsigned int coeff_opt_dist_threshold[2];
+  // Index 0: Default mode evaluation, Winner mode processing is not applicable
+  // (Eg : IntraBc). Index 1: Mode evaluation.
+  // Index 2: Winner mode evaluation
+  // Index 1 and 2 are applicable when enable_winner_mode_for_coeff_opt speed
+  // feature is ON
+  unsigned int coeff_opt_dist_threshold[MODE_EVAL_TYPES];
+
+  // Transform size to be used in transform search
+  // Index 0: Default mode evaluation, Winner mode processing is not applicable
+  // (Eg : IntraBc).
+  // Index 1: Mode evaluation. Index 2: Winner mode evaluation
+  // Index 1 and 2 are applicable when enable_winner_mode_for_tx_size_srch speed
+  // feature is ON
+  TX_SIZE_SEARCH_METHOD tx_size_search_methods[MODE_EVAL_TYPES];
+
+  // Transform domain distortion levels
+  // Index 0: Default mode evaluation, Winner mode processing is not applicable
+  // (Eg : IntraBc).
+  // Index 1: Mode evaluation. Index 2: Winner mode evaluation
+  // Index 1 and 2 are applicable when enable_winner_mode_for_use_tx_domain_dist
+  // speed feature is ON
+  unsigned int use_transform_domain_distortion[MODE_EVAL_TYPES];
 
   AV1LfSync lf_row_sync;
   AV1LrSync lr_row_sync;
diff --git a/av1/encoder/rd.h b/av1/encoder/rd.h
index f4c22fa..22b25de 100644
--- a/av1/encoder/rd.h
+++ b/av1/encoder/rd.h
@@ -50,6 +50,17 @@
 // Factor to weigh the rate for switchable interp filters.
 #define SWITCHABLE_INTERP_RATE_FACTOR 1
 
+enum {
+  // Default initialization
+  DEFAULT_EVAL = 0,
+  // Initialization for default mode evaluation
+  MODE_EVAL,
+  // Initialization for winner mode evaluation
+  WINNER_MODE_EVAL,
+  // All mode evaluation types
+  MODE_EVAL_TYPES,
+} UENUM1BYTE(MODE_EVAL_TYPE);
+
 typedef struct RD_OPT {
   // Thresh_mult is used to set a threshold for the rd score. A higher value
   // means that we will accept the best mode so far more often. This number
@@ -260,7 +271,7 @@
     const uint32_t *const coeff_opt_dist_threshold,
     int enable_winner_mode_for_coeff_opt, int is_winner_mode) {
   // Default initialization of threshold
-  uint32_t coeff_opt_thresh = coeff_opt_dist_threshold[0];
+  uint32_t coeff_opt_thresh = coeff_opt_dist_threshold[DEFAULT_EVAL];
   // TODO(any): Experiment with coeff_opt_dist_threshold values when
   // enable_winner_mode_for_coeff_opt is ON
   // TODO(any): Skip the winner mode processing for blocks with lower residual
@@ -270,9 +281,9 @@
     // Use conservative threshold during mode decision and perform R-D
     // optimization of coeffs always for winner modes
     if (is_winner_mode)
-      coeff_opt_thresh = UINT32_MAX;
+      coeff_opt_thresh = coeff_opt_dist_threshold[WINNER_MODE_EVAL];
     else
-      coeff_opt_thresh = coeff_opt_dist_threshold[1];
+      coeff_opt_thresh = coeff_opt_dist_threshold[MODE_EVAL];
   }
   return coeff_opt_thresh;
 }
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 12a4a96..7dac924 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -3168,7 +3168,7 @@
   // TODO(any): Experiment with variance and mean based thresholds
   int use_transform_domain_distortion =
       (x->use_transform_domain_distortion > 0) &&
-      (block_mse_q8 >= cpi->tx_domain_dist_threshold) &&
+      (block_mse_q8 >= x->tx_domain_dist_threshold) &&
       // Any 64-pt transforms only preserves half the coefficients.
       // Therefore transform domain distortion is not valid for these
       // transform sizes.
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index bdb0844..7d05019 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -36,15 +36,6 @@
 struct macroblock;
 struct RD_STATS;
 
-enum {
-  // Default initialization
-  DEFAULT_EVAL = 0,
-  // Initialization for default mode evaluation
-  MODE_EVAL,
-  // Initialization for winner mode evaluation
-  WINNER_MODE_EVAL,
-} UENUM1BYTE(MODE_EVAL_TYPE);
-
 #if CONFIG_RD_DEBUG
 static INLINE void av1_update_txb_coeff_cost(RD_STATS *rd_stats, int plane,
                                              TX_SIZE tx_size, int blk_row,
@@ -236,31 +227,45 @@
     return cpi->common.tx_mode;
 }
 
+static INLINE TX_MODE get_eval_tx_mode(const AV1_COMP *cpi,
+                                       MODE_EVAL_TYPE eval_type) {
+  return select_tx_mode(cpi, cpi->tx_size_search_methods[eval_type]);
+}
+
 static INLINE void set_tx_size_search_method(
     const struct AV1_COMP *cpi, MACROBLOCK *x,
     int enable_winner_mode_for_tx_size_srch, int is_winner_mode) {
   // Populate transform size search method/transform mode appropriately
-  if (enable_winner_mode_for_tx_size_srch && !is_winner_mode) {
-    x->tx_size_search_method = USE_LARGESTALL;
-  } else {
-    x->tx_size_search_method = cpi->sf.tx_size_search_method;
+  x->tx_size_search_method = cpi->tx_size_search_methods[DEFAULT_EVAL];
+  if (enable_winner_mode_for_tx_size_srch) {
+    if (is_winner_mode)
+      x->tx_size_search_method = cpi->tx_size_search_methods[WINNER_MODE_EVAL];
+    else
+      x->tx_size_search_method = cpi->tx_size_search_methods[MODE_EVAL];
   }
   x->tx_mode = select_tx_mode(cpi, x->tx_size_search_method);
 }
 
-static INLINE void set_tx_domain_dist_type(
+static INLINE void set_tx_domain_dist_params(
     const struct AV1_COMP *cpi, MACROBLOCK *x,
     int enable_winner_mode_for_tx_domain_dist, int is_winner_mode) {
   if (!enable_winner_mode_for_tx_domain_dist) {
     x->use_transform_domain_distortion =
-        cpi->sf.use_transform_domain_distortion;
+        cpi->use_transform_domain_distortion[DEFAULT_EVAL];
+    x->tx_domain_dist_threshold = cpi->tx_domain_dist_threshold[DEFAULT_EVAL];
     return;
   }
 
-  if (is_winner_mode)
-    x->use_transform_domain_distortion = 0;
-  else
-    x->use_transform_domain_distortion = 2;
+  if (is_winner_mode) {
+    x->use_transform_domain_distortion =
+        cpi->use_transform_domain_distortion[WINNER_MODE_EVAL];
+    x->tx_domain_dist_threshold =
+        cpi->tx_domain_dist_threshold[WINNER_MODE_EVAL];
+  } else {
+    x->use_transform_domain_distortion =
+        cpi->use_transform_domain_distortion[MODE_EVAL];
+    x->tx_domain_dist_threshold = cpi->tx_domain_dist_threshold[MODE_EVAL];
+  }
 }
 
 // Checks the conditions to enable winner mode processing
@@ -302,7 +307,7 @@
       x->use_default_inter_tx_type = 0;
       x->use_default_intra_tx_type = 0;
       // Set default transform domain distortion type
-      set_tx_domain_dist_type(cpi, x, 0, 0);
+      set_tx_domain_dist_params(cpi, x, 0, 0);
 
       // Get default threshold for R-D optimization of coefficients
       x->coeff_opt_dist_threshold =
@@ -318,8 +323,8 @@
           cpi->sf.tx_type_search.fast_inter_tx_type_search;
 
       // Set transform domain distortion type for mode evaluation
-      set_tx_domain_dist_type(cpi, x,
-                              sf->enable_winner_mode_for_use_tx_domain_dist, 0);
+      set_tx_domain_dist_params(
+          cpi, x, sf->enable_winner_mode_for_use_tx_domain_dist, 0);
 
       // Get threshold for R-D optimization of coefficients during mode
       // evaluation
@@ -335,8 +340,8 @@
       x->use_default_intra_tx_type = 0;
 
       // Set transform domain distortion type for winner mode evaluation
-      set_tx_domain_dist_type(cpi, x,
-                              sf->enable_winner_mode_for_use_tx_domain_dist, 1);
+      set_tx_domain_dist_params(
+          cpi, x, sf->enable_winner_mode_for_use_tx_domain_dist, 1);
 
       // Get threshold for R-D optimization of coefficients for winner mode
       // evaluation
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index e09d674..b455abb 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -48,21 +48,50 @@
 
 // Threshold values to be used for pruning the txfm_domain_distortion
 // based on block MSE
+// Index 0: Default mode evaluation, Winner mode processing is not
+// applicable (Eg : IntraBc). Index 1: Mode evaluation.
+// Index 2: Winner mode evaluation. Index 1 and 2 are applicable when
+// enable_winner_mode_for_use_tx_domain_dist speed feature is ON
 // TODO(any): Experiment the threshold logic based on variance metric
-static unsigned int tx_domain_dist_thresholds[MAX_TX_DOMAIN_EVAL_SPEED + 1] = {
-  UINT_MAX, 22026, 22026, 22026, 22026, 0
+static unsigned int tx_domain_dist_thresholds[3][MODE_EVAL_TYPES] = {
+  { UINT_MAX, UINT_MAX, UINT_MAX }, { 22026, 22026, 22026 }, { 0, 0, 0 }
 };
+
+// Transform domain distortion type to be used for default, mode and winner mode
+// evaluation Index 0: Default mode evaluation, Winner mode processing is not
+// applicable (Eg : IntraBc). Index 1: Mode evaluation. Index 2: Winner mode
+// evaluation. Index 1 and 2 are applicable when
+// enable_winner_mode_for_use_tx_domain_dist speed feature is ON
+static unsigned int tx_domain_dist_types[3][MODE_EVAL_TYPES] = { { 0, 2, 0 },
+                                                                 { 1, 2, 0 },
+                                                                 { 2, 2, 0 } };
+
 // Threshold values to be used for disabling coeff RD-optimization
 // based on block MSE
 // TODO(any): Experiment the threshold logic based on variance metric
-// Index 0 corresponds to the modes where winner mode processing is not
-// applicable (Eg : IntraBc). Index 1 corresponds to the mode evaluation and is
-// applicable when enable_winner_mode_for_coeff_opt speed feature is ON
-static unsigned int coeff_opt_dist_thresholds[5][2] = { { UINT_MAX, UINT_MAX },
-                                                        { 442413, 36314 },
-                                                        { 162754, 36314 },
-                                                        { 22026, 22026 },
-                                                        { 22026, 22026 } };
+// Index 0: Default mode evaluation, Winner mode processing is not applicable
+// (Eg : IntraBc) Index 1: Mode evaluation. Index 2: Winner mode evaluation.
+// Index 1 and 2 are applicable when enable_winner_mode_for_coeff_opt speed
+// feature is ON
+static unsigned int coeff_opt_dist_thresholds[5][MODE_EVAL_TYPES] = {
+  { UINT_MAX, UINT_MAX, UINT_MAX },
+  { 442413, 36314, UINT_MAX },
+  { 162754, 36314, UINT_MAX },
+  { 22026, 22026, UINT_MAX },
+  { 22026, 22026, UINT_MAX }
+};
+
+// Transform size to be used for default, mode and winner mode evaluation
+// Index 0: Default mode evaluation, Winner mode processing is not applicable
+// (Eg : IntraBc) Index 1: Mode evaluation. Index 2: Winner mode evaluation.
+// Index 1 and 2 are applicable when enable_winner_mode_for_tx_size_srch speed
+// feature is ON
+static TX_SIZE_SEARCH_METHOD tx_size_search_methods[3][MODE_EVAL_TYPES] = {
+  { USE_FULL_RD, USE_LARGESTALL, USE_FULL_RD },
+  { USE_FAST_RD, USE_LARGESTALL, USE_FULL_RD },
+  { USE_LARGESTALL, USE_LARGESTALL, USE_FULL_RD }
+};
+
 // scaling values to be used for gating wedge/compound segment based on best
 // approximate rd
 static int comp_type_rd_threshold_mul[3] = { 1, 11, 12 };
@@ -281,7 +310,8 @@
     sf->gm_search_type = GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2;
     sf->disable_adaptive_warp_error_thresh = 0;
     sf->cb_pred_filter_search = 1;
-    sf->use_transform_domain_distortion = boosted ? 1 : 2;
+    sf->tx_domain_dist_level = boosted ? 1 : 2;
+    sf->tx_domain_dist_thres_level = 1;
     sf->perform_coeff_opt = boosted ? 1 : 2;
     sf->prune_ref_frame_for_rect_partitions =
         (frame_is_intra_only(&cpi->common) || (cm->allow_screen_content_tools))
@@ -413,7 +443,8 @@
     //     : FLAG_SKIP_INTRA_DIRMISMATCH | FLAG_SKIP_INTRA_BESTINTER |
     //     FLAG_SKIP_COMP_BESTINTRA | FLAG_SKIP_INTRA_LOWVAR |
     //     FLAG_EARLY_TERMINATE;
-    // sf->use_transform_domain_distortion = 2;
+    // sf->tx_domain_dist_level = 2;
+    sf->tx_domain_dist_thres_level = 2;
     sf->simple_motion_search_prune_agg = 2;
   }
 }
@@ -500,7 +531,8 @@
     sf->prune_motion_mode_level = 2;
     sf->gm_search_type = GM_REDUCED_REF_SEARCH_SKIP_L2_L3_ARF2;
     sf->cb_pred_filter_search = 1;
-    sf->use_transform_domain_distortion = boosted ? 0 : 1;
+    sf->tx_domain_dist_level = boosted ? 0 : 1;
+    sf->tx_domain_dist_thres_level = 1;
   }
 
   if (speed >= 2) {
@@ -532,14 +564,14 @@
 
   if (speed >= 3) {
     sf->selective_ref_frame = 4;
-    sf->tx_size_search_method = boosted ? USE_FULL_RD : USE_LARGESTALL;
+    sf->tx_size_search_level = boosted ? 0 : 2;
     sf->less_rectangular_check_level = 2;
     // adaptive_motion_search breaks encoder multi-thread tests.
     // The values in x->pred_mv[] differ for single and multi-thread cases.
     // See aomedia:1778.
     // sf->adaptive_motion_search = 1;
     sf->recode_loop = ALLOW_RECODE_KFARFGF;
-    sf->use_transform_domain_distortion = 1;
+    sf->tx_domain_dist_level = 1;
     sf->use_accurate_subpel_search = USE_2_TAPS;
     sf->adaptive_rd_thresh = 2;
     sf->tx_type_search.prune_mode = PRUNE_2D_FAST;
@@ -558,8 +590,7 @@
     sf->use_mb_rd_hash = 0;
     sf->tx_type_search.fast_intra_tx_type_search = 1;
     sf->tx_type_search.fast_inter_tx_type_search = 1;
-    sf->tx_size_search_method =
-        frame_is_intra_only(cm) ? USE_FULL_RD : USE_LARGESTALL;
+    sf->tx_size_search_level = frame_is_intra_only(cm) ? 0 : 2;
     sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED;
     sf->adaptive_mode_search = 1;
     sf->alt_ref_search_fp = 1;
@@ -574,7 +605,7 @@
     sf->intra_uv_mode_mask[TX_32X32] = UV_INTRA_DC_H_V_CFL;
     sf->intra_y_mode_mask[TX_16X16] = INTRA_DC_H_V;
     sf->intra_uv_mode_mask[TX_16X16] = UV_INTRA_DC_H_V_CFL;
-    sf->tx_size_search_method = USE_LARGESTALL;
+    sf->tx_size_search_level = 2;
     sf->mv.search_method = BIGDIA;
     sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
     sf->adaptive_rd_thresh = 4;
@@ -587,7 +618,8 @@
     sf->disable_filter_search_var_thresh = 200;
     sf->use_fast_coef_costing = 1;
     sf->partition_search_breakout_rate_thr = 300;
-    sf->use_transform_domain_distortion = 2;
+    sf->tx_domain_dist_level = 2;
+    sf->tx_domain_dist_thres_level = 2;
   }
 
   if (speed >= 6) {
@@ -611,7 +643,7 @@
     sf->use_real_time_ref_set = 1;
     // Can't use LARGEST TX mode with pre-calculated partition
     // and disabled TX64
-    if (!cpi->oxcf.enable_tx64) sf->tx_size_search_method = USE_FAST_RD;
+    if (!cpi->oxcf.enable_tx64) sf->tx_size_search_level = 1;
     sf->use_comp_ref_nonrd = 0;
     sf->inter_mode_rd_model_estimation = 2;
     sf->cdef_pick_method = CDEF_PICK_FROM_Q;
@@ -629,7 +661,7 @@
     sf->use_real_time_ref_set = 1;
     // Can't use LARGEST TX mode with pre-calculated partition
     // and disabled TX64
-    if (!cpi->oxcf.enable_tx64) sf->tx_size_search_method = USE_FAST_RD;
+    if (!cpi->oxcf.enable_tx64) sf->tx_size_search_level = 1;
     sf->use_nonrd_pick_mode = 1;
     sf->use_comp_ref_nonrd = 0;
     sf->inter_mode_rd_model_estimation = 2;
@@ -639,7 +671,7 @@
   if (speed >= 8) {
     sf->use_fast_nonrd_pick_mode = 1;
     sf->mv.subpel_search_method = SUBPEL_TREE_PRUNED_MORE;
-    sf->tx_size_search_method = USE_FAST_RD;
+    sf->tx_size_search_level = 1;
     sf->estimate_motion_for_var_based_partition = 0;
     sf->short_circuit_low_temp_var = 3;
 // TODO(kyslov) Enable when better model is available
@@ -723,7 +755,6 @@
   sf->adaptive_rd_thresh = 0;
   // TODO(sarahparker) Pair this with a speed setting once experiments are done
   sf->trellis_eob_fast = 0;
-  sf->tx_size_search_method = cpi->oxcf.tx_size_search_method;
   sf->inter_tx_size_search_init_depth_sqr = 0;
   sf->inter_tx_size_search_init_depth_rect = 0;
   sf->intra_tx_size_search_init_depth_rect = 0;
@@ -817,7 +848,9 @@
   sf->intra_cnn_split = 0;
 
   // Set this at the appropriate speed levels
-  sf->use_transform_domain_distortion = 0;
+  sf->tx_size_search_level = cpi->oxcf.tx_size_search_method;
+  sf->tx_domain_dist_level = 0;
+  sf->tx_domain_dist_thres_level = 0;
   sf->gm_search_type = GM_FULL_SEARCH;
   sf->gm_disable_recode = 0;
   sf->use_fast_interpolation_filter_search = 0;
@@ -932,8 +965,18 @@
       comp_type_rd_threshold_mul[sf->prune_comp_type_by_comp_avg];
   cpi->max_comp_type_rd_threshold_div =
       comp_type_rd_threshold_div[sf->prune_comp_type_by_comp_avg];
-  const int tx_domain_speed = AOMMIN(speed, MAX_TX_DOMAIN_EVAL_SPEED);
-  cpi->tx_domain_dist_threshold = tx_domain_dist_thresholds[tx_domain_speed];
+
+  // assert ensures that tx_domain_dist_level is accessed correctly
+  assert(cpi->sf.tx_domain_dist_thres_level >= 0 &&
+         cpi->sf.tx_domain_dist_thres_level < 3);
+  memcpy(cpi->tx_domain_dist_threshold,
+         tx_domain_dist_thresholds[cpi->sf.tx_domain_dist_thres_level],
+         sizeof(cpi->tx_domain_dist_threshold));
+
+  assert(cpi->sf.tx_domain_dist_level >= 0 && cpi->sf.tx_domain_dist_level < 3);
+  memcpy(cpi->use_transform_domain_distortion,
+         tx_domain_dist_types[cpi->sf.tx_domain_dist_level],
+         sizeof(cpi->use_transform_domain_distortion));
 
   // assert ensures that coeff_opt_dist_thresholds is accessed correctly
   assert(cpi->sf.perform_coeff_opt >= 0 && cpi->sf.perform_coeff_opt < 5);
@@ -941,8 +984,19 @@
          coeff_opt_dist_thresholds[cpi->sf.perform_coeff_opt],
          sizeof(cpi->coeff_opt_dist_threshold));
 
+  // Override speed feature setting for user config
+  if (cpi->oxcf.tx_size_search_method != USE_FULL_RD) {
+    cpi->sf.enable_winner_mode_for_tx_size_srch = 0;
+    cpi->sf.tx_size_search_level = cpi->oxcf.tx_size_search_method;
+  }
+  // assert ensures that tx_size_search_level is accessed correctly
+  assert(cpi->sf.tx_size_search_level >= 0 && cpi->sf.tx_size_search_level < 3);
+  memcpy(cpi->tx_size_search_methods,
+         tx_size_search_methods[cpi->sf.tx_size_search_level],
+         sizeof(cpi->tx_size_search_methods));
+
 #if CONFIG_DIST_8X8
-  if (sf->use_transform_domain_distortion > 0) cpi->oxcf.using_dist_8x8 = 0;
+  if (sf->tx_domain_dist_level > 0) cpi->oxcf.using_dist_8x8 = 0;
 
   if (cpi->oxcf.using_dist_8x8) x->min_partition_size = BLOCK_8X8;
 #endif  // CONFIG_DIST_8X8
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index ae94b7e..49cbf0f 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -320,11 +320,6 @@
   // mode to be evaluated. A high value means we will be faster.
   int adaptive_rd_thresh;
 
-  // Determine which method we use to determine transform size. We can choose
-  // between options like full rd, largest for prediction size, largest
-  // for intra and model coefs for the rest.
-  TX_SIZE_SEARCH_METHOD tx_size_search_method;
-
   // Init search depth for square and rectangular transform partitions.
   // Values:
   // 0 - search full tree, 1: search 1 level, 2: search the highest level only
@@ -507,7 +502,10 @@
   // 1: use transform domain in tx_type search, and use image domain for
   // RD_STATS
   // 2: use transform domain
-  int use_transform_domain_distortion;
+  int tx_domain_dist_level;
+
+  // Transform domain distortion threshold level
+  int tx_domain_dist_thres_level;
 
   GM_SEARCH_TYPE gm_search_type;
 
@@ -681,6 +679,13 @@
   // search method
   int enable_winner_mode_for_tx_size_srch;
 
+  // Control transform size search level
+  // Eval type: Default       Mode        Winner
+  // Level 0  : FULL RD     LARGEST ALL   FULL RD
+  // Level 1  : FAST RD     LARGEST ALL   FULL RD
+  // Level 2  : LARGEST ALL LARGEST ALL   FULL RD
+  int tx_size_search_level;
+
   // Flag used to control the winner mode processing for use transform
   // domain distortion
   int enable_winner_mode_for_use_tx_domain_dist;