Commit 2cfb714a authored by Angie Chiang's avatar Angie Chiang

Remove USE_CAUSAL_BR_CTX flag

Change-Id: I103547d5bd4c9537cc0640a10d50f5c3cb6b7771
parent 8f682c9b
......@@ -63,7 +63,6 @@ extern "C" {
#define SIG_COEF_CONTEXTS_2D 26
#define SIG_COEF_CONTEXTS_1D 16
#define USE_CAUSAL_BR_CTX 1
#define SIG_COEF_CONTEXTS_EOB 4
#define SIG_COEF_CONTEXTS (SIG_COEF_CONTEXTS_2D + SIG_COEF_CONTEXTS_1D)
......@@ -72,11 +71,7 @@ extern "C" {
#define BR_TMP_OFFSET 12
#define BR_REF_CAT 4
#if USE_CAUSAL_BR_CTX
#define LEVEL_CONTEXTS 21
#else
#define LEVEL_CONTEXTS (BR_TMP_OFFSET * BR_REF_CAT)
#endif
#define NUM_BASE_LEVELS 2
......
......@@ -43,13 +43,11 @@ static const int base_ref_offset[BASE_CONTEXT_POSITION_NUM][2] = {
};
#define CONTEXT_MAG_POSITION_NUM 3
#if USE_CAUSAL_BR_CTX
static const int mag_ref_offset_with_txclass[3][CONTEXT_MAG_POSITION_NUM][2] = {
{ { 0, 1 }, { 1, 0 }, { 1, 1 } },
{ { 0, 1 }, { 1, 0 }, { 0, 2 } },
{ { 0, 1 }, { 1, 0 }, { 2, 0 } }
};
#endif
static const int mag_ref_offset[CONTEXT_MAG_POSITION_NUM][2] = {
{ 0, 1 }, { 1, 0 }, { 1, 1 }
};
......@@ -195,7 +193,6 @@ static INLINE int get_level_count(const uint8_t *const levels, const int stride,
return count;
}
#if USE_CAUSAL_BR_CTX
static INLINE void get_level_mag_with_txclass(const uint8_t *const levels,
const int stride, const int row,
const int col, int *const mag,
......@@ -207,7 +204,6 @@ static INLINE void get_level_mag_with_txclass(const uint8_t *const levels,
mag[idx] = levels[pos];
}
}
#endif
static INLINE void get_level_mag(const uint8_t *const levels, const int stride,
const int row, const int col, int *const mag) {
......@@ -363,18 +359,13 @@ static INLINE int get_br_ctx_from_count_mag(const int row, const int col,
static INLINE int get_br_ctx(const uint8_t *const levels,
const int c, // raster order
const int bwl, const int count
#if USE_CAUSAL_BR_CTX
,
const TX_TYPE tx_type
#endif
) {
const int bwl, const int count,
const TX_TYPE tx_type) {
const int row = c >> bwl;
const int col = c - (row << bwl);
const int stride = (1 << bwl) + TX_PAD_HOR;
int mag = 0;
int nb_mag[3] = { 0 };
#if USE_CAUSAL_BR_CTX
(void)count;
const TX_CLASS tx_class = tx_type_to_class[tx_type];
get_level_mag_with_txclass(levels, stride, row, col, nb_mag, tx_class);
......@@ -396,12 +387,6 @@ static INLINE int get_br_ctx(const uint8_t *const levels,
}
}
return mag + 14;
#else
get_level_mag(levels, stride, row, col, nb_mag);
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;
#endif
}
#define SIG_REF_OFFSET_NUM 5
......
......@@ -195,26 +195,21 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
break;
}
// printf("Dec: ");
if (k_eob_offset_bits[eob_pt] > 0) {
int bit = aom_read_symbol(
r, ec_ctx->eob_extra_cdf[txs_ctx][plane_type][eob_pt], 2, ACCT_STR);
// printf("eob_extra_cdf: %d %d %2d\n", txs_ctx, plane_type, eob_pt);
if (bit) {
eob_extra += (1 << (k_eob_offset_bits[eob_pt] - 1));
}
for (int i = 1; i < k_eob_offset_bits[eob_pt]; i++) {
bit = aom_read_bit(r, ACCT_STR);
// printf("eob_bit:\n");
if (bit) {
eob_extra += (1 << (k_eob_offset_bits[eob_pt] - 1 - i));
}
// printf("%d ", bit);
}
}
*eob = rec_eob_pos(eob_pt, eob_extra);
// printf("=>[%d, %d], (%d, %d)\n", seg_eob, *eob, eob_pt, eob_extra);
for (int i = 0; i < *eob; ++i) {
const int c = *eob - 1 - i;
......@@ -232,12 +227,8 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
}
int level = aom_read_symbol(r, cdf, nsymbs, ACCT_STR) + (c == *eob - 1);
if (level > NUM_BASE_LEVELS) {
#if USE_CAUSAL_BR_CTX
const int br_ctx =
get_br_ctx(levels, pos, bwl, level_counts[pos], tx_type);
#else
const int br_ctx = get_br_ctx(levels, pos, bwl, level_counts[pos]);
#endif
for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = aom_read_symbol(
r,
......
......@@ -560,13 +560,8 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
if (level > NUM_BASE_LEVELS) {
// level is above 1.
const int base_range = level - 1 - NUM_BASE_LEVELS;
#if USE_CAUSAL_BR_CTX
const int br_ctx =
get_br_ctx(levels, pos, bwl, level_counts[pos], tx_type);
#else
const int br_ctx = get_br_ctx(levels, pos, bwl, level_counts[pos]);
#endif
for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
aom_write_symbol(w, k,
......@@ -757,11 +752,7 @@ int av1_cost_coeffs_txb(const AV1_COMMON *const cm, const MACROBLOCK *x,
}
if (level > NUM_BASE_LEVELS) {
int ctx;
#if USE_CAUSAL_BR_CTX
ctx = get_br_ctx(levels, pos, bwl, level_counts[pos], tx_type);
#else
ctx = get_br_ctx(levels, pos, bwl, level_counts[pos]);
#endif
const int base_range = level - 1 - NUM_BASE_LEVELS;
if (base_range < COEFF_BASE_RANGE) {
cost += coeff_costs->lps_cost[ctx][base_range];
......@@ -1384,17 +1375,10 @@ static int get_coeff_cost(const tran_low_t qc, const int scan_idx,
const int row = pos >> txb_info->bwl;
const int col = pos - (row << txb_info->bwl);
#if USE_CAUSAL_BR_CTX
(void)col;
const int count = 0;
const int ctx = get_br_ctx(txb_info->levels, pos, txb_info->bwl, count,
txb_info->tx_type);
#else
const int count = get_level_count(
txb_info->levels, (1 << txb_info->bwl) + TX_PAD_HOR, row, col,
NUM_BASE_LEVELS, br_ref_offset, BR_CONTEXT_POSITION_NUM);
const int ctx = get_br_ctx(txb_info->levels, pos, txb_info->bwl, count);
#endif
cost += get_br_cost(abs_qc, ctx, txb_costs->lps_cost[ctx]);
cost += get_golomb_cost(abs_qc);
}
......@@ -2357,33 +2341,19 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
}
if (level > NUM_BASE_LEVELS) {
const int base_range = level - 1 - NUM_BASE_LEVELS;
#if USE_CAUSAL_BR_CTX
const int br_ctx =
get_br_ctx(levels, pos, bwl, level_counts[pos], tx_type);
#else
const int br_ctx = get_br_ctx(levels, pos, bwl, level_counts[pos]);
#endif
for (int idx = 0; idx < COEFF_BASE_RANGE; idx += BR_CDF_SIZE - 1) {
const int k = AOMMIN(base_range - idx, BR_CDF_SIZE - 1);
if (allow_update_cdf) {
update_cdf(
#if 0
ec_ctx->coeff_br_cdf[AOMMIN(txsize_ctx, TX_16X16)][plane_type][br_ctx],
#else
ec_ctx->coeff_br_cdf[AOMMIN(txsize_ctx, TX_32X32)][plane_type]
[br_ctx],
#endif
k, BR_CDF_SIZE);
update_cdf(ec_ctx->coeff_br_cdf[AOMMIN(txsize_ctx, TX_32X32)]
[plane_type][br_ctx],
k, BR_CDF_SIZE);
}
for (int lps = 0; lps < BR_CDF_SIZE - 1; lps++) {
#if CONFIG_ENTROPY_STATS
#if 0
++td->counts->coeff_lps[AOMMIN(txsize_ctx, TX_16X16)][plane_type][lps]
[ctx][lps == k];
#else
++td->counts->coeff_lps[AOMMIN(txsize_ctx, TX_32X32)][plane_type][lps]
[br_ctx][lps == k];
#endif
#endif // CONFIG_ENTROPY_STATS
if (lps == k) break;
}
......
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