Commit 9cde59f0 authored by Angie Chiang's avatar Angie Chiang

Add get_base_count_mag()

Compute base level's count/mag together.
This will speed up lv_map exp by 5%

Change-Id: I479098ed2637fc05d454fb0a7dc9f09aa20401f3
parent 481c01fc
......@@ -76,6 +76,37 @@ static INLINE void get_mag(int *mag, const tran_low_t *tcoeffs, int bwl,
}
}
}
static INLINE void get_base_count_mag(int *mag, int *count,
const tran_low_t *tcoeffs, int bwl,
int height, int row, int col) {
mag[0] = 0;
mag[1] = 0;
for (int i = 0; i < NUM_BASE_LEVELS; ++i) count[i] = 0;
for (int idx = 0; idx < BASE_CONTEXT_POSITION_NUM; ++idx) {
const int ref_row = row + base_ref_offset[idx][0];
const int ref_col = col + base_ref_offset[idx][1];
if (ref_row < 0 || ref_col < 0 || ref_row >= height ||
ref_col >= (1 << bwl))
continue;
const int pos = (ref_row << bwl) + ref_col;
tran_low_t abs_coeff = abs(tcoeffs[pos]);
// count
for (int i = 0; i < NUM_BASE_LEVELS; ++i) {
count[i] += abs_coeff > i;
}
// mag
if (base_ref_offset[idx][0] >= 0 && base_ref_offset[idx][1] >= 0) {
if (abs_coeff > mag[0]) {
mag[0] = abs_coeff;
mag[1] = 1;
} else if (abs_coeff == mag[0]) {
++mag[1];
}
}
}
}
static INLINE int get_level_count_mag(int *mag, const tran_low_t *tcoeffs,
int bwl, int height, int row, int col,
int level, int (*nb_offset)[2],
......
......@@ -461,17 +461,15 @@ void gen_txb_cache(TxbCache *txb_cache, TxbInfo *txb_info) {
// gen_base_count_mag_arr
if (!has_base(qcoeff[coeff_idx], 0)) continue;
int *base_mag = txb_cache->base_mag_arr[coeff_idx];
get_mag(base_mag, qcoeff, bwl, height, row, col, base_ref_offset,
BASE_CONTEXT_POSITION_NUM);
int count[NUM_BASE_LEVELS];
get_base_count_mag(base_mag, count, qcoeff, bwl, height, row, col);
for (int i = 0; i < NUM_BASE_LEVELS; ++i) {
if (!has_base(qcoeff[coeff_idx], i)) continue;
int *base_count = txb_cache->base_count_arr[i] + coeff_idx;
*base_count = get_level_count(qcoeff, bwl, height, row, col, i,
base_ref_offset, BASE_CONTEXT_POSITION_NUM);
if (!has_base(qcoeff[coeff_idx], i)) break;
txb_cache->base_count_arr[i][coeff_idx] = count[i];
const int level = i + 1;
txb_cache->base_ctx_arr[i][coeff_idx] = get_base_ctx_from_count_mag(
row, col, *base_count, base_mag[0], level);
txb_cache->base_ctx_arr[i][coeff_idx] =
get_base_ctx_from_count_mag(row, col, count[i], base_mag[0], level);
}
// gen_br_count_mag_arr
......
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