Make prune_tx_type_using_stats feature work at speed 2

Use recorded tx type stats to prune following frame's
tx type search, and make this work at speed 2.
Borg test result:
         avg_psnr:   ovr_psnr:   ssim:   avg encoder speedup:
hdres:    0.094       0.099      0.052     4.4%
midres:   0.117       0.129      0.008     4.7%

Change-Id: I8c3e3b163535b12ed186f7d578185fe1f94855c8
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 766b1aa..c564e2e 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -4967,12 +4967,12 @@
       cm->current_frame.frame_type == KEY_FRAME) {
     av1_copy(cpi->tx_type_probs, default_tx_type_probs);
 
+    int thr[2][2] = { { 15, 10 }, { 17, 10 } };
     for (int f = 0; f < FRAME_UPDATE_TYPES; f++) {
-      // TODO(yunqing): Threshold can be updated adaptively for 1 frame.
-      if (f == KF_UPDATE || f == ARF_UPDATE)
-        cpi->tx_type_probs_thresh[f] = 10;
-      else
-        cpi->tx_type_probs_thresh[f] = 17;
+      int kf_arf_update = (f == KF_UPDATE || f == ARF_UPDATE);
+      cpi->tx_type_probs_thresh[f] =
+          thr[cpi->sf.tx_type_search.prune_tx_type_using_stats - 1]
+             [kf_arf_update];
     }
   }
 
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index af963c8..4a96b62 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -179,6 +179,8 @@
       sf->partition_search_breakout_rate_thr = 100;
     }
     sf->rd_auto_partition_min_limit = set_partition_min_limit(cm);
+
+    if (is_480p_or_larger) sf->tx_type_search.prune_tx_type_using_stats = 1;
   }
 
   if (speed >= 3) {
@@ -199,6 +201,9 @@
     // trained and tuned on speed 1 and 2. We might get better performance if we
     // readjust them for speed 3 and 4.
     sf->simple_motion_search_split = cm->allow_screen_content_tools ? 1 : 2;
+
+    // TODO(yunqing): make this work for speed 3.
+    sf->tx_type_search.prune_tx_type_using_stats = 0;
   }
 
   if (speed >= 4) {
@@ -208,7 +213,7 @@
       sf->partition_search_breakout_dist_thr = (1 << 24);
     }
 
-    if (is_480p_or_larger) sf->tx_type_search.prune_tx_type_using_stats = 1;
+    if (is_480p_or_larger) sf->tx_type_search.prune_tx_type_using_stats = 2;
   }
 }