Commit b8b14a9b authored by Thomas Davies's avatar Thomas Davies

COMPOUND_SINGLEREF: replace deprecated tree coding.

Use multi-symbol CDF coding instead.

Change-Id: I8a69364c8672474021d2ea5933e344d493186967
parent aff92d58
......@@ -5714,6 +5714,9 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
AVERAGE_TILE_CDFS(inter_compound_mode_cdf)
AVERAGE_TILE_CDFS(compound_type_cdf)
#if CONFIG_COMPOUND_SINGLEREF
AVERAGE_TILE_CDFS(inter_singleref_comp_mode_cdf)
#endif
#if CONFIG_INTERINTRA
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -490,6 +490,18 @@ static const aom_prob default_inter_singleref_comp_mode_probs
{ 17, 81, 52 }, // 5 = one intra neighbour
{ 25, 29, 50 }, // 6 = two intra neighbours
};
static const aom_cdf_prob
default_inter_singleref_comp_mode_cdf[INTER_MODE_CONTEXTS][CDF_SIZE(
INTER_SINGLEREF_COMP_MODES)] = {
{ AOM_ICDF(21971), AOM_ICDF(24771), AOM_ICDF(25027), AOM_ICDF(32768), 0 },
{ AOM_ICDF(18053), AOM_ICDF(26690), AOM_ICDF(27586), AOM_ICDF(32768), 0 },
{ AOM_ICDF(20667), AOM_ICDF(26182), AOM_ICDF(27078), AOM_ICDF(32768), 0 },
{ AOM_ICDF(11703), AOM_ICDF(22103), AOM_ICDF(22999), AOM_ICDF(32768), 0 },
{ AOM_ICDF(7936), AOM_ICDF(13888), AOM_ICDF(14912), AOM_ICDF(32768), 0 },
{ AOM_ICDF(9679), AOM_ICDF(13927), AOM_ICDF(16103), AOM_ICDF(32768), 0 },
{ AOM_ICDF(3349), AOM_ICDF(8470), AOM_ICDF(11670), AOM_ICDF(32768), 0 }
};
#endif // CONFIG_COMPOUND_SINGLEREF
#if CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
......@@ -4827,6 +4839,8 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if CONFIG_COMPOUND_SINGLEREF
av1_copy(fc->inter_singleref_comp_mode_probs,
default_inter_singleref_comp_mode_probs);
av1_copy(fc->inter_singleref_comp_mode_cdf,
default_inter_singleref_comp_mode_cdf);
#endif // CONFIG_COMPOUND_SINGLEREF
av1_copy(fc->compound_type_prob, default_compound_type_probs);
av1_copy(fc->compound_type_cdf, default_compound_type_cdf);
......
......@@ -200,6 +200,8 @@ typedef struct frame_contexts {
#if CONFIG_COMPOUND_SINGLEREF
aom_prob inter_singleref_comp_mode_probs[INTER_MODE_CONTEXTS]
[INTER_SINGLEREF_COMP_MODES - 1];
aom_cdf_prob inter_singleref_comp_mode_cdf[INTER_MODE_CONTEXTS][CDF_SIZE(
INTER_SINGLEREF_COMP_MODES)];
#endif // CONFIG_COMPOUND_SINGLEREF
aom_prob compound_type_prob[BLOCK_SIZES_ALL][COMPOUND_TYPES - 1];
aom_cdf_prob compound_type_cdf[BLOCK_SIZES_ALL][CDF_SIZE(COMPOUND_TYPES)];
......
......@@ -177,21 +177,6 @@ static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
}
#endif
#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
static void read_inter_singleref_comp_mode_probs(FRAME_CONTEXT *fc,
aom_reader *r) {
int i, j;
if (aom_read(r, GROUP_DIFF_UPDATE_PROB, ACCT_STR)) {
for (j = 0; j < INTER_MODE_CONTEXTS; ++j) {
for (i = 0; i < INTER_SINGLEREF_COMP_MODES - 1; ++i) {
av1_diff_update_prob(r, &fc->inter_singleref_comp_mode_probs[j][i],
ACCT_STR);
}
}
}
}
#endif // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
static REFERENCE_MODE read_frame_reference_mode(
const AV1_COMMON *cm, struct aom_read_bit_buffer *rb) {
if (is_compound_reference_allowed(cm)) {
......@@ -4932,10 +4917,6 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
#endif
#if CONFIG_EXT_INTER
#if CONFIG_COMPOUND_SINGLEREF
read_inter_singleref_comp_mode_probs(fc, &r);
#endif // CONFIG_COMPOUND_SINGLEREF
#if CONFIG_INTERINTRA
if (cm->reference_mode != COMPOUND_REFERENCE &&
cm->allow_interintra_compound) {
......
......@@ -404,13 +404,12 @@ static PREDICTION_MODE read_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
}
#if CONFIG_COMPOUND_SINGLEREF
static PREDICTION_MODE read_inter_singleref_comp_mode(AV1_COMMON *cm,
MACROBLOCKD *xd,
static PREDICTION_MODE read_inter_singleref_comp_mode(MACROBLOCKD *xd,
aom_reader *r,
int16_t ctx) {
const int mode =
aom_read_tree(r, av1_inter_singleref_comp_mode_tree,
cm->fc->inter_singleref_comp_mode_probs[ctx], ACCT_STR);
aom_read_symbol(r, xd->tile_ctx->inter_singleref_comp_mode_cdf[ctx],
INTER_SINGLEREF_COMP_MODES, ACCT_STR);
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->inter_singleref_comp_mode[ctx][mode];
......@@ -2284,7 +2283,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
mbmi->mode = read_inter_compound_mode(cm, xd, r, mode_ctx);
#if CONFIG_COMPOUND_SINGLEREF
else if (is_singleref_comp_mode)
mbmi->mode = read_inter_singleref_comp_mode(cm, xd, r, mode_ctx);
mbmi->mode = read_inter_singleref_comp_mode(xd, r, mode_ctx);
#endif // CONFIG_COMPOUND_SINGLEREF
else
#endif // CONFIG_EXT_INTER
......
......@@ -308,16 +308,15 @@ static void write_inter_compound_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
}
#if CONFIG_COMPOUND_SINGLEREF
static void write_inter_singleref_comp_mode(AV1_COMMON *cm, aom_writer *w,
static void write_inter_singleref_comp_mode(MACROBLOCKD *xd, aom_writer *w,
PREDICTION_MODE mode,
const int16_t mode_ctx) {
assert(is_inter_singleref_comp_mode(mode));
const aom_prob *const inter_singleref_comp_probs =
cm->fc->inter_singleref_comp_mode_probs[mode_ctx];
aom_cdf_prob *const inter_singleref_comp_cdf =
xd->tile_ctx->inter_singleref_comp_mode_cdf[mode_ctx];
av1_write_token(
w, av1_inter_singleref_comp_mode_tree, inter_singleref_comp_probs,
&inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_OFFSET(mode)]);
aom_write_symbol(w, INTER_SINGLEREF_COMP_OFFSET(mode),
inter_singleref_comp_cdf, INTER_SINGLEREF_COMP_MODES);
}
#endif // CONFIG_COMPOUND_SINGLEREF
#endif // CONFIG_EXT_INTER
......@@ -327,7 +326,7 @@ static void encode_unsigned_max(struct aom_write_bit_buffer *wb, int data,
aom_wb_write_literal(wb, data, get_unsigned_bits(max));
}
#if CONFIG_NCOBMC_ADAPT_WEIGHT || CONFIG_COMPOUND_SINGLEREF
#if CONFIG_NCOBMC_ADAPT_WEIGHT
static void prob_diff_update(const aom_tree_index *tree,
aom_prob probs[/*n - 1*/],
const unsigned int counts[/* n */], int n,
......@@ -344,26 +343,6 @@ static void prob_diff_update(const aom_tree_index *tree,
}
#endif
#if 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,
int probwt) {
int i;
unsigned int branch_ct[32][2];
int savings = 0;
// Assuming max number of probabilities <= 32
assert(n <= 32);
av1_tree_probs_from_distribution(tree, branch_ct, counts);
for (i = 0; i < n - 1; ++i) {
savings +=
av1_cond_prob_diff_update_savings(&probs[i], branch_ct[i], probwt);
}
return savings;
}
#endif // CONFIG_COMPOUND_SINGLEREF
#if CONFIG_VAR_TX
static void write_tx_size_vartx(const AV1_COMMON *cm, MACROBLOCKD *xd,
const MB_MODE_INFO *mbmi, TX_SIZE tx_size,
......@@ -494,34 +473,6 @@ static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
}
#endif
#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
static void update_inter_singleref_comp_mode_probs(AV1_COMMON *cm, int probwt,
aom_writer *w) {
const int savings_thresh = av1_cost_one(GROUP_DIFF_UPDATE_PROB) -
av1_cost_zero(GROUP_DIFF_UPDATE_PROB);
int i;
int savings = 0;
int do_update = 0;
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
savings +=
prob_diff_update_savings(av1_inter_singleref_comp_mode_tree,
cm->fc->inter_singleref_comp_mode_probs[i],
cm->counts.inter_singleref_comp_mode[i],
INTER_SINGLEREF_COMP_MODES, probwt);
}
do_update = savings > savings_thresh;
aom_write(w, do_update, GROUP_DIFF_UPDATE_PROB);
if (do_update) {
for (i = 0; i < INTER_MODE_CONTEXTS; ++i) {
prob_diff_update(av1_inter_singleref_comp_mode_tree,
cm->fc->inter_singleref_comp_mode_probs[i],
cm->counts.inter_singleref_comp_mode[i],
INTER_SINGLEREF_COMP_MODES, probwt, w);
}
}
}
#endif // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
static int write_skip(const AV1_COMMON *cm, const MACROBLOCKD *xd,
int segment_id, const MODE_INFO *mi, aom_writer *w) {
if (segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP)) {
......@@ -1915,7 +1866,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
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);
write_inter_singleref_comp_mode(xd, w, mode, mode_ctx);
#endif // CONFIG_COMPOUND_SINGLEREF
else if (is_inter_singleref_mode(mode))
#endif // CONFIG_EXT_INTER
......@@ -4625,10 +4576,6 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
update_inter_mode_probs(cm, header_bc, counts);
#endif
#if CONFIG_EXT_INTER
#if CONFIG_COMPOUND_SINGLEREF
update_inter_singleref_comp_mode_probs(cm, probwt, header_bc);
#endif // CONFIG_COMPOUND_SINGLEREF
#if CONFIG_INTERINTRA
if (cm->reference_mode != COMPOUND_REFERENCE &&
cm->allow_interintra_compound) {
......
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