Fast motion search in TPL

Currently, TPL motion search could have 4 starting MVs,
which takes over 5% encoder time at speed 5. This patch
adds a condition to accept a new starting MV only if it
is very different from already added starting MVs. This
keeps majority of the quality gain while making the
motion search faster. This can be extended to lower speed
levels.

Borg test results:
       avg_psnr:  ovr_psnr:  ssim:   avg speedups over whole set:
lowres: -0.021    -0.020     0.031          3.3%
midres:  0.015     0.020     0.249          5.7%
hdres:   0.015     0.011     0.182          5.4%

STATS_CHANGED

Change-Id: I2cca2eb1ca0bad00950cbebf00d205d310825d1d
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index bfcad6e..40d5296 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -534,6 +534,7 @@
   if (speed >= 5) {
     sf->tpl_sf.prune_intra_modes = 1;
     sf->tpl_sf.reduce_first_step_size = 6;
+    sf->tpl_sf.skip_repeated_mv_level = 2;
 
     sf->inter_sf.disable_interinter_wedge = 1;
     sf->inter_sf.disable_obmc = 1;
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index 79406ec..13cbee9 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -183,7 +183,7 @@
 static int is_duplicate_mv(int_mv candidate_mv, int_mv *center_mvs,
                            int center_mvs_count, int skip_repeated_mv_level) {
   int_mv candidate_mv_full; /* full-pixel value */
-  static int mv_shift_lookup[2] = { 0, 3 };
+  static int mv_shift_lookup[3] = { 0, 3, 3 };
   int shift = mv_shift_lookup[skip_repeated_mv_level];
   int i;
 
@@ -198,6 +198,17 @@
     if (candidate_mv_full.as_int == center_mv_full.as_int) {
       return 1;
     }
+
+    // TODO(yunqing): will combine this part with the above checking. May also
+    // modify the name of the speed feature.
+    if (skip_repeated_mv_level == 2) {
+      const int mv_diff_thr = 16;
+      if (abs(center_mv_full.as_mv.col - candidate_mv_full.as_mv.col) <
+              mv_diff_thr &&
+          abs(center_mv_full.as_mv.row - candidate_mv_full.as_mv.row) <
+              mv_diff_thr)
+        return 1;
+    }
   }
 
   return 0;