Commit e97b5ea6 authored by Angie Chiang's avatar Angie Chiang

Replace stride by bwl in get_level_count()

Change-Id: Id191159a851513b6eb3f2ddd104a1299eed59292
parent defa7bf1
......@@ -36,16 +36,17 @@ static int base_ref_offset[BASE_CONTEXT_POSITION_NUM][2] = {
/* clang-format on*/
};
static INLINE int get_level_count(const tran_low_t *tcoeffs, int stride,
static INLINE int get_level_count(const tran_low_t *tcoeffs, int bwl,
int height, int row, int col, int level,
int (*nb_offset)[2], int nb_num) {
int count = 0;
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]);
count += abs_coeff > level;
}
......
......@@ -412,19 +412,18 @@ 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 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;
const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << bwl);
int *mag = base_mag_arr[coeff_idx];
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;
int *count = base_count_arr[i] + coeff_idx;
*count = get_level_count(qcoeff, stride, height, row, col, i,
*count = get_level_count(qcoeff, bwl, height, row, col, i,
base_ref_offset, BASE_CONTEXT_POSITION_NUM);
}
}
......@@ -484,15 +483,14 @@ 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 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;
const int row = coeff_idx / stride;
const int col = coeff_idx % stride;
const int row = coeff_idx >> bwl;
const int col = coeff_idx - (row << bwl);
int *count = br_count_arr + coeff_idx;
int *mag = br_mag_arr[coeff_idx];
*count = get_level_count(qcoeff, stride, height, row, col, NUM_BASE_LEVELS,
*count = get_level_count(qcoeff, bwl, height, row, col, NUM_BASE_LEVELS,
br_ref_offset, BR_CONTEXT_POSITION_NUM);
get_mag(mag, qcoeff, bwl, height, row, col, br_ref_offset,
BR_CONTEXT_POSITION_NUM);
......
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