Commit ca710d68 authored by Wei-Ting Lin's avatar Wei-Ting Lin

ncobmc_adapt_weight: read/write ncobmc mode

An ncobmc mode is selected for each squared block
(if motion_mode == ncobmc_adapt_weight) as opposed
to four in training

Change-Id: I81e5dfca3a6fec5a95c96b17f294530880cf8f88
parent 6c998d75
......@@ -738,7 +738,21 @@ static const aom_prob
{ 86, 22, 32, 25, 10, 40, 97, 65 }, // 32X32
{ 28, 32, 37, 43, 51, 64, 85, 128 } // 64X64 equal prob
};
#endif
static const aom_cdf_prob
default_ncobmc_mode_cdf[ADAPT_OVERLAP_BLOCKS][CDF_SIZE(MAX_NCOBMC_MODES)] =
{ { AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 },
{ AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 },
{ AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 },
{ AOM_ICDF(127), AOM_ICDF(4207), AOM_ICDF(8287), AOM_ICDF(12367),
AOM_ICDF(16447), AOM_ICDF(20527), AOM_ICDF(24607), AOM_ICDF(28687),
AOM_ICDF(32768), 0 } };
#endif // CONFIG_NCOBMC_ADAPT_WEIGHT
// Change this section appropriately once warped motion is supported
#if CONFIG_MOTION_VAR && !CONFIG_WARPED_MOTION
......@@ -4843,10 +4857,11 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
#endif
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
av1_copy(fc->motion_mode_prob, default_motion_mode_prob);
av1_copy(fc->motion_mode_cdf, default_motion_mode_cdf);
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
av1_copy(fc->ncobmc_mode_prob, default_ncobmc_mode_prob);
av1_copy(fc->ncobmc_mode_cdf, default_ncobmc_mode_cdf);
#endif
av1_copy(fc->motion_mode_cdf, default_motion_mode_cdf);
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
av1_copy(fc->obmc_prob, default_obmc_prob);
#if CONFIG_NEW_MULTISYMBOL
......
......@@ -222,7 +222,8 @@ typedef struct frame_contexts {
aom_cdf_prob motion_mode_cdf[BLOCK_SIZES_ALL][CDF_SIZE(MOTION_MODES)];
#if CONFIG_NCOBMC_ADAPT_WEIGHT && CONFIG_MOTION_VAR
aom_prob ncobmc_mode_prob[ADAPT_OVERLAP_BLOCKS][MAX_NCOBMC_MODES - 1];
aom_cdf_prob ncobmc_mode_cdf[BLOCK_SIZES][CDF_SIZE(MAX_NCOBMC_MODES)];
aom_cdf_prob ncobmc_mode_cdf[ADAPT_OVERLAP_BLOCKS]
[CDF_SIZE(MAX_NCOBMC_MODES)];
#endif
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
aom_prob obmc_prob[BLOCK_SIZES_ALL];
......
......@@ -359,22 +359,44 @@ static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
}
#if CONFIG_NCOBMC_ADAPT_WEIGHT
static void read_ncobmc_mode(AV1_COMMON *cm, MACROBLOCKD *xd, MODE_INFO *mi,
NCOBMC_MODE ncobmc_mode[2], aom_reader *r) {
static void read_ncobmc_mode(MACROBLOCKD *xd, MODE_INFO *mi,
#ifndef TRAINING_WEIGHTS
NCOBMC_MODE ncobmc_mode[2],
#else
NCOBMC_MODE ncobmc_mode[][4],
#endif
aom_reader *r) {
MB_MODE_INFO *mbmi = &mi->mbmi;
FRAME_COUNTS *counts = xd->counts;
ADAPT_OVERLAP_BLOCK ao_block = adapt_overlap_block_lookup[mbmi->sb_type];
if (mbmi->motion_mode != NCOBMC_ADAPT_WEIGHT) return;
ncobmc_mode[0] = aom_read_tree(r, av1_ncobmc_mode_tree,
cm->fc->ncobmc_mode_prob[ao_block], ACCT_STR);
#ifndef TRAINING_WEIGHTS
ncobmc_mode[0] = aom_read_symbol(r, xd->tile_ctx->ncobmc_mode_cdf[ao_block],
MAX_NCOBMC_MODES, ACCT_STR);
if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[0]];
if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
ncobmc_mode[1] = aom_read_tree(
r, av1_ncobmc_mode_tree, cm->fc->ncobmc_mode_prob[ao_block], ACCT_STR);
ncobmc_mode[1] = aom_read_symbol(r, xd->tile_ctx->ncobmc_mode_cdf[ao_block],
MAX_NCOBMC_MODES, ACCT_STR);
if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[1]];
}
#else
int i;
for (i = 0; i < 4; ++i) {
ncobmc_mode[0][i] = aom_read_symbol(
r, xd->tile_ctx->ncobmc_mode_cdf[ao_block], MAX_NCOBMC_MODES, ACCT_STR);
if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[0][i]];
}
if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
for (i = 0; i < 4; ++i) {
ncobmc_mode[1][i] =
aom_read_symbol(r, xd->tile_ctx->ncobmc_mode_cdf[ao_block],
MAX_NCOBMC_MODES, ACCT_STR);
if (counts) ++counts->ncobmc_mode[ao_block][ncobmc_mode[1][i]];
}
}
#endif
}
#endif
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
......@@ -2659,7 +2681,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
mbmi->motion_mode = read_motion_mode(cm, xd, mi, r);
#if CONFIG_NCOBMC_ADAPT_WEIGHT
read_ncobmc_mode(cm, xd, mi, mbmi->ncobmc_mode, r);
read_ncobmc_mode(xd, mi, mbmi->ncobmc_mode, r);
#endif
#if CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
......
......@@ -546,19 +546,31 @@ static void write_motion_mode(const AV1_COMMON *cm, MACROBLOCKD *xd,
}
#if CONFIG_NCOBMC_ADAPT_WEIGHT
static void write_ncobmc_mode(const AV1_COMMON *cm, const MODE_INFO *mi,
static void write_ncobmc_mode(MACROBLOCKD *xd, const MODE_INFO *mi,
aom_writer *w) {
const MB_MODE_INFO *mbmi = &mi->mbmi;
ADAPT_OVERLAP_BLOCK ao_block = adapt_overlap_block_lookup[mbmi->sb_type];
if (mbmi->motion_mode != NCOBMC_ADAPT_WEIGHT) return;
av1_write_token(w, av1_ncobmc_mode_tree, cm->fc->ncobmc_mode_prob[ao_block],
&ncobmc_mode_encodings[mbmi->ncobmc_mode[0]]);
#ifndef TRAINING_WEIGHTS
aom_write_symbol(w, mbmi->ncobmc_mode[0],
xd->tile_ctx->ncobmc_mode_cdf[ao_block], MAX_NCOBMC_MODES);
if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
av1_write_token(w, av1_ncobmc_mode_tree, cm->fc->ncobmc_mode_prob[ao_block],
&ncobmc_mode_encodings[mbmi->ncobmc_mode[1]]);
aom_write_symbol(w, mbmi->ncobmc_mode[1],
xd->tile_ctx->ncobmc_mode_cdf[ao_block], MAX_NCOBMC_MODES);
}
#else
int block;
for (block = 0; block < 4; ++block)
aom_write_symbol(w, mbmi->ncobmc_mode[0][block],
xd->tile_ctx->ncobmc_mode_cdf[ao_block], MAX_NCOBMC_MODES);
if (mi_size_wide[mbmi->sb_type] != mi_size_high[mbmi->sb_type]) {
for (block = 0; block < 4; ++block)
aom_write_symbol(w, mbmi->ncobmc_mode[1][block],
xd->tile_ctx->ncobmc_mode_cdf[ao_block],
MAX_NCOBMC_MODES);
}
#endif
}
#endif
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
......@@ -2052,7 +2064,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
#endif // CONFIG_EXT_INTER
write_motion_mode(cm, xd, mi, w);
#if CONFIG_NCOBMC_ADAPT_WEIGHT
write_ncobmc_mode(cm, mi, w);
write_ncobmc_mode(xd, mi, w);
#endif
#endif // 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