Take out some early termination speed features

Drop some speed features used in speed 2 and above, during the
algorithm development process. This helps simplify the codebase.

Change-Id: I3b2f5560d90b00d2d8fd57c2cb36f6ddd3f228e4
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index f129c49..2bd7888 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -4039,19 +4039,6 @@
   return best_rd;
 }
 
-static int64_t rd_sbuv_dcpred(const AV1_COMP *cpi, MACROBLOCK *x, int *rate,
-                              int *rate_tokenonly, int64_t *distortion,
-                              int *skippable, BLOCK_SIZE bsize) {
-  int64_t unused;
-
-  x->e_mbd.mi[0]->mbmi.uv_mode = DC_PRED;
-  super_block_uvrd(cpi, x, rate_tokenonly, distortion, skippable, &unused,
-                   bsize, INT64_MAX);
-  *rate = *rate_tokenonly +
-          cpi->intra_uv_mode_cost[x->e_mbd.mi[0]->mbmi.mode][DC_PRED];
-  return RDCOST(x->rdmult, x->rddiv, *rate, *distortion);
-}
-
 static void choose_intra_uv_mode(AV1_COMP *cpi, MACROBLOCK *const x,
                                  PICK_MODE_CONTEXT *ctx, BLOCK_SIZE bsize,
                                  TX_SIZE max_tx_size, int *rate_uv,
@@ -4059,17 +4046,9 @@
                                  int *skip_uv, PREDICTION_MODE *mode_uv) {
   // Use an estimated rd for uv_intra based on DC_PRED if the
   // appropriate speed flag is set.
-  if (cpi->sf.use_uv_intra_rd_estimate) {
-    rd_sbuv_dcpred(cpi, x, rate_uv, rate_uv_tokenonly, dist_uv, skip_uv,
-                   bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize);
-    // Else do a proper rd search for each possible transform size that may
-    // be considered in the main rd loop.
-  } else {
-    (void)ctx;
-    rd_pick_intra_sbuv_mode(cpi, x, rate_uv, rate_uv_tokenonly, dist_uv,
-                            skip_uv, bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize,
-                            max_tx_size);
-  }
+  (void)ctx;
+  rd_pick_intra_sbuv_mode(cpi, x, rate_uv, rate_uv_tokenonly, dist_uv, skip_uv,
+                          bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, max_tx_size);
   *mode_uv = x->e_mbd.mi[0]->mbmi.uv_mode;
 }
 
@@ -8546,11 +8525,9 @@
     int skippable = 0;
     int this_skip2 = 0;
     int64_t total_sse = INT64_MAX;
-    int early_term = 0;
 #if CONFIG_REF_MV
     uint8_t ref_frame_type;
 #endif
-
     mode_index = mode_map[midx];
     this_mode = av1_mode_order[mode_index].mode;
     ref_frame = av1_mode_order[mode_index].ref_frame[0];
@@ -9255,27 +9232,6 @@
           memcpy(ctx->blk_skip[i], x->blk_skip[i],
                  sizeof(uint8_t) * ctx->num_4x4_blk);
 #endif
-
-        // TODO(debargha): enhance this test with a better distortion prediction
-        // based on qp, activity mask and history
-        if ((mode_search_skip_flags & FLAG_EARLY_TERMINATE) &&
-            (mode_index > MIN_EARLY_TERM_INDEX)) {
-          int qstep = xd->plane[0].dequant[1];
-          // TODO(debargha): Enhance this by specializing for each mode_index
-          int scale = 4;
-#if CONFIG_AOM_HIGHBITDEPTH
-          if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-            qstep >>= (xd->bd - 8);
-          }
-#endif  // CONFIG_AOM_HIGHBITDEPTH
-          if (x->source_variance < UINT_MAX) {
-            const int var_adjust = (x->source_variance < 16);
-            scale -= var_adjust;
-          }
-          if (ref_frame > INTRA_FRAME && distortion2 * scale < qstep * qstep) {
-            early_term = 1;
-          }
-        }
       }
     }
 
@@ -9305,8 +9261,6 @@
         best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd;
     }
 
-    if (early_term) break;
-
     if (x->skip && !comp_pred) break;
   }
 
@@ -9710,20 +9664,6 @@
     return;
   }
 
-  // If we used an estimate for the uv intra rd in the loop above...
-  if (sf->use_uv_intra_rd_estimate) {
-    // Do Intra UV best rd mode selection if best mode choice above was intra.
-    if (best_mbmode.ref_frame[0] == INTRA_FRAME) {
-      TX_SIZE uv_tx_size;
-      *mbmi = best_mbmode;
-      uv_tx_size = get_uv_tx_size(mbmi, &xd->plane[1]);
-      rd_pick_intra_sbuv_mode(
-          cpi, x, &rate_uv_intra[uv_tx_size], &rate_uv_tokenonly[uv_tx_size],
-          &dist_uv[uv_tx_size], &skip_uv[uv_tx_size],
-          bsize < BLOCK_8X8 ? BLOCK_8X8 : bsize, uv_tx_size);
-    }
-  }
-
 #if CONFIG_DUAL_FILTER
   assert((cm->interp_filter == SWITCHABLE) ||
          (cm->interp_filter == best_mbmode.interp_filter[0]) ||
@@ -9965,8 +9905,8 @@
 #else
   InterpFilter tmp_best_filter = SWITCHABLE;
 #endif
-  int rate_uv_intra, rate_uv_tokenonly;
-  int64_t dist_uv;
+  int rate_uv_intra, rate_uv_tokenonly = INT_MAX;
+  int64_t dist_uv = INT64_MAX;
   int skip_uv;
   PREDICTION_MODE mode_uv = DC_PRED;
   const int intra_cost_penalty = av1_get_intra_cost_penalty(
@@ -10059,7 +9999,6 @@
     int i;
     int this_skip2 = 0;
     int64_t total_sse = INT_MAX;
-    int early_term = 0;
 
     ref_frame = av1_ref_order[ref_index].ref_frame[0];
     second_ref_frame = av1_ref_order[ref_index].ref_frame[1];
@@ -10601,27 +10540,6 @@
 #endif
 
         for (i = 0; i < 4; i++) best_bmodes[i] = xd->mi[0]->bmi[i];
-
-        // TODO(debargha): enhance this test with a better distortion prediction
-        // based on qp, activity mask and history
-        if ((sf->mode_search_skip_flags & FLAG_EARLY_TERMINATE) &&
-            (ref_index > MIN_EARLY_TERM_INDEX)) {
-          int qstep = xd->plane[0].dequant[1];
-          // TODO(debargha): Enhance this by specializing for each mode_index
-          int scale = 4;
-#if CONFIG_AOM_HIGHBITDEPTH
-          if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
-            qstep >>= (xd->bd - 8);
-          }
-#endif  // CONFIG_AOM_HIGHBITDEPTH
-          if (x->source_variance < UINT_MAX) {
-            const int var_adjust = (x->source_variance < 16);
-            scale -= var_adjust;
-          }
-          if (ref_frame > INTRA_FRAME && distortion2 * scale < qstep * qstep) {
-            early_term = 1;
-          }
-        }
       }
     }
 
@@ -10649,8 +10567,6 @@
         best_pred_rd[REFERENCE_MODE_SELECT] = hybrid_rd;
     }
 
-    if (early_term) break;
-
     if (x->skip && !comp_pred) break;
   }
 
@@ -10663,16 +10579,6 @@
     return;
   }
 
-  // If we used an estimate for the uv intra rd in the loop above...
-  if (sf->use_uv_intra_rd_estimate) {
-    // Do Intra UV best rd mode selection if best mode choice above was intra.
-    if (best_mbmode.ref_frame[0] == INTRA_FRAME) {
-      *mbmi = best_mbmode;
-      rd_pick_intra_sbuv_mode(cpi, x, &rate_uv_intra, &rate_uv_tokenonly,
-                              &dist_uv, &skip_uv, BLOCK_8X8, TX_4X4);
-    }
-  }
-
   if (best_rd == INT64_MAX) {
     rd_cost->rate = INT_MAX;
     rd_cost->dist = INT64_MAX;
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index e8af1a8..190dcc1 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -332,7 +332,6 @@
   if (speed >= 3) {
     sf->use_square_partition_only = 1;
     sf->disable_filter_search_var_thresh = 100;
-    sf->use_uv_intra_rd_estimate = 1;
     sf->mv.subpel_iters_per_step = 1;
     sf->adaptive_rd_thresh = 4;
     sf->mode_skip_start = 6;
@@ -528,7 +527,6 @@
     sf->intra_uv_mode_mask[i] = INTRA_ALL;
   }
   sf->use_rd_breakout = 0;
-  sf->use_uv_intra_rd_estimate = 0;
   sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE;
   sf->use_fast_coef_updates = TWO_LOOP;
   sf->use_fast_coef_costing = 0;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index a6a4278..5c34808 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -410,11 +410,6 @@
   // higher than the best rd we've seen so far.
   int use_rd_breakout;
 
-  // This enables us to use an estimate for intra rd based on dc mode rather
-  // than choosing an actual uv mode in the stage of encoding before the actual
-  // final encode.
-  int use_uv_intra_rd_estimate;
-
   // This feature controls how the loop filter level is determined.
   LPF_PICK_METHOD lpf_pick;