From: Sarah Parker Date: Thu, 11 Aug 2016 22:57:09 +0000 (-0700) Subject: Add integerize function back in warped_motion.c X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3464aff41f6bd8fb2316e4bb72a545451804e658;p=libvpx Add integerize function back in warped_motion.c This function was previously unused and removed in I6bc740e778658d6f81ca54888fc6fa822d3b5ee0. I am adding it back in with previously suggested fixes. Change-Id: Iee0afb39170d25895b11d07e71843eae6913efd1 --- diff --git a/vp10/common/warped_motion.c b/vp10/common/warped_motion.c index 59999f79e..7d5b7a2e8 100644 --- a/vp10/common/warped_motion.c +++ b/vp10/common/warped_motion.c @@ -562,3 +562,30 @@ void vp10_warp_plane(WarpedMotionParams *wm, p_height, p_stride, subsampling_x, subsampling_y, x_scale, y_scale); } + +void vp10_integerize_model(const double *model, TransformationType wmtype, + WarpedMotionParams *wm) { + wm->wmtype = wmtype; + switch (wmtype) { + case HOMOGRAPHY: + assert(fabs(model[8] - 1.0) < 1e-12); + wm->wmmat[7] = + (int)lrint(model[7] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS)); + wm->wmmat[6] = + (int)lrint(model[6] * (1 << WARPEDMODEL_ROW3HOMO_PREC_BITS)); + /* fallthrough intended */ + case AFFINE: + wm->wmmat[5] = (int)lrint(model[5] * (1 << WARPEDMODEL_PREC_BITS)); + wm->wmmat[4] = (int)lrint(model[4] * (1 << WARPEDMODEL_PREC_BITS)); + /* fallthrough intended */ + case ROTZOOM: + wm->wmmat[3] = (int)lrint(model[3] * (1 << WARPEDMODEL_PREC_BITS)); + wm->wmmat[2] = (int)lrint(model[2] * (1 << WARPEDMODEL_PREC_BITS)); + /* fallthrough intended */ + case TRANSLATION: + wm->wmmat[1] = (int)lrint(model[1] * (1 << WARPEDMODEL_PREC_BITS)); + wm->wmmat[0] = (int)lrint(model[0] * (1 << WARPEDMODEL_PREC_BITS)); + break; + default: assert(0 && "Invalid TransformationType"); + } +} diff --git a/vp10/common/warped_motion.h b/vp10/common/warped_motion.h index a9b53a5e1..3e566b6ff 100644 --- a/vp10/common/warped_motion.h +++ b/vp10/common/warped_motion.h @@ -62,4 +62,8 @@ void vp10_warp_plane(WarpedMotionParams *wm, uint8_t *pred, int p_col, int p_row, int p_width, int p_height, int p_stride, int subsampling_x, int subsampling_y, int x_scale, int y_scale); + +// Integerize model into the WarpedMotionParams structure +void vp10_integerize_model(const double *model, TransformationType wmtype, + WarpedMotionParams *wm); #endif // VP10_COMMON_WARPED_MOTION_H