Implement a first TEMPORAL_GLOBAL_MV based tool

Implements a first version of a tool using temporal_global_mv.
In this version, if a non-translational global motion is not
explicitly signaled, the temporal global mv for the SB is used
instead for GLOBALMV and GLOBAL_GLOBALMV modes.
diff --git a/av1/common/av1_common_int.h b/av1/common/av1_common_int.h
index 40bdfd8..2160a25 100644
--- a/av1/common/av1_common_int.h
+++ b/av1/common/av1_common_int.h
@@ -3323,9 +3323,6 @@
 #if CONFIG_FLEX_MVRES
   sbi->sb_mv_precision = cm->features.fr_mv_precision;
 #endif  // CONFIG_FLEX_MVRES
-#if CONFIG_TEMPORAL_GLOBAL_MV
-  av1_set_temporal_global_mvs_sb(cm, xd, mi_row, mi_col);
-#endif  // CONFIG_TEMPORAL_GLOBAL_MV
 }
 
 // Returns true if the frame is fully lossless at the coded resolution.
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index ef10309..b2d812a 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -3376,6 +3376,26 @@
 #endif  // CONFIG_NEW_COLOR_MAP_CODING
 } Av1ColorMapParam;
 
+static INLINE const WarpedMotionParams *effective_global_motion(
+    const MACROBLOCKD *xd, int ref_frame) {
+  if (ref_frame == NONE_FRAME || ref_frame == INTRA_FRAME
+#if CONFIG_TIP
+      || ref_frame == TIP_FRAME
+#endif  // CONFIG_TIP
+  )
+    return &default_warp_params;
+  assert(ref_frame < INTER_REFS_PER_FRAME);
+  const WarpedMotionParams *gm = &xd->global_motion[ref_frame];
+#if CONFIG_TEMPORAL_GLOBAL_MV
+  const WarpedMotionParams *tgm = xd->sbi->tpl_global_motion[ref_frame].invalid
+                                      ? &default_warp_params
+                                      : &xd->sbi->tpl_global_motion[ref_frame];
+  return gm->wmtype > TRANSLATION ? gm : tgm;
+#else
+  return gm;
+#endif  // CONFIG_TEMPORAL_GLOBAL_MV
+}
+
 static INLINE int is_nontrans_global_motion(const MACROBLOCKD *xd,
                                             const MB_MODE_INFO *mbmi) {
   int ref;
@@ -3388,7 +3408,9 @@
 
   // Now check if all global motion is non translational
   for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) {
-    if (xd->global_motion[mbmi->ref_frame[ref]].wmtype == TRANSLATION) return 0;
+    const WarpedMotionParams *global_motion =
+        effective_global_motion(xd, mbmi->ref_frame[ref]);
+    if (global_motion->wmtype <= TRANSLATION) return 0;
   }
   return 1;
 }
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 8f956cf..9c7c461 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -373,10 +373,8 @@
 #endif  // CONFIG_C076_INTER_MOD_CTX
 
 static AOM_INLINE void add_ref_mv_candidate(
-#if CONFIG_TIP
-#if !CONFIG_SMVP_IMPROVEMENT
     const AV1_COMMON *cm,
-#endif  // !CONFIG_SMVP_IMPROVEMENT
+#if CONFIG_TIP
     int mi_row, int mi_col, int mi_row_cand, int mi_col_cand,
 #endif  // CONFIG_TIP
     const MB_MODE_INFO *const candidate,
@@ -386,16 +384,16 @@
     const MV_REFERENCE_FRAME rf[2], uint8_t *refmv_count,
     uint8_t *ref_match_count, uint8_t *newmv_count, CANDIDATE_MV *ref_mv_stack,
     uint16_t *ref_mv_weight, int_mv *gm_mv_candidates,
-    const WarpedMotionParams *gm_params,
+    const WarpedMotionParams *gm_params[INTER_REFS_PER_FRAME],
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
     const MB_MODE_INFO *mbmi,
     MV_REFERENCE_FRAME ref_frame_idx0[MAX_REF_MV_STACK_SIZE],
     MV_REFERENCE_FRAME ref_frame_idx1[MAX_REF_MV_STACK_SIZE],
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
 #if CONFIG_SMVP_IMPROVEMENT
-    const AV1_COMMON *cm, int add_more_mvs, SINGLE_MV_CANDIDATE *single_mv,
-    uint8_t *single_mv_count, CANDIDATE_MV *derived_mv_stack,
-    uint16_t *derived_mv_weight, uint8_t *derived_mv_count,
+    int add_more_mvs, SINGLE_MV_CANDIDATE *single_mv, uint8_t *single_mv_count,
+    CANDIDATE_MV *derived_mv_stack, uint16_t *derived_mv_weight,
+    uint8_t *derived_mv_count,
 #endif  // CONFIG_SMVP_IMPROVEMENT
 #if CONFIG_IBC_SR_EXT
     uint8_t is_intrabc,
@@ -409,6 +407,7 @@
     const MvSubpelPrecision precision
 #endif
 ) {
+  (void)cm;
 #if CONFIG_C071_SUBBLK_WARPMV && CONFIG_FLEX_MVRES
   (void)precision;
 #endif  // CONFIG_C071_SUBBLK_WARPMV && CONFIG_FLEX_MVRES
@@ -438,7 +437,7 @@
 #endif
       int_mv this_refmv[2];
       for (ref = 0; ref < 2; ++ref) {
-        if (is_global_mv_block(candidate, gm_params[rf[ref]].wmtype))
+        if (is_global_mv_block(candidate, gm_params[rf[ref]]->wmtype))
           this_refmv[ref] = gm_mv_candidates[ref];
         else
           this_refmv[ref] = get_block_mv(candidate,
@@ -490,7 +489,9 @@
                                     ref);
         } else {
           const int is_gm_block =
-              is_global_mv_block(candidate, gm_params[rf[0]].wmtype);
+              rf[0] == NONE_FRAME || rf[0] == INTRA_FRAME
+                  ? 0
+                  : is_global_mv_block(candidate, gm_params[rf[0]]->wmtype);
           this_refmv = is_gm_block ? gm_mv_candidates[0]
                                    : get_block_mv(candidate,
 #if CONFIG_C071_SUBBLK_WARPMV
@@ -500,7 +501,9 @@
         }
 #else
         const int is_gm_block =
-            is_global_mv_block(candidate, gm_params[rf[0]].wmtype);
+            rf[0] == NONE_FRAME || rf[0] == INTRA_FRAME
+                ? 0
+                : is_global_mv_block(candidate, gm_params[rf[0]]->wmtype);
         const int_mv this_refmv = is_gm_block ? gm_mv_candidates[0]
                                               : get_block_mv(candidate,
 #if CONFIG_C071_SUBBLK_WARPMV
@@ -552,7 +555,7 @@
               cm->ref_frame_relative_dist[candidate->ref_frame[ref]];
 
           const int is_gm_block = is_global_mv_block(
-              candidate, gm_params[candidate->ref_frame[ref]].wmtype);
+              candidate, gm_params[candidate->ref_frame[ref]]->wmtype);
           const int_mv cand_refmv = is_gm_block ? gm_mv_candidates[0]
                                                 : get_block_mv(candidate,
 #if CONFIG_C071_SUBBLK_WARPMV
@@ -613,7 +616,7 @@
         int_mv this_refmv[2];
 
         for (ref = 0; ref < 2; ++ref) {
-          if (is_global_mv_block(candidate, gm_params[rf[ref]].wmtype))
+          if (is_global_mv_block(candidate, gm_params[rf[ref]]->wmtype))
             this_refmv[ref] = gm_mv_candidates[ref];
           else
             this_refmv[ref] = get_block_mv(candidate,
@@ -664,7 +667,7 @@
         if (candidate_ref_idx0 != -1 && candidate_ref_idx1 != -1) {
           int_mv this_refmv[2];
           const int is_gm_block = is_global_mv_block(
-              candidate, gm_params[rf[candidate_ref_idx0]].wmtype);
+              candidate, gm_params[rf[candidate_ref_idx0]]->wmtype);
           this_refmv[candidate_ref_idx0] =
               is_gm_block ? gm_mv_candidates[candidate_ref_idx0]
                           : get_block_mv(candidate,
@@ -816,6 +819,7 @@
     int mi_col, const MV_REFERENCE_FRAME rf[2], int row_offset,
     CANDIDATE_MV *ref_mv_stack, uint16_t *ref_mv_weight, uint8_t *refmv_count,
     uint8_t *ref_match_count, uint8_t *newmv_count, int_mv *gm_mv_candidates,
+    const WarpedMotionParams *gm_params[INTER_REFS_PER_FRAME],
     int max_row_offset,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
     MV_REFERENCE_FRAME *ref_frame_idx0, MV_REFERENCE_FRAME *ref_frame_idx1,
@@ -830,7 +834,6 @@
     int max_num_of_warp_candidates, uint8_t *valid_num_warp_candidates,
     MV_REFERENCE_FRAME ref_frame,
 #endif  // CONFIG_WARP_REF_LIST
-
     int *processed_rows) {
   int end_mi = AOMMIN(xd->width, cm->mi_params.mi_cols - mi_col);
   end_mi = AOMMIN(end_mi, mi_size_wide[BLOCK_64X64]);
@@ -909,36 +912,34 @@
     }
 #endif  // CONFIG_WARP_REF_LIST
 
-    add_ref_mv_candidate(
+    add_ref_mv_candidate(cm,
 #if CONFIG_TIP
-#if !CONFIG_SMVP_IMPROVEMENT
-        cm,
-#endif  // !CONFIG_SMVP_IMPROVEMENT
-        mi_row, mi_col, cand_mi_row, cand_mi_col,
+                         mi_row, mi_col, cand_mi_row, cand_mi_col,
 #endif  // CONFIG_TIP
-        candidate,
+                         candidate,
 #if CONFIG_C071_SUBBLK_WARPMV
-        submi,
+                         submi,
 #endif  // CONFIG_C071_SUBBLK_WARPMV
-        rf, refmv_count, ref_match_count, newmv_count, ref_mv_stack,
-        ref_mv_weight, gm_mv_candidates, cm->global_motion,
+                         rf, refmv_count, ref_match_count, newmv_count,
+                         ref_mv_stack, ref_mv_weight, gm_mv_candidates,
+                         gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
-        xd->mi[0], ref_frame_idx0, ref_frame_idx1,
+                         xd->mi[0], ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
 #if CONFIG_SMVP_IMPROVEMENT
-        cm, add_more_mvs, single_mv, single_mv_count, derived_mv_stack,
-        derived_mv_weight, derived_mv_count,
+                         add_more_mvs, single_mv, single_mv_count,
+                         derived_mv_stack, derived_mv_weight, derived_mv_count,
 #endif  // CONFIG_SMVP_IMPROVEMENT
 #if CONFIG_IBC_SR_EXT
-        xd->mi[0]->use_intrabc[xd->tree_type == CHROMA_PART],
+                         xd->mi[0]->use_intrabc[xd->tree_type == CHROMA_PART],
 #endif  // CONFIG_IBC_SR_EXT
 #if CONFIG_EXTENDED_WARP_PREDICTION
-        row_offset, col_offset + i,
+                         row_offset, col_offset + i,
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
-        len * weight
+                         len * weight
 #if CONFIG_FLEX_MVRES
-        ,
-        precision
+                         ,
+                         precision
 #endif
     );
 
@@ -980,7 +981,9 @@
 #endif  // CONFIG_TIP || CONFIG_EXT_RECUR_PARTITIONS
     const MV_REFERENCE_FRAME rf[2], int col_offset, CANDIDATE_MV *ref_mv_stack,
     uint16_t *ref_mv_weight, uint8_t *refmv_count, uint8_t *ref_match_count,
-    uint8_t *newmv_count, int_mv *gm_mv_candidates, int max_col_offset,
+    uint8_t *newmv_count, int_mv *gm_mv_candidates,
+    const WarpedMotionParams *gm_params[INTER_REFS_PER_FRAME],
+    int max_col_offset,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
     MV_REFERENCE_FRAME *ref_frame_idx0, MV_REFERENCE_FRAME *ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1070,36 +1073,34 @@
     }
 #endif  // CONFIG_WARP_REF_LIST
 
-    add_ref_mv_candidate(
+    add_ref_mv_candidate(cm,
 #if CONFIG_TIP
-#if !CONFIG_SMVP_IMPROVEMENT
-        cm,
-#endif  // !CONFIG_SMVP_IMPROVEMENT
-        mi_row, mi_col, cand_mi_row, cand_mi_col,
+                         mi_row, mi_col, cand_mi_row, cand_mi_col,
 #endif  // CONFIG_TIP
-        candidate,
+                         candidate,
 #if CONFIG_C071_SUBBLK_WARPMV
-        submi,
+                         submi,
 #endif  // CONFIG_C071_SUBBLK_WARPMV
-        rf, refmv_count, ref_match_count, newmv_count, ref_mv_stack,
-        ref_mv_weight, gm_mv_candidates, cm->global_motion,
+                         rf, refmv_count, ref_match_count, newmv_count,
+                         ref_mv_stack, ref_mv_weight, gm_mv_candidates,
+                         gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
-        xd->mi[0], ref_frame_idx0, ref_frame_idx1,
+                         xd->mi[0], ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
 #if CONFIG_SMVP_IMPROVEMENT
-        cm, add_more_mvs, single_mv, single_mv_count, derived_mv_stack,
-        derived_mv_weight, derived_mv_count,
+                         add_more_mvs, single_mv, single_mv_count,
+                         derived_mv_stack, derived_mv_weight, derived_mv_count,
 #endif  // CONFIG_SMVP_IMPROVEMENT
 #if CONFIG_IBC_SR_EXT
-        xd->mi[0]->use_intrabc[xd->tree_type == CHROMA_PART],
+                         xd->mi[0]->use_intrabc[xd->tree_type == CHROMA_PART],
 #endif  // CONFIG_IBC_SR_EXT
 #if CONFIG_EXTENDED_WARP_PREDICTION
-        row_offset + i, col_offset,
+                         row_offset + i, col_offset,
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
-        len * weight
+                         len * weight
 #if CONFIG_FLEX_MVRES
-        ,
-        precision
+                         ,
+                         precision
 #endif
     );
     i += len;
@@ -1130,6 +1131,7 @@
     const int mi_col, const MV_REFERENCE_FRAME rf[2], int row_offset,
     int col_offset, CANDIDATE_MV *ref_mv_stack, uint16_t *ref_mv_weight,
     uint8_t *ref_match_count, uint8_t *newmv_count, int_mv *gm_mv_candidates,
+    const WarpedMotionParams *gm_params[INTER_REFS_PER_FRAME],
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
     MV_REFERENCE_FRAME *ref_frame_idx0, MV_REFERENCE_FRAME *ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1181,40 +1183,38 @@
     }
 #endif  // CONFIG_WARP_REF_LIST
 
-    add_ref_mv_candidate(
+    add_ref_mv_candidate(cm,
 #if CONFIG_TIP
-#if !CONFIG_SMVP_IMPROVEMENT
-        cm,
-#endif  // !CONFIG_SMVP_IMPROVEMENT
-        mi_row, mi_col, cand_mi_row, cand_mi_col,
+                         mi_row, mi_col, cand_mi_row, cand_mi_col,
 #endif  // CONFIG_TIP
-        candidate,
+                         candidate,
 #if CONFIG_C071_SUBBLK_WARPMV
-        submi,
+                         submi,
 #endif  // CONFIG_C071_SUBBLK_WARPMV
-        rf, refmv_count, ref_match_count, newmv_count, ref_mv_stack,
-        ref_mv_weight, gm_mv_candidates, cm->global_motion,
+                         rf, refmv_count, ref_match_count, newmv_count,
+                         ref_mv_stack, ref_mv_weight, gm_mv_candidates,
+                         gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
-        xd->mi[0], ref_frame_idx0, ref_frame_idx1,
+                         xd->mi[0], ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
 #if CONFIG_SMVP_IMPROVEMENT
-        cm, add_more_mvs, single_mv, single_mv_count, derived_mv_stack,
-        derived_mv_weight, derived_mv_count,
+                         add_more_mvs, single_mv, single_mv_count,
+                         derived_mv_stack, derived_mv_weight, derived_mv_count,
 #endif  // CONFIG_SMVP_IMPROVEMENT
 #if CONFIG_IBC_SR_EXT
-        xd->mi[0]->use_intrabc[xd->tree_type == CHROMA_PART],
+                         xd->mi[0]->use_intrabc[xd->tree_type == CHROMA_PART],
 #endif  // CONFIG_IBC_SR_EXT
 #if CONFIG_EXTENDED_WARP_PREDICTION
-        row_offset, col_offset,
+                         row_offset, col_offset,
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
 #if CONFIG_COMPLEXITY_SCALABLE_MVP
-        weight * len
+                         weight * len
 #else
-        2 * len
+                         2 * len
 #endif
 #if CONFIG_FLEX_MVRES
-        ,
-        precision
+                         ,
+                         precision
 #endif
     );
   }  // Analyze a single 8x8 block motion information.
@@ -1789,8 +1789,12 @@
   const int has_bl = has_bottom_left(cm, xd, mi_row, mi_col, bs);
 #endif  // CONFIG_C043_MVP_IMPROVEMENTS
 #endif  // CONFIG_EXT_RECUR_PARTITIONS
-  MV_REFERENCE_FRAME rf[2];
+  const WarpedMotionParams *gm_params[INTER_REFS_PER_FRAME];
+  for (int r = 0; r < INTER_REFS_PER_FRAME; ++r) {
+    gm_params[r] = effective_global_motion(xd, r);
+  }
 
+  MV_REFERENCE_FRAME rf[2];
   const TileInfo *const tile = &xd->tile;
   int max_row_offset = 0, max_col_offset = 0;
   const int row_adj = (xd->height < mi_size_high[BLOCK_8X8]) && (mi_row & 0x01);
@@ -1858,7 +1862,7 @@
   if (xd->left_available) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, (xd->height - 1), -1,
                   ref_mv_stack, ref_mv_weight, &col_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1877,7 +1881,7 @@
   if (xd->up_available) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, -1, (xd->width - 1), ref_mv_stack,
                   ref_mv_weight, &row_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1894,7 +1898,7 @@
   if (xd->left_available) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, 0, -1, ref_mv_stack,
                   ref_mv_weight, &col_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1913,7 +1917,7 @@
   if (xd->up_available) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, -1, 0, ref_mv_stack,
                   ref_mv_weight, &row_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1930,7 +1934,7 @@
   if (has_bl) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, xd->height, -1, ref_mv_stack,
                   ref_mv_weight, &col_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1947,7 +1951,7 @@
   if (has_tr) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, -1, xd->width, ref_mv_stack,
                   ref_mv_weight, &row_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1966,7 +1970,7 @@
     uint8_t dummy_new_mv_count = 0;
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, -1, -1, ref_mv_stack,
                   ref_mv_weight, &dummy_ref_match_count, &dummy_new_mv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -1983,7 +1987,7 @@
   if (xd->left_available) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, (xd->height >> 1), -1,
                   ref_mv_stack, ref_mv_weight, &col_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -2002,7 +2006,7 @@
   if (xd->up_available) {
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, -1, (xd->width >> 1),
                   ref_mv_stack, ref_mv_weight, &row_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -2024,7 +2028,7 @@
                   mi_row,
 #endif  // CONFIG_TIP || CONFIG_EXT_RECUR_PARTITIONS
                   mi_col, rf, -1, ref_mv_stack, ref_mv_weight, refmv_count,
-                  &row_match_count, &newmv_count, gm_mv_candidates,
+                  &row_match_count, &newmv_count, gm_mv_candidates, gm_params,
                   max_row_offset,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
@@ -2046,7 +2050,7 @@
                   mi_col,
 #endif  // CONFIG_TIP || CONFIG_EXT_RECUR_PARTITIONS
                   rf, -1, ref_mv_stack, ref_mv_weight, refmv_count,
-                  &col_match_count, &newmv_count, gm_mv_candidates,
+                  &col_match_count, &newmv_count, gm_mv_candidates, gm_params,
                   max_col_offset,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
@@ -2065,7 +2069,7 @@
   if (has_tr)
     scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, -1, xd->width, ref_mv_stack,
                   ref_mv_weight, &row_match_count, &newmv_count,
-                  gm_mv_candidates,
+                  gm_mv_candidates, gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                   ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -2202,6 +2206,7 @@
   // Scan the second outer area.
   scan_blk_mbmi(cm, xd, mi_row, mi_col, rf, -1, -1, ref_mv_stack, ref_mv_weight,
                 &row_match_count, &dummy_newmv_count, gm_mv_candidates,
+                gm_params,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                 ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -2227,7 +2232,7 @@
 #endif  // CONFIG_TIP || CONFIG_EXT_RECUR_PARTITIONS
                     rf, col_offset, ref_mv_stack, ref_mv_weight, refmv_count,
                     &col_match_count, &dummy_newmv_count, gm_mv_candidates,
-                    max_col_offset,
+                    gm_params, max_col_offset,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                     ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -2253,7 +2258,7 @@
 #endif  // CONFIG_TIP || CONFIG_EXT_RECUR_PARTITIONS
                     mi_col, rf, row_offset, ref_mv_stack, ref_mv_weight,
                     refmv_count, &row_match_count, &dummy_newmv_count,
-                    gm_mv_candidates, max_row_offset,
+                    gm_mv_candidates, gm_params, max_row_offset,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                     ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -2272,7 +2277,7 @@
 #endif  // CONFIG_TIP || CONFIG_EXT_RECUR_PARTITIONS
                     rf, col_offset, ref_mv_stack, ref_mv_weight, refmv_count,
                     &col_match_count, &dummy_newmv_count, gm_mv_candidates,
-                    max_col_offset,
+                    gm_params, max_col_offset,
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
                     ref_frame_idx0, ref_frame_idx1,
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
@@ -2543,6 +2548,7 @@
     // Handle single reference frame extension
 #if CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
     assert(!xd->mi[0]->skip_mode);
+
 #endif  // CONFIG_SKIP_MODE_DRL_WITH_REF_IDX
 #if CONFIG_IBC_SR_EXT
     if (!xd->mi[0]->use_intrabc[xd->tree_type == CHROMA_PART]) {
@@ -2687,13 +2693,14 @@
 
     // Insert Global motion of the current
     if (*valid_num_warp_candidates < max_num_of_warp_candidates) {
-      if (!xd->global_motion[ref_frame].invalid &&
+      const WarpedMotionParams *global_motion =
+          effective_global_motion(xd, ref_frame);
+      if (!global_motion->invalid &&
           !is_this_param_already_in_list(*valid_num_warp_candidates,
-                                         warp_param_stack,
-                                         xd->global_motion[ref_frame])) {
-        insert_neighbor_warp_candidate(
-            warp_param_stack, &xd->global_motion[ref_frame],
-            *valid_num_warp_candidates, PROJ_GLOBAL_MOTION);
+                                         warp_param_stack, *global_motion)) {
+        insert_neighbor_warp_candidate(warp_param_stack, global_motion,
+                                       *valid_num_warp_candidates,
+                                       PROJ_GLOBAL_MOTION);
         (*valid_num_warp_candidates)++;
       }
     }
@@ -2744,12 +2751,13 @@
 }
 
 #if CONFIG_TEMPORAL_GLOBAL_MV
-// This function compute the projected samples of a 8x8 block
+// This function computes the projected samples of a 8x8 block
 static void get_block_mv_from_single_reference_motion_projection(
     const AV1_COMMON *cm, const MACROBLOCKD *xd, int mi_row, int mi_col,
     MV_REFERENCE_FRAME ref_frame, int blk_row, int blk_col,
     int *const points_count, int_mv *projected_mvs, int *pts, int *pts_inref) {
   POSITION mi_pos;
+
   mi_pos.row = (mi_row & 0x01) ? blk_row : blk_row + 1;
   mi_pos.col = (mi_col & 0x01) ? blk_col : blk_col + 1;
 
@@ -2793,13 +2801,13 @@
   int_mv this_refmv;
   get_mv_projection(&this_refmv.as_mv, projected_frame_mvs->mfmv0.as_mv,
                     cur_offset_0, projected_frame_mvs->ref_frame_offset);
+
 #if CONFIG_FLEX_MVRES
   lower_mv_precision(&this_refmv.as_mv, fr_mv_precision);
 #else
   lower_mv_precision(&this_refmv.as_mv, allow_high_precision_mv,
                      force_integer_mv);
 #endif
-
   // TODO (Mohammed): double check this clamping
   clamp_mv_ref(&this_refmv.as_mv, xd->width << MI_SIZE_LOG2,
                xd->height << MI_SIZE_LOG2, xd);
@@ -2898,8 +2906,20 @@
   return points_count;
 }
 
-void av1_set_temporal_global_mvs_sb(const AV1_COMMON *cm, const MACROBLOCKD *xd,
+void av1_set_temporal_global_mvs_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
                                     const int mi_row, const int mi_col) {
+  // Setup xd size & location parameters for the SB to handle clipping
+  const int mi_rows_left = cm->mi_params.mi_rows - mi_row;
+  const int mi_cols_left = cm->mi_params.mi_cols - mi_col;
+  xd->height = AOMMIN(mi_size_high[cm->seq_params.sb_size], mi_rows_left);
+  xd->width = AOMMIN(mi_size_wide[cm->seq_params.sb_size], mi_cols_left);
+  xd->mb_to_top_edge = -GET_MV_SUBPEL(mi_row * MI_SIZE);
+  xd->mb_to_bottom_edge =
+      GET_MV_SUBPEL((cm->mi_params.mi_rows - xd->height - mi_row) * MI_SIZE);
+  xd->mb_to_left_edge = -GET_MV_SUBPEL((mi_col * MI_SIZE));
+  xd->mb_to_right_edge =
+      GET_MV_SUBPEL((cm->mi_params.mi_cols - xd->width - mi_col) * MI_SIZE);
+
   SB_INFO *sbi = xd->sbi;
   int srcpts[2 * MAX_NUM_OF_8x8_SB];
   int refpts[2 * MAX_NUM_OF_8x8_SB];
@@ -2909,9 +2929,10 @@
     int npts = av1_find_single_ref_projected_samples_sb(
         cm, xd, ref_frame, mi_row, mi_col, NULL, srcpts, refpts);
     if (npts > 0) {
-      av1_find_projection_unconstrained(npts, srcpts, refpts,
-                                        &sbi->tpl_global_motion[ref_frame],
-                                        mi_row, mi_col);
+      if (av1_find_projection_unconstrained(npts, srcpts, refpts,
+                                            &sbi->tpl_global_motion[ref_frame],
+                                            mi_row, mi_col))
+        sbi->tpl_global_motion[ref_frame].invalid = 1;
     }
   }
 }
@@ -3012,12 +3033,13 @@
 #endif
     if (ref_frame < INTER_REFS_PER_FRAME) {
 #if CONFIG_FLEX_MVRES
-      gm_mv[0] = get_warp_motion_vector(xd, &cm->global_motion[ref_frame],
-                                        fr_mv_precision, bsize, mi_col, mi_row);
+      gm_mv[0] =
+          get_warp_motion_vector(xd, effective_global_motion(xd, ref_frame),
+                                 fr_mv_precision, bsize, mi_col, mi_row);
 #else
-      gm_mv[0] = get_warp_motion_vector(xd, &cm->global_motion[ref_frame],
-                                        allow_high_precision_mv, bsize, mi_col,
-                                        mi_row, force_integer_mv);
+      gm_mv[0] = get_warp_motion_vector(
+          xd, effective_global_motion(xd, ref_frame), allow_high_precision_mv,
+          bsize, mi_col, mi_row, force_integer_mv);
 #endif
       gm_mv[1].as_int = 0;
       if (global_mvs != NULL) global_mvs[ref_frame] = gm_mv[0];
@@ -3025,15 +3047,15 @@
       MV_REFERENCE_FRAME rf[2];
       av1_set_ref_frame(rf, ref_frame);
 #if CONFIG_FLEX_MVRES
-      gm_mv[0] = get_warp_motion_vector(xd, &cm->global_motion[rf[0]],
+      gm_mv[0] = get_warp_motion_vector(xd, effective_global_motion(xd, rf[0]),
                                         fr_mv_precision, bsize, mi_col, mi_row);
-      gm_mv[1] = get_warp_motion_vector(xd, &cm->global_motion[rf[1]],
+      gm_mv[1] = get_warp_motion_vector(xd, effective_global_motion(xd, rf[1]),
                                         fr_mv_precision, bsize, mi_col, mi_row);
 #else
-      gm_mv[0] = get_warp_motion_vector(xd, &cm->global_motion[rf[0]],
+      gm_mv[0] = get_warp_motion_vector(xd, effective_global_motion(xd, rf[0]),
                                         allow_high_precision_mv, bsize, mi_col,
                                         mi_row, force_integer_mv);
-      gm_mv[1] = get_warp_motion_vector(xd, &cm->global_motion[rf[1]],
+      gm_mv[1] = get_warp_motion_vector(xd, effective_global_motion(xd, rf[1]),
                                         allow_high_precision_mv, bsize, mi_col,
                                         mi_row, force_integer_mv);
 #endif
@@ -4380,7 +4402,8 @@
     uint8_t *p_valid_num_candidates) {
   // Global MV mode insert the global motion
   if (mbmi->mode == GLOBALMV) {
-    warp_param_stack[0].wm_params = xd->global_motion[mbmi->ref_frame[0]];
+    warp_param_stack[0].wm_params =
+        *effective_global_motion(xd, mbmi->ref_frame[0]);
     warp_param_stack[0].proj_type = PROJ_GLOBAL_MOTION;
     if (p_valid_num_candidates) {
       *p_valid_num_candidates = 1;
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h
index 3be13df..e86a73a 100644
--- a/av1/common/mvref_common.h
+++ b/av1/common/mvref_common.h
@@ -981,7 +981,7 @@
       }
     }
   }
-  *params = xd->global_motion[mbmi->ref_frame[0]];
+  *params = effective_global_motion(xd, mbmi->ref_frame[0]);
 #else
   assert(mbmi->warp_ref_idx < mbmi->max_num_warp_candidates);
   *params = warp_param_stack[mbmi->warp_ref_idx].wm_params;
@@ -1121,7 +1121,7 @@
                                              const int mi_row, const int mi_col,
                                              int_mv *projected_mvs, int *pts,
                                              int *pts_inref);
-void av1_set_temporal_global_mvs_sb(const AV1_COMMON *cm, const MACROBLOCKD *xd,
+void av1_set_temporal_global_mvs_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
                                     const int mi_row, const int mi_col);
 #endif  // CONFIG_TEMPORAL_GLOBAL_MV
 
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index bf3ced3..50039bc 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -121,12 +121,12 @@
 
   if (xd->cur_frame_force_integer_mv) return;
 
-  if (av1_allow_warp(mi, warp_types, &xd->global_motion[mi->ref_frame[ref]],
+  if (av1_allow_warp(
+          mi, warp_types, effective_global_motion(xd, mi->ref_frame[ref]),
 #if CONFIG_EXTENDED_WARP_PREDICTION
-                     ref,
+          ref,
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
-                     0, inter_pred_params->scale_factors,
-                     &inter_pred_params->warp_params))
+          0, inter_pred_params->scale_factors, &inter_pred_params->warp_params))
     inter_pred_params->mode = WARP_PRED;
 }
 
@@ -747,7 +747,8 @@
   struct macroblockd_plane *const pd = &xd->plane[plane];
   struct buf_2d *const dst_buf = &pd->dst;
 
-  const WarpedMotionParams *const wm = &xd->global_motion[mi->ref_frame[ref]];
+  const WarpedMotionParams *const wm =
+      effective_global_motion(xd, mi->ref_frame[ref]);
   const WarpTypesAllowed warp_types = { is_global_mv_block(mi, wm->wmtype),
                                         is_warp_mode(mi->motion_mode) };
 #if CONFIG_OPTFLOW_ON_TIP
@@ -1769,7 +1770,7 @@
     if (!is_tip_ref_frame(mi->ref_frame[ref])) {
 #endif  // CONFIG_TIP
       const WarpedMotionParams *const wm =
-          &xd->global_motion[mi->ref_frame[ref]];
+          effective_global_motion(xd, mi->ref_frame[ref]);
       is_global[ref] = is_global_mv_block(mi, wm->wmtype);
 #if CONFIG_TIP
     }
diff --git a/av1/common/warped_motion.c b/av1/common/warped_motion.c
index 3fd82b6..2c50577 100644
--- a/av1/common/warped_motion.c
+++ b/av1/common/warped_motion.c
@@ -1377,18 +1377,25 @@
 #endif  // CONFIG_EXTENDED_WARP_PREDICTION
 
   wm->wmmat[6] = wm->wmmat[7] = 0;
-  wm->wmtype = AFFINE;
+  set_wmtype_from_params(wm);
   return 0;
 }
 
 int av1_find_projection_unconstrained(int np, const int *pts1, const int *pts2,
                                       WarpedMotionParams *wm_params, int mi_row,
                                       int mi_col) {
-  if (find_affine_unconstrained_int(np, pts1, pts2, wm_params, mi_row, mi_col))
+  *wm_params = default_warp_params;
+  if (find_affine_unconstrained_int(np, pts1, pts2, wm_params, mi_row,
+                                    mi_col)) {
+    wm_params->invalid = 1;
     return 1;
+  }
 
   // check compatibility with the fast warp filter
-  if (!av1_get_shear_params(wm_params)) return 1;
+  if (!av1_get_shear_params(wm_params)) {
+    wm_params->invalid = 1;
+    return 1;
+  }
 
   return 0;
 }
diff --git a/av1/common/warped_motion.h b/av1/common/warped_motion.h
index bd55357..7ac8e0d 100644
--- a/av1/common/warped_motion.h
+++ b/av1/common/warped_motion.h
@@ -344,6 +344,28 @@
 #endif  // CONFIG_INTERINTRA_WARP
 }
 
+static INLINE void set_wmtype_from_params(WarpedMotionParams *wm_params) {
+  if (wm_params->wmmat[2] == (1 << WARPEDMODEL_PREC_BITS) &&
+      wm_params->wmmat[5] == (1 << WARPEDMODEL_PREC_BITS) &&
+      wm_params->wmmat[3] == 0 && wm_params->wmmat[4] == 0 &&
+      wm_params->wmmat[6] == 0 && wm_params->wmmat[7] == 0) {
+    if (wm_params->wmmat[0] == 0 && wm_params->wmmat[1] == 0)
+      wm_params->wmtype = IDENTITY;
+    else
+      wm_params->wmtype = TRANSLATION;
+    return;
+  }
+  if (wm_params->wmmat[6] == 0 && wm_params->wmmat[7] == 0) {
+    if (wm_params->wmmat[2] == wm_params->wmmat[5] &&
+        wm_params->wmmat[3] == -wm_params->wmmat[4])
+      wm_params->wmtype = ROTZOOM;
+    else
+      wm_params->wmtype = AFFINE;
+    return;
+  }
+  wm_params->wmtype = HOMOGRAPHY;
+}
+
 #if CONFIG_IMPROVED_GLOBAL_MOTION
 static INLINE void av1_scale_warp_model(const WarpedMotionParams *in_params,
                                         int in_distance,
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index bdb5dd5..48a2b21 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -4360,6 +4360,9 @@
          mi_col += cm->seq_params.mib_size) {
       av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
       av1_set_sb_info(cm, xd, mi_row, mi_col);
+#if CONFIG_TEMPORAL_GLOBAL_MV
+      av1_set_temporal_global_mvs_sb(cm, xd, mi_row, mi_col);
+#endif  // CONFIG_TEMPORAL_GLOBAL_MV
       set_cb_buffer(pbi, dcb, &td->cb_buffer_base, num_planes, 0, 0);
 #if CONFIG_REF_MV_BANK
       // td->ref_mv_bank is initialized as xd->ref_mv_bank, and used
@@ -4881,6 +4884,9 @@
          mi_col += cm->seq_params.mib_size) {
       av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
       av1_set_sb_info(cm, xd, mi_row, mi_col);
+#if CONFIG_TEMPORAL_GLOBAL_MV
+      av1_set_temporal_global_mvs_sb(cm, xd, mi_row, mi_col);
+#endif  // CONFIG_TEMPORAL_GLOBAL_MV
       set_cb_buffer(pbi, dcb, pbi->cb_buffer_base, num_planes, mi_row, mi_col);
 
 #if CONFIG_REF_MV_BANK
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 55751d6..e47ee97 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -2232,12 +2232,12 @@
     case GLOBALMV: {
 #if CONFIG_FLEX_MVRES
       mv[0].as_int =
-          get_warp_motion_vector(xd, &cm->global_motion[ref_frame[0]],
+          get_warp_motion_vector(xd, effective_global_motion(xd, ref_frame[0]),
                                  features->fr_mv_precision, bsize, xd->mi_col,
                                  xd->mi_row)
 #else
       mv[0].as_int = get_warp_motion_vector(
-                         xd, &cm->global_motion[ref_frame[0]],
+                         xd, effective_global_motion(xd, ref_frame[0]),
                          features->allow_high_precision_mv, bsize, xd->mi_col,
                          xd->mi_row, features->cur_frame_force_integer_mv)
 #endif
@@ -2334,7 +2334,7 @@
     case GLOBAL_GLOBALMV: {
       assert(is_compound);
       mv[0].as_int =
-          get_warp_motion_vector(xd, &cm->global_motion[ref_frame[0]],
+          get_warp_motion_vector(xd, effective_global_motion(xd, ref_frame[0]),
 #if CONFIG_FLEX_MVRES
                                  features->fr_mv_precision,
 #else
@@ -2348,7 +2348,7 @@
                                  )
               .as_int;
       mv[1].as_int =
-          get_warp_motion_vector(xd, &cm->global_motion[ref_frame[1]],
+          get_warp_motion_vector(xd, effective_global_motion(xd, ref_frame[1]),
 #if CONFIG_FLEX_MVRES
                                  features->fr_mv_precision,
 #else
diff --git a/av1/encoder/compound_type.c b/av1/encoder/compound_type.c
index c80874a..03aea21 100644
--- a/av1/encoder/compound_type.c
+++ b/av1/encoder/compound_type.c
@@ -45,7 +45,8 @@
         (st->mv[i].as_int != mi->mv[i].as_int)) {
       return 0;
     }
-    const WarpedMotionParams *const wm = &xd->global_motion[mi->ref_frame[i]];
+    const WarpedMotionParams *const wm =
+        effective_global_motion(xd, mi->ref_frame[i]);
     if (is_global_mv_block(mi, wm->wmtype) != st->is_global[i]) return 0;
   }
 
@@ -1048,7 +1049,7 @@
     const MACROBLOCKD *const xd = &x->e_mbd;
     for (int i = 0; i < 2; ++i) {
       const WarpedMotionParams *const wm =
-          &xd->global_motion[mbmi->ref_frame[i]];
+          effective_global_motion(xd, mbmi->ref_frame[i]);
       rd_stats->is_global[i] = is_global_mv_block(mbmi, wm->wmtype);
     }
     memcpy(&rd_stats->interinter_comp, &mbmi->interinter_comp,
diff --git a/av1/encoder/context_tree.c b/av1/encoder/context_tree.c
index f8e4822..5da7ab7 100644
--- a/av1/encoder/context_tree.c
+++ b/av1/encoder/context_tree.c
@@ -315,6 +315,13 @@
   dst->rd_cost = src->rd_cost;
   dst->none_rd = src->none_rd;
   dst->skippable = src->skippable;
+#if CONFIG_C043_MVP_IMPROVEMENTS
+  dst->ref_mv_bank = src->ref_mv_bank;
+#endif  // CONFIG_C043_MVP_IMPROVEMENTS
+#if WARP_CU_BANK
+  dst->warp_param_bank = src->warp_param_bank;
+#endif  // WARP_CU_BANK
+
   const BLOCK_SIZE bsize = dst->block_size;
   const BLOCK_SIZE subsize = get_partition_subsize(bsize, src->partitioning);
   const int mi_row = src->mi_row;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index fd45509..1063b71 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -945,6 +945,9 @@
     (*(enc_row_mt->sync_read_ptr))(row_mt_sync, sb_row, sb_col_in_tile);
     av1_reset_is_mi_coded_map(xd, cm->seq_params.mib_size);
     av1_set_sb_info(cm, xd, mi_row, mi_col);
+#if CONFIG_TEMPORAL_GLOBAL_MV
+    av1_set_temporal_global_mvs_sb(cm, xd, mi_row, mi_col);
+#endif  // CONFIG_TEMPORAL_GLOBAL_MV
 
     if (tile_data->allow_update_cdf && row_mt_enabled &&
         (tile_info->mi_row_start != mi_row)) {
diff --git a/av1/encoder/partition_search.c b/av1/encoder/partition_search.c
index e2ed6cf..e3e848d 100644
--- a/av1/encoder/partition_search.c
+++ b/av1/encoder/partition_search.c
@@ -370,7 +370,6 @@
   } else {
     int ref;
     const int is_compound = has_second_ref(mbmi);
-
     set_ref_ptrs(cm, xd, mbmi->ref_frame[0], mbmi->ref_frame[1]);
     for (ref = 0; ref < 1 + is_compound; ++ref) {
       const YV12_BUFFER_CONFIG *cfg =
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index a54904f..da3e767 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -905,12 +905,13 @@
     return 0;
   }
   PREDICTION_MODE compare_mode = MB_MODE_COUNT;
+  const MACROBLOCKD *const xd = &x->e_mbd;
   if (this_mode == NEARMV && ref_mv_count == 1 &&
-      cm->global_motion[ref_frames[0]].wmtype <= TRANSLATION) {
+      effective_global_motion(xd, ref_frames[0])->wmtype <= TRANSLATION) {
     compare_mode = GLOBALMV;
   }
   if (this_mode == GLOBALMV && ref_mv_count == 0 &&
-      cm->global_motion[ref_frames[0]].wmtype <= TRANSLATION) {
+      effective_global_motion(xd, ref_frames[0])->wmtype <= TRANSLATION) {
     compare_mode = NEARMV;
   }
   if (this_mode == GLOBALMV && ref_mv_count == 1) {
@@ -2837,11 +2838,14 @@
              mi_size_high[mbmi->sb_type[PLANE_TYPE_Y]]) >= 2) {
     if (this_mode == GLOBALMV) {
       is_global_warp_block =
-          (xd->global_motion[mbmi->ref_frame[0]].wmtype > TRANSLATION);
+          (effective_global_motion(xd, mbmi->ref_frame[0])->wmtype >
+           TRANSLATION);
     } else if (this_mode == GLOBAL_GLOBALMV) {
       is_global_warp_block =
-          (xd->global_motion[mbmi->ref_frame[0]].wmtype > TRANSLATION) ||
-          (xd->global_motion[mbmi->ref_frame[1]].wmtype > TRANSLATION);
+          (effective_global_motion(xd, mbmi->ref_frame[0])->wmtype >
+           TRANSLATION) ||
+          (effective_global_motion(xd, mbmi->ref_frame[1])->wmtype >
+           TRANSLATION);
     }
   }
 
@@ -9018,10 +9022,12 @@
 #endif  // CONFIG_TIP
     mbmi->mv[0].as_int =
 #if CONFIG_FLEX_MVRES
-        get_warp_motion_vector(xd, &cm->global_motion[mbmi->ref_frame[0]],
+        get_warp_motion_vector(xd,
+                               effective_global_motion(xd, mbmi->ref_frame[0]),
                                features->fr_mv_precision, bsize, mi_col, mi_row)
 #else
-      get_warp_motion_vector(xd, &cm->global_motion[mbmi->ref_frame[0]],
+      get_warp_motion_vector(xd,
+                             effective_global_motion(xd, mbmi->ref_frame[0]),
                              features->allow_high_precision_mv, bsize, mi_col,
                              mi_row, features->cur_frame_force_integer_mv)
 #endif
diff --git a/av1/encoder/reconinter_enc.c b/av1/encoder/reconinter_enc.c
index 32bb328..eb73baa 100644
--- a/av1/encoder/reconinter_enc.c
+++ b/av1/encoder/reconinter_enc.c
@@ -337,7 +337,8 @@
   const int mi_x = mi_col * MI_SIZE;
   const int mi_y = mi_row * MI_SIZE;
   WarpTypesAllowed warp_types;
-  const WarpedMotionParams *const wm = &xd->global_motion[mi->ref_frame[ref]];
+  const WarpedMotionParams *const wm =
+      effective_global_motion(xd, mi->ref_frame[ref]);
   warp_types.global_warp_allowed = is_global_mv_block(mi, wm->wmtype);
   warp_types.local_warp_allowed = is_warp_mode(mi->motion_mode);
 
diff --git a/build/cmake/aom_experiment_deps.cmake b/build/cmake/aom_experiment_deps.cmake
index d83d116..4036bc2 100644
--- a/build/cmake/aom_experiment_deps.cmake
+++ b/build/cmake/aom_experiment_deps.cmake
@@ -91,11 +91,7 @@
     change_config_and_warn(CONFIG_H_PARTITION 0 !CONFIG_EXT_RECUR_PARTITIONS)
   endif()
 
-  # CONFIG_TEMPORAL_GLOBAL_MV depends on CONFIG_NEW_REF_SIGNALING and CONFIG_TIP
-  if(NOT CONFIG_NEW_REF_SIGNALING AND CONFIG_TEMPORAL_GLOBAL_MV)
-    change_config_and_warn(CONFIG_TEMPORAL_GLOBAL_MV 0
-                           !CONFIG_NEW_REF_SIGNALING)
-  endif()
+  # CONFIG_TEMPORAL_GLOBAL_MV depends on CONFIG_TIP
   if(NOT CONFIG_TIP AND CONFIG_TEMPORAL_GLOBAL_MV)
     change_config_and_warn(CONFIG_TEMPORAL_GLOBAL_MV 0 !CONFIG_TIP)
   endif()