Remove Global_Motion_Params and GLOBAL_MOTION_TYPE

After https://aomedia-review.googlesource.com/#/c/5589/ ,
the Global_Motion_Params and GLOBAL_MOTION_TYPE types
are redundant, and can be removed in favour of
WarpedMotionParams and TransformationType respectively.

Change-Id: I33f3796e5c469e595fd012ccdb65a672dd1bb86c
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index f1288e6..378708f 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -471,7 +471,7 @@
 
   struct aom_internal_error_info *error_info;
 #if CONFIG_GLOBAL_MOTION
-  Global_Motion_Params *global_motion;
+  WarpedMotionParams *global_motion;
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_DELTA_Q
   int prev_qindex;
diff --git a/av1/common/entropymode.h b/av1/common/entropymode.h
index 37fe2b5..c480613 100644
--- a/av1/common/entropymode.h
+++ b/av1/common/entropymode.h
@@ -159,7 +159,7 @@
   aom_prob filter_intra_probs[PLANE_TYPES];
 #endif  // CONFIG_FILTER_INTRA
 #if CONFIG_GLOBAL_MOTION
-  aom_prob global_motion_types_prob[GLOBAL_MOTION_TYPES - 1];
+  aom_prob global_motion_types_prob[GLOBAL_TRANS_TYPES - 1];
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_LOOP_RESTORATION
   aom_prob switchable_restore_prob[RESTORE_SWITCHABLE_TYPES - 1];
diff --git a/av1/common/entropymv.c b/av1/common/entropymv.c
index 029f9f6..a727169 100644
--- a/av1/common/entropymv.c
+++ b/av1/common/entropymv.c
@@ -128,13 +128,21 @@
 };
 
 #if CONFIG_GLOBAL_MOTION
-const aom_tree_index
-    av1_global_motion_types_tree[TREE_SIZE(GLOBAL_MOTION_TYPES)] = {
-      -GLOBAL_ZERO, 2, -GLOBAL_TRANSLATION, 4, -GLOBAL_ROTZOOM, -GLOBAL_AFFINE
-    };
+#if GLOBAL_TRANS_TYPES == 4
+const aom_tree_index av1_global_motion_types_tree[TREE_SIZE(
+    GLOBAL_TRANS_TYPES)] = { -IDENTITY, 2, -TRANSLATION, 4, -ROTZOOM, -AFFINE };
 
-static const aom_prob default_global_motion_types_prob[GLOBAL_MOTION_TYPES -
-                                                       1] = { 224, 128, 128 };
+static const aom_prob default_global_motion_types_prob[GLOBAL_TRANS_TYPES - 1] =
+    { 224, 128, 240 };
+
+#elif GLOBAL_TRANS_TYPES == 3
+
+const aom_tree_index av1_global_motion_types_tree[TREE_SIZE(
+    GLOBAL_TRANS_TYPES)] = { -IDENTITY, 2, -TRANSLATION, -ROTZOOM };
+
+static const aom_prob default_global_motion_types_prob[GLOBAL_TRANS_TYPES - 1] =
+    { 224, 128 };
+#endif  // GLOBAL_TRANS_TYPES
 #endif  // CONFIG_GLOBAL_MOTION
 
 static INLINE int mv_class_base(MV_CLASS_TYPE c) {
diff --git a/av1/common/entropymv.h b/av1/common/entropymv.h
index 1ebbdb2..32c4d1d 100644
--- a/av1/common/entropymv.h
+++ b/av1/common/entropymv.h
@@ -136,7 +136,7 @@
 void av1_inc_mv(const MV *mv, nmv_context_counts *mvctx, const int usehp);
 #if CONFIG_GLOBAL_MOTION
 extern const aom_tree_index
-    av1_global_motion_types_tree[TREE_SIZE(GLOBAL_MOTION_TYPES)];
+    av1_global_motion_types_tree[TREE_SIZE(GLOBAL_TRANS_TYPES)];
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_EC_MULTISYMBOL
 void av1_set_mv_cdfs(nmv_context *ctx);
diff --git a/av1/common/mv.h b/av1/common/mv.h
index 5715319..43b74c0 100644
--- a/av1/common/mv.h
+++ b/av1/common/mv.h
@@ -51,27 +51,31 @@
 
 #define WARPEDDIFF_PREC_BITS (WARPEDMODEL_PREC_BITS - WARPEDPIXEL_PREC_BITS)
 
+/* clang-format off */
 typedef enum {
-  UNKNOWN_TRANSFORM = -1,
-  HOMOGRAPHY,   // homography, 8-parameter
-  AFFINE,       // affine, 6-parameter
-  ROTZOOM,      // simplified affine with rotation and zoom only, 4-parameter
-  TRANSLATION,  // translational motion 2-parameter
-  IDENTITY,     // identity transformation, 0-parameter
-  TRANS_TYPES
+  IDENTITY = 0,     // identity transformation, 0-parameter
+  TRANSLATION = 1,  // translational motion 2-parameter
+  ROTZOOM = 2,      // simplified affine with rotation and zoom only, 4-parameter
+  AFFINE = 3,       // affine, 6-parameter
+  HOMOGRAPHY = 4,   // homography, 8-parameter
+  TRANS_TYPES = 5,
 } TransformationType;
+/* clang-format on */
+
+// Number of types used for global motion (must be <= TRANS_TYPES)
+#define GLOBAL_TRANS_TYPES 3
 
 // number of parameters used by each transformation in TransformationTypes
-static const int n_trans_model_params[TRANS_TYPES] = { 8, 6, 4, 2, 0 };
+static const int n_trans_model_params[TRANS_TYPES] = { 0, 2, 4, 6, 8 };
 
 // The order of values in the wmmat matrix below is best described
 // by the homography:
 // [x'     (m2 m3 m0   [x
-//  y'  =   m4 m5 m1 =  y
+//  y'  =   m4 m5 m1 *  y
 //  1]      m6 m7 1)    1]
 typedef struct {
   TransformationType wmtype;
-  int32_t wmmat[8];  // For homography wmmat[9] is assumed to be 1
+  int32_t wmmat[8];
 } WarpedMotionParams;
 #endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
@@ -125,71 +129,35 @@
 #define GM_ALPHA_MIN -GM_ALPHA_MAX
 #define GM_ROW3HOMO_MIN -GM_ROW3HOMO_MAX
 
-typedef enum {
-  GLOBAL_ZERO = 0,
-  GLOBAL_TRANSLATION = 1,
-  GLOBAL_ROTZOOM = 2,
-  GLOBAL_AFFINE = 3,
-  // GLOBAL_HOMOGRAPHY = 4,
-  GLOBAL_MOTION_TYPES
-} GLOBAL_MOTION_TYPE;
-
-typedef struct {
-  GLOBAL_MOTION_TYPE gmtype;
-  WarpedMotionParams motion_params;
-} Global_Motion_Params;
-
 // 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 Global_Motion_Params *gm) {
+static INLINE int_mv gm_get_motion_vector(const WarpedMotionParams *gm) {
   int_mv res;
-  res.as_mv.row = (int16_t)ROUND_POWER_OF_TWO_SIGNED(gm->motion_params.wmmat[1],
+  res.as_mv.row = (int16_t)ROUND_POWER_OF_TWO_SIGNED(gm->wmmat[1],
                                                      WARPEDMODEL_PREC_BITS - 3);
-  res.as_mv.col = (int16_t)ROUND_POWER_OF_TWO_SIGNED(gm->motion_params.wmmat[0],
+  res.as_mv.col = (int16_t)ROUND_POWER_OF_TWO_SIGNED(gm->wmmat[0],
                                                      WARPEDMODEL_PREC_BITS - 3);
   return res;
 }
 
-static INLINE TransformationType gm_to_trans_type(GLOBAL_MOTION_TYPE gmtype) {
-  switch (gmtype) {
-    case GLOBAL_ZERO: return IDENTITY; break;
-    case GLOBAL_TRANSLATION: return TRANSLATION; break;
-    case GLOBAL_ROTZOOM: return ROTZOOM; break;
-    case GLOBAL_AFFINE:
-      return AFFINE;
-      break;
-    // case GLOBAL_HOMOGRAPHY: return HOMOGRAPHY; break;
-    default: assert(0);
+static INLINE TransformationType get_gmtype(const WarpedMotionParams *gm) {
+  // if (gm->wmmat[6] != 0 || gm->wmmat[7] != 0) return HOMOGRAPHY;
+  if (gm->wmmat[5] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[4] &&
+      gm->wmmat[2] == (1 << WARPEDMODEL_PREC_BITS) && !gm->wmmat[3]) {
+    return ((!gm->wmmat[1] && !gm->wmmat[0]) ? IDENTITY : TRANSLATION);
   }
-  return UNKNOWN_TRANSFORM;
-}
-
-static INLINE GLOBAL_MOTION_TYPE get_gmtype(const Global_Motion_Params *gm) {
-  // if (gm->motion_params.wmmat[6] != 0 || gm->motion_params.wmmat[7] != 0)
-  //   return GLOBAL_HOMOGRAPHY;
-  if (gm->motion_params.wmmat[5] == (1 << WARPEDMODEL_PREC_BITS) &&
-      !gm->motion_params.wmmat[4] &&
-      gm->motion_params.wmmat[2] == (1 << WARPEDMODEL_PREC_BITS) &&
-      !gm->motion_params.wmmat[3]) {
-    return ((!gm->motion_params.wmmat[1] && !gm->motion_params.wmmat[0])
-                ? GLOBAL_ZERO
-                : GLOBAL_TRANSLATION);
-  }
-  if (gm->motion_params.wmmat[2] == gm->motion_params.wmmat[5] &&
-      gm->motion_params.wmmat[3] == -gm->motion_params.wmmat[4])
-    return GLOBAL_ROTZOOM;
+  if (gm->wmmat[2] == gm->wmmat[5] && gm->wmmat[3] == -gm->wmmat[4])
+    return ROTZOOM;
   else
-    return GLOBAL_AFFINE;
+    return AFFINE;
 }
 
-static INLINE void set_default_gmparams(Global_Motion_Params *gm) {
+static INLINE void set_default_gmparams(WarpedMotionParams *gm) {
   static const int32_t default_gm_params[8] = {
     0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0, (1 << WARPEDMODEL_PREC_BITS), 0, 0
   };
-  memcpy(gm->motion_params.wmmat, default_gm_params,
-         sizeof(gm->motion_params.wmmat));
-  gm->gmtype = GLOBAL_ZERO;
-  gm->motion_params.wmtype = IDENTITY;
+  memcpy(gm->wmmat, default_gm_params, sizeof(gm->wmmat));
+  gm->wmtype = IDENTITY;
 }
 #endif  // CONFIG_GLOBAL_MOTION
 
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index fd6b62b..f3f7172 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -393,7 +393,7 @@
   aom_cdf_prob kf_y_cdf[INTRA_MODES][INTRA_MODES][INTRA_MODES];
 #endif
 #if CONFIG_GLOBAL_MOTION
-  Global_Motion_Params global_motion[TOTAL_REFS_PER_FRAME];
+  WarpedMotionParams global_motion[TOTAL_REFS_PER_FRAME];
 #endif
 
   BLOCK_SIZE sb_size;  // Size of the superblock used for this frame
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index bcdc0c4..f0ba7fd 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -553,12 +553,12 @@
   const int is_compound = has_second_ref(&mi->mbmi);
   int ref;
 #if CONFIG_GLOBAL_MOTION
-  Global_Motion_Params *gm[2];
+  WarpedMotionParams *gm[2];
   int is_global[2];
   for (ref = 0; ref < 1 + is_compound; ++ref) {
     gm[ref] = &xd->global_motion[mi->mbmi.ref_frame[ref]];
     is_global[ref] =
-        (get_y_mode(mi, block) == ZEROMV && gm[ref]->gmtype > GLOBAL_ZERO);
+        (get_y_mode(mi, block) == ZEROMV && gm[ref]->wmtype != IDENTITY);
   }
   // TODO(sarahparker) remove these once gm works with all experiments
   (void)gm;
@@ -710,7 +710,7 @@
 #else  // CONFIG_EXT_INTER
 #if CONFIG_GLOBAL_MOTION
     if (is_global[ref])
-      av1_warp_plane(&(gm[ref]->motion_params),
+      av1_warp_plane(gm[ref],
 #if CONFIG_AOM_HIGHBITDEPTH
                      xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
 #endif  // CONFIG_AOM_HIGHBITDEPTH