#if CONFIG_LOOP_RESTORATION
av1_copy(fc->switchable_restore_prob, default_switchable_restore_prob);
#endif // CONFIG_LOOP_RESTORATION
+#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)] =
{
#if CONFIG_LOOP_RESTORATION
aom_prob switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1];
#endif // CONFIG_LOOP_RESTORATION
+#if CONFIG_DAALA_EC
+ uint16_t switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
+ [SWITCHABLE_FILTERS];
+#endif
} FRAME_CONTEXT;
typedef struct FRAME_COUNTS {
extern const aom_tree_index
av1_switchable_restore_tree[TREE_SIZE(RESTORE_SWITCHABLE_TYPES)];
#endif // CONFIG_LOOP_RESTORATION
+#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);
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) {
const int ctx = av1_get_pred_context_switchable_interp(xd);
#endif
FRAME_COUNTS *counts = xd->counts;
+#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
if (counts) ++counts->switchable_interp[ctx][type];
return type;
}
av1_init_wedge_masks();
#endif // CONFIG_EXT_INTER
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
}
}
av1_tokens_from_tree(switchable_restore_encodings,
av1_switchable_restore_tree);
#endif // CONFIG_LOOP_RESTORATION
+
+#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,
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
+ }
}
#if CONFIG_EXT_TX
#else
{
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];
}
#endif