Commit 1de6c88a authored by Thomas Davies's avatar Thomas Davies

EC_ADAPT: use tile context for inter mode.

Change-Id: I522dfe77cbe0ea4833d11e25386586d7312c463f
parent cef09627
......@@ -151,15 +151,16 @@ static INTERINTRA_MODE read_interintra_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
}
#endif // CONFIG_EXT_INTER
static PREDICTION_MODE read_inter_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
static PREDICTION_MODE read_inter_mode(FRAME_CONTEXT *ec_ctx, MACROBLOCKD *xd,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
MB_MODE_INFO *mbmi,
#endif
aom_reader *r, int16_t ctx) {
#if CONFIG_REF_MV
FRAME_COUNTS *counts = xd->counts;
int16_t mode_ctx = ctx & NEWMV_CTX_MASK;
aom_prob mode_prob = cm->fc->newmv_prob[mode_ctx];
aom_prob mode_prob = ec_ctx->newmv_prob[mode_ctx];
if (aom_read(r, mode_prob, ACCT_STR) == 0) {
if (counts) ++counts->newmv_mode[mode_ctx][0];
......@@ -170,7 +171,7 @@ static PREDICTION_MODE read_inter_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
return NEWMV;
#if CONFIG_EXT_INTER
} else {
mode_prob = cm->fc->new2mv_prob;
mode_prob = ec_ctx->new2mv_prob;
if (aom_read(r, mode_prob, ACCT_STR) == 0) {
if (counts) ++counts->new2mv_mode[0];
return NEWMV;
......@@ -187,7 +188,7 @@ static PREDICTION_MODE read_inter_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
mode_ctx = (ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
mode_prob = cm->fc->zeromv_prob[mode_ctx];
mode_prob = ec_ctx->zeromv_prob[mode_ctx];
if (aom_read(r, mode_prob, ACCT_STR) == 0) {
if (counts) ++counts->zeromv_mode[mode_ctx][0];
return ZEROMV;
......@@ -200,7 +201,7 @@ static PREDICTION_MODE read_inter_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
if (ctx & (1 << SKIP_NEARMV_OFFSET)) mode_ctx = 7;
if (ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) mode_ctx = 8;
mode_prob = cm->fc->refmv_prob[mode_ctx];
mode_prob = ec_ctx->refmv_prob[mode_ctx];
if (aom_read(r, mode_prob, ACCT_STR) == 0) {
if (counts) ++counts->refmv_mode[mode_ctx][0];
......@@ -216,10 +217,10 @@ static PREDICTION_MODE read_inter_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
#else
#if CONFIG_EC_MULTISYMBOL
const int mode = av1_inter_mode_inv[aom_read_symbol(
r, cm->fc->inter_mode_cdf[ctx], INTER_MODES, ACCT_STR)];
r, ec_ctx->inter_mode_cdf[ctx], INTER_MODES, ACCT_STR)];
#else
const int mode = aom_read_tree(r, av1_inter_mode_tree,
cm->fc->inter_mode_probs[ctx], ACCT_STR);
ec_ctx->inter_mode_probs[ctx], ACCT_STR);
#endif
FRAME_COUNTS *counts = xd->counts;
if (counts) ++counts->inter_mode[ctx][mode];
......@@ -1503,6 +1504,11 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#if CONFIG_WARPED_MOTION
double pts[144], pts_inref[144];
#endif // CONFIG_WARPED_MOTION
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
#else
FRAME_CONTEXT *ec_ctx = cm->fc;
#endif
#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[0] = 0;
......@@ -1592,7 +1598,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
mbmi->mode = read_inter_compound_mode(cm, xd, r, mode_ctx);
else
#endif // CONFIG_EXT_INTER
mbmi->mode = read_inter_mode(cm, xd,
mbmi->mode = read_inter_mode(ec_ctx, xd,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
mbmi,
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
......@@ -1710,7 +1716,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
b_mode = read_inter_compound_mode(cm, xd, r, mode_ctx);
else
#endif // CONFIG_EXT_INTER
b_mode = read_inter_mode(cm, xd,
b_mode = read_inter_mode(ec_ctx, xd,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
mbmi,
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
......
......@@ -215,20 +215,20 @@ static void write_interintra_mode(aom_writer *w, INTERINTRA_MODE mode,
}
#endif // CONFIG_EXT_INTER
static void write_inter_mode(AV1_COMMON *cm, aom_writer *w,
PREDICTION_MODE mode,
static void write_inter_mode(aom_writer *w, PREDICTION_MODE mode,
FRAME_CONTEXT *ec_ctx,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
int is_compound,
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
const int16_t mode_ctx) {
#if CONFIG_REF_MV
const int16_t newmv_ctx = mode_ctx & NEWMV_CTX_MASK;
const aom_prob newmv_prob = cm->fc->newmv_prob[newmv_ctx];
const aom_prob newmv_prob = ec_ctx->newmv_prob[newmv_ctx];
#if CONFIG_EXT_INTER
aom_write(w, mode != NEWMV && mode != NEWFROMNEARMV, newmv_prob);
if (!is_compound && (mode == NEWMV || mode == NEWFROMNEARMV))
aom_write(w, mode == NEWFROMNEARMV, cm->fc->new2mv_prob);
aom_write(w, mode == NEWFROMNEARMV, ec_ctx->new2mv_prob);
if (mode != NEWMV && mode != NEWFROMNEARMV) {
#else
......@@ -237,7 +237,7 @@ static void write_inter_mode(AV1_COMMON *cm, aom_writer *w,
if (mode != NEWMV) {
#endif // CONFIG_EXT_INTER
const int16_t zeromv_ctx = (mode_ctx >> ZEROMV_OFFSET) & ZEROMV_CTX_MASK;
const aom_prob zeromv_prob = cm->fc->zeromv_prob[zeromv_ctx];
const aom_prob zeromv_prob = ec_ctx->zeromv_prob[zeromv_ctx];
if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) {
assert(mode == ZEROMV);
......@@ -254,7 +254,7 @@ static void write_inter_mode(AV1_COMMON *cm, aom_writer *w,
if (mode_ctx & (1 << SKIP_NEARMV_OFFSET)) refmv_ctx = 7;
if (mode_ctx & (1 << SKIP_NEARESTMV_SUB8X8_OFFSET)) refmv_ctx = 8;
refmv_prob = cm->fc->refmv_prob[refmv_ctx];
refmv_prob = ec_ctx->refmv_prob[refmv_ctx];
aom_write(w, mode != NEARESTMV, refmv_prob);
}
}
......@@ -262,10 +262,10 @@ static void write_inter_mode(AV1_COMMON *cm, aom_writer *w,
assert(is_inter_mode(mode));
#if CONFIG_EC_MULTISYMBOL
aom_write_symbol(w, av1_inter_mode_ind[INTER_OFFSET(mode)],
cm->fc->inter_mode_cdf[mode_ctx], INTER_MODES);
ec_ctx->inter_mode_cdf[mode_ctx], INTER_MODES);
#else
{
const aom_prob *const inter_probs = cm->fc->inter_mode_probs[mode_ctx];
const aom_prob *const inter_probs = ec_ctx->inter_mode_probs[mode_ctx];
av1_write_token(w, av1_inter_mode_tree, inter_probs,
&inter_mode_encodings[INTER_OFFSET(mode)]);
}
......@@ -1421,7 +1421,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
write_inter_compound_mode(cm, w, mode, mode_ctx);
else if (is_inter_singleref_mode(mode))
#endif // CONFIG_EXT_INTER
write_inter_mode(cm, w, mode,
write_inter_mode(w, mode, ec_ctx,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
is_compound,
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
......@@ -1458,7 +1458,7 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const MODE_INFO *mi,
write_inter_compound_mode(cm, w, b_mode, mode_ctx);
else if (is_inter_singleref_mode(b_mode))
#endif // CONFIG_EXT_INTER
write_inter_mode(cm, w, b_mode,
write_inter_mode(w, b_mode, ec_ctx,
#if CONFIG_REF_MV && CONFIG_EXT_INTER
has_second_ref(mbmi),
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
......
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