diff --git a/av1/common/txb_common.h b/av1/common/txb_common.h index 1cb8325e1826c4660a7159dc9faeffde1985fc24..b5b34612b08747c4e66f0a381120a8c1b942b5ca 100644 --- a/av1/common/txb_common.h +++ b/av1/common/txb_common.h @@ -96,28 +96,6 @@ static INLINE int get_level_count_mag( return count; } -static INLINE int get_level_count_mag_coeff( - int *const mag, const tran_low_t *const tcoeffs, const int bwl, - const int height, const int row, const int col, const int level, - const int (*nb_offset)[2], const int nb_num) { - const int stride = 1 << bwl; - 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]; - if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride) - continue; - const int pos = (ref_row << bwl) + ref_col; - tran_low_t abs_coeff = abs(tcoeffs[pos]); - count += abs_coeff > level; - - if (nb_offset[idx][0] == 0 && nb_offset[idx][1] == 1) mag[0] = abs_coeff; - if (nb_offset[idx][0] == 1 && nb_offset[idx][1] == 0) mag[1] = abs_coeff; - if (nb_offset[idx][0] == 1 && nb_offset[idx][1] == 1) mag[2] = abs_coeff; - } - return count; -} - static INLINE int get_base_ctx_from_count_mag(int row, int col, int count, int sig_mag) { const int ctx = base_level_count_to_index[count]; @@ -299,22 +277,6 @@ static INLINE int get_br_ctx(const uint8_t *const levels, return ctx; } -static INLINE int get_br_ctx_coeff(const tran_low_t *const tcoeffs, - const int c, // raster order - const int bwl, const int height) { - const int row = c >> bwl; - const int col = c - (row << bwl); - const int level_minus_1 = NUM_BASE_LEVELS; - int mag = 0; - int nb_mag[3] = { 0 }; - const int count = get_level_count_mag_coeff(nb_mag, tcoeffs, bwl, height, row, - col, level_minus_1, br_ref_offset, - BR_CONTEXT_POSITION_NUM); - for (int idx = 0; idx < 3; ++idx) mag = AOMMAX(mag, nb_mag[idx]); - const int ctx = get_br_ctx_from_count_mag(row, col, count, mag); - return ctx; -} - #define SIG_REF_OFFSET_NUM 7 static const int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = { diff --git a/av1/encoder/encodetxb.c b/av1/encoder/encodetxb.c index 03e68ea7c1f0d338524955156642d248b974bf57..1e8ea8d8782bb1747bf8a1336c6872de0894ee3f 100644 --- a/av1/encoder/encodetxb.c +++ b/av1/encoder/encodetxb.c @@ -486,8 +486,8 @@ void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x, } } -static INLINE void get_base_ctx_set(const tran_low_t *tcoeffs, - int c, // raster order +static INLINE void get_base_ctx_set(const uint8_t *const levels, + const int c, // raster order const int bwl, const int height, int ctx_set[NUM_BASE_LEVELS]) { const int row = c >> bwl; @@ -496,7 +496,6 @@ static INLINE void get_base_ctx_set(const tran_low_t *tcoeffs, int mag_count[NUM_BASE_LEVELS] = { 0 }; int nb_mag[NUM_BASE_LEVELS][3] = { { 0 } }; int idx; - tran_low_t abs_coeff; int i; for (idx = 0; idx < BASE_CONTEXT_POSITION_NUM; ++idx) { @@ -507,7 +506,7 @@ static INLINE void get_base_ctx_set(const tran_low_t *tcoeffs, if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride) continue; - abs_coeff = abs(tcoeffs[pos]); + const uint8_t abs_coeff = levels[pos]; for (i = 0; i < NUM_BASE_LEVELS; ++i) { ctx_set[i] += abs_coeff > i; @@ -636,7 +635,7 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane, if (is_k == 0) break; } #else - get_base_ctx_set(qcoeff, scan[c], bwl, height, ctx_ls); + get_base_ctx_set(levels, scan[c], bwl, height, ctx_ls); int i; for (i = 0; i < NUM_BASE_LEVELS; ++i) { @@ -652,7 +651,7 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane, if (level > NUM_BASE_LEVELS) { int ctx; - ctx = get_br_ctx_coeff(qcoeff, scan[c], bwl, height); + ctx = get_br_ctx(levels, scan[c], bwl, height); int base_range = level - 1 - NUM_BASE_LEVELS; if (base_range < COEFF_BASE_RANGE) { cost += coeff_costs->lps_cost[ctx][base_range]; @@ -1435,7 +1434,7 @@ static int get_coeff_cost(const tran_low_t qc, const int scan_idx, } #else int ctx_ls[NUM_BASE_LEVELS] = { 0 }; - get_base_ctx_set(txb_info->qcoeff, scan[scan_idx], txb_info->bwl, + get_base_ctx_set(txb_info->levels, scan[scan_idx], txb_info->bwl, txb_info->height, ctx_ls); int i; @@ -1446,8 +1445,8 @@ static int get_coeff_cost(const tran_low_t qc, const int scan_idx, #endif if (abs_qc > NUM_BASE_LEVELS) { - int ctx = get_br_ctx_coeff(txb_info->qcoeff, scan[scan_idx], - txb_info->bwl, txb_info->height); + int ctx = get_br_ctx(txb_info->levels, scan[scan_idx], txb_info->bwl, + txb_info->height); cost += get_br_cost(abs_qc, ctx, txb_costs->lps_cost[ctx]); cost += get_golomb_cost(abs_qc); }