Commit 0d22b52a authored by Nathan E. Egge's avatar Nathan E. Egge

Update switchable_interp_cdf once per frame.

Move from computing the switchable_interp_cdf per symbol to
 computing once per frame when the probabilities are adapted.

Change-Id: I6571126239f0327e22bb09ee8bad94114291683e
parent 42792f35
......@@ -396,8 +396,17 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif
av1_copy(fc->intra_ext_tx_prob, default_intra_ext_tx_prob);
av1_copy(fc->inter_ext_tx_prob, default_inter_ext_tx_prob);
#if CONFIG_DAALA_EC
av1_tree_to_cdf_1D(av1_switchable_interp_tree, fc->switchable_interp_prob,
fc->switchable_interp_cdf, SWITCHABLE_FILTER_CONTEXTS);
#endif
}
#if CONFIG_DAALA_EC
int av1_switchable_interp_ind[SWITCHABLE_FILTERS];
int av1_switchable_interp_inv[SWITCHABLE_FILTERS];
#endif
#if CONFIG_EXT_INTERP
const aom_tree_index av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)] =
{
......
......@@ -94,6 +94,10 @@ typedef struct frame_contexts {
aom_prob intra_ext_tx_prob[EXT_TX_SIZES][TX_TYPES][TX_TYPES - 1];
aom_prob inter_ext_tx_prob[EXT_TX_SIZES][TX_TYPES - 1];
int initialized;
#if CONFIG_DAALA_EC
uint16_t
switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS][SWITCHABLE_FILTERS];
#endif
} FRAME_CONTEXT;
typedef struct FRAME_COUNTS {
......@@ -153,6 +157,11 @@ extern const aom_tree_index av1_partition_tree[TREE_SIZE(PARTITION_TYPES)];
extern const aom_tree_index
av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)];
#if CONFIG_DAALA_EC
extern int av1_switchable_interp_ind[SWITCHABLE_FILTERS];
extern int av1_switchable_interp_inv[SWITCHABLE_FILTERS];
#endif
void av1_setup_past_independence(struct AV1Common *cm);
void av1_adapt_intra_frame_probs(struct AV1Common *cm);
......
......@@ -128,9 +128,14 @@ static void read_tx_mode_probs(struct tx_probs *tx_probs, aom_reader *r) {
static void read_switchable_interp_probs(FRAME_CONTEXT *fc, aom_reader *r) {
int i, j;
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) {
for (i = 0; i < SWITCHABLE_FILTERS - 1; ++i)
av1_diff_update_prob(r, &fc->switchable_interp_prob[j][i]);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_switchable_interp_tree, fc->switchable_interp_prob[j],
fc->switchable_interp_cdf[j]);
#endif
}
}
static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
......
......@@ -594,8 +594,14 @@ static INLINE InterpFilter read_switchable_interp_filter(AV1_COMMON *const cm,
#endif
{
const int ctx = av1_get_pred_context_switchable_interp(xd);
#if CONFIG_DAALA_EC
const InterpFilter type =
(InterpFilter)av1_switchable_interp_inv[aom_read_tree_cdf(
r, cm->fc->switchable_interp_cdf[ctx], SWITCHABLE_FILTERS)];
#else
const InterpFilter type = (InterpFilter)aom_read_tree(
r, av1_switchable_interp_tree, cm->fc->switchable_interp_prob[ctx]);
#endif
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->switchable_interp[ctx][type];
return type;
......
......@@ -43,6 +43,10 @@ static void initialize_dec(void) {
aom_scale_rtcd();
av1_init_intra_predictors();
init_done = 1;
#if CONFIG_DAALA_EC
av1_indices_from_tree(av1_switchable_interp_ind, av1_switchable_interp_inv,
SWITCHABLE_FILTERS, av1_switchable_interp_tree);
#endif
}
}
......
......@@ -65,6 +65,13 @@ void av1_encode_token_init() {
av1_tokens_from_tree(motion_mode_encodings, av1_motion_mode_tree);
#endif // CONFIG_MOTION_VAR
av1_tokens_from_tree(ext_tx_encodings, av1_ext_tx_tree);
#if CONFIG_DAALA_EC
/* This hack is necessary when CONFIG_EXT_INTERP is enabled because the five
SWITCHABLE_FILTERS are not consecutive, e.g., 0, 1, 2, 3, 4, when doing
an in-order traversal of the av1_switchable_interp_tree structure. */
av1_indices_from_tree(av1_switchable_interp_ind, av1_switchable_interp_inv,
SWITCHABLE_FILTERS, av1_switchable_interp_tree);
#endif
}
static void write_intra_mode(aom_writer *w, PREDICTION_MODE mode,
......@@ -249,10 +256,16 @@ static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
static void update_switchable_interp_probs(AV1_COMMON *cm, aom_writer *w,
FRAME_COUNTS *counts) {
int j;
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j)
for (j = 0; j < SWITCHABLE_FILTER_CONTEXTS; ++j) {
prob_diff_update(av1_switchable_interp_tree,
cm->fc->switchable_interp_prob[j],
counts->switchable_interp[j], SWITCHABLE_FILTERS, w);
#if CONFIG_DAALA_EC
av1_tree_to_cdf(av1_switchable_interp_tree,
cm->fc->switchable_interp_prob[j],
cm->fc->switchable_interp_cdf[j]);
#endif
}
}
static void update_ext_tx_probs(AV1_COMMON *cm, aom_writer *w) {
......@@ -518,9 +531,15 @@ static void write_switchable_interp_filter(AV1_COMP *const cpi,
if (is_interp_needed(xd)) {
#endif
const int ctx = av1_get_pred_context_switchable_interp(xd);
#if CONFIG_DAALA_EC
aom_write_tree_cdf(w, av1_switchable_interp_ind[mbmi->interp_filter],
cm->fc->switchable_interp_cdf[ctx],
SWITCHABLE_FILTERS);
#else
av1_write_token(w, av1_switchable_interp_tree,
cm->fc->switchable_interp_prob[ctx],
&switchable_interp_encodings[mbmi->interp_filter]);
#endif
++cpi->interp_filter_selected[0][mbmi->interp_filter];
#if CONFIG_EXT_INTERP
} else {
......
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