Commit e6eb3b53 authored by Debargha Mukherjee's avatar Debargha Mukherjee

Integerize warped motion computation

Integerizes computation of the least squares for warped motion.
The model is restricted to only Affine. Affine seems easiest
to compute and integerize since it can be split into two 3-dim
least squares problems, as opposed to rotation-zoom which needs
a 4-dim least-squares problem to be solved.
The current implementation requires only one division per block.

BDRATE impact is mminimal. The upgrade to the affine model improves
coding efficiency but integerization also degrades efficiency a
little. Overall there is a net gain of about -0.07% BDRATE on
the lowres set.
BDRATE lowres: -1.113% with ----enable-warped-motion vs. without
(up from -1.044%).

Change-Id: I6b9216ac0737d76f59054293eabee48e17739ec4
parent 4db04d36
......@@ -1114,7 +1114,7 @@ void calc_projection_samples(MB_MODE_INFO *const mbmi,
#if CONFIG_GLOBAL_MOTION
MACROBLOCKD *xd,
#endif
int x, int y, double *pts_inref) {
int x, int y, int *pts_inref) {
if (mbmi->motion_mode == WARPED_CAUSAL
#if CONFIG_GLOBAL_MOTION
|| (mbmi->mode == ZEROMV &&
......@@ -1131,16 +1131,19 @@ void calc_projection_samples(MB_MODE_INFO *const mbmi,
&mbmi->wm_params[0];
project_points(wm, ipts, ipts_inref, 1, 2, 2, 0, 0);
pts_inref[0] = (double)ipts_inref[0] / (double)WARPEDPIXEL_PREC_SHIFTS;
pts_inref[1] = (double)ipts_inref[1] / (double)WARPEDPIXEL_PREC_SHIFTS;
pts_inref[0] =
ROUND_POWER_OF_TWO_SIGNED(ipts_inref[0], WARPEDPIXEL_PREC_BITS - 3);
pts_inref[1] =
ROUND_POWER_OF_TWO_SIGNED(ipts_inref[1], WARPEDPIXEL_PREC_BITS - 3);
} else {
pts_inref[0] = (double)x + (double)(mbmi->mv[0].as_mv.col) * 0.125;
pts_inref[1] = (double)y + (double)(mbmi->mv[0].as_mv.row) * 0.125;
pts_inref[0] = (x * 8) + mbmi->mv[0].as_mv.col;
pts_inref[1] = (y * 8) + mbmi->mv[0].as_mv.row;
}
}
// Note: Samples returned are at 1/8-pel precision
int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
double *pts, double *pts_inref) {
int *pts, int *pts_inref) {
MB_MODE_INFO *const mbmi0 = &(xd->mi[0]->mbmi);
int ref_frame = mbmi0->ref_frame[0];
int up_available = xd->up_available;
......@@ -1178,8 +1181,8 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
int x = cc_offset + j % 2 + global_offset_c;
int y = cr_offset + j / 2 + global_offset_r;
pts[0] = (double)x;
pts[1] = (double)y;
pts[0] = (x * 8);
pts[1] = (y * 8);
calc_projection_samples(mbmi,
#if CONFIG_GLOBAL_MOTION
xd,
......@@ -1221,8 +1224,8 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
int x = cc_offset + j % 2 + global_offset_c;
int y = cr_offset + j / 2 + global_offset_r;
pts[0] = (double)x;
pts[1] = (double)y;
pts[0] = (x * 8);
pts[1] = (y * 8);
calc_projection_samples(mbmi,
#if CONFIG_GLOBAL_MOTION
xd,
......@@ -1260,8 +1263,8 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
int x = cc_offset + j % 2 + global_offset_c;
int y = cr_offset + j / 2 + global_offset_r;
pts[0] = (double)x;
pts[1] = (double)y;
pts[0] = (x * 8);
pts[1] = (y * 8);
calc_projection_samples(mbmi,
#if CONFIG_GLOBAL_MOTION
xd,
......@@ -1298,11 +1301,13 @@ int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
int r_offset = j / 2;
int c_offset = j % 2;
pts[0] = (double)(cc_offset + c_offset + global_offset_c);
pts[1] = (double)(cr_offset + r_offset + global_offset_r);
int x = (cc_offset + c_offset + global_offset_c);
int y = (cr_offset + r_offset + global_offset_r);
pts_inref[0] = pts[0] + (double)(mv_col)*0.125;
pts_inref[1] = pts[1] + (double)(mv_row)*0.125;
pts[0] = (x * 8);
pts[1] = (y * 8);
pts_inref[0] = pts[0] + mv_col;
pts_inref[1] = pts[1] + mv_row;
pts += 2;
pts_inref += 2;
......
......@@ -515,7 +515,7 @@ void av1_update_mv_context(const MACROBLOCKD *xd, MODE_INFO *mi,
#if CONFIG_WARPED_MOTION
int findSamples(const AV1_COMMON *cm, MACROBLOCKD *xd, int mi_row, int mi_col,
double *pts, double *pts_inref);
int *pts, int *pts_inref);
#endif // CONFIG_WARPED_MOTION
#ifdef __cplusplus
......
This diff is collapsed.
......@@ -27,7 +27,7 @@
#if CONFIG_WARPED_MOTION
#define SAMPLES_PER_NEIGHBOR 4
#define SAMPLES_ARRAY_SIZE ((2 * MAX_MIB_SIZE + 2) * SAMPLES_PER_NEIGHBOR * 2)
#define DEFAULT_WMTYPE ROTZOOM
#define DEFAULT_WMTYPE AFFINE
#endif // CONFIG_WARPED_MOTION
const int16_t warped_filter[WARPEDPIXEL_PREC_SHIFTS * 3][8];
......@@ -86,16 +86,6 @@ void av1_warp_plane(WarpedMotionParams *wm,
int p_height, int p_stride, int subsampling_x,
int subsampling_y, int x_scale, int y_scale, int ref_frm);
// Integerize model into the WarpedMotionParams structure
void av1_integerize_model(const double *model, TransformationType wmtype,
WarpedMotionParams *wm);
int find_translation(const int np, double *pts1, double *pts2, double *mat);
int find_rotzoom(const int np, double *pts1, double *pts2, double *mat);
int find_affine(const int np, double *pts1, double *pts2, double *mat);
int find_hortrapezoid(const int np, double *pts1, double *pts2, double *mat);
int find_vertrapezoid(const int np, double *pts1, double *pts2, double *mat);
int find_homography(const int np, double *pts1, double *pts2, double *mat);
int find_projection(const int np, double *pts1, double *pts2,
int find_projection(const int np, int *pts1, int *pts2,
WarpedMotionParams *wm_params);
#endif // AV1_COMMON_WARPED_MOTION_H_
......@@ -1577,7 +1577,7 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
#endif // CONFIG_REF_MV && CONFIG_EXT_INTER
int16_t mode_ctx = 0;
#if CONFIG_WARPED_MOTION
double pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
#endif // CONFIG_WARPED_MOTION
#if CONFIG_EC_ADAPT
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
......
This diff is collapsed.
......@@ -7944,7 +7944,7 @@ static int64_t handle_inter_mode(
#endif // CONFIG_EXT_INTER
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
#if CONFIG_WARPED_MOTION
double pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
int pts[SAMPLES_ARRAY_SIZE], pts_inref[SAMPLES_ARRAY_SIZE];
#endif // CONFIG_WARPED_MOTION
int64_t rd = INT64_MAX;
BUFFER_SET orig_dst, tmp_dst;
......
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