Disable 'prune_ref_frame_for_gm_search' for mt

The speed feature 'prune_ref_frame_for_gm_search' has been
disabled for multi-thread path to achieve better parallelism
when number of threads available are greater than or
equal to maximum number of reference frames allowed for
global motion.

STATS_CHANGED for --row-mt=1

Change-Id: Ibfd22ffdfb76d5d2bea6c3565576b7568c7cc9b2
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index 4d1b066..adba88d 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -112,6 +112,16 @@
                                                                 { 1, 1, 1 },
                                                                 { 1, 2, 1 } };
 
+// This table holds the maximum number of reference frames for global motion.
+// The table is indexed as per the speed feature 'gm_search_type'.
+// 0 : All reference frames are allowed.
+// 1 : All reference frames except L2 and L3 are allowed.
+// 2 : All reference frames except L2, L3 and ARF2 are allowed.
+// 3 : No reference frame is allowed.
+static int gm_available_reference_frames[GM_DISABLE_SEARCH + 1] = {
+  INTER_REFS_PER_FRAME, INTER_REFS_PER_FRAME - 2, INTER_REFS_PER_FRAME - 3, 0
+};
+
 // Intra only frames, golden frames (except alt ref overlays) and
 // alt ref frames tend to be coded at a higher than ambient quality
 static int frame_is_boosted(const AV1_COMP *cpi) {
@@ -1301,6 +1311,14 @@
       // Revert to type 2
       sf->inter_sf.inter_mode_rd_model_estimation = 2;
     }
+
+    // Disable the speed feature 'prune_ref_frame_for_gm_search' to achieve
+    // better parallelism when number of threads available are greater than or
+    // equal to maximum number of reference frames allowed for global motion.
+    if (sf->gm_sf.gm_search_type != GM_DISABLE_SEARCH &&
+        (cpi->oxcf.max_threads >=
+         gm_available_reference_frames[sf->gm_sf.gm_search_type]))
+      sf->gm_sf.prune_ref_frame_for_gm_search = 0;
   }
 }