Commit 841a84d6 authored by Linfeng Zhang's avatar Linfeng Zhang

Remove get_level_count_mag_coeff() and get_br_ctx_coeff()

Change-Id: Ie6d663aacbed1452060cdef60e96d6acf469d430
parent b6957c29
...@@ -96,28 +96,6 @@ static INLINE int get_level_count_mag( ...@@ -96,28 +96,6 @@ static INLINE int get_level_count_mag(
return count; 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, static INLINE int get_base_ctx_from_count_mag(int row, int col, int count,
int sig_mag) { int sig_mag) {
const int ctx = base_level_count_to_index[count]; const int ctx = base_level_count_to_index[count];
...@@ -299,22 +277,6 @@ static INLINE int get_br_ctx(const uint8_t *const levels, ...@@ -299,22 +277,6 @@ static INLINE int get_br_ctx(const uint8_t *const levels,
return ctx; 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 #define SIG_REF_OFFSET_NUM 7
static const int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = { static const int sig_ref_offset[SIG_REF_OFFSET_NUM][2] = {
......
...@@ -486,8 +486,8 @@ void av1_write_coeffs_mb(const AV1_COMMON *const cm, MACROBLOCK *x, ...@@ -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, static INLINE void get_base_ctx_set(const uint8_t *const levels,
int c, // raster order const int c, // raster order
const int bwl, const int height, const int bwl, const int height,
int ctx_set[NUM_BASE_LEVELS]) { int ctx_set[NUM_BASE_LEVELS]) {
const int row = c >> bwl; const int row = c >> bwl;
...@@ -496,7 +496,6 @@ static INLINE void get_base_ctx_set(const tran_low_t *tcoeffs, ...@@ -496,7 +496,6 @@ static INLINE void get_base_ctx_set(const tran_low_t *tcoeffs,
int mag_count[NUM_BASE_LEVELS] = { 0 }; int mag_count[NUM_BASE_LEVELS] = { 0 };
int nb_mag[NUM_BASE_LEVELS][3] = { { 0 } }; int nb_mag[NUM_BASE_LEVELS][3] = { { 0 } };
int idx; int idx;
tran_low_t abs_coeff;
int i; int i;
for (idx = 0; idx < BASE_CONTEXT_POSITION_NUM; ++idx) { 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, ...@@ -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) if (ref_row < 0 || ref_col < 0 || ref_row >= height || ref_col >= stride)
continue; continue;
abs_coeff = abs(tcoeffs[pos]); const uint8_t abs_coeff = levels[pos];
for (i = 0; i < NUM_BASE_LEVELS; ++i) { for (i = 0; i < NUM_BASE_LEVELS; ++i) {
ctx_set[i] += abs_coeff > 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, ...@@ -636,7 +635,7 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
if (is_k == 0) break; if (is_k == 0) break;
} }
#else #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; int i;
for (i = 0; i < NUM_BASE_LEVELS; ++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, ...@@ -652,7 +651,7 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCK *x, int plane,
if (level > NUM_BASE_LEVELS) { if (level > NUM_BASE_LEVELS) {
int ctx; 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; int base_range = level - 1 - NUM_BASE_LEVELS;
if (base_range < COEFF_BASE_RANGE) { if (base_range < COEFF_BASE_RANGE) {
cost += coeff_costs->lps_cost[ctx][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, ...@@ -1435,7 +1434,7 @@ static int get_coeff_cost(const tran_low_t qc, const int scan_idx,
} }
#else #else
int ctx_ls[NUM_BASE_LEVELS] = { 0 }; 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); txb_info->height, ctx_ls);
int i; int i;
...@@ -1446,8 +1445,8 @@ static int get_coeff_cost(const tran_low_t qc, const int scan_idx, ...@@ -1446,8 +1445,8 @@ static int get_coeff_cost(const tran_low_t qc, const int scan_idx,
#endif #endif
if (abs_qc > NUM_BASE_LEVELS) { if (abs_qc > NUM_BASE_LEVELS) {
int ctx = get_br_ctx_coeff(txb_info->qcoeff, scan[scan_idx], int ctx = get_br_ctx(txb_info->levels, scan[scan_idx], txb_info->bwl,
txb_info->bwl, txb_info->height); txb_info->height);
cost += get_br_cost(abs_qc, ctx, txb_costs->lps_cost[ctx]); cost += get_br_cost(abs_qc, ctx, txb_costs->lps_cost[ctx]);
cost += get_golomb_cost(abs_qc); cost += get_golomb_cost(abs_qc);
} }
......
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