Macro to disable warped/obmc_causal with global motion

Enabling SEPARATE_GLOBAL_MOTION will remove the ability for
a block that uses zeromv with global motion to pick warped_causal
or obmc_causal as the motion mode. When this is enabled there is:

0.05% drop on lowres for global + warped enabled
0.15% drop on midres for global + warped enabled

0.12% drop on lowres with global + motion var enabled
0.07% drop on midres with global + motion var enabled
No performance change for global, warped, or motion var individually.

Change-Id: Idbfb8dd7a93da14902438504b06a08e5212e48cb
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index a924ed8..4cf7b5b 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -415,6 +415,25 @@
 PREDICTION_MODE av1_above_block_mode(const MODE_INFO *cur_mi,
                                      const MODE_INFO *above_mi, int b);
 
+#if CONFIG_GLOBAL_MOTION
+static INLINE int is_global_mv_block(const MODE_INFO *mi, int block,
+                                     TransformationType type) {
+  PREDICTION_MODE mode = get_y_mode(mi, block);
+#if GLOBAL_SUB8X8_USED
+  const int block_size_allowed = 1;
+#else
+  const BLOCK_SIZE bsize = mi->mbmi.sb_type;
+  const int block_size_allowed = (bsize >= BLOCK_8X8);
+#endif  // GLOBAL_SUB8X8_USED
+#if CONFIG_EXT_INTER
+  return (mode == ZEROMV || mode == ZERO_ZEROMV) && type > TRANSLATION &&
+         block_size_allowed;
+#else
+  return mode == ZEROMV && type > TRANSLATION && block_size_allowed;
+#endif  // CONFIG_EXT_INTER
+}
+#endif  // CONFIG_GLOBAL_MOTION
+
 enum mv_precision { MV_PRECISION_Q3, MV_PRECISION_Q4 };
 
 struct buf_2d {
@@ -1061,7 +1080,16 @@
 }
 #endif
 
-static INLINE MOTION_MODE motion_mode_allowed(const MB_MODE_INFO *mbmi) {
+static INLINE MOTION_MODE motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+    int block, const WarpedMotionParams *gm_params,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+    const MODE_INFO *mi) {
+  const MB_MODE_INFO *mbmi = &mi->mbmi;
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+  const TransformationType gm_type = gm_params[mbmi->ref_frame[0]].wmtype;
+  if (is_global_mv_block(mi, block, gm_type)) return SIMPLE_TRANSLATION;
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
 #if CONFIG_EXT_INTER
   if (is_motion_variation_allowed_bsize(mbmi->sb_type) &&
       is_inter_mode(mbmi->mode) && mbmi->ref_frame[1] != INTRA_FRAME) {
@@ -1087,6 +1115,22 @@
   }
 }
 
+static INLINE void assert_motion_mode_valid(MOTION_MODE mode,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                            int block,
+                                            const WarpedMotionParams *gm_params,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                            const MODE_INFO *mi) {
+  const MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      block, gm_params,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      mi);
+  // Check that the input mode is not illegal
+  if (last_motion_mode_allowed < mode)
+    assert(0 && "Illegal motion mode selected");
+}
+
 #if CONFIG_MOTION_VAR
 static INLINE int is_neighbor_overlappable(const MB_MODE_INFO *mbmi) {
   return (is_inter_block(mbmi));
diff --git a/av1/common/mv.h b/av1/common/mv.h
index a2ba42c..122aa18 100644
--- a/av1/common/mv.h
+++ b/av1/common/mv.h
@@ -35,6 +35,9 @@
   int32_t col;
 } MV32;
 
+#if (CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR) && CONFIG_GLOBAL_MOTION
+#define SEPARATE_GLOBAL_MOTION 0
+#endif  // (CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR) && CONFIG_GLOBAL_MOTION
 #if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 // Bits of precision used for the model
 #define WARPEDMODEL_PREC_BITS 16
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index 7e3f9f3..61d46fa 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -1839,6 +1839,12 @@
       } else {
 #if CONFIG_WARPED_MOTION
         if (above_mbmi->motion_mode == WARPED_CAUSAL) {
+          assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   above_mi);
+
           av1_warp_plane(&above_mbmi->wm_params[0],
 #if CONFIG_AOM_HIGHBITDEPTH
                          xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
@@ -1961,6 +1967,12 @@
       } else {
 #if CONFIG_WARPED_MOTION
         if (left_mbmi->motion_mode == WARPED_CAUSAL) {
+          assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   left_mi);
+
           av1_warp_plane(&left_mbmi->wm_params[0],
 #if CONFIG_AOM_HIGHBITDEPTH
                          xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
@@ -2133,6 +2145,12 @@
       } else {
 #if CONFIG_WARPED_MOTION
         if (mbmi->motion_mode == WARPED_CAUSAL) {
+          assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   mi);
+
           av1_warp_plane(&mbmi->wm_params[0],
 #if CONFIG_AOM_HIGHBITDEPTH
                          xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
@@ -2258,6 +2276,12 @@
       } else {
 #if CONFIG_WARPED_MOTION
         if (mbmi->motion_mode == WARPED_CAUSAL) {
+          assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                   mi);
+
           av1_warp_plane(&mbmi->wm_params[0],
 #if CONFIG_AOM_HIGHBITDEPTH
                          xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
diff --git a/av1/common/reconinter.h b/av1/common/reconinter.h
index 5283217..533c79c 100644
--- a/av1/common/reconinter.h
+++ b/av1/common/reconinter.h
@@ -24,20 +24,6 @@
 extern "C" {
 #endif
 
-#if CONFIG_GLOBAL_MOTION
-static INLINE int is_global_mv_block(const MODE_INFO *mi, int block,
-                                     TransformationType type) {
-  PREDICTION_MODE mode = get_y_mode(mi, block);
-#if GLOBAL_SUB8X8_USED
-  const int block_size_allowed = 1;
-#else
-  const BLOCK_SIZE bsize = mi->mbmi.sb_type;
-  const int block_size_allowed = (bsize >= BLOCK_8X8);
-#endif  // GLOBAL_SUB8X8_USED
-  return mode == ZEROMV && type > TRANSLATION && block_size_allowed;
-}
-#endif  // CONFIG_GLOBAL_MOTION
-
 static INLINE void inter_predictor(const uint8_t *src, int src_stride,
                                    uint8_t *dst, int dst_stride,
                                    const int subpel_x, const int subpel_y,
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 0897f0c..fc7dcde 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1701,6 +1701,11 @@
 #if CONFIG_WARPED_MOTION
     if (mbmi->motion_mode == WARPED_CAUSAL) {
       int i;
+      assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               xd->mi[0]);
       for (i = 0; i < 3; ++i) {
         const struct macroblockd_plane *pd = &xd->plane[i];
 
@@ -1730,6 +1735,11 @@
 #endif  // CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
     if (mbmi->motion_mode == OBMC_CAUSAL) {
+      assert_motion_mode_valid(OBMC_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               xd->mi[0]);
 #if CONFIG_NCOBMC
       av1_build_ncobmc_inter_predictors_sb(cm, xd, mi_row, mi_col);
 #else
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index c7da753..afd2654 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -293,8 +293,13 @@
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 static MOTION_MODE read_motion_mode(AV1_COMMON *cm, MACROBLOCKD *xd,
-                                    MB_MODE_INFO *mbmi, aom_reader *r) {
-  MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(mbmi);
+                                    MODE_INFO *mi, aom_reader *r) {
+  MB_MODE_INFO *mbmi = &mi->mbmi;
+  const MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      mi);
   int motion_mode;
   FRAME_COUNTS *counts = xd->counts;
 
@@ -1991,7 +1996,13 @@
 #if CONFIG_EXT_INTER
     if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
-      mbmi->motion_mode = read_motion_mode(cm, xd, mbmi, r);
+      mbmi->motion_mode = read_motion_mode(cm, xd, mi, r);
+    assert_motion_mode_valid(mbmi->motion_mode,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                             0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                             xd->mi[0]);
+
 #if CONFIG_WARPED_MOTION
     if (mbmi->motion_mode == WARPED_CAUSAL) {
       mbmi->wm_params[0].wmtype = DEFAULT_WMTYPE;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 3c63639..f71201b 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -550,9 +550,14 @@
 }
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
-static void write_motion_mode(const AV1_COMMON *cm, const MB_MODE_INFO *mbmi,
+static void write_motion_mode(const AV1_COMMON *cm, const MODE_INFO *mi,
                               aom_writer *w) {
-  MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(mbmi);
+  const MB_MODE_INFO *mbmi = &mi->mbmi;
+  MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      mi);
 
   if (last_motion_mode_allowed == SIMPLE_TRANSLATION) return;
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
@@ -1862,7 +1867,7 @@
 #if CONFIG_EXT_INTER
       if (mbmi->ref_frame[1] != INTRA_FRAME)
 #endif  // CONFIG_EXT_INTER
-        write_motion_mode(cm, mbmi, w);
+        write_motion_mode(cm, mi, w);
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 5c6a4d2..fbd5ad5 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -2143,6 +2143,11 @@
 #endif  // CONFIG_EXT_INTER
 
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
+        const MOTION_MODE motion_allowed = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+            0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+            mi);
 #if CONFIG_SUPERTX
         if (!supertx_enabled)
 #endif  // CONFIG_SUPERTX
@@ -2151,13 +2156,13 @@
 #endif  // CONFIG_EXT_INTER
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
           {
-            if (motion_mode_allowed(mbmi) == WARPED_CAUSAL)
+            if (motion_allowed == WARPED_CAUSAL)
               counts->motion_mode[mbmi->sb_type][mbmi->motion_mode]++;
-            else if (motion_mode_allowed(mbmi) == OBMC_CAUSAL)
+            else if (motion_allowed == OBMC_CAUSAL)
               counts->obmc[mbmi->sb_type][mbmi->motion_mode == OBMC_CAUSAL]++;
           }
 #else
-        if (motion_mode_allowed(mbmi) > SIMPLE_TRANSLATION)
+        if (motion_allowed > SIMPLE_TRANSLATION)
           counts->motion_mode[mbmi->sb_type][mbmi->motion_mode]++;
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
@@ -2402,8 +2407,12 @@
   update_state(cpi, td, ctx, mi_row, mi_col, bsize, dry_run);
 #if CONFIG_MOTION_VAR && CONFIG_NCOBMC
   mbmi = &xd->mi[0]->mbmi;
-  check_ncobmc =
-      is_inter_block(mbmi) && motion_mode_allowed(mbmi) >= OBMC_CAUSAL;
+  const MOTION_MODE motion_allowed = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      mi);
+  check_ncobmc = is_inter_block(mbmi) && motion_allowed >= OBMC_CAUSAL;
   if (!dry_run && check_ncobmc) {
     av1_check_ncobmc_rd(cpi, x, mi_row, mi_col);
     av1_setup_dst_planes(x->e_mbd.plane, get_frame_new_buffer(&cpi->common),
@@ -5712,9 +5721,13 @@
 #if CONFIG_WARPED_MOTION
     if (mbmi->motion_mode == WARPED_CAUSAL) {
       int i;
+      assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               mi);
       for (i = 0; i < 3; ++i) {
         const struct macroblockd_plane *pd = &xd->plane[i];
-
         av1_warp_plane(&mbmi->wm_params[0],
 #if CONFIG_AOM_HIGHBITDEPTH
                        xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
@@ -5740,6 +5753,11 @@
 
 #if CONFIG_MOTION_VAR
     if (mbmi->motion_mode == OBMC_CAUSAL) {
+      assert_motion_mode_valid(OBMC_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               mi);
 #if CONFIG_NCOBMC
       if (dry_run == OUTPUT_ENABLED)
         av1_build_ncobmc_inter_predictors_sb(cm, xd, mi_row, mi_col);
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index cd126e7..daee3c4 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -8189,7 +8189,8 @@
     int mi_col, HandleInterModeArgs *args, const int64_t ref_best_rd) {
   const AV1_COMMON *cm = &cpi->common;
   MACROBLOCKD *xd = &x->e_mbd;
-  MB_MODE_INFO *mbmi = &xd->mi[0]->mbmi;
+  MODE_INFO *mi = xd->mi[0];
+  MB_MODE_INFO *mbmi = &mi->mbmi;
   MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
   const int is_comp_pred = has_second_ref(mbmi);
   const int this_mode = mbmi->mode;
@@ -8789,7 +8790,11 @@
 #endif  // CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
   rate2_nocoeff = rd_stats->rate;
-  last_motion_mode_allowed = motion_mode_allowed(mbmi);
+  last_motion_mode_allowed = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+      mi);
   base_mbmi = *mbmi;
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 
@@ -8811,6 +8816,11 @@
     mbmi->motion_mode = motion_mode;
 #if CONFIG_MOTION_VAR
     if (mbmi->motion_mode == OBMC_CAUSAL) {
+      assert_motion_mode_valid(OBMC_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               mi);
 #if CONFIG_EXT_INTER
       *mbmi = best_bmc_mbmi;
       mbmi->motion_mode = OBMC_CAUSAL;
@@ -8855,6 +8865,11 @@
 
 #if CONFIG_WARPED_MOTION
     if (mbmi->motion_mode == WARPED_CAUSAL) {
+      assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                               mi);
 #if CONFIG_EXT_INTER
       *mbmi = best_bmc_mbmi;
       mbmi->motion_mode = WARPED_CAUSAL;
@@ -10661,12 +10676,17 @@
         *returnrate_nocoef -= av1_cost_bit(av1_get_intra_inter_prob(cm, xd),
                                            mbmi->ref_frame[0] != INTRA_FRAME);
 #if CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
+        const MOTION_MODE motion_allowed = motion_mode_allowed(
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+            0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+            mi);
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
-        if (motion_mode_allowed(mbmi) == WARPED_CAUSAL)
+        if (motion_allowed == WARPED_CAUSAL)
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
           *returnrate_nocoef -= cpi->motion_mode_cost[bsize][mbmi->motion_mode];
 #if CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
-        else if (motion_mode_allowed(mbmi) == OBMC_CAUSAL)
+        else if (motion_allowed == OBMC_CAUSAL)
           *returnrate_nocoef -=
               cpi->motion_mode_cost1[bsize][mbmi->motion_mode];
 #endif  // CONFIG_MOTION_VAR && CONFIG_WARPED_MOTION
@@ -10744,6 +10764,11 @@
     if (is_inter_mode(mbmi->mode)) {
 #if CONFIG_WARPED_MOTION
       if (mbmi->motion_mode == WARPED_CAUSAL) {
+        assert_motion_mode_valid(WARPED_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                 0, xd->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                 xd->mi[0]);
         assert(!has_second_ref(mbmi));
 
         int plane;
@@ -10770,10 +10795,16 @@
       }
 #endif  // CONFIG_WARPED_MOTION
 #if CONFIG_MOTION_VAR
-      if (mbmi->motion_mode == OBMC_CAUSAL)
+      if (mbmi->motion_mode == OBMC_CAUSAL) {
+        assert_motion_mode_valid(OBMC_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                 0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                                 xd->mi[0]);
         av1_build_obmc_inter_prediction(
             cm, xd, mi_row, mi_col, args.above_pred_buf, args.above_pred_stride,
             args.left_pred_buf, args.left_pred_stride);
+      }
 #endif  // CONFIG_MOTION_VAR
       av1_subtract_plane(x, bsize, 0);
 #if CONFIG_VAR_TX
@@ -11221,6 +11252,18 @@
       || mbmi->mode == ZERO_ZEROMV
 #endif  // CONFIG_EXT_INTER
       ) {
+#if CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR
+    // Correct the motion mode for ZEROMV
+    const MOTION_MODE last_motion_mode_allowed = motion_mode_allowed(
+#if SEPARATE_GLOBAL_MOTION
+        0, xd->global_motion,
+#endif  // SEPARATE_GLOBAL_MOTION
+        xd->mi[0]);
+    if (mbmi->motion_mode > last_motion_mode_allowed)
+      mbmi->motion_mode = last_motion_mode_allowed;
+#endif  // CONFIG_WARPED_MOTION || CONFIG_MOTION_VAR
+
+    // Correct the interpolation filter for ZEROMV
     if (is_nontrans_global_motion(xd)) {
 #if CONFIG_DUAL_FILTER
       mbmi->interp_filter[0] = cm->interp_filter == SWITCHABLE
@@ -12472,6 +12515,11 @@
 
   // Check non-causal mode
   mbmi->motion_mode = OBMC_CAUSAL;
+  assert_motion_mode_valid(OBMC_CAUSAL,
+#if CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                           0, cm->global_motion,
+#endif  // CONFIG_GLOBAL_MOTION && SEPARATE_GLOBAL_MOTION
+                           mi);
   av1_build_ncobmc_inter_predictors_sb(cm, xd, mi_row, mi_col);
 
   av1_subtract_plane(x, bsize, 0);