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
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index d0ac7c1..38b7261 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -4020,44 +4020,37 @@
 #endif  // CONFIG_SUPERTX
 
 #if CONFIG_GLOBAL_MOTION
-static void read_global_motion_params(Global_Motion_Params *params,
+static void read_global_motion_params(WarpedMotionParams *params,
                                       aom_prob *probs, aom_reader *r) {
-  GLOBAL_MOTION_TYPE gmtype =
+  TransformationType type =
       aom_read_tree(r, av1_global_motion_types_tree, probs, ACCT_STR);
   set_default_gmparams(params);
-  params->gmtype = gmtype;
-  params->motion_params.wmtype = gm_to_trans_type(gmtype);
-  switch (gmtype) {
-    case GLOBAL_ZERO: break;
-    case GLOBAL_AFFINE:
-    case GLOBAL_ROTZOOM:
-      params->motion_params.wmmat[2] =
-          (aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
-           GM_ALPHA_DECODE_FACTOR) +
-          (1 << WARPEDMODEL_PREC_BITS);
-      params->motion_params.wmmat[3] =
-          aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
-          GM_ALPHA_DECODE_FACTOR;
-      if (gmtype == GLOBAL_AFFINE) {
-        params->motion_params.wmmat[4] =
-            (aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
-             GM_ALPHA_DECODE_FACTOR);
-        params->motion_params.wmmat[5] =
-            aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
-                GM_ALPHA_DECODE_FACTOR +
-            (1 << WARPEDMODEL_PREC_BITS);
+  params->wmtype = type;
+  switch (type) {
+    case IDENTITY: break;
+    case AFFINE:
+    case ROTZOOM:
+      params->wmmat[2] = (aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
+                          GM_ALPHA_DECODE_FACTOR) +
+                         (1 << WARPEDMODEL_PREC_BITS);
+      params->wmmat[3] = aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
+                         GM_ALPHA_DECODE_FACTOR;
+      if (type == AFFINE) {
+        params->wmmat[4] = (aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
+                            GM_ALPHA_DECODE_FACTOR);
+        params->wmmat[5] = aom_read_primitive_symmetric(r, GM_ABS_ALPHA_BITS) *
+                               GM_ALPHA_DECODE_FACTOR +
+                           (1 << WARPEDMODEL_PREC_BITS);
       } else {
-        params->motion_params.wmmat[4] = -params->motion_params.wmmat[3];
-        params->motion_params.wmmat[5] = params->motion_params.wmmat[2];
+        params->wmmat[4] = -params->wmmat[3];
+        params->wmmat[5] = params->wmmat[2];
       }
     // fallthrough intended
-    case GLOBAL_TRANSLATION:
-      params->motion_params.wmmat[0] =
-          aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
-          GM_TRANS_DECODE_FACTOR;
-      params->motion_params.wmmat[1] =
-          aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
-          GM_TRANS_DECODE_FACTOR;
+    case TRANSLATION:
+      params->wmmat[0] = aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
+                         GM_TRANS_DECODE_FACTOR;
+      params->wmmat[1] = aom_read_primitive_symmetric(r, GM_ABS_TRANS_BITS) *
+                         GM_TRANS_DECODE_FACTOR;
       break;
     default: assert(0);
   }
@@ -4071,10 +4064,10 @@
     /*
     printf("Dec Ref %d [%d/%d]: %d %d %d %d\n",
            frame, cm->current_video_frame, cm->show_frame,
-           cm->global_motion[frame].motion_params.wmmat[0],
-           cm->global_motion[frame].motion_params.wmmat[1],
-           cm->global_motion[frame].motion_params.wmmat[2],
-           cm->global_motion[frame].motion_params.wmmat[3]);
+           cm->global_motion[frame].wmmat[0],
+           cm->global_motion[frame].wmmat[1],
+           cm->global_motion[frame].wmmat[2],
+           cm->global_motion[frame].wmmat[3]);
            */
   }
 }
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index e8bf18c..4c8c2fa 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -104,7 +104,7 @@
 static struct av1_token ext_tx_encodings[TX_TYPES];
 #endif  // CONFIG_EXT_TX
 #if CONFIG_GLOBAL_MOTION
-static struct av1_token global_motion_types_encodings[GLOBAL_MOTION_TYPES];
+static struct av1_token global_motion_types_encodings[GLOBAL_TRANS_TYPES];
 #endif  // CONFIG_GLOBAL_MOTION
 #if CONFIG_EXT_INTRA
 static struct av1_token intra_filter_encodings[INTRA_FILTERS];
@@ -3952,39 +3952,35 @@
 }
 
 #if CONFIG_GLOBAL_MOTION
-static void write_global_motion_params(Global_Motion_Params *params,
+static void write_global_motion_params(WarpedMotionParams *params,
                                        aom_prob *probs, aom_writer *w) {
-  GLOBAL_MOTION_TYPE gmtype = params->gmtype;
+  TransformationType type = params->wmtype;
   av1_write_token(w, av1_global_motion_types_tree, probs,
-                  &global_motion_types_encodings[gmtype]);
-  switch (gmtype) {
-    case GLOBAL_ZERO: break;
-    case GLOBAL_AFFINE:
-    case GLOBAL_ROTZOOM:
+                  &global_motion_types_encodings[type]);
+  switch (type) {
+    case IDENTITY: break;
+    case AFFINE:
+    case ROTZOOM:
       aom_write_primitive_symmetric(
-          w, (params->motion_params.wmmat[2] >> GM_ALPHA_PREC_DIFF) -
-                 (1 << GM_ALPHA_PREC_BITS),
+          w,
+          (params->wmmat[2] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS),
           GM_ABS_ALPHA_BITS);
-      aom_write_primitive_symmetric(
-          w, (params->motion_params.wmmat[3] >> GM_ALPHA_PREC_DIFF),
-          GM_ABS_ALPHA_BITS);
-      if (gmtype == GLOBAL_AFFINE) {
+      aom_write_primitive_symmetric(w, (params->wmmat[3] >> GM_ALPHA_PREC_DIFF),
+                                    GM_ABS_ALPHA_BITS);
+      if (type == AFFINE) {
         aom_write_primitive_symmetric(
-            w, (params->motion_params.wmmat[4] >> GM_ALPHA_PREC_DIFF),
-            GM_ABS_ALPHA_BITS);
-        aom_write_primitive_symmetric(
-            w, (params->motion_params.wmmat[5] >> GM_ALPHA_PREC_DIFF) -
-                   (1 << GM_ALPHA_PREC_BITS),
-            GM_ABS_ALPHA_BITS);
+            w, (params->wmmat[4] >> GM_ALPHA_PREC_DIFF), GM_ABS_ALPHA_BITS);
+        aom_write_primitive_symmetric(w,
+                                      (params->wmmat[5] >> GM_ALPHA_PREC_DIFF) -
+                                          (1 << GM_ALPHA_PREC_BITS),
+                                      GM_ABS_ALPHA_BITS);
       }
     // fallthrough intended
-    case GLOBAL_TRANSLATION:
-      aom_write_primitive_symmetric(
-          w, (params->motion_params.wmmat[0] >> GM_TRANS_PREC_DIFF),
-          GM_ABS_TRANS_BITS);
-      aom_write_primitive_symmetric(
-          w, (params->motion_params.wmmat[1] >> GM_TRANS_PREC_DIFF),
-          GM_ABS_TRANS_BITS);
+    case TRANSLATION:
+      aom_write_primitive_symmetric(w, (params->wmmat[0] >> GM_TRANS_PREC_DIFF),
+                                    GM_ABS_TRANS_BITS);
+      aom_write_primitive_symmetric(w, (params->wmmat[1] >> GM_TRANS_PREC_DIFF),
+                                    GM_ABS_TRANS_BITS);
       break;
     default: assert(0);
   }
@@ -4003,10 +3999,10 @@
     printf("Enc Ref %d [%d/%d] (used %d): %d %d %d %d\n",
            frame, cm->current_video_frame, cm->show_frame,
            cpi->global_motion_used[frame],
-           cm->global_motion[frame].motion_params.wmmat[0],
-           cm->global_motion[frame].motion_params.wmmat[1],
-           cm->global_motion[frame].motion_params.wmmat[2],
-           cm->global_motion[frame].motion_params.wmmat[3]);
+           cm->global_motion[frame].wmmat[0],
+           cm->global_motion[frame].wmmat[1],
+           cm->global_motion[frame].wmmat[2],
+           cm->global_motion[frame].wmmat[3]);
            */
   }
 }
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index ffa77d6..b624cbb 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4757,10 +4757,9 @@
 }
 
 static void convert_model_to_params(const double *params,
-                                    Global_Motion_Params *model) {
-  convert_to_params(params, model->motion_params.wmmat);
-  model->gmtype = get_gmtype(model);
-  model->motion_params.wmtype = gm_to_trans_type(model->gmtype);
+                                    WarpedMotionParams *model) {
+  convert_to_params(params, model->wmmat);
+  model->wmtype = get_gmtype(model);
 }
 #endif  // CONFIG_GLOBAL_MOTION
 
@@ -4802,9 +4801,9 @@
         if (compute_global_motion_feature_based(GLOBAL_MOTION_MODEL,
                                                 cpi->Source, ref_buf, params)) {
           convert_model_to_params(params, &cm->global_motion[frame]);
-          if (cm->global_motion[frame].gmtype > GLOBAL_ZERO) {
+          if (cm->global_motion[frame].wmtype != IDENTITY) {
             refine_integerized_param(
-                &cm->global_motion[frame].motion_params,
+                &cm->global_motion[frame],
 #if CONFIG_AOM_HIGHBITDEPTH
                 xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
 #endif  // CONFIG_AOM_HIGHBITDEPTH
@@ -4813,7 +4812,7 @@
                 cpi->Source->y_height, cpi->Source->y_stride, 3);
             // compute the advantage of using gm parameters over 0 motion
             erroradvantage = av1_warp_erroradv(
-                &cm->global_motion[frame].motion_params,
+                &cm->global_motion[frame],
 #if CONFIG_AOM_HIGHBITDEPTH
                 xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
 #endif  // CONFIG_AOM_HIGHBITDEPTH
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 52114b0..49e8b2d 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -4312,23 +4312,23 @@
 }
 
 #if CONFIG_GLOBAL_MOTION
-static int get_gmbitcost(const Global_Motion_Params *gm,
-                         const aom_prob *probs) {
-  int gmtype_cost[GLOBAL_MOTION_TYPES];
+static int get_gmbitcost(const WarpedMotionParams *gm, const aom_prob *probs) {
+  int gmtype_cost[TRANS_TYPES];
   int bits;
+  TransformationType type = gm->wmtype;
   av1_cost_tokens(gmtype_cost, probs, av1_global_motion_types_tree);
-  switch (gm->gmtype) {
-    case GLOBAL_AFFINE:
-      bits = (GM_ABS_TRANS_BITS + 1) * 2 + 4 * GM_ABS_ALPHA_BITS + 4;
+  switch (type) {
+    case AFFINE:
+      bits = (GM_ABS_TRANS_BITS + 1) * 2 + (GM_ABS_ALPHA_BITS + 1) * 4;
       break;
-    case GLOBAL_ROTZOOM:
-      bits = (GM_ABS_TRANS_BITS + 1) * 2 + 2 * GM_ABS_ALPHA_BITS + 2;
+    case ROTZOOM:
+      bits = (GM_ABS_TRANS_BITS + 1) * 2 + (GM_ABS_ALPHA_BITS + 1) * 2;
       break;
-    case GLOBAL_TRANSLATION: bits = (GM_ABS_TRANS_BITS + 1) * 2; break;
-    case GLOBAL_ZERO: bits = 0; break;
+    case TRANSLATION: bits = (GM_ABS_TRANS_BITS + 1) * 2; break;
+    case IDENTITY: bits = 0; break;
     default: assert(0); return 0;
   }
-  return bits ? (bits << AV1_PROB_COST_SHIFT) + gmtype_cost[gm->gmtype] : 0;
+  return bits ? (bits << AV1_PROB_COST_SHIFT) + gmtype_cost[type] : 0;
 }
 
 #define GLOBAL_MOTION_RATE(ref)                            \
@@ -5337,9 +5337,9 @@
 #endif  // CONFIG_REF_MV
 
 #if CONFIG_GLOBAL_MOTION
-        if (cm->global_motion[mbmi->ref_frame[0]].gmtype == GLOBAL_ZERO &&
+        if (cm->global_motion[mbmi->ref_frame[0]].wmtype == IDENTITY &&
             (!has_second_rf ||
-             cm->global_motion[mbmi->ref_frame[1]].gmtype == GLOBAL_ZERO))
+             cm->global_motion[mbmi->ref_frame[1]].wmtype == IDENTITY))
 #endif  // CONFIG_GLOBAL_MOTION
 
           if (!check_best_zero_mv(cpi, mbmi_ext->mode_context,
@@ -8857,9 +8857,9 @@
         }
       }
 #if CONFIG_GLOBAL_MOTION
-    } else if (cm->global_motion[ref_frame].gmtype == GLOBAL_ZERO &&
+    } else if (cm->global_motion[ref_frame].wmtype == IDENTITY &&
                (!comp_pred ||
-                cm->global_motion[second_ref_frame].gmtype == GLOBAL_ZERO)) {
+                cm->global_motion[second_ref_frame].wmtype == IDENTITY)) {
 #else   // CONFIG_GLOBAL_MOTION
     } else {
 #endif  // CONFIG_GLOBAL_MOTION