Consolidate 2 two pass partition search speed features

Consolidated 2 two pass partition search speed features to make it
simple.

BUG=aomedia:2324

Change-Id: Id1384c85a9cf4bcd1b0d1f6e293840f0afb907d3
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 7221cfb..2458698 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -155,7 +155,7 @@
 
 // Region size for mode decision sampling in the first pass of partition
 // search(two_pass_partition_search speed feature), in units of mi size(4).
-// Used by the mode_pruning_based_on_two_pass_partition_search speed feature.
+// Used by the mode pruning in two_pass_partition_search feature.
 #define FIRST_PARTITION_PASS_SAMPLE_REGION 8
 #define FIRST_PARTITION_PASS_SAMPLE_REGION_LOG2 3
 #define FIRST_PARTITION_PASS_STATS_TABLES                     \
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index ad93203..02cf215 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -5414,8 +5414,8 @@
   }
 }
 
-// Minimum number of samples to trigger the
-// mode_pruning_based_on_two_pass_partition_search feature.
+// Minimum number of samples to trigger the mode pruning in
+// two_pass_partition_search feature.
 #define FIRST_PARTITION_PASS_MIN_SAMPLES 16
 
 static int get_rdmult_delta(AV1_COMP *cpi, BLOCK_SIZE bsize, int mi_row,
@@ -5538,8 +5538,7 @@
 
   const SPEED_FEATURES *const sf = &cpi->sf;
   // Reset the stats tables.
-  if (cpi->mode_pruning_based_on_two_pass_partition_search)
-    av1_zero(x->first_partition_pass_stats);
+  av1_zero(x->first_partition_pass_stats);
 
   AV1_COMMON *const cm = &cpi->common;
   const BLOCK_SIZE sb_size = cm->seq_params.sb_size;
@@ -5580,22 +5579,19 @@
 
   x->use_cb_search_range = 1;
 
-  if (cpi->mode_pruning_based_on_two_pass_partition_search) {
-    for (int i = 0; i < FIRST_PARTITION_PASS_STATS_TABLES; ++i) {
-      FIRST_PARTITION_PASS_STATS *const stat =
-          &x->first_partition_pass_stats[i];
-      if (stat->sample_counts < FIRST_PARTITION_PASS_MIN_SAMPLES) {
-        // If there are not enough samples collected, make all available.
-        memset(stat->ref0_counts, 0xff, sizeof(stat->ref0_counts));
-        memset(stat->ref1_counts, 0xff, sizeof(stat->ref1_counts));
-      } else if (sf->selective_ref_frame < 3) {
-        // ALTREF2_FRAME and BWDREF_FRAME may be skipped during the
-        // initial partition scan, so we don't eliminate them.
-        stat->ref0_counts[ALTREF2_FRAME] = 0xff;
-        stat->ref1_counts[ALTREF2_FRAME] = 0xff;
-        stat->ref0_counts[BWDREF_FRAME] = 0xff;
-        stat->ref1_counts[BWDREF_FRAME] = 0xff;
-      }
+  for (int i = 0; i < FIRST_PARTITION_PASS_STATS_TABLES; ++i) {
+    FIRST_PARTITION_PASS_STATS *const stat = &x->first_partition_pass_stats[i];
+    if (stat->sample_counts < FIRST_PARTITION_PASS_MIN_SAMPLES) {
+      // If there are not enough samples collected, make all available.
+      memset(stat->ref0_counts, 0xff, sizeof(stat->ref0_counts));
+      memset(stat->ref1_counts, 0xff, sizeof(stat->ref1_counts));
+    } else if (sf->selective_ref_frame < 3) {
+      // ALTREF2_FRAME and BWDREF_FRAME may be skipped during the
+      // initial partition scan, so we don't eliminate them.
+      stat->ref0_counts[ALTREF2_FRAME] = 0xff;
+      stat->ref1_counts[ALTREF2_FRAME] = 0xff;
+      stat->ref0_counts[BWDREF_FRAME] = 0xff;
+      stat->ref1_counts[BWDREF_FRAME] = 0xff;
     }
   }
 }
@@ -7052,8 +7048,7 @@
   const int mi_height = mi_size_high[bsize];
   const int is_inter = is_inter_block(mbmi);
 
-  if (cpi->mode_pruning_based_on_two_pass_partition_search &&
-      x->cb_partition_scan) {
+  if (cpi->two_pass_partition_search && x->cb_partition_scan) {
     for (int row = mi_row; row < mi_row + mi_width;
          row += FIRST_PARTITION_PASS_SAMPLE_REGION) {
       for (int col = mi_col; col < mi_col + mi_height;
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 754dddc..5a7ab46 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4835,9 +4835,6 @@
 
   cpi->two_pass_partition_search = cpi->sf.two_pass_partition_search &&
                                    !cpi->partition_search_skippable_frame;
-  cpi->mode_pruning_based_on_two_pass_partition_search =
-      cpi->sf.mode_pruning_based_on_two_pass_partition_search &&
-      !cpi->partition_search_skippable_frame;
 
   if (encode_show_existing_frame(cm)) {
     restore_coding_context(cpi);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index 26b038e..f587e10 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -727,9 +727,8 @@
 
   // For a still frame, this flag is set to 1 to skip partition search.
   int partition_search_skippable_frame;
-  // The following 2 items correspond to 2 speed features.
+  // The following item corresponds to two_pass_partition_search speed features.
   int two_pass_partition_search;
-  int mode_pruning_based_on_two_pass_partition_search;
 
   double csm_rate_array[32];
   double m_rate_array[32];
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index a2b8cc6..61af6ac 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -11823,8 +11823,7 @@
     if (skip_ref) return 1;
   }
 
-  if (cpi->mode_pruning_based_on_two_pass_partition_search &&
-      !x->cb_partition_scan) {
+  if (cpi->two_pass_partition_search && !x->cb_partition_scan) {
     const int mi_width = mi_size_wide[bsize];
     const int mi_height = mi_size_high[bsize];
     int found = 0;
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index db0664b..d873430 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -245,10 +245,9 @@
     sf->intra_tx_size_search_init_depth_rect = 1;
     sf->tx_size_search_lgr_block = 1;
     if (speed >= CONFIG_2PASS_PARTITION_SEARCH_LVL_START &&
-        speed < CONFIG_2PASS_PARTITION_SEARCH_LVL_END) {
+        speed < CONFIG_2PASS_PARTITION_SEARCH_LVL_END)
       sf->two_pass_partition_search = 1;
-      sf->mode_pruning_based_on_two_pass_partition_search = 1;
-    }
+
     sf->prune_ext_partition_types_search_level = 2;
     sf->skip_repeat_interpolation_filter_search = 1;
     sf->tx_type_search.skip_tx_search = 1;
@@ -726,7 +725,6 @@
   sf->txb_split_cap = 1;
   sf->adaptive_txb_search_level = 0;
   sf->two_pass_partition_search = 0;
-  sf->mode_pruning_based_on_two_pass_partition_search = 0;
   sf->use_intra_txb_hash = 0;
   // TODO(any) : clean use_inter_txb_hash code
   sf->use_inter_txb_hash = 0;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index 0cd5288..6daf626 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -375,13 +375,10 @@
 
   int fast_cdef_search;
 
-  // 2-pass coding block partition search
+  // 2-pass coding block partition search, and also use the mode decisions made
+  // in the initial partition search to prune mode candidates, e.g. ref frames.
   int two_pass_partition_search;
 
-  // Use the mode decisions made in the initial partition search to prune mode
-  // candidates, e.g. ref frames.
-  int mode_pruning_based_on_two_pass_partition_search;
-
   // Skip rectangular partition test when partition type none gives better
   // rd than partition type split. Can take values 0 - 2, 0 referring to no
   // skipping, and 1 - 2 increasing aggressiveness of skipping in order.