Commit 26d3e45f authored by Angie Chiang's avatar Angie Chiang

Fix lv_map when BR_NODE is off

Change-Id: I17c2193202b7b5299c31f8387ad22409ac6f9c79
parent 83d72790
......@@ -74,10 +74,12 @@ typedef struct {
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];
......
......@@ -523,15 +523,24 @@ static INLINE void get_base_ctx_set(const tran_low_t *tcoeffs,
}
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 @@ static int try_self_level_down(tran_low_t *low_coeff, int coeff_idx,
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);
......
......@@ -555,7 +555,6 @@ void av1_fill_coeff_costs(MACROBLOCK *x, FRAME_CONTEXT *fc) {
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 @@ void av1_fill_coeff_costs(MACROBLOCK *x, FRAME_CONTEXT *fc) {
// 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],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment