Commit 36773c7a authored by Jingning Han's avatar Jingning Han
Browse files

Clean up br-node in lv-map

Use br-node approach, which can be easily turned into multi-symbol
if desired.

Change-Id: I40df5178ab299af24d347d91f01a88dbfc9305a6
parent 00803a77
......@@ -2202,9 +2202,7 @@ void av1_average_tile_coef_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
AVERAGE_TILE_CDFS(dc_sign_cdf)
AVERAGE_TILE_CDFS(coeff_base_cdf)
AVERAGE_TILE_CDFS(coeff_lps_cdf)
#if BR_NODE
AVERAGE_TILE_CDFS(coeff_br_cdf)
#endif
#if CONFIG_CTX1D
AVERAGE_TILE_CDFS(eob_mode_cdf)
AVERAGE_TILE_CDFS(empty_line_cdf)
......
......@@ -488,7 +488,7 @@ const aom_prob default_coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS] = {
172, 184, 192, 176, 201, 183, 177, 190, 128, 192, 199, 144,
192, 192, 1, 196, 192, 255, 171, 178, 255, 128, 171, 179 } }
};
#if BR_NODE
const aom_prob
default_coeff_br[TX_SIZES][PLANE_TYPES][BASE_RANGE_SETS][LEVEL_CONTEXTS] = {
{ { { 62, 128, 54, 116, 128, 51, 97, 128, 59, 68, 107, 128,
......@@ -588,7 +588,6 @@ const aom_prob
26, 27, 128, 126, 128, 255, 63, 142, 128, 128, 1, 1,
125, 159, 128, 173, 212, 128, 85, 189, 128, 128, 255, 171 } } }
};
#endif // BR_NODE
#if CONFIG_CTX1D
static const aom_prob default_eob_mode[TX_SIZES][PLANE_TYPES][TX_CLASSES] = {
{ { 128, 176, 157 }, { 128, 222, 198 } },
......@@ -6343,9 +6342,7 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->dc_sign, default_dc_sign);
av1_copy(fc->coeff_base, default_coeff_base);
av1_copy(fc->coeff_lps, default_coeff_lps);
#if BR_NODE
av1_copy(fc->coeff_br, default_coeff_br);
#endif
#if CONFIG_CTX1D
av1_copy(fc->eob_mode, default_eob_mode);
av1_copy(fc->empty_line, default_empty_line);
......
......@@ -156,9 +156,7 @@ typedef struct frame_contexts {
aom_prob coeff_base[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS];
aom_prob coeff_lps[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS];
#if BR_NODE
aom_prob coeff_br[TX_SIZES][PLANE_TYPES][BASE_RANGE_SETS][LEVEL_CONTEXTS];
#endif
#if CONFIG_CTX1D
aom_prob eob_mode[TX_SIZES][PLANE_TYPES][TX_CLASSES];
aom_prob empty_line[TX_SIZES][PLANE_TYPES][TX_CLASSES][EMPTY_LINE_CONTEXTS];
......@@ -179,10 +177,8 @@ typedef struct frame_contexts {
[COEFF_BASE_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob coeff_lps_cdf[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS]
[CDF_SIZE(2)];
#if BR_NODE
aom_cdf_prob coeff_br_cdf[TX_SIZES][PLANE_TYPES][BASE_RANGE_SETS]
[LEVEL_CONTEXTS][CDF_SIZE(2)];
#endif
#if CONFIG_CTX1D
aom_cdf_prob eob_mode_cdf[TX_SIZES][PLANE_TYPES][TX_CLASSES][CDF_SIZE(2)];
aom_cdf_prob empty_line_cdf[TX_SIZES][PLANE_TYPES][TX_CLASSES]
......
......@@ -168,7 +168,7 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) {
fc->coeff_lps_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->coeff_lps_cdf[tx_size][plane][ctx][2] = 0;
}
#if BR_NODE
for (int br = 0; br < BASE_RANGE_SETS; ++br) {
for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
fc->coeff_br_cdf[tx_size][plane][br][ctx][0] = AOM_ICDF(
......@@ -177,7 +177,6 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) {
fc->coeff_br_cdf[tx_size][plane][br][ctx][2] = 0;
}
}
#endif // BR_NODE
}
}
#if CONFIG_CTX1D
......
......@@ -485,7 +485,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
ctx = get_br_ctx(levels, scan[c], bwl, height);
#if BR_NODE
for (idx = 0; idx < BASE_RANGE_SETS; ++idx) {
if (av1_read_record_bin(
counts, r, ec_ctx->coeff_br_cdf[txs_ctx][plane_type][idx][ctx], 2,
......@@ -517,26 +516,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
}
if (idx < BASE_RANGE_SETS) continue;
#else
for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
#if LV_MAP_PROB
if (av1_read_record_bin(counts, r,
ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx],
2, ACCT_STR))
#else
if (aom_read(r, ec_ctx->coeff_lps[txs_ctx][plane_type][ctx], ACCT_STR))
#endif
{
*level = idx + 1 + NUM_BASE_LEVELS;
cul_level += *level;
if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][1];
break;
}
if (counts) ++counts->coeff_lps[txs_ctx][plane_type][ctx][0];
}
if (idx < COEFF_BASE_RANGE) continue;
#endif
// decode 0-th order Golomb code
*level = COEFF_BASE_RANGE + 1 + NUM_BASE_LEVELS;
......
......@@ -65,12 +65,8 @@ typedef struct {
#endif
int dc_sign_cost[DC_SIGN_CONTEXTS][2];
int base_cost[NUM_BASE_LEVELS][COEFF_BASE_CONTEXTS][2];
#if BR_NODE
int lps_cost[LEVEL_CONTEXTS][COEFF_BASE_RANGE + 1];
int br_cost[BASE_RANGE_SETS][LEVEL_CONTEXTS][2];
#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];
......
......@@ -567,7 +567,6 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
// level is above 1.
ctx = get_br_ctx(levels, scan[c], bwl, height);
#if BR_NODE
int base_range = level - 1 - NUM_BASE_LEVELS;
int br_set_idx = 0;
int br_base = 0;
......@@ -600,24 +599,6 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
}
if (br_set_idx < BASE_RANGE_SETS) continue;
#else // BR_NODE
for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
if (level == (idx + 1 + NUM_BASE_LEVELS)) {
#if LV_MAP_PROB
aom_write_bin(w, 1, ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx], 2);
#else
aom_write(w, 1, ec_ctx->coeff_lps[txs_ctx][plane_type][ctx]);
#endif
break;
}
#if LV_MAP_PROB
aom_write_bin(w, 0, ec_ctx->coeff_lps_cdf[txs_ctx][plane_type][ctx], 2);
#else
aom_write(w, 0, ec_ctx->coeff_lps[txs_ctx][plane_type][ctx]);
#endif
}
if (idx < COEFF_BASE_RANGE) continue;
#endif // BR_NODE
// use 0-th order Golomb code to handle the residual level.
write_golomb(w,
......@@ -695,19 +676,10 @@ static INLINE int get_br_cost(tran_low_t abs_qc, int ctx,
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;
}
......@@ -917,7 +889,6 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
if (level > NUM_BASE_LEVELS) {
int ctx;
ctx = get_br_ctx_coeff(qcoeff, scan[c], bwl, height);
#if BR_NODE
int base_range = level - 1 - NUM_BASE_LEVELS;
if (base_range < COEFF_BASE_RANGE) {
cost += coeff_costs->lps_cost[ctx][base_range];
......@@ -925,15 +896,6 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
cost += coeff_costs->lps_cost[ctx][COEFF_BASE_RANGE];
}
#else
for (int idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
if (level == (idx + 1 + NUM_BASE_LEVELS)) {
cost += coeff_costs->lps_cost[ctx][1];
break;
}
cost += coeff_costs->lps_cost[ctx][0];
}
#endif
if (level >= 1 + NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
// residual cost
int r = level - COEFF_BASE_RANGE - NUM_BASE_LEVELS;
......@@ -1411,33 +1373,20 @@ 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);
......@@ -2701,7 +2650,6 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
// level is above 1.
ctx = get_br_ctx(levels, scan[c], bwl, height);
#if BR_NODE
int base_range = level - 1 - NUM_BASE_LEVELS;
int br_set_idx = base_range < COEFF_BASE_RANGE
? coeff_to_br_index[base_range]
......@@ -2730,22 +2678,6 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
++td->counts->coeff_br[txsize_ctx][plane_type][idx][ctx][0];
update_bin(ec_ctx->coeff_br_cdf[txsize_ctx][plane_type][idx][ctx], 0, 2);
}
#else // BR_NODE
for (idx = 0; idx < COEFF_BASE_RANGE; ++idx) {
if (level == (idx + 1 + NUM_BASE_LEVELS)) {
++td->counts->coeff_lps[txsize_ctx][plane_type][ctx][1];
#if LV_MAP_PROB
update_bin(ec_ctx->coeff_lps_cdf[txsize_ctx][plane_type][ctx], 1, 2);
#endif
break;
}
++td->counts->coeff_lps[txsize_ctx][plane_type][ctx][0];
#if LV_MAP_PROB
update_bin(ec_ctx->coeff_lps_cdf[txsize_ctx][plane_type][ctx], 0, 2);
#endif
}
if (idx < COEFF_BASE_RANGE) continue;
#endif // BR_NODE
// use 0-th order Golomb code to handle the residual level.
}
......
......@@ -64,9 +64,7 @@ typedef struct TxbProbs {
const aom_prob *coeff_lps;
const aom_prob *eob_flag;
const aom_prob *txb_skip;
#if BR_NODE
const aom_prob *coeff_br;
#endif
} TxbProbs;
void av1_alloc_txb_buf(AV1_COMP *cpi);
......
......@@ -611,7 +611,6 @@ void av1_fill_coeff_costs(MACROBLOCK *x, FRAME_CONTEXT *fc) {
pcost->base_cost[layer][ctx],
fc->coeff_base_cdf[tx_size][plane][layer][ctx], NULL);
#if BR_NODE
for (int br = 0; br < BASE_RANGE_SETS; ++br)
for (int ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx)
av1_cost_tokens_from_cdf(pcost->br_cost[br][ctx],
......@@ -654,11 +653,6 @@ 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],
......
......@@ -794,7 +794,6 @@ int main(int argc, const char **argv) {
"default_coeff_lps_cdf[TX_SIZES][PLANE_TYPES][LEVEL_"
"CONTEXTS][CDF_SIZE(2)]");
#if BR_NODE
cts_each_dim[0] = TX_SIZES;
cts_each_dim[1] = PLANE_TYPES;
cts_each_dim[2] = BASE_RANGE_SETS;
......@@ -809,7 +808,6 @@ int main(int argc, const char **argv) {
"static const aom_cdf_prob "
"default_coeff_br_cdf[TX_SIZES][PLANE_TYPES][BASE_RANGE_"
"SETS][LEVEL_CONTEXTS][CDF_SIZE(2)]");
#endif // BR_NODE
#if CONFIG_CTX1D
cts_each_dim[0] = TX_SIZES;
......
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