Fix lv_map when BR_NODE is off

Change-Id: I17c2193202b7b5299c31f8387ad22409ac6f9c79
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 1b3fa38..b28848d 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -74,10 +74,12 @@
   int eob_cost[EOB_COEF_CONTEXTS][2];
   int dc_sign_cost[DC_SIGN_CONTEXTS][2];
   int base_cost[NUM_BASE_LEVELS][COEFF_BASE_CONTEXTS][2];
-  int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1];
 #if BR_NODE
+  int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1];
   int br_cost[BASE_RANGE_SETS][LEVEL_CONTEXTS][2];
-#endif
+#else   // BR_NODE
+  int lps_cost[LEVEL_CONTEXTS][2];
+#endif  // BR_NODE
 #if CONFIG_CTX1D
   int eob_mode_cost[TX_CLASSES][2];
   int empty_line_cost[TX_CLASSES][EMPTY_LINE_CONTEXTS][2];
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c
index 837be8a..d60e819 100644
--- a/av1/encoder/encodetxb.c
+++ b/av1/encoder/encodetxb.c
@@ -523,15 +523,24 @@
 }
 
 static INLINE int get_br_cost(tran_low_t abs_qc, int ctx,
-                              const int coeff_lps[COEFF_BASE_RANGE + 1]) {
+                              const int *coeff_lps) {
   const tran_low_t min_level = 1 + NUM_BASE_LEVELS;
   const tran_low_t max_level = 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE;
   (void)ctx;
   if (abs_qc >= min_level) {
+#if BR_NODE
     if (abs_qc >= max_level)
       return coeff_lps[COEFF_BASE_RANGE];  // COEFF_BASE_RANGE * cost0;
     else
       return coeff_lps[(abs_qc - min_level)];  //  * cost0 + cost1;
+#else
+    const int cost0 = coeff_lps[0];
+    const int cost1 = coeff_lps[1];
+    if (abs_qc >= max_level)
+      return COEFF_BASE_RANGE * cost0;
+    else
+      return (abs_qc - min_level) * cost0 + cost1;
+#endif
   } else {
     return 0;
   }
@@ -1119,20 +1128,33 @@
         get_level_prob(abs_qc, coeff_idx, txb_cache, txb_costs);
     const int *low_level_cost =
         get_level_prob(abs(*low_coeff), coeff_idx, txb_cache, txb_costs);
+#if BR_NODE
     cost_diff = -level_cost[0] + low_level_cost[1] - low_level_cost[0];
+#else
+    cost_diff = -level_cost[1] + low_level_cost[1] - low_level_cost[0];
+#endif
   } else if (abs_qc < 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
     const int *level_cost =
         get_level_prob(abs_qc, coeff_idx, txb_cache, txb_costs);
     const int *low_level_cost =
         get_level_prob(abs(*low_coeff), coeff_idx, txb_cache, txb_costs);
 
+#if BR_NODE
     cost_diff = -level_cost[abs_qc - 1 - NUM_BASE_LEVELS] +
                 low_level_cost[abs(*low_coeff) - 1 - NUM_BASE_LEVELS];
+#else
+    cost_diff = -level_cost[1] + low_level_cost[1] - low_level_cost[0];
+#endif
   } else if (abs_qc == 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
     const int *low_level_cost =
         get_level_prob(abs(*low_coeff), coeff_idx, txb_cache, txb_costs);
+#if BR_NODE
     cost_diff = -get_golomb_cost(abs_qc) - low_level_cost[COEFF_BASE_RANGE] +
                 low_level_cost[COEFF_BASE_RANGE - 1];
+#else
+    cost_diff =
+        -get_golomb_cost(abs_qc) + low_level_cost[1] - low_level_cost[0];
+#endif
   } else {
     assert(abs_qc > 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE);
     const tran_low_t abs_low_coeff = abs(*low_coeff);
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index 8524ca2..20f279a 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -555,7 +555,6 @@
           av1_cost_tokens_from_cdf(pcost->br_cost[br][ctx],
                                    fc->coeff_br_cdf[tx_size][plane][br][ctx],
                                    NULL);
-#endif  // BR_NODE
 
       for (int ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
         int lps_rate[2];
@@ -593,6 +592,11 @@
           // load the base range cost
         }
       }
+#else   // BR_NODE
+      for (int ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx)
+        av1_cost_tokens_from_cdf(pcost->lps_cost[ctx],
+                                 fc->coeff_lps_cdf[tx_size][plane][ctx], NULL);
+#endif  // BR_NODE
 #if CONFIG_CTX1D
       for (int tx_class = 0; tx_class < TX_CLASSES; ++tx_class)
         av1_cost_tokens_from_cdf(pcost->eob_mode_cost[tx_class],