Commit 04e5aa7f authored by Thomas Davies's avatar Thomas Davies

Adapt motion mode syntax.

Remove deprecated tree coding when EC_ADAPT is on.

AWCY, objective-1-fast, High Latency:

PSNR (Y, Cb, Cr) : -0.10%, -0.40%, -0.37%
SSIM: -0.11%
PSNR-HVS: -0.07%
MS-SSIM: -0.06%

Change-Id: Ic2d436e037312e1af238a8586983f1288a9a95a8
parent 0a2dab22
......@@ -5703,8 +5703,6 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
AVERAGE_TILE_CDFS(drl_cdf)
#endif
// FIXME: cdfs not defined for motion_mode_prob
// FIXME: cdfs not defined for super_tx
#if CONFIG_EXT_INTER
......@@ -5732,10 +5730,13 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
}
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(intra_inter_cdf)
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
AVERAGE_TILE_CDFS(motion_mode_cdf)
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
AVERAGE_TILE_CDFS(obmc_cdf)
#endif
#endif
#endif
}
#if CONFIG_PVQ
......
......@@ -1310,8 +1310,8 @@ static const aom_prob
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, -OBMC_CAUSAL
};
static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
{
static const aom_cdf_prob
default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ 255 }, { 255 }, { 255 },
#endif
......@@ -1343,6 +1343,34 @@ static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
#endif // CONFIG_EXT_PARTITION
};
#endif
#if CONFIG_EC_ADAPT
static const aom_cdf_prob
default_motion_mode_cdf[BLOCK_SIZES][CDF_SIZE(MOTION_MODES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(151 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(153 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(144 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(178 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(165 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(160 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(207 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(195 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(168 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(244 * 128), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(252 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(252 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(252 * 128), AOM_ICDF(32768), 0 },
#endif // CONFIG_EXT_PARTITION
};
#endif // CONFIG_EC_ADAPT
#elif !CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
......@@ -1362,6 +1390,35 @@ static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
#endif // CONFIG_EXT_PARTITION
};
#if CONFIG_EC_ADAPT
static const aom_cdf_prob
default_motion_mode_cdf[BLOCK_SIZES][CDF_SIZE(MOTION_MODES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(255 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(151 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(153 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(144 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(178 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(165 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(160 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(207 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(195 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(168 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(244 * 128), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(252 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(252 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(252 * 128), AOM_ICDF(32768), 0 },
#endif // CONFIG_EXT_PARTITION
};
#endif // CONFIG_EC_ADAPT
#elif CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
......@@ -1380,6 +1437,35 @@ static const aom_prob default_motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1] =
#endif // CONFIG_EXT_PARTITION
};
#if CONFIG_EC_ADAPT
static const aom_cdf_prob
default_motion_mode_cdf[BLOCK_SIZES][CDF_SIZE(MOTION_MODES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(19328), AOM_ICDF(29828), AOM_ICDF(32768), 0 },
{ AOM_ICDF(19584), AOM_ICDF(29884), AOM_ICDF(32768), 0 },
{ AOM_ICDF(18432), AOM_ICDF(29632), AOM_ICDF(32768), 0 },
{ AOM_ICDF(22784), AOM_ICDF(30584), AOM_ICDF(32768), 0 },
{ AOM_ICDF(21120), AOM_ICDF(30220), AOM_ICDF(32768), 0 },
{ AOM_ICDF(20480), AOM_ICDF(30080), AOM_ICDF(32768), 0 },
{ AOM_ICDF(26496), AOM_ICDF(31396), AOM_ICDF(32768), 0 },
{ AOM_ICDF(24960), AOM_ICDF(31060), AOM_ICDF(32768), 0 },
{ AOM_ICDF(21504), AOM_ICDF(30304), AOM_ICDF(32768), 0 },
{ AOM_ICDF(31232), AOM_ICDF(32432), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32768), 0 },
#endif
};
#endif // !CONFIG_EC_ADAPT
// Probability for the case that only 1 additional motion mode is allowed
static const aom_prob default_obmc_prob[BLOCK_SIZES] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
......@@ -4931,6 +5017,9 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
av1_copy(fc->ncobmc_mode_prob, default_ncobmc_mode_prob);
#endif
#if CONFIG_EC_ADAPT
av1_copy(fc->motion_mode_cdf, default_motion_mode_cdf);
#endif
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
av1_copy(fc->obmc_prob, default_obmc_prob);
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -223,11 +223,12 @@ typedef struct frame_contexts {
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
aom_prob motion_mode_prob[BLOCK_SIZES][MOTION_MODES - 1];
#if CONFIG_EC_ADAPT
aom_cdf_prob motion_mode_cdf[BLOCK_SIZES][CDF_SIZE(MOTION_MODES)];
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
aom_prob ncobmc_mode_prob[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES - 1];
#endif
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
aom_prob obmc_prob[BLOCK_SIZES];
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -5004,8 +5004,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
FRAME_CONTEXT *const fc = cm->fc;
aom_reader r;
int i;
#if !CONFIG_EC_ADAPT || \
(CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION || CONFIG_EXT_INTER)
#if !CONFIG_EC_ADAPT
int j;
#endif
......@@ -5183,12 +5182,14 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
#endif // !CONFIG_EC_ADAPT && (CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE)
#endif // CONFIG_EXT_INTER
#if !CONFIG_EC_ADAPT
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i) {
for (j = 0; j < MOTION_MODES - 1; ++j)
av1_diff_update_prob(&r, &fc->motion_mode_prob[i][j], ACCT_STR);
}
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#endif // !CONFIG_EC_ADAPT
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
for (i = 0; i < ADAPT_OVERLAP_BLOCKS; ++i) {
......@@ -5199,7 +5200,7 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
#if !CONFIG_EC_ADAPT
if (cm->interp_filter == SWITCHABLE) read_switchable_interp_probs(fc, &r);
#endif
#endif // !CONFIG_EC_ADAPT
#if !CONFIG_NEW_MULTISYMBOL
for (i = 0; i < INTRA_INTER_CONTEXTS; i++)
av1_diff_update_prob(&r, &fc->intra_inter_prob[i], ACCT_STR);
......
......@@ -322,6 +322,10 @@ static void read_drl_idx(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
MODE_INFO *mi, aom_reader *r) {
MB_MODE_INFO *mbmi = &mi->mbmi;
#if CONFIG_NEW_MULTISYMBOL
(void)cm;
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
const MOTION_MODE last_motion_mode_allowed =
motion_mode_allowed_wrapper(0,
......@@ -352,9 +356,15 @@ static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
return (MOTION_MODE)(SIMPLE_TRANSLATION + motion_mode);
} else {
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#if CONFIG_EC_ADAPT
motion_mode =
aom_read_tree(r, av1_motion_mode_tree,
cm->fc->motion_mode_prob[mbmi->sb_type], ACCT_STR);
aom_read_symbol(r, xd->tile_ctx->motion_mode_cdf[mbmi->sb_type],
MOTION_MODES, ACCT_STR);
#else
motion_mode =
aom_read_tree(r, av1_motion_mode_tree,
cm->fc->motion_mode_prob[mbmi->sb_type], ACCT_STR);
#endif
if (counts) ++counts->motion_mode[mbmi->sb_type][motion_mode];
return (MOTION_MODE)(SIMPLE_TRANSLATION + motion_mode);
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
......
......@@ -116,7 +116,9 @@ static struct av1_token compound_type_encodings[COMPOUND_TYPES];
#endif // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if !CONFIG_EC_ADAPT
static struct av1_token motion_mode_encodings[MOTION_MODES];
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
static struct av1_token ncobmc_mode_encodings[MAX_NCOBMC_MODES];
#endif
......@@ -172,7 +174,9 @@ void av1_encode_token_init(void) {
#endif // CONFIG_COMPOUND_SEGMENT || CONFIG_WEDGE
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if !CONFIG_EC_ADAPT
av1_tokens_from_tree(motion_mode_encodings, av1_motion_mode_tree);
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
av1_tokens_from_tree(ncobmc_mode_encodings, av1_ncobmc_mode_tree);
#endif
......@@ -351,8 +355,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_EC_ADAPT || \
(CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION || CONFIG_EXT_INTER)
#if !CONFIG_EC_ADAPT || CONFIG_NCOBMC_ADAPT_WEIGHT || CONFIG_COMPOUND_SINGLEREF
static void prob_diff_update(const aom_tree_index *tree,
aom_prob probs[/*n - 1*/],
const unsigned int counts[/* n */], int n,
......@@ -612,7 +615,7 @@ static void write_is_inter(const AV1_COMMON *cm, const MACROBLOCKD *xd,
static void write_motion_mode(const AV1_COMMON *cm, MACROBLOCKD *xd,
const MODE_INFO *mi, aom_writer *w) {
const MB_MODE_INFO *mbmi = &mi->mbmi;
#if !CONFIG_NEW_MULTISYMBOL
#if !CONFIG_EC_ADAPT
(void)xd;
#endif
......@@ -642,9 +645,15 @@ static void write_motion_mode(const AV1_COMMON *cm, MACROBLOCKD *xd,
#endif
} else {
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
av1_write_token(w, av1_motion_mode_tree,
cm->fc->motion_mode_prob[mbmi->sb_type],
&motion_mode_encodings[mbmi->motion_mode]);
#if CONFIG_EC_ADAPT
aom_write_symbol(w, mbmi->motion_mode,
xd->tile_ctx->motion_mode_cdf[mbmi->sb_type],
MOTION_MODES);
#else
av1_write_token(w, av1_motion_mode_tree,
cm->fc->motion_mode_prob[mbmi->sb_type],
&motion_mode_encodings[mbmi->motion_mode]);
#endif
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
}
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
......@@ -5022,6 +5031,11 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
#else
const int probwt = 1;
#endif
#if CONFIG_EC_ADAPT
(void)probwt;
(void)i;
(void)fc;
#endif
#if CONFIG_ANS
int header_size;
......@@ -5193,9 +5207,11 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
#endif // CONFIG_EXT_INTER
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if !CONFIG_EC_ADAPT
for (i = BLOCK_8X8; i < BLOCK_SIZES; ++i)
prob_diff_update(av1_motion_mode_tree, fc->motion_mode_prob[i],
counts->motion_mode[i], MOTION_MODES, probwt, header_bc);
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
for (i = ADAPT_OVERLAP_BLOCK_8X8; i < ADAPT_OVERLAP_BLOCKS; ++i) {
prob_diff_update(av1_ncobmc_mode_tree, fc->ncobmc_mode_prob[i],
......@@ -5204,10 +5220,11 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
}
#endif
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if !CONFIG_EC_ADAPT
if (cm->interp_filter == SWITCHABLE)
update_switchable_interp_probs(cm, header_bc, counts);
#endif
#endif // !CONFIG_EC_ADAPT
#if !CONFIG_NEW_MULTISYMBOL
for (i = 0; i < INTRA_INTER_CONTEXTS; 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