Introduce early exit for partition split

Added conservative early exit based on neural net confidence score to skip evaluation of partition split.

For speed = 3 and 4 presets, BD-rate impact is seen as 0.02% and 0.09% (as per AWCY runs),
with encode time reduction of 4.53% and 5.80% (averaged across multiple test cases) respectively.

STATS_CHANGED

Change-Id: I72b782ee166796d87be8d32ee7d8332fe81d413a
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 6b0de5e..08fffb9 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -3300,8 +3300,8 @@
   if (try_split_only) {
     av1_simple_motion_search_based_split(
         cpi, x, mi_row, mi_col, bsize, &partition_none_allowed,
-        &partition_horz_allowed, &partition_vert_allowed,
-        &do_rectangular_split);
+        &partition_horz_allowed, &partition_vert_allowed, &do_rectangular_split,
+        &do_square_split);
   }
 
   const int try_prune_rect =
diff --git a/av1/encoder/partition_strategy.c b/av1/encoder/partition_strategy.c
index be930e2..292f570 100644
--- a/av1/encoder/partition_strategy.c
+++ b/av1/encoder/partition_strategy.c
@@ -82,7 +82,8 @@
 void av1_simple_motion_search_based_split(
     AV1_COMP *const cpi, MACROBLOCK *x, int mi_row, int mi_col,
     BLOCK_SIZE bsize, int *partition_none_allowed, int *partition_horz_allowed,
-    int *partition_vert_allowed, int *do_rectangular_split) {
+    int *partition_vert_allowed, int *do_rectangular_split,
+    int *do_square_split) {
   const NN_CONFIG *nn_config = NULL;
   float split_only_thresh = 0.0f;
   if (bsize == BLOCK_128X128) {
@@ -118,6 +119,10 @@
       *partition_vert_allowed = 0;
       *do_rectangular_split = 0;
     }
+    // TODO(Venkat): Experiment to skip only rectangular/extended parititions
+    if (cpi->sf.simple_motion_search_split_only >= 2) {
+      if (score < -split_only_thresh) *do_square_split = 0;
+    }
   }
 }
 
diff --git a/av1/encoder/partition_strategy.h b/av1/encoder/partition_strategy.h
index cb2e70b..401ef48 100644
--- a/av1/encoder/partition_strategy.h
+++ b/av1/encoder/partition_strategy.h
@@ -28,7 +28,8 @@
 void av1_simple_motion_search_based_split(
     AV1_COMP *const cpi, MACROBLOCK *x, int mi_row, int mi_col,
     BLOCK_SIZE bsize, int *partition_none_allowed, int *partition_horz_allowed,
-    int *partition_vert_allowed, int *do_rectangular_split);
+    int *partition_vert_allowed, int *do_rectangular_split,
+    int *do_square_split);
 
 // Performs a simple_motion_search with two reference frames and extract
 // the variance of residues. Then use the features to determine whether we want
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 4ee013d..231220d 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -327,6 +327,12 @@
         frame_is_intra_only(&cpi->common) ? 0 : (boosted ? 1 : 2);
     sf->perform_coeff_opt = is_boosted_arf2_bwd_type ? 2 : 3;
     sf->prune_comp_type_by_model_rd = boosted ? 0 : 1;
+    // TODO(Venkat): Clean-up frame type dependency for
+    // simple_motion_search_split_only in partition search function and set the
+    // speed feature accordingly
+    // TODO(Venkat): Evaluate this speed feature for speed 1 & 2
+    sf->simple_motion_search_split_only =
+        cm->allow_screen_content_tools ? 1 : 2;
     sf->disable_smooth_intra =
         !frame_is_intra_only(&cpi->common) || (cpi->rc.frames_to_key != 1);
   }