Enable mode conversion in sub8x8 block

Convert the newmv mode into reference motion vector modes.

Change-Id: I51bd2543dafb70345c1340fba700b44f67f20853
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 05cb75c..17e842b 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -4951,7 +4951,7 @@
 #if CONFIG_REF_MV
         run_mv_search = 2;
 #if !CONFIG_EXT_INTER
-        if (filter_idx > 0) {
+        if (filter_idx > 0 && this_mode == NEWMV) {
           BEST_SEG_INFO* ref_bsi = bsi_buf;
           SEG_RDSTAT *ref_rdstat = &ref_bsi->rdstat[i][mode_idx];
 
@@ -5345,6 +5345,24 @@
                   ref_bsi->rdstat[i + 2][mode_idx].eobs;
 
             if (bsi->rdstat[i][mode_idx].brdcost < best_rd) {
+#if CONFIG_REF_MV
+              // If the NEWMV mode is using the same motion vector as the
+              // NEARESTMV mode, skip the rest rate-distortion calculations
+              // and use the inferred motion vector modes.
+              if (this_mode == NEWMV) {
+                if (has_second_rf) {
+                  if (bsi->rdstat[i][mode_idx].mvs[0].as_int ==
+                          bsi->ref_mv[0]->as_int &&
+                      bsi->rdstat[i][mode_idx].mvs[1].as_int ==
+                          bsi->ref_mv[1]->as_int)
+                    continue;
+                } else {
+                  if (bsi->rdstat[i][mode_idx].mvs[0].as_int ==
+                      bsi->ref_mv[0]->as_int)
+                    continue;
+                }
+              }
+#endif
               mode_selected = this_mode;
               best_rd = bsi->rdstat[i][mode_idx].brdcost;
             }
@@ -5375,6 +5393,24 @@
         }
 
         if (bsi->rdstat[i][mode_idx].brdcost < best_rd) {
+#if CONFIG_REF_MV
+          // If the NEWMV mode is using the same motion vector as the
+          // NEARESTMV mode, skip the rest rate-distortion calculations
+          // and use the inferred motion vector modes.
+          if (this_mode == NEWMV) {
+            if (has_second_rf) {
+              if (bsi->rdstat[i][mode_idx].mvs[0].as_int ==
+                      bsi->ref_mv[0]->as_int &&
+                  bsi->rdstat[i][mode_idx].mvs[1].as_int ==
+                      bsi->ref_mv[1]->as_int)
+                continue;
+            } else {
+              if (bsi->rdstat[i][mode_idx].mvs[0].as_int ==
+                  bsi->ref_mv[0]->as_int)
+                continue;
+            }
+          }
+#endif
           mode_selected = this_mode;
           best_rd = bsi->rdstat[i][mode_idx].brdcost;
         }