Create speed feature switches for RD hashing

Change-Id: I6801dbbdfbd5235862556043260a286f0d448d0c
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index dbad7ca..330811c 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -4364,17 +4364,18 @@
   const TX_SIZE min_tx_size = sub_tx_size_map[1][max_txsize_rect_lookup[bsize]];
   const TxSetType tx_set_type = get_ext_tx_set_type(
       min_tx_size, bsize, is_inter, cm->reduced_tx_set_used);
-  int within_border = mi_row >= xd->tile.mi_row_start &&
-                      (mi_row + mi_size_high[bsize] < xd->tile.mi_row_end) &&
-                      mi_col >= xd->tile.mi_col_start &&
-                      (mi_col + mi_size_wide[bsize] < xd->tile.mi_col_end);
+  const int within_border =
+      mi_row >= xd->tile.mi_row_start &&
+      (mi_row + mi_size_high[bsize] < xd->tile.mi_row_end) &&
+      mi_col >= xd->tile.mi_col_start &&
+      (mi_col + mi_size_wide[bsize] < xd->tile.mi_col_end);
 
   av1_invalid_rd_stats(rd_stats);
 
   const uint32_t hash = get_block_residue_hash(x, bsize);
   MB_RD_RECORD *mb_rd_record = &x->mb_rd_record;
 
-  if (ref_best_rd != INT64_MAX && within_border) {
+  if (ref_best_rd != INT64_MAX && within_border && cpi->sf.use_mb_rd_hash) {
     for (int i = 0; i < mb_rd_record->num; ++i) {
       const int index = (mb_rd_record->index_start + i) % RD_RECORD_BUFFER_LEN;
       // If there is a match in the tx_rd_record, fetch the RD decision and
@@ -4402,7 +4403,7 @@
   // store and reuse rate and distortion values to speed up TX size search.
   TXB_RD_INFO_NODE matched_rd_info[16 + 64 + 256];
   int found_rd_info = 0;
-  if (ref_best_rd != INT64_MAX && within_border) {
+  if (ref_best_rd != INT64_MAX && within_border && cpi->sf.use_inter_txb_hash) {
     found_rd_info =
         find_tx_size_rd_records(x, bsize, mi_row, mi_col, matched_rd_info);
   }
@@ -4444,7 +4445,8 @@
   memcpy(x->blk_skip[0], best_blk_skip, sizeof(best_blk_skip[0]) * n4);
 
   // Save the RD search results into tx_rd_record.
-  if (within_border) save_tx_rd_info(n4, hash, x, rd_stats, mb_rd_record);
+  if (within_border && cpi->sf.use_mb_rd_hash)
+    save_tx_rd_info(n4, hash, x, rd_stats, mb_rd_record);
 }
 
 static void tx_block_uvrd(const AV1_COMP *cpi, MACROBLOCK *x, int blk_row,
diff --git a/av1/encoder/speed_features.c b/av1/encoder/speed_features.c
index a2ee8e5..f49953c 100644
--- a/av1/encoder/speed_features.c
+++ b/av1/encoder/speed_features.c
@@ -448,6 +448,8 @@
   sf->adaptive_txb_search = 0;
   sf->two_pass_partition_search = 0;
   sf->use_intra_txb_hash = 0;
+  sf->use_inter_txb_hash = 1;
+  sf->use_mb_rd_hash = 1;
 
   for (i = 0; i < TX_SIZES; i++) {
     sf->intra_y_mode_mask[i] = INTRA_ALL;
diff --git a/av1/encoder/speed_features.h b/av1/encoder/speed_features.h
index a855202..4867c37 100644
--- a/av1/encoder/speed_features.h
+++ b/av1/encoder/speed_features.h
@@ -553,6 +553,14 @@
   // Use hash table to store intra(keyframe only) txb transform search results
   // to avoid repeated search on the same residue signal.
   int use_intra_txb_hash;
+
+  // Use hash table to store inter txb transform search results
+  // to avoid repeated search on the same residue signal.
+  int use_inter_txb_hash;
+
+  // Use hash table to store macroblock RD search results
+  // to avoid repeated search on the same residue signal.
+  int use_mb_rd_hash;
 } SPEED_FEATURES;
 
 struct AV1_COMP;