Fix consistency issue with intra txb hash

When matching hash is found for intra tx blocks,
one corner case issue is fixed with coeff optimization.

          Encode Time      Quality Loss(%)
Cpu-used  Reduction(%)        (AWCY)
  1         0.50               +0.02
  2         0.00               -0.02
  3         0.50               +0.02

STATS_CHANGED

Change-Id: I8069f1adac5898c7330e6bb519cbced2dbc9aa58
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index d516a3f..363deca 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -127,6 +127,7 @@
   uint8_t txb_entropy_ctx;
   uint8_t valid;
   uint8_t fast;  // This is not being used now.
+  uint8_t perform_block_coeff_opt;
 } TXB_RD_INFO;
 
 #define TX_SIZE_RD_RECORD_BUFFER_LEN 256
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 8bfedbe..0f492c2 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -2974,7 +2974,7 @@
   tran_low_t *best_dqcoeff = this_dqcoeff;
   const int txk_type_idx =
       av1_get_txk_type_index(plane_bsize, blk_row, blk_col);
-  int perform_block_coeff_opt;
+  int perform_block_coeff_opt = 0;
   av1_invalid_rd_stats(best_rd_stats);
 
   TXB_RD_INFO *intra_txb_rd_info = NULL;
@@ -3016,6 +3016,7 @@
         best_rd = RDCOST(x->rdmult, best_rd_stats->rate, best_rd_stats->dist);
         best_eob = intra_txb_rd_info->eob;
         best_tx_type = intra_txb_rd_info->tx_type;
+        perform_block_coeff_opt = intra_txb_rd_info->perform_block_coeff_opt;
         update_txk_array(mbmi->txk_type, plane_bsize, blk_row, blk_col, tx_size,
                          best_tx_type);
         goto RECON_INTRA;
@@ -3302,6 +3303,7 @@
     intra_txb_rd_info->sse = best_rd_stats->sse;
     intra_txb_rd_info->eob = best_eob;
     intra_txb_rd_info->txb_entropy_ctx = best_txb_ctx;
+    intra_txb_rd_info->perform_block_coeff_opt = perform_block_coeff_opt;
     if (plane == 0) intra_txb_rd_info->tx_type = best_tx_type;
   }
 
@@ -3314,7 +3316,7 @@
     // if the last search tx_type is the best tx_type, we don't need to
     // do this again
     if (best_tx_type != last_tx_type) {
-      if (skip_trellis) {
+      if (skip_trellis || (!perform_block_coeff_opt)) {
         av1_xform_quant(
             cm, x, plane, block, blk_row, blk_col, plane_bsize, tx_size,
             best_tx_type,