Add partition search speed feature

Use simple rate-distortion search route for the first pass coding
block partition.

Change-Id: Iaaec3e1af83f46f625d3de8361eddd79a2bc6cef
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index ea53550..28fa1a7 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -169,6 +169,8 @@
   // to select transform kernel.
   int rd_model;
 
+  int cb_partition_scan;
+
   // Also save RD info on the TX size search level for square TX sizes.
   TX_SIZE_RD_RECORD
   tx_size_rd_record_8X8[(MAX_MIB_SIZE >> 1) * (MAX_MIB_SIZE >> 1)];
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 31de6fb..0a9c189 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -3660,9 +3660,11 @@
       if (cpi->sf.two_pass_partition_search &&
           mi_row + mi_size_high[cm->sb_size] < cm->mi_rows &&
           mi_col + mi_size_wide[cm->sb_size] < cm->mi_cols) {
+        x->cb_partition_scan = 1;
         rd_pick_sqr_partition(cpi, td, tile_data, tp, mi_row, mi_col,
                               cm->sb_size, &dummy_rdc, INT64_MAX, pc_root,
                               NULL);
+        x->cb_partition_scan = 0;
 
         x->source_variance = UINT_MAX;
         if (sf->adaptive_pred_interp_filter) {
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index d6e2ba0..0764608 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -1824,7 +1824,9 @@
   int rate_cost = 0;
   const int is_inter = is_inter_block(mbmi);
   TX_TYPE txk_start = DCT_DCT;
-  TX_TYPE txk_end = x->rd_model == LOW_TXFM_RD ? DCT_DCT : TX_TYPES - 1;
+  TX_TYPE txk_end = (x->rd_model == LOW_TXFM_RD || x->cb_partition_scan)
+                        ? DCT_DCT
+                        : TX_TYPES - 1;
   TX_TYPE best_tx_type = txk_start;
   int64_t best_rd = INT64_MAX;
   uint8_t best_txb_ctx = 0;
@@ -2346,6 +2348,8 @@
   const MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
   const int is_inter = is_inter_block(mbmi);
 
+  if (x->cb_partition_scan && tx_type != DCT_DCT) return 1;
+
   if (mbmi->ref_mv_idx > 0 && tx_type != DCT_DCT) return 1;
   if (!is_inter && x->use_default_intra_tx_type &&
       tx_type != get_default_tx_type(0, xd, tx_size))