Commit f76828cf authored by Angie Chiang's avatar Angie Chiang

Replace mult by left shift in get_mag()

Change-Id: Idfa722cf2d1ed2f73630c7480ce166286955e1c5
parent 2ad6ee65
......@@ -52,7 +52,7 @@ static INLINE int get_level_count(const tran_low_t *tcoeffs, int stride,
return count;
}
static INLINE void get_mag(int *mag, const tran_low_t *tcoeffs, int stride,
static INLINE void get_mag(int *mag, const tran_low_t *tcoeffs, int bwl,
int height, int row, int col, int (*nb_offset)[2],
int nb_num) {
mag[0] = 0;
......@@ -60,9 +60,10 @@ static INLINE void get_mag(int *mag, const tran_low_t *tcoeffs, int stride,
for (int idx = 0; idx < nb_num; ++idx) {
const int ref_row = row + nb_offset[idx][0];
const int ref_col = col + nb_offset[idx][1];
const int pos = ref_row * stride + ref_col;
if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
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]);
if (nb_offset[idx][0] >= 0 && nb_offset[idx][1] >= 0) {
if (abs_coeff > mag[0]) {
......
......@@ -410,15 +410,16 @@ static INLINE int has_base(tran_low_t qc, int base_idx) {
static void gen_base_count_mag_arr(int (*base_count_arr)[MAX_TX_SQUARE],
int (*base_mag_arr)[2],
const tran_low_t *qcoeff, int stride,
const tran_low_t *qcoeff, int bwl,
int height, int eob, const int16_t *scan) {
const int stride = 1 << bwl;
for (int c = 0; c < eob; ++c) {
const int coeff_idx = scan[c]; // raster order
if (!has_base(qcoeff[coeff_idx], 0)) continue;
const int row = coeff_idx / stride;
const int col = coeff_idx % stride;
int *mag = base_mag_arr[coeff_idx];
get_mag(mag, qcoeff, stride, height, row, col, base_ref_offset,
get_mag(mag, qcoeff, bwl, height, row, col, base_ref_offset,
BASE_CONTEXT_POSITION_NUM);
for (int i = 0; i < NUM_BASE_LEVELS; ++i) {
if (!has_base(qcoeff[coeff_idx], i)) continue;
......@@ -481,8 +482,9 @@ static INLINE int has_br(tran_low_t qc) {
}
static void gen_br_count_mag_arr(int *br_count_arr, int (*br_mag_arr)[2],
const tran_low_t *qcoeff, int stride,
int height, int eob, const int16_t *scan) {
const tran_low_t *qcoeff, int bwl, int height,
int eob, const int16_t *scan) {
const int stride = 1 << bwl;
for (int c = 0; c < eob; ++c) {
const int coeff_idx = scan[c]; // raster order
if (!has_br(qcoeff[coeff_idx])) continue;
......@@ -492,7 +494,7 @@ static void gen_br_count_mag_arr(int *br_count_arr, int (*br_mag_arr)[2],
int *mag = br_mag_arr[coeff_idx];
*count = get_level_count(qcoeff, stride, height, row, col, NUM_BASE_LEVELS,
br_ref_offset, BR_CONTEXT_POSITION_NUM);
get_mag(mag, qcoeff, stride, height, row, col, br_ref_offset,
get_mag(mag, qcoeff, bwl, height, row, col, br_ref_offset,
BR_CONTEXT_POSITION_NUM);
}
}
......@@ -551,13 +553,13 @@ void gen_txb_cache(TxbCache *txb_cache, TxbInfo *txb_info) {
txb_info->qcoeff, txb_info->bwl, txb_info->eob,
txb_info->scan_order);
gen_base_count_mag_arr(txb_cache->base_count_arr, txb_cache->base_mag_arr,
txb_info->qcoeff, txb_info->stride, txb_info->height,
txb_info->qcoeff, txb_info->bwl, txb_info->height,
txb_info->eob, scan);
gen_base_ctx_arr(txb_cache->base_ctx_arr, txb_cache->base_count_arr,
txb_cache->base_mag_arr, txb_info->qcoeff, txb_info->stride,
txb_info->eob, scan);
gen_br_count_mag_arr(txb_cache->br_count_arr, txb_cache->br_mag_arr,
txb_info->qcoeff, txb_info->stride, txb_info->height,
txb_info->qcoeff, txb_info->bwl, txb_info->height,
txb_info->eob, scan);
gen_br_ctx_arr(txb_cache->br_ctx_arr, txb_cache->br_count_arr,
txb_cache->br_mag_arr, txb_info->qcoeff, txb_info->stride,
......
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