Commit 07ed3ab2 authored by Wei-Ting Lin's avatar Wei-Ting Lin Committed by Wei-ting Lin

ncobmc-adapt-weight: add bitstream to support warped motion

Change-Id: I0e9df3719e5f9a55e1386afe44851d1707e2e01b
parent 668d3d99
......@@ -1106,6 +1106,113 @@ static const aom_cdf_prob
};
#elif CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#if CONFIG_NCOBMC_ADAPT_WEIGHT
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, 4, -NCOBMC_ADAPT_WEIGHT, -WARPED_CAUSAL
};
static const aom_prob default_motion_mode_prob[BLOCK_SIZES_ALL][MOTION_MODES -
1] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ 128, 128, 255 }, { 128, 128, 128 }, { 128, 128, 128 },
#endif
{ 128, 128, 128 }, { 128, 128, 128 }, { 128, 128, 128 }, { 62, 115, 128 },
{ 39, 131, 128 }, { 39, 132, 128 }, { 118, 94, 128 }, { 77, 125, 128 },
{ 100, 121, 128 }, { 190, 66, 128 }, { 207, 102, 128 }, { 197, 100, 128 },
{ 239, 76, 128 },
#if CONFIG_EXT_PARTITION
{ 252, 200, 128 }, { 252, 200, 128 }, { 252, 200, 128 },
#endif // CONFIG_EXT_PARTITION
{ 208, 200, 128 }, { 208, 200, 128 }, { 208, 200, 128 }, { 208, 200, 128 }
};
static const aom_cdf_prob
default_motion_mode_cdf[BLOCK_SIZES_ALL][CDF_SIZE(MOTION_MODES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
/** Only these nine block sizes allow ncobmc_adapt_weight **/
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
{ AOM_ICDF(8192), AOM_ICDF(16384), AOM_ICDF(24576), AOM_ICDF(32768), 0 },
/***********************************************************/
{ AOM_ICDF(30592), AOM_ICDF(31238), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32256), AOM_ICDF(32656), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32767), AOM_ICDF(32768), 0 }
};
const aom_tree_index av1_ncobmc_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -NCOBMC_ADAPT_WEIGHT
};
static const aom_prob
default_ncobmc_prob[BLOCK_SIZES_ALL][OBMC_FAMILY_MODES - 1] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ 128, 255 }, { 128, 255 }, { 128, 255 },
#endif
{ 128, 255 }, { 128, 255 }, { 128, 255 }, { 45, 255 }, { 79, 255 },
{ 75, 255 }, { 130, 255 }, { 141, 255 }, { 144, 255 }, { 208, 255 },
{ 201, 255 }, { 186, 255 }, { 231, 255 },
#if CONFIG_EXT_PARTITION
{ 252, 255 }, { 252, 255 }, { 252, 255 },
#endif // CONFIG_EXT_PARTITION
{ 208, 255 }, { 208, 255 }, { 208, 255 }, { 208, 255 }
};
static const aom_cdf_prob
default_ncobmc_cdf[BLOCK_SIZES_ALL][CDF_SIZE(OBMC_FAMILY_MODES)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(128 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
#endif
{ AOM_ICDF(128 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
/** Only these nine block sizes allow ncobmc_adapt_weight **/
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
{ AOM_ICDF(10922), AOM_ICDF(21845), AOM_ICDF(32768), 0 },
/***********************************************************/
{ AOM_ICDF(231 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
#if CONFIG_EXT_PARTITION
{ AOM_ICDF(252 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(252 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(252 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
#endif // CONFIG_EXT_PARTITION
{ AOM_ICDF(208 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(208 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(208 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(208 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(208 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 },
{ AOM_ICDF(208 * 128), AOM_ICDF(32767), AOM_ICDF(32768), 0 }
};
#else
const aom_tree_index av1_motion_mode_tree[TREE_SIZE(MOTION_MODES)] = {
-SIMPLE_TRANSLATION, 2, -OBMC_CAUSAL, -WARPED_CAUSAL,
};
......@@ -1156,7 +1263,7 @@ static const aom_cdf_prob
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
{ AOM_ICDF(32640), AOM_ICDF(32740), AOM_ICDF(32768), 0 },
};
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
// Probability for the case that only 1 additional motion mode is allowed
static const aom_prob default_obmc_prob[BLOCK_SIZES_ALL] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
......@@ -1169,7 +1276,7 @@ static const aom_prob default_obmc_prob[BLOCK_SIZES_ALL] = {
208, 208, 208, 208, 208, 208,
};
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_NEW_MULTISYMBOL || CONFIG_NCOBMC_ADAPT_WEIGHT
static const aom_cdf_prob default_obmc_cdf[BLOCK_SIZES_ALL][CDF_SIZE(2)] = {
#if CONFIG_CHROMA_2X2 || CONFIG_CHROMA_SUB8X8
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
......@@ -5034,9 +5141,13 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
av1_copy(fc->obmc_prob, default_obmc_prob);
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_NEW_MULTISYMBOL || CONFIG_NCOBMC_ADAPT_WEIGHT
av1_copy(fc->obmc_cdf, default_obmc_cdf);
#endif
#if CONFIG_NCOBMC_ADAPT_WEIGHT
av1_copy(fc->ncobmc_prob, default_ncobmc_prob);
av1_copy(fc->ncobmc_cdf, default_ncobmc_cdf);
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if CONFIG_EXT_INTER
......
......@@ -237,8 +237,12 @@ typedef struct frame_contexts {
[CDF_SIZE(MAX_NCOBMC_MODES)];
#endif
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#if CONFIG_NCOBMC_ADAPT_WEIGHT
aom_prob ncobmc_prob[BLOCK_SIZES_ALL][OBMC_FAMILY_MODES - 1];
aom_cdf_prob ncobmc_cdf[BLOCK_SIZES_ALL][CDF_SIZE(OBMC_FAMILY_MODES)];
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
aom_prob obmc_prob[BLOCK_SIZES_ALL];
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_NEW_MULTISYMBOL || CONFIG_NCOBMC_ADAPT_WEIGHT
aom_cdf_prob obmc_cdf[BLOCK_SIZES_ALL][CDF_SIZE(2)];
#endif // CONFIG_NEW_MULTISYMBOL
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
......@@ -459,6 +463,9 @@ typedef struct FRAME_COUNTS {
unsigned int ncobmc_mode[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES];
#endif
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#if CONFIG_NCOBMC_ADAPT_WEIGHT
unsigned int ncobmc[BLOCK_SIZES_ALL][OBMC_FAMILY_MODES];
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
unsigned int obmc[BLOCK_SIZES_ALL][2];
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
......
......@@ -505,6 +505,10 @@ typedef enum {
WARPED_CAUSAL, // 2-sided WARPED
#endif // CONFIG_WARPED_MOTION
MOTION_MODES
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_WARPED_MOTION
,
OBMC_FAMILY_MODES = NCOBMC_ADAPT_WEIGHT + 1
#endif
} MOTION_MODE;
#if CONFIG_EXT_INTER
......
......@@ -300,7 +300,8 @@ 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_MOTION_VAR || !CONFIG_WARPED_MOTION || CONFIG_NEW_MULTISYMBOL
#if !CONFIG_MOTION_VAR || !CONFIG_WARPED_MOTION || CONFIG_NEW_MULTISYMBOL || \
CONFIG_NCOBMC_ADAPT_WEIGHT
(void)cm;
#endif
......@@ -317,6 +318,19 @@ static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
if (last_motion_mode_allowed == SIMPLE_TRANSLATION) return SIMPLE_TRANSLATION;
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#if CONFIG_NCOBMC_ADAPT_WEIGHT
if (last_motion_mode_allowed == NCOBMC_ADAPT_WEIGHT) {
motion_mode = aom_read_symbol(r, xd->tile_ctx->ncobmc_cdf[mbmi->sb_type],
OBMC_FAMILY_MODES, ACCT_STR);
if (counts) ++counts->ncobmc[mbmi->sb_type][motion_mode];
return (MOTION_MODE)(SIMPLE_TRANSLATION + motion_mode);
} else if (last_motion_mode_allowed == OBMC_CAUSAL) {
motion_mode =
aom_read_symbol(r, xd->tile_ctx->obmc_cdf[mbmi->sb_type], 2, ACCT_STR);
if (counts) ++counts->obmc[mbmi->sb_type][motion_mode];
return (MOTION_MODE)(SIMPLE_TRANSLATION + motion_mode);
} else {
#else
if (last_motion_mode_allowed == OBMC_CAUSAL) {
#if CONFIG_NEW_MULTISYMBOL
motion_mode =
......@@ -327,6 +341,7 @@ static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
if (counts) ++counts->obmc[mbmi->sb_type][motion_mode];
return (MOTION_MODE)(SIMPLE_TRANSLATION + motion_mode);
} else {
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
motion_mode =
aom_read_symbol(r, xd->tile_ctx->motion_mode_cdf[mbmi->sb_type],
......
......@@ -511,6 +511,16 @@ static void write_motion_mode(const AV1_COMMON *cm, MACROBLOCKD *xd,
mi);
if (last_motion_mode_allowed == SIMPLE_TRANSLATION) return;
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#if CONFIG_NCOBMC_ADAPT_WEIGHT
if (last_motion_mode_allowed == NCOBMC_ADAPT_WEIGHT) {
aom_write_symbol(w, mbmi->motion_mode,
xd->tile_ctx->ncobmc_cdf[mbmi->sb_type],
OBMC_FAMILY_MODES);
} else if (last_motion_mode_allowed == OBMC_CAUSAL) {
aom_write_symbol(w, mbmi->motion_mode == OBMC_CAUSAL,
xd->tile_ctx->obmc_cdf[mbmi->sb_type], 2);
} else {
#else
if (last_motion_mode_allowed == OBMC_CAUSAL) {
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, mbmi->motion_mode == OBMC_CAUSAL,
......@@ -520,6 +530,7 @@ static void write_motion_mode(const AV1_COMMON *cm, MACROBLOCKD *xd,
cm->fc->obmc_prob[mbmi->sb_type]);
#endif
} else {
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
aom_write_symbol(w, mbmi->motion_mode,
xd->tile_ctx->motion_mode_cdf[mbmi->sb_type],
......
......@@ -214,6 +214,9 @@ struct macroblock {
int motion_mode_cost[BLOCK_SIZES_ALL][MOTION_MODES];
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
int motion_mode_cost1[BLOCK_SIZES_ALL][2];
#if CONFIG_NCOBMC_ADAPT_WEIGHT
int motion_mode_cost2[BLOCK_SIZES_ALL][OBMC_FAMILY_MODES];
#endif
#endif // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
#if CONFIG_MOTION_VAR && CONFIG_NCOBMC_ADAPT_WEIGHT
int ncobmc_mode_cost[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES];
......
......@@ -1839,6 +1839,16 @@ static void update_stats(const AV1_COMMON *const cm, ThreadData *td, int mi_row,
counts->motion_mode[mbmi->sb_type][mbmi->motion_mode]++;
update_cdf(fc->motion_mode_cdf[mbmi->sb_type], mbmi->motion_mode,
MOTION_MODES);
#if CONFIG_NCOBMC_ADAPT_WEIGHT
} else if (motion_allowed == NCOBMC_ADAPT_WEIGHT) {
counts->ncobmc[mbmi->sb_type][mbmi->motion_mode]++;
update_cdf(fc->ncobmc_cdf[mbmi->sb_type], mbmi->motion_mode,
OBMC_FAMILY_MODES);
} else if (motion_allowed == OBMC_CAUSAL) {
counts->obmc[mbmi->sb_type][mbmi->motion_mode == OBMC_CAUSAL]++;
update_cdf(fc->obmc_cdf[mbmi->sb_type], mbmi->motion_mode, 2);
}
#else
} else if (motion_allowed == OBMC_CAUSAL) {
counts->obmc[mbmi->sb_type][mbmi->motion_mode == OBMC_CAUSAL]++;
#if CONFIG_NEW_MULTISYMBOL
......@@ -1846,6 +1856,7 @@ static void update_stats(const AV1_COMMON *const cm, ThreadData *td, int mi_row,
mbmi->motion_mode == OBMC_CAUSAL, 2);
#endif
}
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
}
#else
if (motion_allowed > SIMPLE_TRANSLATION) {
......
......@@ -272,7 +272,11 @@ void av1_fill_mode_rates(AV1_COMMON *const cm, MACROBLOCK *x,
}
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
for (i = BLOCK_8X8; i < BLOCK_SIZES_ALL; i++) {
#if CONFIG_NEW_MULTISYMBOL
#if CONFIG_NCOBMC_ADAPT_WEIGHT
av1_cost_tokens_from_cdf(x->motion_mode_cost2[i], fc->ncobmc_cdf[i],
NULL);
#endif
#if CONFIG_NEW_MULTISYMBOL || CONFIG_NCOBMC_ADAPT_WEIGHT
av1_cost_tokens_from_cdf(x->motion_mode_cost1[i], fc->obmc_cdf[i], NULL);
#else
x->motion_mode_cost1[i][0] = av1_cost_bit(fc->obmc_prob[i], 0);
......
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