Commit f8a68225 authored by Angie Chiang's avatar Angie Chiang

Add get_lower_levels_ctx{|_eob}

This is to separate the logic of getting lower level coeff ctx
for eob and non-eob position

BUG=aomedia:1369

Change-Id: Id1d85d7fbb67e57c58479e00b633d794381132ea
parent da708cd9
......@@ -509,6 +509,21 @@ static INLINE int get_nz_map_ctx_from_stats(
return ctx + map[AOMMIN(idx, 2)];
}
}
static INLINE int get_lower_levels_ctx_eob(int bwl, int height, int scan_idx) {
if (scan_idx == 0) return 0;
if (scan_idx <= (height << bwl) / 8) return 1;
if (scan_idx <= (height << bwl) / 4) return 2;
return 3;
}
static INLINE int get_lower_levels_ctx(const uint8_t *levels, int coeff_idx,
int bwl, TX_SIZE tx_size,
TX_TYPE tx_type) {
const TX_CLASS tx_class = tx_type_to_class[tx_type];
const int stats =
get_nz_mag(levels + get_padded_idx(coeff_idx, bwl), bwl, tx_class);
return get_nz_map_ctx_from_stats(stats, coeff_idx, bwl, tx_size, tx_class);
}
static INLINE int get_nz_map_ctx(const uint8_t *const levels,
const int coeff_idx, const int bwl,
......
......@@ -196,12 +196,11 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
*eob = rec_eob_pos(eob_pt, eob_extra);
{
// Read the last non-zero coefficient
// Read the non-zero coefficient with scan index eob-1
// TODO(angiebird): Put this into a function
const int c = *eob - 1;
const int pos = scan[c];
const int coeff_ctx =
get_nz_map_ctx(levels, pos, bwl, height, c, 1, tx_size, tx_type);
const int coeff_ctx = get_lower_levels_ctx_eob(bwl, height, c);
const int nsymbs = 3;
aom_cdf_prob *cdf =
ec_ctx->coeff_base_eob_cdf[txs_ctx][plane_type][coeff_ctx];
......@@ -228,7 +227,7 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int c = *eob - 1 - i;
const int pos = scan[c];
const int coeff_ctx =
get_nz_map_ctx(levels, pos, bwl, height, c, 0, tx_size, tx_type);
get_lower_levels_ctx(levels, pos, bwl, tx_size, tx_type);
aom_cdf_prob *cdf = ec_ctx->coeff_base_cdf[txs_ctx][plane_type][coeff_ctx];
const int nsymbs = 4;
int level = aom_read_symbol(r, cdf, nsymbs, ACCT_STR);
......
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