Commit 8c08a33a authored by Thomas Davies's avatar Thomas Davies

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
parent 47558170
...@@ -5710,7 +5710,7 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc, ...@@ -5710,7 +5710,7 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
// FIXME: cdfs not defined for super_tx // FIXME: cdfs not defined for super_tx
// FIXME: CONFIG_EXT_INTER cdfs not defined for inter_compound_mode, AVERAGE_TILE_CDFS(inter_compound_mode_cdf)
// interintra_mode etc // interintra_mode etc
AVERAGE_TILE_CDFS(y_mode_cdf) AVERAGE_TILE_CDFS(y_mode_cdf)
......
...@@ -1045,6 +1045,27 @@ static const aom_prob default_inter_compound_mode_probs ...@@ -1045,6 +1045,27 @@ static const aom_prob default_inter_compound_mode_probs
{ 25, 29, 50, 192, 128, 180, 180 }, // 6 = two intra neighbours { 25, 29, 50, 192, 128, 180, 180 }, // 6 = two intra neighbours
}; };
#if CONFIG_EC_ADAPT
static const aom_cdf_prob
default_inter_compound_mode_cdf[INTER_MODE_CONTEXTS][CDF_SIZE(
INTER_COMPOUND_MODES)] = {
{ AOM_ICDF(21971), AOM_ICDF(24071), AOM_ICDF(24317), AOM_ICDF(24421),
AOM_ICDF(24667), AOM_ICDF(24771), AOM_ICDF(25027), AOM_ICDF(32768), 0 },
{ AOM_ICDF(18052), AOM_ICDF(24530), AOM_ICDF(25289), AOM_ICDF(25610),
AOM_ICDF(26369), AOM_ICDF(26690), AOM_ICDF(27586), AOM_ICDF(32768), 0 },
{ AOM_ICDF(20666), AOM_ICDF(24802), AOM_ICDF(25287), AOM_ICDF(25492),
AOM_ICDF(25977), AOM_ICDF(26182), AOM_ICDF(27078), AOM_ICDF(32768), 0 },
{ AOM_ICDF(11703), AOM_ICDF(19503), AOM_ICDF(20417), AOM_ICDF(20803),
AOM_ICDF(21717), AOM_ICDF(22103), AOM_ICDF(22999), AOM_ICDF(32768), 0 },
{ AOM_ICDF(7936), AOM_ICDF(12400), AOM_ICDF(12923), AOM_ICDF(13144),
AOM_ICDF(13667), AOM_ICDF(13888), AOM_ICDF(14912), AOM_ICDF(32768), 0 },
{ AOM_ICDF(9679), AOM_ICDF(12865), AOM_ICDF(13238), AOM_ICDF(13396),
AOM_ICDF(13769), AOM_ICDF(13927), AOM_ICDF(16103), AOM_ICDF(32768), 0 },
{ AOM_ICDF(3349), AOM_ICDF(7190), AOM_ICDF(7640), AOM_ICDF(7830),
AOM_ICDF(8280), AOM_ICDF(8470), AOM_ICDF(11670), AOM_ICDF(32768), 0 }
};
#endif
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
// TODO(zoeliu): Default values to be further adjusted based on the collected // TODO(zoeliu): Default values to be further adjusted based on the collected
// stats. // stats.
...@@ -4747,6 +4768,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) { ...@@ -4747,6 +4768,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION #endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
av1_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs); av1_copy(fc->inter_compound_mode_probs, default_inter_compound_mode_probs);
#if CONFIG_EC_ADAPT
av1_copy(fc->inter_compound_mode_cdf, default_inter_compound_mode_cdf);
#endif
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
av1_copy(fc->inter_singleref_comp_mode_probs, av1_copy(fc->inter_singleref_comp_mode_probs,
default_inter_singleref_comp_mode_probs); default_inter_singleref_comp_mode_probs);
......
...@@ -195,6 +195,10 @@ typedef struct frame_contexts { ...@@ -195,6 +195,10 @@ typedef struct frame_contexts {
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
aom_prob inter_compound_mode_probs[INTER_MODE_CONTEXTS] aom_prob inter_compound_mode_probs[INTER_MODE_CONTEXTS]
[INTER_COMPOUND_MODES - 1]; [INTER_COMPOUND_MODES - 1];
#if CONFIG_EC_ADAPT
aom_cdf_prob inter_compound_mode_cdf[INTER_MODE_CONTEXTS]
[CDF_SIZE(INTER_COMPOUND_MODES)];
#endif
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
aom_prob inter_singleref_comp_mode_probs[INTER_MODE_CONTEXTS] aom_prob inter_singleref_comp_mode_probs[INTER_MODE_CONTEXTS]
[INTER_SINGLEREF_COMP_MODES - 1]; [INTER_SINGLEREF_COMP_MODES - 1];
......
...@@ -193,6 +193,7 @@ static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) { ...@@ -193,6 +193,7 @@ static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
#endif #endif
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
#if !CONFIG_EC_ADAPT
static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) { static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
int i, j; int i, j;
if (aom_read(r, GROUP_DIFF_UPDATE_PROB, ACCT_STR)) { if (aom_read(r, GROUP_DIFF_UPDATE_PROB, ACCT_STR)) {
...@@ -203,6 +204,7 @@ static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) { ...@@ -203,6 +204,7 @@ static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
} }
} }
} }
#endif // CONFIG_EC_ADAPT
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
static void read_inter_singleref_comp_mode_probs(FRAME_CONTEXT *fc, static void read_inter_singleref_comp_mode_probs(FRAME_CONTEXT *fc,
...@@ -5100,7 +5102,9 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data, ...@@ -5100,7 +5102,9 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
#endif #endif
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
#if !CONFIG_EC_ADAPT
read_inter_compound_mode_probs(fc, &r); read_inter_compound_mode_probs(fc, &r);
#endif
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
read_inter_singleref_comp_mode_probs(fc, &r); read_inter_singleref_comp_mode_probs(fc, &r);
#endif // CONFIG_COMPOUND_SINGLEREF #endif // CONFIG_COMPOUND_SINGLEREF
......
...@@ -380,9 +380,16 @@ static void read_ncobmc_mode(AV1_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *mi, ...@@ -380,9 +380,16 @@ static void read_ncobmc_mode(AV1_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *mi,
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd, static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r, int16_t ctx) { aom_reader *r, int16_t ctx) {
#if CONFIG_EC_ADAPT
(void)cm;
const int mode =
aom_read_symbol(r, xd->tile_ctx->inter_compound_mode_cdf[ctx],
INTER_COMPOUND_MODES, ACCT_STR);
#else
const int mode = const int mode =
aom_read_tree(r, av1_inter_compound_mode_tree, aom_read_tree(r, av1_inter_compound_mode_tree,
cm->fc->inter_compound_mode_probs[ctx], ACCT_STR); cm->fc->inter_compound_mode_probs[ctx], ACCT_STR);
#endif
FRAME_COUNTS *counts = xd->counts; FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->inter_compound_mode[ctx][mode]; if (counts) ++counts->inter_compound_mode[ctx][mode];
......
...@@ -64,11 +64,13 @@ ...@@ -64,11 +64,13 @@
#define ENC_MISMATCH_DEBUG 0 #define ENC_MISMATCH_DEBUG 0
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
#if !CONFIG_EC_ADAPT
static const struct av1_token static const struct av1_token
inter_compound_mode_encodings[INTER_COMPOUND_MODES] = { inter_compound_mode_encodings[INTER_COMPOUND_MODES] = {
{ 2, 2 }, { 12, 4 }, { 52, 6 }, { 53, 6 }, { 2, 2 }, { 12, 4 }, { 52, 6 }, { 53, 6 },
{ 54, 6 }, { 55, 6 }, { 0, 1 }, { 7, 3 } { 54, 6 }, { 55, 6 }, { 0, 1 }, { 7, 3 }
}; };
#endif
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
static struct av1_token static struct av1_token
inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_MODES]; inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_MODES];
...@@ -318,15 +320,23 @@ static void write_drl_idx(FRAME_CONTEXT *ec_ctx, const MB_MODE_INFO *mbmi, ...@@ -318,15 +320,23 @@ static void write_drl_idx(FRAME_CONTEXT *ec_ctx, const MB_MODE_INFO *mbmi,
} }
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
static void write_inter_compound_mode(AV1_COMMON *cm, aom_writer *w, static void write_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
PREDICTION_MODE mode, aom_writer *w, PREDICTION_MODE mode,
const int16_t mode_ctx) { 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 = const aom_prob *const inter_compound_probs =
cm->fc->inter_compound_mode_probs[mode_ctx]; 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, av1_write_token(w, av1_inter_compound_mode_tree, inter_compound_probs,
&inter_compound_mode_encodings[INTER_COMPOUND_OFFSET(mode)]); &inter_compound_mode_encodings[INTER_COMPOUND_OFFSET(mode)]);
#endif
} }
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
...@@ -367,7 +377,7 @@ static void prob_diff_update(const aom_tree_index *tree, ...@@ -367,7 +377,7 @@ static void prob_diff_update(const aom_tree_index *tree,
} }
#endif #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, static int prob_diff_update_savings(const aom_tree_index *tree,
aom_prob probs[/*n - 1*/], aom_prob probs[/*n - 1*/],
const unsigned int counts[/*n - 1*/], int n, const unsigned int counts[/*n - 1*/], int n,
...@@ -385,7 +395,7 @@ static int prob_diff_update_savings(const aom_tree_index *tree, ...@@ -385,7 +395,7 @@ static int prob_diff_update_savings(const aom_tree_index *tree,
} }
return savings; return savings;
} }
#endif // CONFIG_EXT_INTER || !CONFIG_EC_ADAPT #endif // !CONFIG_EC_ADAPT || CONFIG_COMPOUND_SINGLEREF
#if CONFIG_VAR_TX #if CONFIG_VAR_TX
static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd, static void write_tx_size_vartx(const AV1_COMMON *cm, const MACROBLOCKD *xd,
...@@ -507,6 +517,7 @@ static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w, ...@@ -507,6 +517,7 @@ static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
#endif #endif
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
#if !CONFIG_EC_ADAPT
static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt, static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt,
aom_writer *w) { aom_writer *w) {
const int savings_thresh = av1_cost_one(GROUP_DIFF_UPDATE_PROB) - const int savings_thresh = av1_cost_one(GROUP_DIFF_UPDATE_PROB) -
...@@ -529,6 +540,7 @@ static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt, ...@@ -529,6 +540,7 @@ static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt,
} }
} }
} }
#endif
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
static void update_inter_singleref_comp_mode_probs(AV1_COMMON *cm, int probwt, static void update_inter_singleref_comp_mode_probs(AV1_COMMON *cm, int probwt,
...@@ -2065,7 +2077,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row, ...@@ -2065,7 +2077,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
if (bsize >= BLOCK_8X8 || unify_bsize) { if (bsize >= BLOCK_8X8 || unify_bsize) {
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
if (is_inter_compound_mode(mode)) 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 #if CONFIG_COMPOUND_SINGLEREF
else if (is_inter_singleref_comp_mode(mode)) else if (is_inter_singleref_comp_mode(mode))
write_inter_singleref_comp_mode(cm, w, mode, mode_ctx); write_inter_singleref_comp_mode(cm, w, mode, mode_ctx);
...@@ -2112,7 +2124,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row, ...@@ -2112,7 +2124,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
mbmi->ref_frame, bsize, j); mbmi->ref_frame, bsize, j);
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
if (is_inter_compound_mode(b_mode)) 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)) else if (is_inter_singleref_mode(b_mode))
#endif // CONFIG_EXT_INTER #endif // CONFIG_EXT_INTER
write_inter_mode(w, b_mode, ec_ctx, mode_ctx); write_inter_mode(w, b_mode, ec_ctx, mode_ctx);
...@@ -5086,7 +5098,9 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) { ...@@ -5086,7 +5098,9 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
update_inter_mode_probs(cm, header_bc, counts); update_inter_mode_probs(cm, header_bc, counts);
#endif #endif
#if CONFIG_EXT_INTER #if CONFIG_EXT_INTER
#if !CONFIG_EC_ADAPT
update_inter_compound_mode_probs(cm, probwt, header_bc); update_inter_compound_mode_probs(cm, probwt, header_bc);
#endif
#if CONFIG_COMPOUND_SINGLEREF #if CONFIG_COMPOUND_SINGLEREF
update_inter_singleref_comp_mode_probs(cm, probwt, header_bc); update_inter_singleref_comp_mode_probs(cm, probwt, header_bc);
#endif // CONFIG_COMPOUND_SINGLEREF #endif // CONFIG_COMPOUND_SINGLEREF
......
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