Commit 1e959897 authored by Hui Su's avatar Hui Su

lv-map: remove probability model

Change-Id: Iadaa189717787dbb82e485ff92125ee1ef591496
parent bf7cd0dd
This diff is collapsed.
......@@ -79,12 +79,6 @@ typedef struct frame_contexts {
coeff_cdf_model coef_head_cdfs[TX_SIZES][PLANE_TYPES];
#if CONFIG_LV_MAP
aom_prob txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS];
aom_prob eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS];
aom_prob dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS];
aom_prob coeff_lps[TX_SIZES][PLANE_TYPES][BR_CDF_SIZE - 1][LEVEL_CONTEXTS];
aom_cdf_prob txb_skip_cdf[TX_SIZES][TXB_SKIP_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob eob_extra_cdf[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS]
[CDF_SIZE(2)];
......@@ -140,7 +134,6 @@ typedef struct frame_contexts {
aom_cdf_prob uni_comp_ref_cdf[UNI_COMP_REF_CONTEXTS][UNIDIR_COMP_REFS - 1]
[CDF_SIZE(2)];
#endif // CONFIG_EXT_COMP_REFS
aom_prob comp_ref_prob[REF_CONTEXTS][FWD_REFS - 1];
aom_cdf_prob comp_ref_cdf[REF_CONTEXTS][FWD_REFS - 1][CDF_SIZE(2)];
aom_cdf_prob comp_bwdref_cdf[COMP_BWDREF_CONTEXTS][BWD_REFS - 1][CDF_SIZE(2)];
aom_cdf_prob txfm_partition_cdf[TXFM_PARTITION_CONTEXTS][CDF_SIZE(2)];
......@@ -244,11 +237,14 @@ typedef struct FRAME_COUNTS {
[SWITCHABLE_FILTERS];
#if CONFIG_LV_MAP
#if CONFIG_ENTROPY_STATS
unsigned int txb_skip[TX_SIZES][TXB_SKIP_CONTEXTS][2];
unsigned int eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS][2];
unsigned int eob_extra[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS][2];
unsigned int dc_sign[PLANE_TYPES][DC_SIGN_CONTEXTS][2];
unsigned int coeff_lps[TX_SIZES][PLANE_TYPES][BR_CDF_SIZE - 1][LEVEL_CONTEXTS]
[2];
#endif // CONFIG_ENTROPY_STATS
unsigned int eob_flag[TX_SIZES][PLANE_TYPES][EOB_COEF_CONTEXTS][2];
unsigned int eob_multi16[PLANE_TYPES][2][5];
unsigned int eob_multi32[PLANE_TYPES][2][6];
unsigned int eob_multi64[PLANE_TYPES][2][7];
......@@ -256,9 +252,6 @@ typedef struct FRAME_COUNTS {
unsigned int eob_multi256[PLANE_TYPES][2][9];
unsigned int eob_multi512[PLANE_TYPES][2][10];
unsigned int eob_multi1024[PLANE_TYPES][2][11];
unsigned int coeff_lps[TX_SIZES][PLANE_TYPES][BR_CDF_SIZE - 1][LEVEL_CONTEXTS]
[2];
unsigned int coeff_lps_multi[TX_SIZES][PLANE_TYPES][LEVEL_CONTEXTS]
[BR_CDF_SIZE];
unsigned int coeff_base_multi[TX_SIZES][PLANE_TYPES][SIG_COEF_CONTEXTS]
......
......@@ -221,99 +221,6 @@ const int8_t av1_nz_map_ctx_offset[TX_SIZES_ALL][5][5] = {
#endif // CONFIG_TX64X64
};
void av1_init_txb_probs(FRAME_CONTEXT *fc) {
TX_SIZE tx_size;
int plane, ctx;
// Update probability models for transform block skip flag
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (ctx = 0; ctx < TXB_SKIP_CONTEXTS; ++ctx) {
fc->txb_skip_cdf[tx_size][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->txb_skip[tx_size][ctx]);
fc->txb_skip_cdf[tx_size][ctx][1] = AOM_ICDF(32768);
fc->txb_skip_cdf[tx_size][ctx][2] = 0;
}
}
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (ctx = 0; ctx < DC_SIGN_CONTEXTS; ++ctx) {
fc->dc_sign_cdf[plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->dc_sign[plane][ctx]);
fc->dc_sign_cdf[plane][ctx][1] = AOM_ICDF(32768);
fc->dc_sign_cdf[plane][ctx][2] = 0;
}
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
#if 0
for (ctx = 0; ctx < SIG_COEF_CONTEXTS_EOB; ++ctx) {
int p = fc->coeff_base[tx_size][plane][0][SIG_COEF_CONTEXTS -
SIG_COEF_CONTEXTS_EOB + ctx] *
128;
fc->coeff_base_eob_cdf[tx_size][plane][ctx][0] = AOM_ICDF(p);
p += ((32768 - p) *
fc->coeff_base[tx_size][plane][1][SIG_COEF_CONTEXTS -
SIG_COEF_CONTEXTS_EOB + ctx]) >>
8;
fc->coeff_base_eob_cdf[tx_size][plane][ctx][1] = AOM_ICDF(p);
fc->coeff_base_eob_cdf[tx_size][plane][ctx][2] = AOM_ICDF(32768);
fc->coeff_base_eob_cdf[tx_size][plane][ctx][3] = 0;
}
for (ctx = 0; ctx < COEFF_BASE_CONTEXTS; ++ctx) {
int p = fc->nz_map[tx_size][plane][ctx] * 128;
fc->coeff_base_cdf[tx_size][plane][ctx][0] = AOM_ICDF(p);
p += ((32768 - p) * fc->coeff_base[tx_size][plane][0][ctx]) >> 8;
fc->coeff_base_cdf[tx_size][plane][ctx][1] = AOM_ICDF(p);
p += ((32768 - p) * fc->coeff_base[tx_size][plane][1][ctx]) >> 8;
fc->coeff_base_cdf[tx_size][plane][ctx][2] = AOM_ICDF(p);
fc->coeff_base_cdf[tx_size][plane][ctx][3] = AOM_ICDF(32768);
fc->coeff_base_cdf[tx_size][plane][ctx][4] = 0;
}
#else
(void)plane;
#endif
}
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (ctx = 0; ctx < EOB_COEF_CONTEXTS; ++ctx) {
fc->eob_extra_cdf[tx_size][plane][ctx][0] =
AOM_ICDF(128 * (aom_cdf_prob)fc->eob_extra[tx_size][plane][ctx]);
fc->eob_extra_cdf[tx_size][plane][ctx][1] = AOM_ICDF(32768);
fc->eob_extra_cdf[tx_size][plane][ctx][2] = 0;
}
}
}
for (tx_size = 0; tx_size < TX_SIZES; ++tx_size) {
for (plane = 0; plane < PLANE_TYPES; ++plane) {
for (ctx = 0; ctx < LEVEL_CONTEXTS; ++ctx) {
#if 0
int p = 32768 - fc->coeff_lps[tx_size][plane][0][ctx] * 128;
int sum = p;
fc->coeff_br_cdf[tx_size][plane][ctx][0] = AOM_ICDF(sum);
p = 32768 - fc->coeff_lps[tx_size][plane][1][ctx] * 128;
sum += ((32768 - sum) * p) >> 15;
fc->coeff_br_cdf[tx_size][plane][ctx][1] = AOM_ICDF(sum);
p = 32768 - fc->coeff_lps[tx_size][plane][2][ctx] * 128;
sum += ((32768 - sum) * p) >> 15;
fc->coeff_br_cdf[tx_size][plane][ctx][2] = AOM_ICDF(sum);
fc->coeff_br_cdf[tx_size][plane][ctx][3] = AOM_ICDF(32768);
fc->coeff_br_cdf[tx_size][plane][ctx][4] = 0;
// printf("br_cdf: %d %d %2d : %3d %3d %3d\n", tx_size, plane, ctx,
// fc->coeff_br_cdf[tx_size][plane][ctx][0] >> 7,
// fc->coeff_br_cdf[tx_size][plane][ctx][1] >> 7,
// fc->coeff_br_cdf[tx_size][plane][ctx][2] >> 7);
#else
(void)ctx; // coeff_br_cdf is initialized in init_mode_probs
#endif
}
}
}
}
void av1_init_lv_map(AV1_COMMON *cm) {
LV_MAP_CTX_TABLE *coeff_ctx_table = &cm->coeff_ctx_table;
for (int row = 0; row < 2; ++row) {
......
......@@ -633,8 +633,6 @@ static INLINE void get_txb_ctx(const BLOCK_SIZE plane_bsize,
#undef MAX_TX_SIZE_UNIT
}
void av1_init_txb_probs(FRAME_CONTEXT *fc);
void av1_init_lv_map(AV1_COMMON *cm);
void av1_get_base_level_counts(const uint8_t *const levels,
......
......@@ -110,8 +110,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
counts, r, ec_ctx->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2,
ACCT_STR);
// printf("txb_skip: %d %2d\n", txs_ctx, txb_ctx->txb_skip_ctx);
if (xd->counts)
++xd->counts->txb_skip[txs_ctx][txb_ctx->txb_skip_ctx][all_zero];
*eob = 0;
if (all_zero) {
*max_scan_line = 0;
......@@ -225,7 +223,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
counts, 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 (counts) ++counts->eob_extra[txs_ctx][plane_type][eob_pt][bit];
if (bit) {
eob_extra += (1 << (k_eob_offset_bits[eob_pt] - 1));
}
......@@ -309,7 +306,6 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
const int dc_sign_ctx = txb_ctx->dc_sign_ctx;
*sign = av1_read_record_bin(
counts, r, ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], 2, ACCT_STR);
if (counts) ++counts->dc_sign[plane_type][dc_sign_ctx][*sign];
} else {
*sign = av1_read_record_bit(counts, r, ACCT_STR);
}
......@@ -337,11 +333,8 @@ uint8_t av1_read_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *const xd,
BR_CDF_SIZE, ACCT_STR);
*level += k;
if (counts) {
for (int lps = 0; lps < BR_CDF_SIZE - 1; lps++) {
++counts->coeff_lps[AOMMIN(txs_ctx, TX_32X32)][plane_type][lps][ctx]
[lps == k];
for (int lps = 0; lps < BR_CDF_SIZE - 1; lps++)
if (lps == k) break;
}
++counts->coeff_lps_multi[AOMMIN(txs_ctx, TX_32X32)][plane_type][ctx]
[k];
}
......
......@@ -228,7 +228,9 @@ void av1_update_eob_context(int eob, int seg_eob, TX_SIZE tx_size,
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;
#if CONFIG_ENTROPY_STATS
counts->eob_extra[txs_ctx][plane][eob_pt][bit]++;
#endif // CONFIG_ENTROPY_STATS
if (allow_update_cdf)
update_cdf(ec_ctx->eob_extra_cdf[txs_ctx][plane][eob_pt], bit, 2);
}
......@@ -2206,8 +2208,9 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
DECLARE_ALIGNED(16, int8_t, coeff_contexts[MAX_TX_SQUARE]);
memcpy(tcoeff, qcoeff, sizeof(*tcoeff) * seg_eob);
#if CONFIG_ENTROPY_STATS
++td->counts->txb_skip[txsize_ctx][txb_ctx.txb_skip_ctx][eob == 0];
#endif // CONFIG_ENTROPY_STATS
if (allow_update_cdf)
update_bin(ec_ctx->txb_skip_cdf[txsize_ctx][txb_ctx.txb_skip_ctx], eob == 0,
2);
......@@ -2267,8 +2270,9 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
const int sign = (tcoeff[0] < 0) ? 1 : 0;
if (tcoeff[0] != 0) {
int dc_sign_ctx = txb_ctx.dc_sign_ctx;
#if CONFIG_ENTROPY_STATS
++td->counts->dc_sign[plane_type][dc_sign_ctx][sign];
#endif // CONFIG_ENTROPY_STATS
if (allow_update_cdf)
update_bin(ec_ctx->dc_sign_cdf[plane_type][dc_sign_ctx], sign, 2);
x->mbmi_ext->dc_sign_ctx[plane][block] = dc_sign_ctx;
......@@ -2304,6 +2308,7 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
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];
......@@ -2311,6 +2316,7 @@ void av1_update_and_record_txb_context(int plane, int block, int blk_row,
++td->counts->coeff_lps[AOMMIN(txsize_ctx, TX_32X32)][plane_type][lps]
[ctx][lps == k];
#endif
#endif // CONFIG_ENTROPY_STATS
if (lps == k) break;
}
++td->counts->coeff_lps_multi[AOMMIN(txsize_ctx, TX_32X32)][plane_type]
......
......@@ -65,16 +65,6 @@ typedef struct TxbCache {
int br_ctx_arr[MAX_TX_SQUARE];
} TxbCache;
typedef struct TxbProbs {
const aom_prob *dc_sign_prob;
const aom_prob *nz_map;
aom_prob (*coeff_base)[COEFF_BASE_CONTEXTS];
const aom_prob *coeff_lps;
const aom_prob *eob_flag;
const aom_prob *txb_skip;
const aom_prob *coeff_br;
} TxbProbs;
void av1_alloc_txb_buf(AV1_COMP *cpi);
void av1_free_txb_buf(AV1_COMP *cpi);
int av1_cost_coeffs_txb(const AV1_COMMON *const cm, const MACROBLOCK *x,
......
......@@ -36,7 +36,6 @@ typedef struct {
// TODO(yaowu: use packed enum type if appropriate)
int8_t eob_val;
int8_t first_val;
const aom_prob *context_tree;
EXTRABIT extra;
uint8_t token;
} TOKENEXTRA;
......
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