Update y_mode_cdf tables once per frame.
Move computing the y_mode_cdf tables per coded intra mode symbol to
computing them only when the probabilities are updated.
Change-Id: I8c43d09b8ef5febe2a3ec64bd51d28bd78ea73ed
diff --git a/av1/common/entropymode.c b/av1/common/entropymode.c
index 3a6b3c3..d16f4f7 100644
--- a/av1/common/entropymode.c
+++ b/av1/common/entropymode.c
@@ -1411,6 +1411,8 @@
av1_copy(fc->switchable_restore_prob, default_switchable_restore_prob);
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_DAALA_EC
+ av1_tree_to_cdf_1D(av1_intra_mode_tree, fc->y_mode_prob, fc->y_mode_cdf,
+ BLOCK_SIZE_GROUPS);
av1_tree_to_cdf_1D(av1_switchable_interp_tree, fc->switchable_interp_prob,
fc->switchable_interp_cdf, SWITCHABLE_FILTER_CONTEXTS);
av1_tree_to_cdf_2D(av1_ext_tx_tree, fc->intra_ext_tx_prob,
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index f889c56..11bf124 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -165,6 +165,7 @@
aom_prob switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1];
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_DAALA_EC
+ aom_cdf_prob y_mode_cdf[BLOCK_SIZE_GROUPS][INTRA_MODES];
aom_cdf_prob partition_cdf[PARTITION_CONTEXTS][PARTITION_TYPES];
aom_cdf_prob switchable_interp_cdf[SWITCHABLE_FILTER_CONTEXTS]
[SWITCHABLE_FILTERS];
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index b579934..060c79c 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -3817,9 +3817,14 @@
read_frame_reference_mode_probs(cm, &r);
- for (j = 0; j < BLOCK_SIZE_GROUPS; j++)
+ for (j = 0; j < BLOCK_SIZE_GROUPS; j++) {
for (i = 0; i < INTRA_MODES - 1; ++i)
av1_diff_update_prob(&r, &fc->y_mode_prob[j][i], ACCT_STR);
+#if CONFIG_DAALA_EC
+ av1_tree_to_cdf(av1_intra_mode_tree, fc->y_mode_prob[j],
+ fc->y_mode_cdf[j]);
+#endif
+ }
#if CONFIG_REF_MV
for (i = 0; i < NMV_CONTEXTS; ++i)
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 68eb482..9d8bb5c 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -91,7 +91,11 @@
static PREDICTION_MODE read_intra_mode_y(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r, int size_group) {
const PREDICTION_MODE y_mode =
+#if CONFIG_DAALA_EC
+ read_intra_mode_cdf(r, cm->fc->y_mode_cdf[size_group]);
+#else
read_intra_mode(r, cm->fc->y_mode_prob[size_group]);
+#endif
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->y_mode[size_group][y_mode];
return y_mode;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 70f7e7b..e8b5d50 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -1235,7 +1235,13 @@
if (!is_inter) {
if (bsize >= BLOCK_8X8) {
+#if CONFIG_DAALA_EC
+ aom_write_symbol(w, av1_intra_mode_ind[mode],
+ cm->fc->y_mode_cdf[size_group_lookup[bsize]],
+ INTRA_MODES);
+#else
write_intra_mode(w, mode, cm->fc->y_mode_prob[size_group_lookup[bsize]]);
+#endif
} else {
int idx, idy;
const int num_4x4_w = num_4x4_blocks_wide_lookup[bsize];
@@ -1243,7 +1249,12 @@
for (idy = 0; idy < 2; idy += num_4x4_h) {
for (idx = 0; idx < 2; idx += num_4x4_w) {
const PREDICTION_MODE b_mode = mi->bmi[idy * 2 + idx].as_mode;
+#if CONFIG_DAALA_EC
+ aom_write_symbol(w, av1_intra_mode_ind[b_mode], cm->fc->y_mode_cdf[0],
+ INTRA_MODES);
+#else
write_intra_mode(w, b_mode, cm->fc->y_mode_prob[0]);
+#endif
}
}
}
@@ -3734,9 +3745,14 @@
}
}
- for (i = 0; i < BLOCK_SIZE_GROUPS; ++i)
+ for (i = 0; i < BLOCK_SIZE_GROUPS; ++i) {
prob_diff_update(av1_intra_mode_tree, cm->fc->y_mode_prob[i],
counts->y_mode[i], INTRA_MODES, header_bc);
+#if CONFIG_DAALA_EC
+ av1_tree_to_cdf(av1_intra_mode_tree, cm->fc->y_mode_prob[i],
+ cm->fc->y_mode_cdf[i]);
+#endif
+ }
av1_write_nmv_probs(cm, cm->allow_high_precision_mv, header_bc,
#if CONFIG_REF_MV