Remove translational models from syntax
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 9d911c0..8651d3c 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -6100,13 +6100,21 @@
 #else
                                      MvSubpelPrecision precision) {
   const int precision_loss = get_gm_precision_loss(precision);
-#endif
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+  (void)precision_loss;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
+#endif  // !CONFIG_FLEX_MVRES
   TransformationType type = aom_rb_read_bit(rb);
   if (type != IDENTITY) {
-    if (aom_rb_read_bit(rb))
+    if (aom_rb_read_bit(rb)) {
       type = ROTZOOM;
-    else
+    } else {
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+      type = AFFINE;
+#else
       type = aom_rb_read_bit(rb) ? TRANSLATION : AFFINE;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
+    }
   }
 
   *params = default_warp_params;
@@ -6142,6 +6150,11 @@
   }
 
   if (type >= TRANSLATION) {
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+    const int trans_bits = GM_ABS_TRANS_BITS;
+    const int trans_dec_factor = GM_TRANS_DECODE_FACTOR;
+    const int trans_prec_diff = GM_TRANS_PREC_DIFF;
+#else
     const int trans_bits = (type == TRANSLATION)
 #if CONFIG_FLEX_MVRES
                                ? GM_ABS_TRANS_ONLY_BITS - precision_loss
@@ -6164,6 +6177,7 @@
                                     ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp
 #endif
                                     : GM_TRANS_PREC_DIFF;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
 
     params->wmmat[0] = aom_rb_read_signed_primitive_refsubexpfin(
                            rb, (1 << trans_bits) + 1, SUBEXPFIN_K,
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index b190452..2c94af4 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -4504,13 +4504,22 @@
 #else
     struct aom_write_bit_buffer *wb, MvSubpelPrecision precision) {
   const int precision_loss = get_gm_precision_loss(precision);
-#endif
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+  (void)precision_loss;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
+#endif  // !CONFIG_FLEX_MVRES
   const TransformationType type = params->wmtype;
 
   aom_wb_write_bit(wb, type != IDENTITY);
   if (type != IDENTITY) {
     aom_wb_write_bit(wb, type == ROTZOOM);
-    if (type != ROTZOOM) aom_wb_write_bit(wb, type == TRANSLATION);
+    if (type != ROTZOOM) {
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+      assert(type == AFFINE);
+#else
+      aom_wb_write_bit(wb, type == TRANSLATION);
+#endif  // !CONFIG_IMPROVED_GLOBAL_MOTION
+    }
   }
 
   if (type >= ROTZOOM) {
@@ -4538,6 +4547,10 @@
   }
 
   if (type >= TRANSLATION) {
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+    const int trans_bits = GM_ABS_TRANS_BITS;
+    const int trans_prec_diff = GM_TRANS_PREC_DIFF;
+#else
 #if CONFIG_FLEX_MVRES
     const int trans_bits = (type == TRANSLATION)
                                ? GM_ABS_TRANS_ONLY_BITS - precision_loss
@@ -4552,7 +4565,8 @@
     const int trans_prec_diff = (type == TRANSLATION)
                                     ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp
                                     : GM_TRANS_PREC_DIFF;
-#endif
+#endif  // CONFIG_FLEX_MVRES
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
 
     aom_wb_write_signed_primitive_refsubexpfin(
         wb, (1 << trans_bits) + 1, SUBEXPFIN_K,
diff --git a/av1/encoder/global_motion.c b/av1/encoder/global_motion.c
index 43a9a41..d57cb9b 100644
--- a/av1/encoder/global_motion.c
+++ b/av1/encoder/global_motion.c
@@ -37,7 +37,9 @@
 
 static void convert_to_params(const double *params, int32_t *model) {
   int i;
+#if !CONFIG_IMPROVED_GLOBAL_MOTION
   int alpha_present = 0;
+#endif  // !CONFIG_IMPROVED_GLOBAL_MOTION
   model[0] = (int32_t)floor(params[0] * (1 << GM_TRANS_PREC_BITS) + 0.5);
   model[1] = (int32_t)floor(params[1] * (1 << GM_TRANS_PREC_BITS) + 0.5);
   model[0] = (int32_t)clamp(model[0], GM_TRANS_MIN, GM_TRANS_MAX) *
@@ -50,22 +52,28 @@
     model[i] = (int32_t)floor(params[i] * (1 << GM_ALPHA_PREC_BITS) + 0.5);
     model[i] =
         (int32_t)clamp(model[i] - diag_value, GM_ALPHA_MIN, GM_ALPHA_MAX);
+#if !CONFIG_IMPROVED_GLOBAL_MOTION
     alpha_present |= (model[i] != 0);
+#endif  // !CONFIG_IMPROVED_GLOBAL_MOTION
     model[i] = (model[i] + diag_value) * GM_ALPHA_DECODE_FACTOR;
   }
   for (; i < 8; ++i) {
     model[i] = (int32_t)floor(params[i] * (1 << GM_ROW3HOMO_PREC_BITS) + 0.5);
     model[i] = (int32_t)clamp(model[i], GM_ROW3HOMO_MIN, GM_ROW3HOMO_MAX) *
                GM_ROW3HOMO_DECODE_FACTOR;
+#if !CONFIG_IMPROVED_GLOBAL_MOTION
     alpha_present |= (model[i] != 0);
+#endif  // !CONFIG_IMPROVED_GLOBAL_MOTION
   }
 
+#if !CONFIG_IMPROVED_GLOBAL_MOTION
   if (!alpha_present) {
     if (abs(model[0]) < MIN_TRANS_THRESH && abs(model[1]) < MIN_TRANS_THRESH) {
       model[0] = 0;
       model[1] = 0;
     }
   }
+#endif  // !CONFIG_IMPROVED_GLOBAL_MOTION
 }
 
 void av1_convert_model_to_params(const double *params,
diff --git a/av1/encoder/global_motion_facade.c b/av1/encoder/global_motion_facade.c
index 5aa4e57..69b725c 100644
--- a/av1/encoder/global_motion_facade.c
+++ b/av1/encoder/global_motion_facade.c
@@ -35,11 +35,33 @@
                               const WarpedMotionParams *ref_gm,
                               MvSubpelPrecision precision) {
   const int precision_loss = get_gm_precision_loss(precision);
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+  (void)precision_loss;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
 #else
                               const WarpedMotionParams *ref_gm, int allow_hp) {
-#endif
+#endif  // CONFIG_FLEX_MVRES
   int params_cost = 0;
-  int trans_bits, trans_prec_diff;
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+  const int trans_bits = GM_ABS_TRANS_BITS;
+  const int trans_prec_diff = GM_TRANS_PREC_DIFF;
+#else
+  const int trans_bits = (gm->wmtype == TRANSLATION)
+#if CONFIG_FLEX_MVRES
+                             ? GM_ABS_TRANS_ONLY_BITS - precision_loss
+#else
+                             ? GM_ABS_TRANS_ONLY_BITS - !allow_hp
+#endif
+                             : GM_ABS_TRANS_BITS;
+  const int trans_prec_diff = (gm->wmtype == TRANSLATION)
+#if CONFIG_FLEX_MVRES
+                                  ? GM_TRANS_ONLY_PREC_DIFF + precision_loss
+#else
+                                  ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp
+#endif
+                                  : GM_TRANS_PREC_DIFF;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
+
   switch (gm->wmtype) {
     case AFFINE:
     case ROTZOOM:
@@ -62,22 +84,6 @@
                 (1 << GM_ALPHA_PREC_BITS),
             (gm->wmmat[5] >> GM_ALPHA_PREC_DIFF) - (1 << GM_ALPHA_PREC_BITS));
       }
-      AOM_FALLTHROUGH_INTENDED;
-    case TRANSLATION:
-      trans_bits = (gm->wmtype == TRANSLATION)
-#if CONFIG_FLEX_MVRES
-                       ? GM_ABS_TRANS_ONLY_BITS - precision_loss
-#else
-                       ? GM_ABS_TRANS_ONLY_BITS - !allow_hp
-#endif
-                       : GM_ABS_TRANS_BITS;
-      trans_prec_diff = (gm->wmtype == TRANSLATION)
-#if CONFIG_FLEX_MVRES
-                            ? GM_TRANS_ONLY_PREC_DIFF + precision_loss
-#else
-                            ? GM_TRANS_ONLY_PREC_DIFF + !allow_hp
-#endif
-                            : GM_TRANS_PREC_DIFF;
       params_cost += aom_count_signed_primitive_refsubexpfin(
           (1 << trans_bits) + 1, SUBEXPFIN_K,
           (ref_gm->wmmat[0] >> trans_prec_diff),
@@ -152,10 +158,18 @@
       params_this_motion = motion_models[i].params;
       av1_convert_model_to_params(params_this_motion, &tmp_wm_params);
 
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+      // If the found model can be represented as a simple translation,
+      // then reject it. This is because translational motion is cheaper
+      // to signal through the standard MV coding tools, rather than through
+      // global motion
+      if (tmp_wm_params.wmtype <= TRANSLATION) continue;
+#else
       // For IDENTITY type models, we don't need to evaluate anything because
       // all the following logic is effectively comparing the estimated model
       // to an identity model.
       if (tmp_wm_params.wmtype == IDENTITY) continue;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
 
       av1_compute_feature_segmentation_map(
           segment_map, segment_map_w, segment_map_h, motion_models[i].inliers,
@@ -179,9 +193,16 @@
           num_refinements, best_warp_error, segment_map, segment_map_w,
           erroradv_threshold);
 
+#if CONFIG_IMPROVED_GLOBAL_MOTION
+      // av1_refine_integerized_param() can change the wmtype to a simpler
+      // model type than its input. So we need to check again to see if
+      // we have a translational model
+      if (tmp_wm_params.wmtype <= TRANSLATION) continue;
+#else
       // av1_refine_integerized_param() can return a simpler model type than
       // its input, so re-check model type here
       if (tmp_wm_params.wmtype == IDENTITY) continue;
+#endif  // CONFIG_IMPROVED_GLOBAL_MOTION
 
       if (warp_error < best_warp_error) {
         best_ref_frame_error = ref_frame_error;
@@ -197,6 +218,7 @@
       if (!av1_get_shear_params(&cm->global_motion[frame]))
         cm->global_motion[frame] = default_warp_params;
 
+#if !CONFIG_IMPROVED_GLOBAL_MOTION
     if (cm->global_motion[frame].wmtype == TRANSLATION) {
       cm->global_motion[frame].wmmat[0] =
 #if CONFIG_FLEX_MVRES
@@ -215,6 +237,7 @@
                                 cm->global_motion[frame].wmmat[1]) *
           GM_TRANS_ONLY_DECODE_FACTOR;
     }
+#endif  // !CONFIG_IMPROVED_GLOBAL_MOTION
 
     if (cm->global_motion[frame].wmtype == IDENTITY) continue;