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