]> granicus.if.org Git - libvpx/commitdiff
Add integerize function back in warped_motion.c
authorSarah Parker <sarahparker@google.com>
Thu, 11 Aug 2016 22:57:09 +0000 (15:57 -0700)
committerSarah Parker <sarahparker@google.com>
Mon, 22 Aug 2016 19:29:26 +0000 (12:29 -0700)
This function was previously unused and removed in
I6bc740e778658d6f81ca54888fc6fa822d3b5ee0. I am adding it back in
with previously suggested fixes.

Change-Id: Iee0afb39170d25895b11d07e71843eae6913efd1

vp10/common/warped_motion.c
vp10/common/warped_motion.h

index 59999f79e920feab3873f29bfb3858bb9f5a7603..7d5b7a2e8a7b3d145c984348e9ce165242f6cb15 100644 (file)
@@ -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");
+  }
+}
index a9b53a5e16335a58599ea774004678de35229d13..3e566b6ffa60f36239556632e8634a962656382f 100644 (file)
@@ -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