Commit 94a504af authored by Jingning Han's avatar Jingning Han

Integrate mfmv with codebase

Accomodate recent codebase in the motion field estimation system.
This solves out of boundary buffer access issues.

Change-Id: Ib99b38940690871b700ceb36cdcc015b52aca113
parent 89ff793b
......@@ -1217,6 +1217,7 @@ void av1_setup_frame_buf_refs(AV1_COMMON *cm) {
int lst2_buf_idx = cm->frame_refs[LAST2_FRAME - LAST_FRAME].idx;
int lst3_buf_idx = cm->frame_refs[LAST3_FRAME - LAST_FRAME].idx;
int bwd_buf_idx = cm->frame_refs[BWDREF_FRAME - LAST_FRAME].idx;
int alt2_buf_idx = cm->frame_refs[ALTREF2_FRAME - LAST_FRAME].idx;
#endif
if (alt_buf_idx >= 0)
......@@ -1243,6 +1244,10 @@ void av1_setup_frame_buf_refs(AV1_COMMON *cm) {
if (bwd_buf_idx >= 0)
cm->cur_frame->bwd_frame_offset =
cm->buffer_pool->frame_bufs[bwd_buf_idx].cur_frame_offset;
if (alt2_buf_idx >= 0)
cm->cur_frame->alt2_frame_offset =
cm->buffer_pool->frame_bufs[alt2_buf_idx].cur_frame_offset;
#endif
}
......@@ -1285,7 +1290,8 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
int cur_frame_index = cm->cur_frame->cur_frame_offset;
int lst_frame_index = 0, alt_frame_index = 0, gld_frame_index = 0;
#if CONFIG_EXT_REFS
int lst2_frame_index = 0, lst3_frame_index = 0, bwd_frame_index = 0;
int lst2_frame_index = 0, lst3_frame_index = 0;
int bwd_frame_index = 0, alt2_frame_index = 0;
#endif
TPL_MV_REF *tpl_mvs_base = cm->cur_frame->tpl_mvs;
......@@ -1304,6 +1310,7 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
int lst2_buf_idx = cm->frame_refs[LAST2_FRAME - LAST_FRAME].idx;
int lst3_buf_idx = cm->frame_refs[LAST3_FRAME - LAST_FRAME].idx;
int bwd_buf_idx = cm->frame_refs[BWDREF_FRAME - LAST_FRAME].idx;
int alt2_buf_idx = cm->frame_refs[ALTREF2_FRAME - LAST_FRAME].idx;
#endif
if (alt_buf_idx >= 0)
......@@ -1326,6 +1333,10 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
if (bwd_buf_idx >= 0)
bwd_frame_index = cm->buffer_pool->frame_bufs[bwd_buf_idx].cur_frame_offset;
if (alt2_buf_idx >= 0)
alt2_frame_index =
cm->buffer_pool->frame_bufs[alt2_buf_idx].cur_frame_offset;
#endif
if (alt_frame_index < cur_frame_index) return;
......@@ -1348,6 +1359,8 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
cm->buffer_pool->frame_bufs[lst_buf_idx].lst3_frame_offset;
const int bwd_frame_idx =
cm->buffer_pool->frame_bufs[lst_buf_idx].bwd_frame_offset;
const int alt2_frame_idx =
cm->buffer_pool->frame_bufs[lst_buf_idx].alt2_frame_offset;
#endif
int alt_offset = AOMMAX(1, alt_frame_idx - lst_frame_index);
......@@ -1359,11 +1372,13 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
#if CONFIG_EXT_REFS
int bwd_offset = AOMMAX(1, bwd_frame_idx - lst_frame_index);
int alt2_offset = AOMMAX(1, alt2_frame_idx - lst_frame_index);
int lst2_offset = AOMMAX(1, lst_frame_index - lst2_frame_idx);
int lst3_offset = AOMMAX(1, lst_frame_index - lst3_frame_idx);
int cur_to_lst2 = cur_frame_index - lst2_frame_index;
int cur_to_lst3 = cur_frame_index - lst3_frame_index;
int cur_to_bwd = bwd_frame_index - cur_frame_index;
int cur_to_alt2 = alt2_frame_index - cur_frame_index;
#endif
const int is_lst_overlay = (alt_frame_idx == gld_frame_index);
......@@ -1371,7 +1386,7 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
const int ref_frame_offset_buffer[TOTAL_REFS_PER_FRAME] = {
#if CONFIG_EXT_REFS
0, lst_offset, lst2_offset, lst3_offset, gld_offset,
bwd_offset, alt_offset
bwd_offset, alt2_offset, alt_offset
#else
0, lst_offset, gld_offset, alt_offset
#endif
......@@ -1446,6 +1461,10 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
ref_frame_offset);
tpl_mvs_base[mi_offset].mfmv[FWD_RF_OFFSET(BWDREF_FRAME)]
[0].as_int = this_mv.as_int;
get_mv_projection(&this_mv.as_mv, fwd_mv, cur_to_alt2,
ref_frame_offset);
tpl_mvs_base[mi_offset].mfmv[FWD_RF_OFFSET(ALTREF2_FRAME)]
[0].as_int = this_mv.as_int;
#endif
}
}
......@@ -1469,6 +1488,8 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
cm->buffer_pool->frame_bufs[alt_buf_idx].lst3_frame_offset;
const int bwd_frame_idx =
cm->buffer_pool->frame_bufs[alt_buf_idx].bwd_frame_offset;
const int alt2_frame_idx =
cm->buffer_pool->frame_bufs[alt_buf_idx].alt2_frame_offset;
#endif
int lst_offset = AOMMAX(1, alt_frame_index - lst_frame_idx);
......@@ -1478,18 +1499,20 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
int cur_to_gld = cur_frame_index - gld_frame_index;
#if CONFIG_EXT_REFS
int bwd_offset = AOMMAX(1, alt_frame_index - bwd_frame_idx);
int alt2_offset = AOMMAX(1, alt_frame_index - alt2_frame_idx);
int lst2_offset = AOMMAX(1, alt_frame_index - lst2_frame_idx);
int lst3_offset = AOMMAX(1, alt_frame_index - lst3_frame_idx);
int cur_to_lst2 = cur_frame_index - lst2_frame_index;
int cur_to_lst3 = cur_frame_index - lst3_frame_index;
int cur_to_bwd = bwd_frame_index - cur_frame_index;
int cur_to_alt2 = alt2_frame_index - cur_frame_index;
#endif
const int ref_stamp = FWD_RF_OFFSET(ALTREF_FRAME);
// clang-format off
const int ref_frame_offset_buffer[TOTAL_REFS_PER_FRAME] = {
#if CONFIG_EXT_REFS
0, lst_offset, lst2_offset, lst3_offset, gld_offset,
bwd_offset, 0,
bwd_offset, alt2_offset, 0,
#else
0, lst_offset, gld_offset, 0,
#endif
......@@ -1533,6 +1556,12 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
.mfmv[FWD_RF_OFFSET(BWDREF_FRAME)][ref_stamp]
.as_int = mv_sign_reverse(this_mv);
get_mv_projection(&this_mv.as_mv, fwd_mv, cur_to_alt2,
ref_frame_offset);
tpl_mvs_base[mi_offset]
.mfmv[FWD_RF_OFFSET(ALTREF2_FRAME)][ref_stamp]
.as_int = mv_sign_reverse(this_mv);
if (ref_frame[0] >= LAST2_FRAME) {
get_mv_projection(&this_mv.as_mv, fwd_mv, cur_to_lst2,
ref_frame_offset);
......@@ -1578,6 +1607,8 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
cm->buffer_pool->frame_bufs[bwd_buf_idx].lst3_frame_offset;
const int bwd_frame_idx =
cm->buffer_pool->frame_bufs[bwd_buf_idx].bwd_frame_offset;
const int alt2_frame_idx =
cm->buffer_pool->frame_bufs[bwd_buf_idx].alt2_frame_offset;
const int alt_frame_idx =
cm->buffer_pool->frame_bufs[bwd_buf_idx].alt_frame_offset;
......@@ -1588,6 +1619,7 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
int lst2_offset = AOMMAX(1, bwd_frame_index - lst2_frame_idx);
int lst3_offset = AOMMAX(1, bwd_frame_index - lst3_frame_idx);
int bwd_offset = AOMMAX(1, bwd_frame_idx - bwd_frame_index);
int alt2_offset = AOMMAX(1, alt2_frame_idx - bwd_frame_index);
int alt_offset = AOMMAX(1, alt_frame_idx - bwd_frame_index);
int cur_to_lst2 = cur_frame_index - lst2_frame_index;
int cur_to_lst3 = cur_frame_index - lst3_frame_index;
......@@ -1597,7 +1629,7 @@ void av1_setup_motion_field(AV1_COMMON *cm) {
const int ref_stamp = FWD_RF_OFFSET(BWDREF_FRAME);
const int ref_frame_offset_buffer[TOTAL_REFS_PER_FRAME] = {
0, lst_offset, lst2_offset, lst3_offset,
gld_offset, bwd_offset, alt_offset,
gld_offset, bwd_offset, alt2_offset, alt_offset,
};
for (int blk_row = 0; blk_row < cm->mi_rows; ++blk_row) {
......
......@@ -137,6 +137,7 @@ typedef struct {
int lst2_frame_offset;
int lst3_frame_offset;
int bwd_frame_offset;
int alt2_frame_offset;
#endif
TPL_MV_REF *tpl_mvs;
#endif
......
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