Commit 69b50d28 authored by Jingning Han's avatar Jingning Han

Support context based entropy coding for compound mode syntax

This commit allows the compound mode to use entropy coding contexted
on the dynamic motion vector referencing system.

Change-Id: Ie6f3219183ac3fce322d340728af26c1c1dfa37f
parent 35488f67
......@@ -652,9 +652,13 @@ void av1_find_mv_refs(const AV1_COMMON *cm, const MACROBLOCKD *xd,
int16_t *mode_context) {
#if CONFIG_REF_MV
int idx, all_zero = 1;
#endif
if (ref_frame <= ALTREF_FRAME)
find_mv_refs_idx(cm, xd, mi, ref_frame, mv_ref_list, -1, mi_row, mi_col,
sync, data, mode_context);
#else
find_mv_refs_idx(cm, xd, mi, ref_frame, mv_ref_list, -1, mi_row, mi_col, sync,
data, mode_context);
#endif
#if CONFIG_REF_MV
setup_ref_mv_list(cm, xd, ref_frame,
......@@ -666,8 +670,11 @@ void av1_find_mv_refs(const AV1_COMMON *cm, const MACROBLOCKD *xd,
for (idx = 0; idx < AOMMIN(3, *ref_mv_count); ++idx) {
if (ref_mv_stack[idx].this_mv.as_int != 0)
all_zero = 0;
if (ref_frame > ALTREF_FRAME)
if (ref_mv_stack[idx].comp_mv.as_int != 0)
all_zero = 0;
}
} else {
} else if (ref_frame <= ALTREF_FRAME) {
for (idx = 0; idx < MAX_MV_REF_CANDIDATES; ++idx)
if (mv_ref_list[idx].as_int != 0)
all_zero = 0;
......
......@@ -361,6 +361,8 @@ static int16_t av1_mode_context_analyzer(const int16_t *const mode_context,
const MV_REFERENCE_FRAME *const rf,
BLOCK_SIZE bsize, int block) {
int16_t mode_ctx = 0;
int8_t ref_frame_type = av1_ref_frame_type(rf);
if (block >= 0) {
mode_ctx = mode_context[rf[0]] & 0x00ff;
......@@ -370,12 +372,7 @@ static int16_t av1_mode_context_analyzer(const int16_t *const mode_context,
return mode_ctx;
}
if (rf[1] > INTRA_FRAME)
return mode_context[rf[0]] & (mode_context[rf[1]] | 0x00ff);
else if (rf[0] != ALTREF_FRAME)
return mode_context[rf[0]] & ~(mode_context[ALTREF_FRAME] & 0xfe00);
else
return mode_context[rf[0]];
return mode_context[ref_frame_type];
}
static INLINE uint8_t av1_drl_ctx(const CANDIDATE_MV *ref_mv_stack,
......
......@@ -661,7 +661,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
av1_setup_pre_planes(xd, ref, ref_buf->buf, mi_row, mi_col, &ref_buf->sf);
}
for (ref_frame = LAST_FRAME; ref_frame < MODE_CTX_REF_FRAMES; ++ref_frame) {
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
av1_find_mv_refs(cm, xd, mi, ref_frame,
#if CONFIG_REF_MV
&xd->ref_mv_count[ref_frame],
......@@ -672,6 +672,26 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
}
#if CONFIG_REF_MV
for (; ref_frame < MODE_CTX_REF_FRAMES; ++ref_frame) {
av1_find_mv_refs(cm, xd, mi, ref_frame,
&xd->ref_mv_count[ref_frame],
xd->ref_mv_stack[ref_frame],
ref_mvs[ref_frame], mi_row, mi_col,
fpm_sync, (void *)pbi, inter_mode_ctx);
if (xd->ref_mv_count[ref_frame] < 2) {
MV_REFERENCE_FRAME rf[2];
av1_set_ref_frame(rf, ref_frame);
for (ref = 0; ref < 2; ++ref) {
lower_mv_precision(&ref_mvs[rf[ref]][0].as_mv, allow_hp);
lower_mv_precision(&ref_mvs[rf[ref]][1].as_mv, allow_hp);
}
if (ref_mvs[rf[0]][0].as_int != 0 || ref_mvs[rf[0]][1].as_int != 0 ||
ref_mvs[rf[1]][0].as_int != 0 || ref_mvs[rf[1]][1].as_int != 0)
inter_mode_ctx[ref_frame] &= ~(1 << ALL_ZERO_FLAG_OFFSET);
}
}
mode_ctx = av1_mode_context_analyzer(inter_mode_ctx,
mbmi->ref_frame, bsize, -1);
mbmi->ref_mv_idx = 0;
......
......@@ -3029,6 +3029,16 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
mbmi_ext->ref_mv_stack[ref_frame],
candidates, mi_row, mi_col,
NULL, NULL, mbmi_ext->mode_context);
if (mbmi_ext->ref_mv_count[ref_frame] < 2) {
MV_REFERENCE_FRAME rf[2];
av1_set_ref_frame(rf, ref_frame);
if (mbmi_ext->ref_mvs[rf[0]][0].as_int != 0 ||
mbmi_ext->ref_mvs[rf[0]][1].as_int != 0 ||
mbmi_ext->ref_mvs[rf[1]][0].as_int != 0 ||
mbmi_ext->ref_mvs[rf[1]][1].as_int != 0)
mbmi_ext->mode_context[ref_frame] &= ~(1 << ALL_ZERO_FLAG_OFFSET);
}
}
#endif
......@@ -3642,9 +3652,8 @@ void av1_rd_pick_inter_mode_sb(AV1_COMP *cpi, TileDataEnc *tile_data,
if (best_mbmode.ref_frame[0] > INTRA_FRAME &&
best_mbmode.mv[0].as_int == 0 &&
(best_mbmode.ref_frame[1] == NONE || best_mbmode.mv[1].as_int == 0)) {
int16_t mode_ctx = mbmi_ext->mode_context[best_mbmode.ref_frame[0]];
if (best_mbmode.ref_frame[1] > NONE)
mode_ctx &= (mbmi_ext->mode_context[best_mbmode.ref_frame[1]] | 0x00ff);
int8_t ref_frame_type = av1_ref_frame_type(best_mbmode.ref_frame);
int16_t mode_ctx = mbmi_ext->mode_context[ref_frame_type];
if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET))
best_mbmode.mode = ZEROMV;
}
......
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