OSUOSL/Nero are experiencing Internet connectivity problems. This affects us as we're hosted with OSUOSL. We apologize for the inconvenience.

Commit 4947c296 authored by Nathan E. Egge's avatar Nathan E. Egge Committed by Yaowu Xu

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 5cb0a7ab
......@@ -1380,8 +1380,17 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#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)] =
{
......
......@@ -131,6 +131,10 @@ typedef struct frame_contexts {
#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 {
......@@ -278,6 +282,10 @@ extern const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)];
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);
......
......@@ -107,9 +107,14 @@ static TX_MODE read_tx_mode(struct aom_read_bit_buffer *rb) {
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) {
......
......@@ -867,8 +867,14 @@ static INLINE InterpFilter read_interp_filter(AV1_COMMON *const cm,
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;
}
......
......@@ -47,6 +47,10 @@ static void initialize_dec(void) {
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
}
}
......
......@@ -189,6 +189,14 @@ void av1_encode_token_init(void) {
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,
......@@ -486,10 +494,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
}
}
#if CONFIG_EXT_TX
......@@ -963,9 +977,15 @@ static void write_switchable_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
#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
......
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