Commit 6dea31ea authored by Angie Chiang's avatar Angie Chiang

[lv_map] Add read_coeffs_reverse()

Move coeff decoding logics into read_coeffs_reverse()

Change-Id: Iea7fa09d387af1d797de3df1cf2878516e039203
parent 52e27901
......@@ -507,6 +507,10 @@ static INLINE int get_nz_map_ctx_from_stats(
return ctx + map[AOMMIN(idx, 2)];
}
}
typedef aom_cdf_prob (*base_cdf_arr)[CDF_SIZE(4)];
typedef aom_cdf_prob (*br_cdf_arr)[CDF_SIZE(BR_CDF_SIZE)];
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;
......
......@@ -63,6 +63,35 @@ static INLINE int get_dqv(const int16_t *dequant, int coeff_idx,
return dqv;
}
static INLINE void read_coeffs_reverse(aom_reader *r, TX_SIZE tx_size,
TX_TYPE tx_type, int start_si,
int end_si, const int16_t *scan, int bwl,
uint8_t *levels, base_cdf_arr base_cdf,
br_cdf_arr br_cdf, int *num_updates,
uint16_t *update_pos) {
for (int c = end_si; c >= start_si; --c) {
const int pos = scan[c];
const int coeff_ctx =
get_lower_levels_ctx(levels, pos, bwl, tx_size, tx_type);
const int nsymbs = 4;
int level = aom_read_symbol(r, base_cdf[coeff_ctx], nsymbs, ACCT_STR);
if (level > NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx(levels, pos, bwl, tx_type);
aom_cdf_prob *cdf = br_cdf[br_ctx];
for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = aom_read_symbol(r, cdf, BR_CDF_SIZE, ACCT_STR);
level += k;
if (k < BR_CDF_SIZE - 1) break;
}
if (level > NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
update_pos[*num_updates] = pos;
++*num_updates;
}
}
levels[get_padded_idx(pos, bwl)] = level;
}
}
uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
aom_reader *const r, const int blk_row,
const int blk_col, const int plane,
......@@ -221,31 +250,11 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
}
levels[get_padded_idx(pos, bwl)] = level;
}
for (int i = 1; i < *eob; ++i) {
const int c = *eob - 1 - i;
const int pos = scan[c];
const int coeff_ctx =
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);
if (level > NUM_BASE_LEVELS) {
const int br_ctx = get_br_ctx(levels, pos, bwl, tx_type);
for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = aom_read_symbol(
r,
ec_ctx->coeff_br_cdf[AOMMIN(txs_ctx, TX_32X32)][plane_type][br_ctx],
BR_CDF_SIZE, ACCT_STR);
level += k;
if (k < BR_CDF_SIZE - 1) break;
}
if (level > NUM_BASE_LEVELS + COEFF_BASE_RANGE) {
update_pos[num_updates] = pos;
++num_updates;
}
}
levels[get_padded_idx(pos, bwl)] = level;
}
base_cdf_arr base_cdf = ec_ctx->coeff_base_cdf[txs_ctx][plane_type];
br_cdf_arr br_cdf =
ec_ctx->coeff_br_cdf[AOMMIN(txs_ctx, TX_32X32)][plane_type];
read_coeffs_reverse(r, tx_size, tx_type, 0, *eob - 1 - 1, scan, bwl, levels,
base_cdf, br_cdf, &num_updates, update_pos);
for (int i = 0; i < num_updates; ++i) {
const int pos = update_pos[i];
......
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