Commit febb59cd authored by Debargha Mukherjee's avatar Debargha Mukherjee

Allow global motion based translation for sub8x8

Also handle block centers for sub8x8 blocks correctly.

BDRATE: lowres: -1.308%

Change-Id: I6bdb25bdaceb5086a8b951617fd62ed41cd89023
parent 5dcc48ba
......@@ -1131,6 +1131,9 @@ static INLINE int is_nontrans_global_motion(const MACROBLOCKD *xd) {
if (mbmi->mode != ZEROMV) return 0;
#endif // CONFIG_EXT_INTER
} else {
#if !GLOBAL_SUB8X8_USED
return 0;
#endif // !GLOBAL_SUB8X8_USED
#if CONFIG_EXT_INTER
if (mi->bmi[0].as_mode != ZEROMV || mi->bmi[1].as_mode != ZEROMV ||
mi->bmi[2].as_mode != ZEROMV || mi->bmi[3].as_mode != ZEROMV ||
......
......@@ -152,33 +152,33 @@ typedef struct {
static INLINE int block_center_x(int mi_col, BLOCK_SIZE bs) {
const int bw = block_size_wide[bs];
return mi_col * MI_SIZE + AOMMAX(bw, MI_SIZE) / 2;
return mi_col * MI_SIZE + bw / 2;
}
static INLINE int block_center_y(int mi_row, BLOCK_SIZE bs) {
const int bh = block_size_high[bs];
return mi_row * MI_SIZE + AOMMAX(bh, MI_SIZE) / 2;
return mi_row * MI_SIZE + bh / 2;
}
// Convert a global motion translation vector (which may have more bits than a
// regular motion vector) into a motion vector
static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm,
int allow_hp, BLOCK_SIZE bsize,
int mi_col, int mi_row) {
#if !GLOBAL_SUB8X8_USED
if (bsize < BLOCK_8X8) {
int_mv res_zero;
res_zero.as_mv.row = 0;
res_zero.as_mv.col = 0;
return res_zero;
}
#endif
int mi_col, int mi_row,
int block_idx) {
const int unify_bsize = CONFIG_CB4X4;
int_mv res;
const int32_t *mat = gm->wmmat;
const int x = block_center_x(mi_col, bsize);
const int y = block_center_y(mi_row, bsize);
int xc, yc;
int xc, yc, x, y;
if (bsize >= BLOCK_8X8 || unify_bsize) {
x = block_center_x(mi_col, bsize);
y = block_center_y(mi_row, bsize);
} else {
x = block_center_x(mi_col, bsize);
y = block_center_y(mi_row, bsize);
x += (block_idx & 1) * MI_SIZE / 2;
y += (block_idx & 2) * MI_SIZE / 4;
}
int shift = allow_hp ? WARPEDMODEL_PREC_BITS - 3 : WARPEDMODEL_PREC_BITS - 2;
int scale = allow_hp ? 0 : 1;
......
......@@ -940,20 +940,20 @@ void av1_find_mv_refs(const AV1_COMMON *cm, const MACROBLOCKD *xd,
#if CONFIG_GLOBAL_MOTION
#if CONFIG_REF_MV
av1_set_ref_frame(rf, ref_frame);
zeromv[0].as_int =
gm_get_motion_vector(&cm->global_motion[rf[0]],
cm->allow_high_precision_mv, bsize, mi_col, mi_row)
zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[rf[0]],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row, 0)
.as_int;
zeromv[1].as_int = (rf[1] != NONE_FRAME)
? gm_get_motion_vector(&cm->global_motion[rf[1]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int
: 0;
#else
zeromv[0].as_int =
gm_get_motion_vector(&cm->global_motion[ref_frame],
cm->allow_high_precision_mv, bsize, mi_col, mi_row)
zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row, 0)
.as_int;
zeromv[1].as_int = 0;
#endif // CONFIG_REF_MV
......@@ -1041,7 +1041,7 @@ void av1_append_sub8x8_mvs_for_idx(const AV1_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_GLOBAL_MOTION
zeromv.as_int =
gm_get_motion_vector(&cm->global_motion[ref], cm->allow_high_precision_mv,
mi->mbmi.sb_type, mi_col, mi_row)
mi->mbmi.sb_type, mi_col, mi_row, block)
.as_int;
#else
zeromv.as_int = 0;
......
......@@ -1360,12 +1360,12 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_GLOBAL_MOTION
mv[0].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[0]],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row)
mi_col, mi_row, block)
.as_int;
if (is_compound)
mv[1].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[1]],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row)
mi_col, mi_row, block)
.as_int;
#else
mv[0].as_int = 0;
......@@ -1373,8 +1373,8 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
#endif // CONFIG_GLOBAL_MOTION
#if CONFIG_REF_MV
pred_mv[0].as_int = 0;
if (is_compound) pred_mv[1].as_int = 0;
pred_mv[0].as_int = mv[0].as_int;
if (is_compound) pred_mv[1].as_int = mv[1].as_int;
#endif
break;
}
......@@ -1515,11 +1515,11 @@ static INLINE int assign_mv(AV1_COMMON *cm, MACROBLOCKD *xd,
#if CONFIG_GLOBAL_MOTION
mv[0].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[0]],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row)
mi_col, mi_row, block)
.as_int;
mv[1].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[1]],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row)
mi_col, mi_row, block)
.as_int;
#else
mv[0].as_int = 0;
......@@ -1627,12 +1627,12 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#if CONFIG_GLOBAL_MOTION
zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[rf[0]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int;
zeromv[1].as_int = (rf[1] != NONE_FRAME)
? gm_get_motion_vector(&cm->global_motion[rf[1]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int
: 0;
#else
......
......@@ -5046,7 +5046,7 @@ static int set_and_cost_bmi_mvs(
gm_get_motion_vector(
&cpi->common.global_motion[mbmi->ref_frame[ref]],
cpi->common.allow_high_precision_mv, mbmi->sb_type, mi_col,
mi_row)
mi_row, i)
.as_int;
thismvcost += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[ref]);
#else
......@@ -5104,12 +5104,12 @@ static int set_and_cost_bmi_mvs(
this_mv[0].as_int =
gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[0]],
cpi->common.allow_high_precision_mv,
mbmi->sb_type, mi_col, mi_row)
mbmi->sb_type, mi_col, mi_row, i)
.as_int;
this_mv[1].as_int =
gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[1]],
cpi->common.allow_high_precision_mv,
mbmi->sb_type, mi_col, mi_row)
mbmi->sb_type, mi_col, mi_row, i)
.as_int;
thismvcost += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[0]) +
GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[1]);
......@@ -5380,7 +5380,7 @@ static int check_best_zero_mv(
zeromv[cur_frm].as_int =
gm_get_motion_vector(&cpi->common.global_motion[ref_frames[cur_frm]],
cpi->common.allow_high_precision_mv, bsize,
mi_col, mi_row)
mi_col, mi_row, block)
.as_int;
else
#endif // CONFIG_GLOBAL_MOTION
......@@ -5842,7 +5842,7 @@ static int64_t rd_pick_inter_best_sub8x8_mode(
frame_mv[ZEROMV][frame].as_int =
gm_get_motion_vector(&cm->global_motion[frame],
cm->allow_high_precision_mv, mbmi->sb_type,
mi_col, mi_row)
mi_col, mi_row, index)
.as_int;
#else // CONFIG_GLOBAL_MOTION
frame_mv[ZEROMV][frame].as_int = 0;
......@@ -5875,7 +5875,7 @@ static int64_t rd_pick_inter_best_sub8x8_mode(
frame_mv[ZERO_ZEROMV][frame].as_int =
gm_get_motion_vector(&cm->global_motion[frame],
cm->allow_high_precision_mv, mbmi->sb_type,
mi_col, mi_row)
mi_col, mi_row, index)
.as_int;
#else
frame_mv[ZERO_ZEROMV][frame].as_int = 0;
......@@ -9602,7 +9602,8 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
#if CONFIG_GLOBAL_MOTION
frame_mv[ZEROMV][ref_frame].as_int =
gm_get_motion_vector(&cm->global_motion[ref_frame],
cm->allow_high_precision_mv, bsize, mi_col, mi_row)
cm->allow_high_precision_mv, bsize, mi_col, mi_row,
0)
.as_int;
#else // CONFIG_GLOBAL_MOTION
frame_mv[ZEROMV][ref_frame].as_int = 0;
......@@ -9613,7 +9614,8 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
#if CONFIG_GLOBAL_MOTION
frame_mv[ZERO_ZEROMV][ref_frame].as_int =
gm_get_motion_vector(&cm->global_motion[ref_frame],
cm->allow_high_precision_mv, bsize, mi_col, mi_row)
cm->allow_high_precision_mv, bsize, mi_col, mi_row,
0)
.as_int;
#else // CONFIG_GLOBAL_MOTION
frame_mv[ZERO_ZEROMV][ref_frame].as_int = 0;
......@@ -9724,7 +9726,7 @@ void av1_rd_pick_inter_mode_sb(const AV1_COMP *cpi, TileDataEnc *tile_data,
#if CONFIG_GLOBAL_MOTION
zeromv.as_int = gm_get_motion_vector(&cm->global_motion[ALTREF_FRAME],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row)
mi_col, mi_row, 0)
.as_int;
#else
zeromv.as_int = 0;
......@@ -10918,14 +10920,14 @@ PALETTE_EXIT:
const uint8_t rf_type = av1_ref_frame_type(best_mbmode.ref_frame);
#endif // CONFIG_REF_MV
#if CONFIG_GLOBAL_MOTION
zeromv[0].as_int =
gm_get_motion_vector(&cm->global_motion[refs[0]],
cm->allow_high_precision_mv, bsize, mi_col, mi_row)
zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[refs[0]],
cm->allow_high_precision_mv, bsize,
mi_col, mi_row, 0)
.as_int;
zeromv[1].as_int = comp_pred_mode
? gm_get_motion_vector(&cm->global_motion[refs[1]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int
: 0;
#else
......@@ -11037,12 +11039,12 @@ PALETTE_EXIT:
#if CONFIG_GLOBAL_MOTION
zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[refs[0]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int;
zeromv[1].as_int = comp_pred_mode
? gm_get_motion_vector(&cm->global_motion[refs[1]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int
: 0;
#else
......@@ -11088,11 +11090,11 @@ PALETTE_EXIT:
best_mbmode.ref_frame[1] };
zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[refs[0]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int;
zeromv[1].as_int = gm_get_motion_vector(&cm->global_motion[refs[1]],
cm->allow_high_precision_mv,
bsize, mi_col, mi_row)
bsize, mi_col, mi_row, 0)
.as_int;
lower_mv_precision(&zeromv[0].as_mv, cm->allow_high_precision_mv);
lower_mv_precision(&zeromv[1].as_mv, cm->allow_high_precision_mv);
......@@ -11254,7 +11256,8 @@ void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
#if CONFIG_GLOBAL_MOTION
mbmi->mv[0].as_int =
gm_get_motion_vector(&cm->global_motion[mbmi->ref_frame[0]],
cm->allow_high_precision_mv, bsize, mi_col, mi_row)
cm->allow_high_precision_mv, bsize, mi_col, mi_row,
0)
.as_int;
#else // CONFIG_GLOBAL_MOTION
mbmi->mv[0].as_int = 0;
......
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