From c96c3fa2b31a36b954009f8dd458c6e0d1e80cff Mon Sep 17 00:00:00 2001
From: Yaowu Xu <yaowu@google.com>
Date: Mon, 21 Mar 2016 10:28:29 -0700
Subject: [PATCH] Properly set rate_nocoef when pallete mode is used

Change-Id: Iff04c82b3d3b5cf2c7700717c3c3d678bbbb9f9b
---
 vp10/encoder/encodeframe.c |  5 ++++-
 vp10/encoder/rdopt.c       | 12 ++++++++++++
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/vp10/encoder/encodeframe.c b/vp10/encoder/encodeframe.c
index 2c47be9b52..6379713a19 100644
--- a/vp10/encoder/encodeframe.c
+++ b/vp10/encoder/encodeframe.c
@@ -1234,7 +1234,10 @@ static void update_state_supertx(VP10_COMP *cpi, ThreadData *td,
                                  PICK_MODE_CONTEXT *ctx,
                                  int mi_row, int mi_col, BLOCK_SIZE bsize,
                                  int output_enabled) {
-  int i, y, x_idx;
+  int y, x_idx;
+#if CONFIG_VAR_TX
+  int i;
+#endif
   VP10_COMMON *const cm = &cpi->common;
   RD_COUNTS *const rdc = &td->rd_counts;
   MACROBLOCK *const x = &td->mb;
diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c
index 3d92591964..c15db0bf18 100644
--- a/vp10/encoder/rdopt.c
+++ b/vp10/encoder/rdopt.c
@@ -8435,6 +8435,9 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
   if (cm->allow_screen_content_tools && !is_inter_mode(best_mbmode.mode)) {
     PREDICTION_MODE mode_selected;
     int rate2 = 0, rate_y = 0;
+#if CONFIG_SUPERTX
+    int best_rate_nocoef;
+#endif
     int64_t distortion2 = 0, distortion_y = 0, dummy_rd = best_rd, this_rd;
     int skippable = 0, rate_overhead = 0;
     TX_SIZE best_tx_size, uv_tx;
@@ -8504,8 +8507,14 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
 
     if (skippable) {
       rate2 -= (rate_y + rate_uv_tokenonly[uv_tx]);
+#if CONFIG_SUPERTX
+      best_rate_nocoef = rate2;
+#endif
       rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 1);
     } else {
+#if CONFIG_SUPERTX
+      best_rate_nocoef = rate2 - (rate_y + rate_uv_tokenonly[uv_tx]);
+#endif
       rate2 += vp10_cost_bit(vp10_get_skip_prob(cm, xd), 0);
     }
     this_rd = RDCOST(x->rdmult, x->rddiv, rate2, distortion2);
@@ -8515,6 +8524,9 @@ void vp10_rd_pick_inter_mode_sb(VP10_COMP *cpi,
       mbmi->mv[0].as_int = 0;
       max_plane = 1;
       rd_cost->rate = rate2;
+#if CONFIG_SUPERTX
+      *returnrate_nocoef = best_rate_nocoef;
+#endif
       rd_cost->dist = distortion2;
       rd_cost->rdcost = this_rd;
       best_rd = this_rd;
-- 
GitLab