Skip compound mode evaluation for speed 2 and 3

In order to adjust speed feature setting, reverted the consolidation
of skiping extended comp mode speed features. Looked like the feature
prune_comp_using_best_single_mode_ref = 2 gave good tradeoff for speed
2 and 3.

         avg_psnr:  ovr_psnr:  ssim:  speedup:
speed2
lowres2  0.191       0.184     0.156    7.4
midres2  0.133       0.150     0.117    6.1

speed3
lowres2  0.270       0.270     0.185    8.6
midres2  0.262       0.268     0.186    8.0

STATS_CHANGED

Change-Id: If82707a98ad2e34f03b2a4f5e489fa42009e586a
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index d1e211d..fc1e9ce 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -4445,7 +4445,7 @@
 // Prune compound mode using ref frames of neighbor blocks.
 static INLINE int compound_skip_using_neighbor_refs(
     MACROBLOCKD *const xd, const PREDICTION_MODE this_mode,
-    const MV_REFERENCE_FRAME *ref_frames, int prune_extended_comp_mode) {
+    const MV_REFERENCE_FRAME *ref_frames, int prune_compound_using_neighbors) {
   // Exclude non-extended compound modes from pruning
   if (this_mode == NEAREST_NEARESTMV || this_mode == NEAR_NEARMV ||
       this_mode == NEW_NEWMV || this_mode == GLOBAL_GLOBALMV)
@@ -4465,7 +4465,7 @@
   const int track_ref_match = is_ref_match[0] + is_ref_match[1];
 
   // Pruning based on ref frame match with neighbors.
-  if (track_ref_match >= prune_extended_comp_mode) return 0;
+  if (track_ref_match >= prune_compound_using_neighbors) return 0;
   return 1;
 }
 
@@ -4483,7 +4483,8 @@
 // Prune compound mode using best single mode for the same reference.
 static INLINE int skip_compound_using_best_single_mode_ref(
     const PREDICTION_MODE this_mode, const MV_REFERENCE_FRAME *ref_frames,
-    const PREDICTION_MODE *best_single_mode) {
+    const PREDICTION_MODE *best_single_mode,
+    int prune_comp_using_best_single_mode_ref) {
   // Exclude non-extended compound modes from pruning
   if (this_mode == NEAREST_NEARESTMV || this_mode == NEAR_NEARMV ||
       this_mode == NEW_NEWMV || this_mode == GLOBAL_GLOBALMV)
@@ -4506,6 +4507,9 @@
   const PREDICTION_MODE single_mode = best_single_mode[ref_frames[newmv_dir]];
   if (single_mode == NEWMV) return 0;
 
+  // Avoid pruning the compound mode when best single mode is not available
+  if (prune_comp_using_best_single_mode_ref == 1)
+    if (single_mode == MB_MODE_COUNT) return 0;
   return 1;
 }
 
@@ -4759,16 +4763,18 @@
       return 1;
   }
 
-  if (sf->inter_sf.prune_extended_comp_mode && comp_pred) {
+  if (sf->inter_sf.prune_compound_using_neighbors && comp_pred) {
     if (compound_skip_using_neighbor_refs(
-            xd, this_mode, ref_frames, sf->inter_sf.prune_extended_comp_mode))
+            xd, this_mode, ref_frames,
+            sf->inter_sf.prune_compound_using_neighbors))
       return 1;
+  }
 
-    if (sf->inter_sf.prune_extended_comp_mode > 1) {
-      if (skip_compound_using_best_single_mode_ref(
-              this_mode, ref_frames, args->search_state->best_single_mode))
-        return 1;
-    }
+  if (sf->inter_sf.prune_comp_using_best_single_mode_ref && comp_pred) {
+    if (skip_compound_using_best_single_mode_ref(
+            this_mode, ref_frames, args->search_state->best_single_mode,
+            sf->inter_sf.prune_comp_using_best_single_mode_ref))
+      return 1;
   }
 
   return 0;
@@ -5459,7 +5465,7 @@
       collect_single_states(x, &search_state, mbmi);
     }
 
-    if (sf->inter_sf.prune_extended_comp_mode > 1 &&
+    if (sf->inter_sf.prune_comp_using_best_single_mode_ref > 0 &&
         is_inter_singleref_mode(this_mode))
       update_best_single_mode(&search_state, this_mode, ref_frame, this_rd);
 
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 9ada886..7aae582 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -495,7 +495,8 @@
     sf->inter_sf.disable_interinter_wedge_var_thresh = 100;
     sf->inter_sf.fast_interintra_wedge_search = 1;
     sf->inter_sf.prune_comp_search_by_single_result = boosted ? 4 : 1;
-    sf->inter_sf.prune_extended_comp_mode = 1;
+    sf->inter_sf.prune_compound_using_neighbors = 1;
+    sf->inter_sf.prune_comp_using_best_single_mode_ref = 2;
     sf->inter_sf.prune_comp_type_by_comp_avg = 2;
     sf->inter_sf.reuse_best_prediction_for_part_ab = 1;
     sf->inter_sf.selective_ref_frame = 3;
@@ -611,7 +612,7 @@
     sf->inter_sf.txfm_rd_gate_level = boosted ? 0 : 4;
 
     sf->inter_sf.prune_inter_modes_based_on_tpl = boosted ? 0 : 2;
-    sf->inter_sf.prune_extended_comp_mode = 2;
+    sf->inter_sf.prune_compound_using_neighbors = 2;
     sf->inter_sf.prune_obmc_prob_thresh = INT_MAX;
     sf->inter_sf.disable_onesided_comp = 1;
 
@@ -1148,7 +1149,8 @@
   inter_sf->skip_repeated_full_newmv = 0;
   inter_sf->inter_mode_rd_model_estimation = 0;
   inter_sf->prune_compound_using_single_ref = 0;
-  inter_sf->prune_extended_comp_mode = 0;
+  inter_sf->prune_compound_using_neighbors = 0;
+  inter_sf->prune_comp_using_best_single_mode_ref = 0;
   inter_sf->disable_onesided_comp = 0;
   inter_sf->prune_mode_search_simple_translation = 0;
   inter_sf->prune_comp_type_by_comp_avg = 0;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index 67c9019..6a4ea3c 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -667,12 +667,18 @@
   int prune_compound_using_single_ref;
 
   // Skip extended compound mode using ref frames of above and left neighbor
-  // blocks and also skip when ref frame NEWMV mode does not have NEWMV as
-  // single mode winner
+  // blocks.
   // 0 : no pruning
   // 1 : prune extended compound mode (less aggressiveness)
   // 2 : prune extended compound mode (high aggressiveness)
-  int prune_extended_comp_mode;
+  int prune_compound_using_neighbors;
+
+  // Skip extended compound mode when ref frame corresponding to NEWMV does not
+  // have NEWMV as single mode winner.
+  // 0 : no pruning
+  // 1 : prune extended compound mode (less aggressiveness)
+  // 2 : prune extended compound mode (high aggressiveness)
+  int prune_comp_using_best_single_mode_ref;
 
   // Based on previous ref_mv_idx search result, prune the following search.
   int prune_ref_mv_idx_search;