rtc: Use best_pred for IDTX mode test

To bypass enc_build_inter_predictor.
Only affects screen.

Stats changed, for speeed 10:
bit-exact, IC% speedup: 0.13

Change-Id: Ice9ec825971d7be46d237946b81735954dcc51ab
diff --git a/av1/encoder/nonrd_opt.c b/av1/encoder/nonrd_opt.c
index 5aa11b4..eae8b4d 100644
--- a/av1/encoder/nonrd_opt.c
+++ b/av1/encoder/nonrd_opt.c
@@ -367,6 +367,8 @@
  * uses low-precision set of functions (16-bit) and 32 bit for high bit depth
  * \param[in]    x              Pointer to structure holding all the data for
                                 the current macroblock
+ * \param[in]    pred_buf       Pointer to the prediction buffer
+ * \param[in]    pred_stride    Stride for the prediction buffer
  * \param[in]    this_rdc       Pointer to calculated RD Cost
  * \param[in]    skippable      Pointer to a flag indicating possible tx skip
  * \param[in]    bsize          Current block size
@@ -375,10 +377,10 @@
  * \remark Nothing is returned. Instead, calculated RD cost is placed to
  * \c this_rdc. \c skippable flag is set if all coefficients are zero.
  */
-void av1_block_yrd_idtx(MACROBLOCK *x, RD_STATS *this_rdc, int *skippable,
+void av1_block_yrd_idtx(MACROBLOCK *x, const uint8_t *const pred_buf,
+                        int pred_stride, RD_STATS *this_rdc, int *skippable,
                         BLOCK_SIZE bsize, TX_SIZE tx_size) {
   MACROBLOCKD *xd = &x->e_mbd;
-  const struct macroblockd_plane *pd = &xd->plane[AOM_PLANE_Y];
   struct macroblock_plane *const p = &x->plane[AOM_PLANE_Y];
   assert(bsize < BLOCK_SIZES_ALL);
   const int num_4x4_w = mi_size_wide[bsize];
@@ -425,7 +427,7 @@
   this_rdc->dist = 0;
   this_rdc->rate = 0;
   aom_subtract_block(bh, bw, p->src_diff, bw, p->src.buf, p->src.stride,
-                     pd->dst.buf, pd->dst.stride);
+                     pred_buf, pred_stride);
   // Keep track of the row and column of the blocks we use so that we know
   // if we are in the unrestricted motion border.
   DECLARE_BLOCK_YRD_BUFFERS()
diff --git a/av1/encoder/nonrd_opt.h b/av1/encoder/nonrd_opt.h
index 5df399e..e834e99 100644
--- a/av1/encoder/nonrd_opt.h
+++ b/av1/encoder/nonrd_opt.h
@@ -544,7 +544,8 @@
 void av1_block_yrd(MACROBLOCK *x, RD_STATS *this_rdc, int *skippable,
                    BLOCK_SIZE bsize, TX_SIZE tx_size);
 
-void av1_block_yrd_idtx(MACROBLOCK *x, RD_STATS *this_rdc, int *skippable,
+void av1_block_yrd_idtx(MACROBLOCK *x, const uint8_t *const pred_buf,
+                        int pred_stride, RD_STATS *this_rdc, int *skippable,
                         BLOCK_SIZE bsize, TX_SIZE tx_size);
 
 int64_t av1_model_rd_for_sb_uv(AV1_COMP *cpi, BLOCK_SIZE plane_bsize,
diff --git a/av1/encoder/nonrd_pickmode.c b/av1/encoder/nonrd_pickmode.c
index a412d32..6113a10 100644
--- a/av1/encoder/nonrd_pickmode.c
+++ b/av1/encoder/nonrd_pickmode.c
@@ -2903,8 +2903,6 @@
   MACROBLOCKD *const xd = &x->e_mbd;
   MB_MODE_INFO *const mi = xd->mi[0];
   struct macroblockd_plane *const pd = &xd->plane[0];
-  const int mi_row = xd->mi_row;
-  const int mi_col = xd->mi_col;
   const int bw = block_size_wide[bsize];
   const int bh = block_size_high[bsize];
   TxfmSearchInfo *txfm_info = &x->txfm_search_info;
@@ -2918,6 +2916,7 @@
       cpi->oxcf.tune_cfg.content == AOM_CONTENT_SCREEN && !skip_idtx_palette &&
       !cpi->oxcf.txfm_cfg.use_inter_dct_only && !x->force_zeromv_skip_for_blk &&
       is_inter_mode(best_pickmode->best_mode) &&
+      best_pickmode->best_pred != NULL &&
       (!rt_sf->prune_idtx_nonrd ||
        (rt_sf->prune_idtx_nonrd && bsize <= BLOCK_32X32 &&
         best_pickmode->best_mode_skip_txfm != 1 && x->source_variance > 200))) {
@@ -2927,18 +2926,9 @@
     this_mode_pred = &tmp_buffer[get_pred_buffer(tmp_buffer, 3)];
     pd->dst.buf = this_mode_pred->data;
     pd->dst.stride = bw;
-
-    // Build inter predicted samples and compute RD cost using Identity
-    // transform.
-    mi->ref_frame[0] = best_pickmode->best_ref_frame;
-    mi->ref_frame[1] = best_pickmode->best_second_ref_frame;
-    xd->plane[0].pre[0] = search_state->yv12_mb[mi->ref_frame[0]][0];
-    if (mi->ref_frame[1] > INTRA_FRAME)
-      xd->plane[0].pre[1] = search_state->yv12_mb[mi->ref_frame[1]][0];
-    set_ref_ptrs(cm, xd, mi->ref_frame[0], mi->ref_frame[1]);
-    av1_enc_build_inter_predictor(cm, xd, mi_row, mi_col, NULL, bsize,
-                                  AOM_PLANE_Y, AOM_PLANE_Y);
-    av1_block_yrd_idtx(x, &idtx_rdc, &is_skippable, bsize, mi->tx_size);
+    const PRED_BUFFER *const best_pred = best_pickmode->best_pred;
+    av1_block_yrd_idtx(x, best_pred->data, best_pred->stride, &idtx_rdc,
+                       &is_skippable, bsize, mi->tx_size);
     int64_t idx_rdcost = RDCOST(x->rdmult, idtx_rdc.rate, idtx_rdc.dist);
     if (idx_rdcost < search_state->best_rdc.rdcost) {
       // Keep the skip_txfm off if the color_sensitivity is set.