Commit 6ec4d10d authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

Update inter_mode_cdf tables once per frame.

Move computing the inter_mode_cdf tables per coded inter mode symbol to
 computing them only when the probabilities are updated.

Change-Id: I7a7b059ee75723cb6f278ed82a20cf34c27915d8
parent b808b43b
......@@ -373,6 +373,8 @@ static const aom_prob default_delta_q_probs[DELTA_Q_CONTEXTS] = { 220, 220,
#endif
int av1_intra_mode_ind[INTRA_MODES];
int av1_intra_mode_inv[INTRA_MODES];
int av1_inter_mode_ind[INTER_MODES];
int av1_inter_mode_inv[INTER_MODES];
/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
const aom_tree_index av1_intra_mode_tree[TREE_SIZE(INTRA_MODES)] = {
......@@ -1417,12 +1419,14 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
INTRA_MODES);
av1_tree_to_cdf_1D(av1_switchable_interp_tree, fc->switchable_interp_prob,
fc->switchable_interp_cdf, SWITCHABLE_FILTER_CONTEXTS);
av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf,
PARTITION_CONTEXTS);
av1_tree_to_cdf_1D(av1_inter_mode_tree, fc->inter_mode_probs,
fc->inter_mode_cdf, INTER_MODE_CONTEXTS);
av1_tree_to_cdf_2D(av1_ext_tx_tree, fc->intra_ext_tx_prob,
fc->intra_ext_tx_cdf, EXT_TX_SIZES, TX_TYPES);
av1_tree_to_cdf_1D(av1_ext_tx_tree, fc->inter_ext_tx_prob,
fc->inter_ext_tx_cdf, EXT_TX_SIZES);
av1_tree_to_cdf_1D(av1_partition_tree, fc->partition_prob, fc->partition_cdf,
PARTITION_CONTEXTS);
av1_tree_to_cdf_2D(av1_intra_mode_tree, av1_kf_y_mode_prob, av1_kf_y_mode_cdf,
INTRA_MODES, INTRA_MODES);
av1_tree_to_cdf(av1_segment_tree, fc->seg.tree_probs, fc->seg.tree_cdf);
......
......@@ -170,6 +170,7 @@ typedef struct frame_contexts {
aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
aom_cdf_prob switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
aom_cdf_prob inter_mode_cdf[INTER_MODE_CONTEXTS][INTER_MODES];
aom_cdf_prob intra_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES][TX_TYPES];
aom_cdf_prob inter_ext_tx_cdf[EXT_TX_SIZES][TX_TYPES];
#endif
......@@ -302,6 +303,8 @@ extern const aom_tree_index av1_inter_mode_tree[TREE_SIZE(INTER_MODES)];
#if CONFIG_DAALA_EC
extern int av1_intra_mode_ind[INTRA_MODES];
extern int av1_intra_mode_inv[INTRA_MODES];
extern int av1_inter_mode_ind[INTER_MODES];
extern int av1_inter_mode_inv[INTER_MODES];
#endif
#if CONFIG_EXT_INTER
extern const aom_tree_index
......
......@@ -134,9 +134,14 @@ static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
#endif // CONFIG_EXT_INTER
#else
int j;
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
for (j = 0; j < INTER_MODES - 1; ++j)
av1_diff_update_prob(r, &fc->inter_mode_probs[i][j], ACCT_STR);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_inter_mode_tree, fc->inter_mode_probs[i],
fc->inter_mode_cdf[i]);
#endif
}
#endif
}
......
......@@ -189,9 +189,14 @@ static PREDICTION_MODE read_inter_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
// Invalid prediction mode.
assert(0);
#else
#if CONFIG_DAALA_EC
const int mode = av1_inter_mode_inv[aom_read_symbol(
r, cm->fc->inter_mode_cdf[ctx], INTER_MODES, ACCT_STR)];
#else
const int mode = aom_read_tree(r, av1_inter_mode_tree,
cm->fc->inter_mode_probs[ctx], ACCT_STR);
#endif
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->inter_mode[ctx][mode];
......
......@@ -54,6 +54,8 @@ static void initialize_dec(void) {
av1_ext_tx_tree);
av1_indices_from_tree(av1_intra_mode_ind, av1_intra_mode_inv, INTRA_MODES,
av1_intra_mode_tree);
av1_indices_from_tree(av1_inter_mode_ind, av1_inter_mode_inv, INTER_MODES,
av1_inter_mode_tree);
#endif
}
}
......
......@@ -194,6 +194,8 @@ void av1_encode_token_init(void) {
av1_ext_tx_tree);
av1_indices_from_tree(av1_intra_mode_ind, av1_intra_mode_inv, INTRA_MODES,
av1_intra_mode_tree);
av1_indices_from_tree(av1_inter_mode_ind, av1_inter_mode_inv, INTER_MODES,
av1_inter_mode_tree);
#endif
}
......@@ -256,10 +258,17 @@ static void write_inter_mode(AV1_COMMON *cm, aom_writer *w,
}
}
#else
const aom_prob *const inter_probs = cm->fc->inter_mode_probs[mode_ctx];
assert(is_inter_mode(mode));
av1_write_token(w, av1_inter_mode_tree, inter_probs,
&inter_mode_encodings[INTER_OFFSET(mode)]);
#if CONFIG_DAALA_EC
aom_write_symbol(w, av1_inter_mode_ind[INTER_OFFSET(mode)],
cm->fc->inter_mode_cdf[mode_ctx], INTER_MODES);
#else
{
const aom_prob *const inter_probs = cm->fc->inter_mode_probs[mode_ctx];
av1_write_token(w, av1_inter_mode_tree, inter_probs,
&inter_mode_encodings[INTER_OFFSET(mode)]);
}
#endif
#endif
}
......@@ -3677,9 +3686,14 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
#if CONFIG_REF_MV
update_inter_mode_probs(cm, header_bc, counts);
#else
for (i = 0; i < INTER_MODE_CONTEXTS; ++i)
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
prob_diff_update(av1_inter_mode_tree, cm->fc->inter_mode_probs[i],
counts->inter_mode[i], INTER_MODES, header_bc);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_inter_mode_tree, cm->fc->inter_mode_probs[i],
cm->fc->inter_mode_cdf[i]);
#endif
}
#endif
#if CONFIG_EXT_INTER
......
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