Commit 7ab884e1 authored by Angie Chiang's avatar Angie Chiang Committed by Yaowu Xu

Do entropy coding on eob_extra

Change-Id: Ia67beabb85eedd5da5eb69f434dde71f66f08006
parent a47cd6c0
......@@ -168,6 +168,10 @@ typedef struct frame_contexts {
[CDF_SIZE(2)];
aom_cdf_prob eob_flag_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)];
#if CONFIG_EOB_FIRST
aom_cdf_prob eob_extra_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)];
#endif
aom_cdf_prob dc_sign_cdf[PLANE_TYPES][DC_SIGN_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob coeff_base_cdf[TX_SIZES][PLANE_TYPES][NUM_BASE_LEVELS]
[COEFF_BASE_CONTEXTS][CDF_SIZE(2)];
......
......@@ -149,6 +149,14 @@ void av1_init_txb_probs(FRAME_CONTEXT *fc) {
fc->eob_flag_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->eob_flag_cdf[tx_size][plane][ctx][2] = 0;
}
#if CONFIG_EOB_FIRST
for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) {
fc->eob_extra_cdf[tx_size][plane][ctx][0] = AOM_ICDF(128 * 145);
fc->eob_flag_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->eob_flag_cdf[tx_size][plane][ctx][2] = 0;
}
#endif
}
}
......
......@@ -370,9 +370,17 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
// printf("Dec: ");
if (k_eob_offset_bits[eob_pt] > 0) {
for (int i = 0; i < k_eob_offset_bits[eob_pt]; i++) {
int eob_shift = k_eob_offset_bits[eob_pt] - 1 - i;
int bit = av1_read_record_bit(counts, r, ACCT_STR);
int eob_shift = k_eob_offset_bits[eob_pt] - 1;
int bit = av1_read_record_bin(
counts, r, ec_ctx->eob_extra_cdf[txs_ctx][plane_type][eob_pt], 2,
ACCT_STR);
if (bit) {
eob_extra += (1 << eob_shift);
}
for (int i = 1; i < k_eob_offset_bits[eob_pt]; i++) {
eob_shift = k_eob_offset_bits[eob_pt] - 1 - i;
bit = av1_read_record_bit(counts, r, ACCT_STR);
if (bit) {
eob_extra += (1 << eob_shift);
}
......
......@@ -60,6 +60,9 @@ typedef struct {
int txb_skip_cost[TXB_SKIP_CONTEXTS][2];
int nz_map_cost[SIG_COEF_CONTEXTS][2];
int eob_cost[EOB_COEF_CONTEXTS][2];
#if CONFIG_EOB_FIRST
int eob_extra_cost[EOB_COEF_CONTEXTS][2];
#endif
int dc_sign_cost[DC_SIGN_CONTEXTS][2];
int base_cost[NUM_BASE_LEVELS][COEFF_BASE_CONTEXTS][2];
#if BR_NODE
......
......@@ -152,6 +152,14 @@ void av1_update_eob_context(int eob, int seg_eob, TX_SIZE txsize,
break;
}
}
if (k_eob_offset_bits[eob_pt] > 0) {
int eob_shift = k_eob_offset_bits[eob_pt] - 1;
int bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
// TODO(angiebird): update count as well
#if LV_MAP_PROB
update_cdf(ec_ctx->eob_extra_cdf[txsize][plane][eob_pt], bit, 2);
#endif
}
}
static int get_eob_cost(int eob, int seg_eob,
......@@ -171,9 +179,12 @@ static int get_eob_cost(int eob, int seg_eob,
}
}
if (k_eob_offset_bits[eob_pt] > 0) {
for (int i = 0; i < k_eob_offset_bits[eob_pt]; i++) {
int eob_shift = k_eob_offset_bits[eob_pt] - 1 - i;
int bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
int eob_shift = k_eob_offset_bits[eob_pt] - 1;
int bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
eob_cost += txb_costs->eob_extra_cost[eob_pt][bit];
for (int i = 1; i < k_eob_offset_bits[eob_pt]; i++) {
eob_shift = k_eob_offset_bits[eob_pt] - 1 - i;
bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
eob_cost += av1_cost_bit(128, bit);
}
}
......@@ -475,9 +486,13 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
}
if (k_eob_offset_bits[eob_pt] > 0) {
for (int i = 0; i < k_eob_offset_bits[eob_pt]; i++) {
int eob_shift = k_eob_offset_bits[eob_pt] - 1 - i;
int bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
int eob_shift = k_eob_offset_bits[eob_pt] - 1;
int bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
aom_write_bin(w, bit, ec_ctx->eob_extra_cdf[txs_ctx][plane_type][eob_pt],
2);
for (int i = 1; i < k_eob_offset_bits[eob_pt]; i++) {
eob_shift = k_eob_offset_bits[eob_pt] - 1 - i;
bit = (eob_extra & (1 << eob_shift)) ? 1 : 0;
aom_write_bit(w, bit);
// printf("%d ", bit);
}
......
......@@ -608,6 +608,12 @@ void av1_fill_coeff_costs(MACROBLOCK *x, FRAME_CONTEXT *fc) {
av1_cost_tokens_from_cdf(pcost->eob_cost[ctx],
fc->eob_flag_cdf[tx_size][plane][ctx], NULL);
#if CONFIG_EOB_FIRST
for (int ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx)
av1_cost_tokens_from_cdf(pcost->eob_extra_cost[ctx],
fc->eob_extra_cdf[tx_size][plane][ctx], NULL);
#endif
for (int ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx)
av1_cost_tokens_from_cdf(pcost->dc_sign_cost[ctx],
fc->dc_sign_cdf[plane][ctx], NULL);
......
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