Replace mult by left shift in get_mag() Change-Id: Idfa722cf2d1ed2f73630c7480ce166286955e1c5
diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h index cbecacb..72de63e 100644 --- a/av1/common/txb_common.h +++ b/av1/common/txb_common.h
@@ -52,7 +52,7 @@ 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 @@ 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]) {
diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c index f6ea47e..6a28a6a 100644 --- a/av1/encoder/encodetxb.c +++ b/av1/encoder/encodetxb.c
@@ -410,15 +410,16 @@ 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 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 @@ 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 @@ 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,