Remove sample sorting in warped motion sample selection

The original sample selection process involves finding best 8 sorted
samples according to motion vector difference(MVD) between neighbor
block and current block, and then trimming samples. To reduce the
complexity, use the current block width/height as the MVD threshold,
and trim the samples without sorting.

This gives slightly less gain than the original method.
AWCY result:
         PSNR   PSNR HVS   SSIM
Average  -0.07   -0.13     -0.12
Borg test result:
             avg_psnr ovr_psnr ssim
cam_lowres:  -0.112   -0.112  -0.180
lowres:      -0.068   -0.073  -0.125

Change-Id: Ic2f79a170441d5bcb04ea87dddf490ef7fbba8bc
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index cfd3a89..b8f6c36 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -7361,7 +7361,6 @@
 
 #if CONFIG_EXT_WARPED_MOTION
   int pts0[SAMPLES_ARRAY_SIZE], pts_inref0[SAMPLES_ARRAY_SIZE];
-  int pts_mv0[SAMPLES_ARRAY_SIZE];
   int total_samples;
 #else
   int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
@@ -7372,8 +7371,7 @@
   if (cm->interp_filter == SWITCHABLE) rd_stats->rate += rs;
   aom_clear_system_state();
 #if CONFIG_EXT_WARPED_MOTION
-  mbmi->num_proj_ref[0] =
-      findSamples(cm, xd, mi_row, mi_col, pts0, pts_inref0, pts_mv0);
+  mbmi->num_proj_ref[0] = findSamples(cm, xd, mi_row, mi_col, pts0, pts_inref0);
   total_samples = mbmi->num_proj_ref[0];
 #else
   mbmi->num_proj_ref[0] = findSamples(cm, xd, mi_row, mi_col, pts, pts_inref);
@@ -7435,10 +7433,10 @@
 #if CONFIG_EXT_WARPED_MOTION
       memcpy(pts, pts0, total_samples * 2 * sizeof(*pts0));
       memcpy(pts_inref, pts_inref0, total_samples * 2 * sizeof(*pts_inref0));
-      // Rank the samples by motion vector difference
+      // Select the samples according to motion vector difference
       if (mbmi->num_proj_ref[0] > 1) {
-        mbmi->num_proj_ref[0] = sortSamples(pts_mv0, &mbmi->mv[0].as_mv, pts,
-                                            pts_inref, mbmi->num_proj_ref[0]);
+        mbmi->num_proj_ref[0] = selectSamples(
+            &mbmi->mv[0].as_mv, pts, pts_inref, mbmi->num_proj_ref[0], bsize);
         best_bmc_mbmi->num_proj_ref[0] = mbmi->num_proj_ref[0];
       }
 #endif  // CONFIG_EXT_WARPED_MOTION
@@ -7456,7 +7454,7 @@
 
           // Refine MV in a small range.
           av1_refine_warped_mv(cpi, x, bsize, mi_row, mi_col, pts0, pts_inref0,
-                               pts_mv0, total_samples);
+                               total_samples);
 #else
           // Refine MV in a small range.
           av1_refine_warped_mv(cpi, x, bsize, mi_row, mi_col, pts, pts_inref);
@@ -10611,16 +10609,12 @@
   av1_count_overlappable_neighbors(cm, xd, mi_row, mi_col);
   if (is_motion_variation_allowed_bsize(bsize) && !has_second_ref(mbmi)) {
     int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
-#if CONFIG_EXT_WARPED_MOTION
-    int pts_mv[SAMPLES_ARRAY_SIZE];
-    mbmi->num_proj_ref[0] =
-        findSamples(cm, xd, mi_row, mi_col, pts, pts_inref, pts_mv);
-    // Rank the samples by motion vector difference
-    if (mbmi->num_proj_ref[0] > 1)
-      mbmi->num_proj_ref[0] = sortSamples(pts_mv, &mbmi->mv[0].as_mv, pts,
-                                          pts_inref, mbmi->num_proj_ref[0]);
-#else
     mbmi->num_proj_ref[0] = findSamples(cm, xd, mi_row, mi_col, pts, pts_inref);
+#if CONFIG_EXT_WARPED_MOTION
+    // Select the samples according to motion vector difference
+    if (mbmi->num_proj_ref[0] > 1)
+      mbmi->num_proj_ref[0] = selectSamples(&mbmi->mv[0].as_mv, pts, pts_inref,
+                                            mbmi->num_proj_ref[0], bsize);
 #endif  // CONFIG_EXT_WARPED_MOTION
   }