Commit 149eda56 authored by Thomas Davies's avatar Thomas Davies

NEW_MULTISYMBOL: adapt inter mode flags.

Old inter_mode coding was obsoleted by REF_MV.

Change-Id: Ib812f626fe9f8e3342eee5d7b0214ed55701bec3
parent f6ad9355
......@@ -5690,13 +5690,18 @@ void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
aom_cdf_prob *fc_cdf_ptr;
// FIXME: comp_inter_cdf not defined
// FIXME: comp_inter_cdf not defined
// FIXME: comp_ref_cdf and comp_bwd_ref not defined
// FIXME: comp_ref_cdf and comp_bwd_ref not defined
// FIXME: single_ref_cdf not defined
// FIXME: single_ref_cdf not defined
// FIXME: cdfs not defined for newmv_mode, zeromv_mode, drl_mode, new2mv_mode
#if CONFIG_NEW_MULTISYMBOL
AVERAGE_TILE_CDFS(newmv_cdf)
AVERAGE_TILE_CDFS(zeromv_cdf)
AVERAGE_TILE_CDFS(refmv_cdf)
AVERAGE_TILE_CDFS(drl_cdf)
#endif
// FIXME: cdfs not defined for motion_mode_prob, obmc_prob
......
......@@ -1000,6 +1000,36 @@ static const aom_prob default_refmv_prob[REFMV_MODE_CONTEXTS] = {
static const aom_prob default_drl_prob[DRL_MODE_CONTEXTS] = { 128, 160, 180,
128, 160 };
#if CONFIG_NEW_MULTISYMBOL
static const aom_cdf_prob default_newmv_cdf[NEWMV_MODE_CONTEXTS][CDF_SIZE(2)] =
{ { AOM_ICDF(128 * 200), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 150), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 150), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 110), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 70), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 60), AOM_ICDF(32768), 0 } };
static const aom_cdf_prob default_zeromv_cdf[ZEROMV_MODE_CONTEXTS][CDF_SIZE(
2)] = { { AOM_ICDF(128 * 192), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 64), AOM_ICDF(32768), 0 } };
static const aom_cdf_prob default_refmv_cdf[REFMV_MODE_CONTEXTS][CDF_SIZE(2)] =
{ { AOM_ICDF(128 * 220), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 220), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 200), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 200), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 30), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 220), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 30), AOM_ICDF(32768), 0 } };
static const aom_cdf_prob default_drl_cdf[DRL_MODE_CONTEXTS][CDF_SIZE(2)] = {
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 160), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 180), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 128), AOM_ICDF(32768), 0 },
{ AOM_ICDF(128 * 160), AOM_ICDF(32768), 0 }
};
#endif
#if CONFIG_EXT_INTER
static const aom_prob default_inter_compound_mode_probs
......@@ -4521,6 +4551,12 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->zeromv_prob, default_zeromv_prob);
av1_copy(fc->refmv_prob, default_refmv_prob);
av1_copy(fc->drl_prob, default_drl_prob);
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->newmv_cdf, default_newmv_cdf);
av1_copy(fc->zeromv_cdf, default_zeromv_cdf);
av1_copy(fc->refmv_cdf, default_refmv_cdf);
av1_copy(fc->drl_cdf, default_drl_cdf);
#endif
#if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
av1_copy(fc->motion_mode_prob, default_motion_mode_prob);
#if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
......
......@@ -185,6 +185,12 @@ typedef struct frame_contexts {
aom_prob zeromv_prob[ZEROMV_MODE_CONTEXTS];
aom_prob refmv_prob[REFMV_MODE_CONTEXTS];
aom_prob drl_prob[DRL_MODE_CONTEXTS];
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob newmv_cdf[NEWMV_MODE_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob zeromv_cdf[ZEROMV_MODE_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob refmv_cdf[REFMV_MODE_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob drl_cdf[DRL_MODE_CONTEXTS][CDF_SIZE(2)];
#endif
#if CONFIG_EXT_INTER
aom_prob inter_compound_mode_probs[INTER_MODE_CONTEXTS]
......
......@@ -192,6 +192,7 @@ static void read_switchable_interp_probs(FRAME_CONTEXT *fc, aom_reader *r) {
}
#endif
#if !CONFIG_NEW_MULTISYMBOL
static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
int i;
for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
......@@ -203,6 +204,7 @@ static void read_inter_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
for (i = 0; i < DRL_MODE_CONTEXTS; ++i)
av1_diff_update_prob(r, &fc->drl_prob[i], ACCT_STR);
}
#endif
#if CONFIG_EXT_INTER
static void read_inter_compound_mode_probs(FRAME_CONTEXT *fc, aom_reader *r) {
......@@ -5060,7 +5062,9 @@ static int read_compressed_header(AV1Decoder *pbi, const uint8_t *data,
}
#endif
} else {
#if !CONFIG_NEW_MULTISYMBOL
read_inter_mode_probs(fc, &r);
#endif
#if CONFIG_EXT_INTER
read_inter_compound_mode_probs(fc, &r);
......
......@@ -201,9 +201,14 @@ static PREDICTION_MODE read_inter_mode(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
aom_reader *r, int16_t ctx) {
FRAME_COUNTS *counts = xd->counts;
int16_t mode_ctx = ctx & NEWMV_CTX_MASK;
aom_prob mode_prob = ec_ctx->newmv_prob[mode_ctx];
int is_newmv, is_zeromv, is_refmv;
#if CONFIG_NEW_MULTISYMBOL
is_newmv = aom_read_symbol(r, ec_ctx->newmv_cdf[mode_ctx], 2, ACCT_STR) == 0;
#else
is_newmv = aom_read(r, ec_ctx->newmv_prob[mode_ctx], ACCT_STR) == 0;
#endif
if (aom_read(r, mode_prob, ACCT_STR) == 0) {
if (is_newmv) {
if (counts) ++counts->newmv_mode[mode_ctx][0];
return NEWMV;
}
......@@ -213,8 +218,13 @@ static PREDICTION_MODE read_inter_mode(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
mode_ctx = (ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
mode_prob = ec_ctx->zeromv_prob[mode_ctx];
if (aom_read(r, mode_prob, ACCT_STR) == 0) {
#if CONFIG_NEW_MULTISYMBOL
is_zeromv =
aom_read_symbol(r, ec_ctx->zeromv_cdf[mode_ctx], 2, ACCT_STR) == 0;
#else
is_zeromv = aom_read(r, ec_ctx->zeromv_prob[mode_ctx], ACCT_STR) == 0;
#endif
if (is_zeromv) {
if (counts) ++counts->zeromv_mode[mode_ctx][0];
return ZEROMV;
}
......@@ -226,9 +236,13 @@ static PREDICTION_MODE read_inter_mode(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
if (ctx & (1 << SKIP_NEARMV_OFFSET)) mode_ctx = 7;
if (ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) mode_ctx = 8;
mode_prob = ec_ctx->refmv_prob[mode_ctx];
#if CONFIG_NEW_MULTISYMBOL
is_refmv = aom_read_symbol(r, ec_ctx->refmv_cdf[mode_ctx], 2, ACCT_STR) == 0;
#else
is_refmv = aom_read(r, ec_ctx->refmv_prob[mode_ctx], ACCT_STR) == 0;
#endif
if (aom_read(r, mode_prob, ACCT_STR) == 0) {
if (is_refmv) {
if (counts) ++counts->refmv_mode[mode_ctx][0];
return NEARESTMV;
......@@ -241,7 +255,7 @@ static PREDICTION_MODE read_inter_mode(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
assert(0);
}
static void read_drl_idx(const AV1_COMMON *cm, MACROBLOCKD *xd,
static void read_drl_idx(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
MB_MODE_INFO *mbmi, aom_reader *r) {
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
mbmi->ref_mv_idx = 0;
......@@ -260,14 +274,14 @@ static void read_drl_idx(const AV1_COMMON *cm, MACROBLOCKD *xd,
for (idx = 0; idx < 2; ++idx) {
if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
if (!aom_read(r, drl_prob, ACCT_STR)) {
mbmi->ref_mv_idx = idx;
if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0];
return;
}
mbmi->ref_mv_idx = idx + 1;
if (xd->counts) ++xd->counts->drl_mode[drl_ctx][1];
#if CONFIG_NEW_MULTISYMBOL
int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR);
#else
int drl_idx = aom_read(r, ec_ctx->drl_prob[drl_ctx], ACCT_STR);
#endif
mbmi->ref_mv_idx = idx + drl_idx;
if (xd->counts) ++xd->counts->drl_mode[drl_ctx][drl_idx];
if (!drl_idx) return;
}
}
}
......@@ -280,14 +294,14 @@ static void read_drl_idx(const AV1_COMMON *cm, MACROBLOCKD *xd,
for (idx = 1; idx < 3; ++idx) {
if (xd->ref_mv_count[ref_frame_type] > idx + 1) {
uint8_t drl_ctx = av1_drl_ctx(xd->ref_mv_stack[ref_frame_type], idx);
aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
if (!aom_read(r, drl_prob, ACCT_STR)) {
mbmi->ref_mv_idx = idx - 1;
if (xd->counts) ++xd->counts->drl_mode[drl_ctx][0];
return;
}
mbmi->ref_mv_idx = idx;
if (xd->counts) ++xd->counts->drl_mode[drl_ctx][1];
#if CONFIG_NEW_MULTISYMBOL
int drl_idx = aom_read_symbol(r, ec_ctx->drl_cdf[drl_ctx], 2, ACCT_STR);
#else
int drl_idx = aom_read(r, ec_ctx->drl_prob[drl_ctx], ACCT_STR);
#endif
mbmi->ref_mv_idx = idx + drl_idx - 1;
if (xd->counts) ++xd->counts->drl_mode[drl_ctx][drl_idx];
if (!drl_idx) return;
}
}
}
......@@ -2059,7 +2073,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#else // !CONFIG_EXT_INTER
if (mbmi->mode == NEARMV || mbmi->mode == NEWMV)
#endif // CONFIG_EXT_INTER
read_drl_idx(cm, xd, mbmi, r);
read_drl_idx(ec_ctx, xd, mbmi, r);
}
}
......
......@@ -226,36 +226,42 @@ static void write_interintra_mode(aom_writer *w, INTERINTRA_MODE mode,
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;
const aom_prob newmv_prob = ec_ctx->newmv_prob[newmv_ctx];
aom_write(w, mode != NEWMV, newmv_prob);
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, mode != NEWMV, ec_ctx->newmv_cdf[newmv_ctx], 2);
#else
aom_write(w, mode != NEWMV, ec_ctx->newmv_prob[newmv_ctx]);
#endif
if (mode != NEWMV) {
const int16_t zeromv_ctx = (mode_ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
const aom_prob zeromv_prob = ec_ctx->zeromv_prob[zeromv_ctx];
if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) {
assert(mode == ZEROMV);
return;
}
aom_write(w, mode != ZEROMV, zeromv_prob);
const int16_t zeromv_ctx = (mode_ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, mode != ZEROMV, ec_ctx->zeromv_cdf[zeromv_ctx], 2);
#else
aom_write(w, mode != ZEROMV, ec_ctx->zeromv_prob[zeromv_ctx]);
#endif
if (mode != ZEROMV) {
int16_t refmv_ctx = (mode_ctx >> REFMV_OFFSET) & REFMV_CTX_MASK;
aom_prob refmv_prob;
if (mode_ctx & (1 << SKIP_NEARESTMV_OFFSET)) refmv_ctx = 6;
if (mode_ctx & (1 << SKIP_NEARMV_OFFSET)) refmv_ctx = 7;
if (mode_ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) refmv_ctx = 8;
refmv_prob = ec_ctx->refmv_prob[refmv_ctx];
aom_write(w, mode != NEARESTMV, refmv_prob);
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, mode != NEARESTMV, ec_ctx->refmv_cdf[refmv_ctx], 2);
#else
aom_write(w, mode != NEARESTMV, ec_ctx->refmv_prob[refmv_ctx]);
#endif
}
}
}
static void write_drl_idx(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
static void write_drl_idx(FRAME_CONTEXT *ec_ctx, const MB_MODE_INFO *mbmi,
const MB_MODE_INFO_EXT *mbmi_ext, aom_writer *w) {
uint8_t ref_frame_type = av1_ref_frame_type(mbmi->ref_frame);
......@@ -276,9 +282,13 @@ static void write_drl_idx(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) {
uint8_t drl_ctx =
av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx);
aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
aom_write(w, mbmi->ref_mv_idx != idx, drl_prob);
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, mbmi->ref_mv_idx != idx, ec_ctx->drl_cdf[drl_ctx],
2);
#else
aom_write(w, mbmi->ref_mv_idx != idx, ec_ctx->drl_prob[drl_ctx]);
#endif
if (mbmi->ref_mv_idx == idx) return;
}
}
......@@ -292,9 +302,12 @@ static void write_drl_idx(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
if (mbmi_ext->ref_mv_count[ref_frame_type] > idx + 1) {
uint8_t drl_ctx =
av1_drl_ctx(mbmi_ext->ref_mv_stack[ref_frame_type], idx);
aom_prob drl_prob = cm->fc->drl_prob[drl_ctx];
aom_write(w, mbmi->ref_mv_idx != (idx - 1), drl_prob);
#if CONFIG_NEW_MULTISYMBOL
aom_write_symbol(w, mbmi->ref_mv_idx != (idx - 1),
ec_ctx->drl_cdf[drl_ctx], 2);
#else
aom_write(w, mbmi->ref_mv_idx != (idx - 1), ec_ctx->drl_prob[drl_ctx]);
#endif
if (mbmi->ref_mv_idx == (idx - 1)) return;
}
}
......@@ -467,6 +480,7 @@ static void write_selected_tx_size(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
}
#if !CONFIG_NEW_MULTISYMBOL
static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
FRAME_COUNTS *counts) {
int i;
......@@ -488,6 +502,7 @@ static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
av1_cond_prob_diff_update(w, &cm->fc->drl_prob[i], counts->drl_mode[i],
probwt);
}
#endif
#if CONFIG_EXT_INTER
static void update_inter_compound_mode_probs(AV1_COMMON *cm, int probwt,
......@@ -2006,7 +2021,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
#else // !CONFIG_EXT_INTER
if (mode == NEARMV || mode == NEWMV)
#endif // CONFIG_EXT_INTER
write_drl_idx(cm, mbmi, mbmi_ext, w);
write_drl_idx(ec_ctx, mbmi, mbmi_ext, w);
else
assert(mbmi->ref_mv_idx == 0);
}
......@@ -4942,7 +4957,9 @@ static uint32_t write_compressed_header(AV1_COMP *cpi, uint8_t *data) {
}
#endif
} else {
#if !CONFIG_NEW_MULTISYMBOL
update_inter_mode_probs(cm, header_bc, counts);
#endif
#if CONFIG_EXT_INTER
update_inter_compound_mode_probs(cm, probwt, header_bc);
#if CONFIG_COMPOUND_SINGLEREF
......
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