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

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