Commit d8dac22f authored by Thomas Davies's avatar Thomas Davies

Adapt the compound_type syntax element.

This syntax element was encoded using legacy tree encoding, and is
used in the compound_segment and wedge experiments.

AWCY: -0.01% all metrics (objective-1-fast, High Latency)

Change-Id: I3771ed27e13dd74841c615bec4c2918d39b76093
parent e4c6fc18
......@@ -5713,6 +5713,9 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
AVERAGE_TILE_CDFS(inter_compound_mode_cdf)
// interintra_mode etc
#endif
AVERAGE_TILE_CDFS(compound_type_cdf)
AVERAGE_TILE_CDFS(y_mode_cdf)
if (cm->interp_filter == SWITCHABLE) {
......
......@@ -1134,6 +1134,94 @@ static const aom_prob default_compound_type_probs[BLOCK_SIZES]
[COMPOUND_TYPES - 1];
#endif // CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
#if CONFIG_EC_ADAPT
#if CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
static const aom_cdf_prob
default_compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(32640), AOM_ICDF(32704), AOM_ICDF(32768), 0 }, // 255, 128
{ AOM_ICDF(32640), AOM_ICDF(32704), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32704), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 }, // 208, 128
{ AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(29696), AOM_ICDF(32768), 0 },
{ AOM_ICDF(27648), AOM_ICDF(30208), AOM_ICDF(32768), 0 }, // 216, 128
{ AOM_ICDF(27648), AOM_ICDF(30208), AOM_ICDF(32768), 0 },
{ AOM_ICDF(27648), AOM_ICDF(30208), AOM_ICDF(32768), 0 },
{ AOM_ICDF(28672), AOM_ICDF(30720), AOM_ICDF(32768), 0 }, // 224, 128
{ AOM_ICDF(28672), AOM_ICDF(28688), AOM_ICDF(32768), 0 }, // 224, 1
{ AOM_ICDF(30720), AOM_ICDF(30728), AOM_ICDF(32768), 0 }, // 240, 1
{ AOM_ICDF(30720), AOM_ICDF(30728), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(32640), AOM_ICDF(32641), AOM_ICDF(32768), 0 }, // 255, 1
{ AOM_ICDF(32640), AOM_ICDF(32641), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32641), AOM_ICDF(32768), 0 },
#endif // CONFIG_EXT_PARTITION
};
#elif !CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
static const aom_cdf_prob
default_compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 }, // 255
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 }, // 208
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(27648), AOM_ICDF(32768), 0 }, // 216
{ AOM_ICDF(27648), AOM_ICDF(32768), 0 },
{ AOM_ICDF(27648), AOM_ICDF(32768), 0 },
{ AOM_ICDF(28672), AOM_ICDF(32768), 0 }, // 224
{ AOM_ICDF(28672), AOM_ICDF(32768), 0 },
{ AOM_ICDF(30720), AOM_ICDF(32768), 0 }, // 240
{ AOM_ICDF(30720), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 }, // 255
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
#endif // CONFIG_EXT_PARTITION
};
#elif CONFIG_COMPOUND_SEGMENT && !CONFIG_WEDGE
static const aom_cdf_prob
default_compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 }, // 255
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 }, // 208
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26624), AOM_ICDF(32768), 0 },
{ AOM_ICDF(27648), AOM_ICDF(32768), 0 }, // 216
{ AOM_ICDF(27648), AOM_ICDF(32768), 0 },
{ AOM_ICDF(27648), AOM_ICDF(32768), 0 },
{ AOM_ICDF(28672), AOM_ICDF(32768), 0 }, // 224
{ AOM_ICDF(28672), AOM_ICDF(32768), 0 },
{ AOM_ICDF(30720), AOM_ICDF(32768), 0 }, // 240
{ AOM_ICDF(30720), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 }, // 255
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32768), 0 },
#endif // CONFIG_EXT_PARTITION
};
#else
static const aom_cdf_prob default_compound_type_cdf[BLOCK_SIZES]
[CDF_SIZE(COMPOUND_TYPES)];
#endif // CONFIG_COMPOUND_SEGMENT && CONFIG_WEDGE
#endif // CONFIG_EC_ADAPT
#if CONFIG_INTERINTRA
static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
208, 208, 208, 208,
......@@ -4776,6 +4864,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
default_inter_singleref_comp_mode_probs);
#endif // CONFIG_COMPOUND_SINGLEREF
av1_copy(fc->compound_type_prob, default_compound_type_probs);
#if CONFIG_EC_ADAPT
av1_copy(fc->compound_type_cdf, default_compound_type_cdf);
#endif
#if CONFIG_INTERINTRA
av1_copy(fc->interintra_prob, default_interintra_prob);
av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
......
......@@ -204,6 +204,9 @@ typedef struct frame_contexts {
[INTER_SINGLEREF_COMP_MODES - 1];
#endif // CONFIG_COMPOUND_SINGLEREF
aom_prob compound_type_prob[BLOCK_SIZES][COMPOUND_TYPES - 1];
#if CONFIG_EC_ADAPT
aom_cdf_prob compound_type_cdf[BLOCK_SIZES][CDF_SIZE(COMPOUND_TYPES)];
#endif
#if CONFIG_INTERINTRA
aom_prob interintra_prob[BLOCK_SIZE_GROUPS];
aom_prob interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1];
......
......@@ -5130,7 +5130,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
#endif // CONFIG_WEDGE
}
#endif // CONFIG_INTERINTRA
#if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
#if !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
#if CONFIG_COMPOUND_SINGLEREF
if (cm->allow_masked_compound) {
#else // !CONFIG_COMPOUND_SINGLEREF
......@@ -5144,7 +5144,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
}
}
}
#endif // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
#endif // !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
......
......@@ -2643,9 +2643,14 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
if (is_any_masked_compound_used(bsize)) {
#if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
if (cm->allow_masked_compound) {
#if CONFIG_EC_ADAPT
mbmi->interinter_compound_type = aom_read_symbol(
r, ec_ctx->compound_type_cdf[bsize], COMPOUND_TYPES, ACCT_STR);
#else
mbmi->interinter_compound_type =
aom_read_tree(r, av1_compound_type_tree,
cm->fc->compound_type_prob[bsize], ACCT_STR);
#endif
#if CONFIG_WEDGE
if (mbmi->interinter_compound_type == COMPOUND_WEDGE) {
mbmi->wedge_index =
......
......@@ -2278,9 +2278,14 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
is_any_masked_compound_used(bsize)) {
#if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
if (cm->allow_masked_compound) {
#if CONFIG_EC_ADAPT
aom_write_symbol(w, mbmi->interinter_compound_type,
ec_ctx->compound_type_cdf[bsize], COMPOUND_TYPES);
#else
av1_write_token(
w, av1_compound_type_tree, cm->fc->compound_type_prob[bsize],
&compound_type_encodings[mbmi->interinter_compound_type]);
#endif
#if CONFIG_WEDGE
if (mbmi->interinter_compound_type == COMPOUND_WEDGE) {
aom_write_literal(w, mbmi->wedge_index, get_wedge_bits_lookup(bsize));
......@@ -5128,7 +5133,7 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
#endif // CONFIG_WEDGE
}
#endif // CONFIG_INTERINTRA
#if CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
#if !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
#if CONFIG_COMPOUND_SINGLEREF
if (cm->allow_masked_compound) {
#else // !CONFIG_COMPOUND_SINGLEREF
......@@ -5142,7 +5147,7 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
}
}
}
#endif // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
#endif // !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
......
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