Commit 299ff04f authored by Thomas Davies's avatar Thomas Davies

INTERINTRA : adapt interintra_mode as cdf.

Use CDFs to code intrainter_mode instead of deprecated
tree coding.

AWCY, objective-1-fast, High Latency :
-0.02% all metrics, standard configuration

Change-Id: I839eec7cae9783e28d2018511989b7b56dc948a5
parent a14f2bbf
......@@ -5711,11 +5711,14 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
// FIXME: cdfs not defined for super_tx
#if CONFIG_EXT_INTER
AVERAGE_TILE_CDFS(inter_compound_mode_cdf)
// interintra_mode etc
#endif
AVERAGE_TILE_CDFS(compound_type_cdf)
#if CONFIG_INTERINTRA
AVERAGE_TILE_CDFS(interintra_mode_cdf)
#endif
AVERAGE_TILE_CDFS(y_mode_cdf)
if (cm->interp_filter == SWITCHABLE) {
......
......@@ -1226,7 +1226,6 @@ static const aom_cdf_prob default_compound_type_cdf[BLOCK_SIZES]
static const aom_prob default_interintra_prob[BLOCK_SIZE_GROUPS] = {
208, 208, 208, 208,
};
static const aom_prob
default_interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1] = {
{ 88, 16, 150 }, // block_size < 8x8
......@@ -1234,6 +1233,16 @@ static const aom_prob
{ 73, 24, 150 }, // block_size < 32x32
{ 96, 27, 150 } // block_size >= 32x32
};
#if CONFIG_EC_ADAPT
static const aom_cdf_prob
default_interintra_mode_cdf[BLOCK_SIZE_GROUPS][CDF_SIZE(
INTERINTRA_MODES)] = {
{ AOM_ICDF(11263), AOM_ICDF(23076), AOM_ICDF(31424), AOM_ICDF(32768), 0 },
{ AOM_ICDF(9600), AOM_ICDF(21796), AOM_ICDF(30415), AOM_ICDF(32768), 0 },
{ AOM_ICDF(9344), AOM_ICDF(21782), AOM_ICDF(30572), AOM_ICDF(32768), 0 },
{ AOM_ICDF(12288), AOM_ICDF(23022), AOM_ICDF(30608), AOM_ICDF(32768), 0 }
};
#endif
static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
......@@ -1244,6 +1253,7 @@ static const aom_prob default_wedge_interintra_prob[BLOCK_SIZES] = {
208, 208, 208
#endif // CONFIG_EXT_PARTITION
};
#endif // CONFIG_INTERINTRA
#endif // CONFIG_EXT_INTER
......@@ -4869,9 +4879,12 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif
#if CONFIG_INTERINTRA
av1_copy(fc->interintra_prob, default_interintra_prob);
av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
av1_copy(fc->wedge_interintra_prob, default_wedge_interintra_prob);
av1_copy(fc->interintra_mode_prob, default_interintra_mode_prob);
#if CONFIG_EC_ADAPT
av1_copy(fc->interintra_mode_cdf, default_interintra_mode_cdf);
#endif
#endif // CONFIG_INTERINTRA
#endif // CONFIG_EXT_INTER
#if CONFIG_SUPERTX
av1_copy(fc->supertx_prob, default_supertx_prob);
......
......@@ -209,8 +209,12 @@ typedef struct frame_contexts {
#endif
#if CONFIG_INTERINTRA
aom_prob interintra_prob[BLOCK_SIZE_GROUPS];
aom_prob interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1];
aom_prob wedge_interintra_prob[BLOCK_SIZES];
aom_prob interintra_mode_prob[BLOCK_SIZE_GROUPS][INTERINTRA_MODES - 1];
#if CONFIG_EC_ADAPT
aom_cdf_prob interintra_mode_cdf[BLOCK_SIZE_GROUPS]
[CDF_SIZE(INTERINTRA_MODES)];
#endif
#endif // CONFIG_INTERINTRA
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
......
......@@ -5117,10 +5117,12 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
av1_diff_update_prob(&r, &fc->interintra_prob[i], ACCT_STR);
}
}
#if !CONFIG_EC_ADAPT
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
for (j = 0; j < INTERINTRA_MODES - 1; j++)
av1_diff_update_prob(&r, &fc->interintra_mode_prob[i][j], ACCT_STR);
}
#endif
#if CONFIG_WEDGE
for (i = 0; i < BLOCK_SIZES; i++) {
if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i)) {
......
......@@ -192,9 +192,16 @@ static int read_cfl_alphas(FRAME_CONTEXT *const ec_ctx, aom_reader *r,
#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
static INTERINTRA_MODE read_interintra_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
aom_reader *r, int size_group) {
#if CONFIG_EC_ADAPT
(void)cm;
const INTERINTRA_MODE ii_mode = (INTERINTRA_MODE)aom_read_symbol(
r, xd->tile_ctx->interintra_mode_cdf[size_group], INTERINTRA_MODES,
ACCT_STR);
#else
const INTERINTRA_MODE ii_mode = (INTERINTRA_MODE)aom_read_tree(
r, av1_interintra_mode_tree, cm->fc->interintra_mode_prob[size_group],
ACCT_STR);
#endif
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->interintra_mode[size_group][ii_mode];
return ii_mode;
......
......@@ -219,14 +219,6 @@ static void write_intra_mode_kf(const AV1_COMMON *cm, FRAME_CONTEXT *frame_ctx,
(void)cm;
}
#if CONFIG_EXT_INTER && CONFIG_INTERINTRA
static void write_interintra_mode(aom_writer *w, INTERINTRA_MODE mode,
const aom_prob *probs) {
av1_write_token(w, av1_interintra_mode_tree, probs,
&interintra_mode_encodings[mode]);
}
#endif // CONFIG_EXT_INTER && CONFIG_INTERINTRA
static void write_inter_mode(aom_writer *w, PREDICTION_MODE mode,
FRAME_CONTEXT *ec_ctx, const int16_t mode_ctx) {
const int16_t newmv_ctx = mode_ctx & NEWMV_CTX_MASK;
......@@ -2236,8 +2228,15 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
const int bsize_group = size_group_lookup[bsize];
aom_write(w, interintra, cm->fc->interintra_prob[bsize_group]);
if (interintra) {
write_interintra_mode(w, mbmi->interintra_mode,
cm->fc->interintra_mode_prob[bsize_group]);
#if CONFIG_EC_ADAPT
aom_write_symbol(w, mbmi->interintra_mode,
ec_ctx->interintra_mode_cdf[bsize_group],
INTERINTRA_MODES);
#else
av1_write_token(w, av1_interintra_mode_tree,
cm->fc->interintra_mode_prob[bsize_group],
&interintra_mode_encodings[mbmi->interintra_mode]);
#endif
if (is_interintra_wedge_used(bsize)) {
aom_write(w, mbmi->use_wedge_interintra,
cm->fc->wedge_interintra_prob[bsize]);
......@@ -5119,11 +5118,13 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
cm->counts.interintra[i], probwt);
}
}
#if !CONFIG_EC_ADAPT
for (i = 0; i < BLOCK_SIZE_GROUPS; i++) {
prob_diff_update(
av1_interintra_mode_tree, cm->fc->interintra_mode_prob[i],
counts->interintra_mode[i], INTERINTRA_MODES, probwt, header_bc);
}
#endif
#if CONFIG_WEDGE
for (i = 0; i < BLOCK_SIZES; i++) {
if (is_interintra_allowed_bsize(i) && is_interintra_wedge_used(i))
......
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