EXT_INTER: CDF coding for inter_compound_mode.
Replace deprecated tree coding when EC_ADAPT is on.
AWCY: -0.01% all metrics.
Change-Id: I021dbc1e5f2a64fec66da1a427a0bf930cfed292
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 386c8b3..4797a9d 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -64,11 +64,13 @@
#define ENC_MISMATCH_DEBUG 0
#if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
static const struct av1_token
inter_compound_mode_encodings[INTER_COMPOUND_MODES] = {
{ 2, 2 }, { 12, 4 }, { 52, 6 }, { 53, 6 },
{ 54, 6 }, { 55, 6 }, { 0, 1 }, { 7, 3 }
};
+#endif
#if CONFIG_COMPOUND_SINGLEREF
static struct av1_token
inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_MODES];
@@ -318,15 +320,23 @@
}
#if CONFIG_EXT_INTER
-static void write_inter_compound_mode(AV1_COMMON *cm, aom_writer *w,
- PREDICTION_MODE mode,
+static void write_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
+ aom_writer *w, PREDICTION_MODE mode,
const int16_t mode_ctx) {
+ assert(is_inter_compound_mode(mode));
+#if CONFIG_EC_ADAPT
+ (void)cm;
+ aom_write_symbol(w, INTER_COMPOUND_OFFSET(mode),
+ xd->tile_ctx->inter_compound_mode_cdf[mode_ctx],
+ INTER_COMPOUND_MODES);
+#else
+ (void)xd;
const aom_prob *const inter_compound_probs =
cm->fc->inter_compound_mode_probs[mode_ctx];
- assert(is_inter_compound_mode(mode));
av1_write_token(w, av1_inter_compound_mode_tree, inter_compound_probs,
&inter_compound_mode_encodings[INTER_COMPOUND_OFFSET(mode)]);
+#endif
}
#if CONFIG_COMPOUND_SINGLEREF
@@ -367,7 +377,7 @@
}
#endif
-#if CONFIG_EXT_INTER || !CONFIG_EC_ADAPT
+#if !CONFIG_EC_ADAPT || CONFIG_COMPOUND_SINGLEREF
static int prob_diff_update_savings(const aom_tree_index *tree,
aom_prob probs[/*n - 1*/],
const unsigned int counts[/*n - 1*/], int n,
@@ -385,7 +395,7 @@
}
return savings;
}
-#endif // CONFIG_EXT_INTER || !CONFIG_EC_ADAPT
+#endif // !CONFIG_EC_ADAPT || CONFIG_COMPOUND_SINGLEREF
#if CONFIG_VAR_TX
static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
@@ -507,6 +517,7 @@
#endif
#if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt,
aom_writer *w) {
const int savings_thresh = av1_cost_one(GROUP_DIFF_UPDATE_PROB) -
@@ -529,6 +540,7 @@
}
}
}
+#endif
#if CONFIG_COMPOUND_SINGLEREF
static void update_inter_singleref_comp_mode_probs(AV1_COMMON *cm, int probwt,
@@ -2065,7 +2077,7 @@
if (bsize >= BLOCK_8X8 || unify_bsize) {
#if CONFIG_EXT_INTER
if (is_inter_compound_mode(mode))
- write_inter_compound_mode(cm, w, mode, mode_ctx);
+ write_inter_compound_mode(cm, xd, w, mode, mode_ctx);
#if CONFIG_COMPOUND_SINGLEREF
else if (is_inter_singleref_comp_mode(mode))
write_inter_singleref_comp_mode(cm, w, mode, mode_ctx);
@@ -2112,7 +2124,7 @@
mbmi->ref_frame, bsize, j);
#if CONFIG_EXT_INTER
if (is_inter_compound_mode(b_mode))
- write_inter_compound_mode(cm, w, b_mode, mode_ctx);
+ write_inter_compound_mode(cm, xd, w, b_mode, mode_ctx);
else if (is_inter_singleref_mode(b_mode))
#endif // CONFIG_EXT_INTER
write_inter_mode(w, b_mode, ec_ctx, mode_ctx);
@@ -5086,7 +5098,9 @@
update_inter_mode_probs(cm, header_bc, counts);
#endif
#if CONFIG_EXT_INTER
+#if !CONFIG_EC_ADAPT
update_inter_compound_mode_probs(cm, probwt, header_bc);
+#endif
#if CONFIG_COMPOUND_SINGLEREF
update_inter_singleref_comp_mode_probs(cm, probwt, header_bc);
#endif // CONFIG_COMPOUND_SINGLEREF