rtc: Extend sse based early termination to speed-10

This patch extends the sse based inter mode search early
termination to speed-10. Aggressiveness of early termination
logic is adjusted according to the block size, speed level
and prediction mode.

          Instruction Count         BD-Rate Loss(%)
cpu-used    Reduction(%)    avg.psnr   ovr.psnr    ssim
   10         0.883          0.0840     0.0952    0.0881

STATS_CHANGED

Change-Id: I9dea07ebf08928a283a5f80776fa583eba98c015
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index a1e04b6..faa787d 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -140,16 +140,24 @@
 static INLINE int early_term_inter_search_with_sse(int early_term_idx,
                                                    BLOCK_SIZE bsize,
                                                    int64_t this_sse,
-                                                   int64_t best_sse) {
+                                                   int64_t best_sse,
+                                                   PREDICTION_MODE this_mode) {
   // Aggressiveness to terminate inter mode search early is adjusted based on
   // speed and block size.
-  const double early_term_thresh[3][4] = { { 0.65, 0.65, 0.65, 0.7 },
+  const double early_term_thresh[4][4] = { { 0.65, 0.65, 0.65, 0.7 },
                                            { 0.6, 0.65, 0.85, 0.9 },
-                                           { 0.5, 0.5, 0.55, 0.6 } };
+                                           { 0.5, 0.5, 0.55, 0.6 },
+                                           { 0.6, 0.75, 0.85, 0.85 } };
+  const double early_term_thresh_newmv_nearestmv[4] = { 0.3, 0.3, 0.3, 0.3 };
+
   const int size_group = size_group_lookup[bsize];
   assert(size_group < 4);
   assert((early_term_idx > 0) && (early_term_idx < EARLY_TERM_INDICES));
-  const double threshold = early_term_thresh[early_term_idx - 1][size_group];
+  const double threshold =
+      ((early_term_idx == EARLY_TERM_IDX_4) &&
+       (this_mode == NEWMV || this_mode == NEARESTMV))
+          ? early_term_thresh_newmv_nearestmv[size_group]
+          : early_term_thresh[early_term_idx - 1][size_group];
 
   // Terminate inter mode search early based on best sse so far.
   if ((early_term_idx > 0) && (threshold * this_sse > best_sse)) {
@@ -631,9 +639,11 @@
 
   // Skipping test
   *early_term = 0;
+  MB_MODE_INFO *const mi = xd->mi[0];
   if (!calculate_rd && cpi->sf.rt_sf.sse_early_term_inter_search &&
       early_term_inter_search_with_sse(
-          cpi->sf.rt_sf.sse_early_term_inter_search, bsize, sse, best_sse))
+          cpi->sf.rt_sf.sse_early_term_inter_search, bsize, sse, best_sse,
+          mi->mode))
     test_skip = 0;
 
   // Evaluate if the partition block is a skippable block in Y plane.
@@ -2829,7 +2839,7 @@
     if (cpi->sf.rt_sf.sse_early_term_inter_search &&
         early_term_inter_search_with_sse(
             cpi->sf.rt_sf.sse_early_term_inter_search, bsize, this_rdc.sse,
-            best_pickmode.best_sse)) {
+            best_pickmode.best_sse, this_mode)) {
       if (reuse_inter_pred) free_pred_buffer(this_mode_pred);
       continue;
     }
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 2beaefc..1ebcc8f 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -1606,7 +1606,7 @@
       sf->rt_sf.intra_y_mode_bsize_mask_nrd[i] = INTRA_DC;
   }
   if (speed >= 10) {
-    sf->rt_sf.sse_early_term_inter_search = EARLY_TERM_DISABLED;
+    sf->rt_sf.sse_early_term_inter_search = EARLY_TERM_IDX_4;
     sf->rt_sf.nonrd_agressive_skip = 1;
     sf->rt_sf.nonrd_prune_ref_frame_search = 3;
     sf->rt_sf.var_part_split_threshold_shift = 10;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index afa6090..378f483 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -372,6 +372,8 @@
       2, /*!< Early terminate inter mode search based on sse, index 2. */
   EARLY_TERM_IDX_3 =
       3, /*!< Early terminate inter mode search based on sse, index 3. */
+  EARLY_TERM_IDX_4 =
+      4, /*!< Early terminate inter mode search based on sse, index 4. */
   EARLY_TERM_INDICES, /*!< Total number of early terminate indices */
 } INTER_SEARCH_EARLY_TERM_IDX;