Make global_motion work with ext_inter

Change-Id: I2a490e144099d7692296992528192c1f11d2c06f
diff --git a/av1/common/reconinter.c b/av1/common/reconinter.c
index 34e31b4..5442583 100644
--- a/av1/common/reconinter.c
+++ b/av1/common/reconinter.c
@@ -24,9 +24,6 @@
 #if CONFIG_MOTION_VAR
 #include "av1/common/onyxc_int.h"
 #endif  // CONFIG_MOTION_VAR
-#if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
-#include "av1/common/warped_motion.h"
-#endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 
 #if CONFIG_EXT_INTER
 
@@ -605,9 +602,13 @@
 #if CONFIG_SUPERTX
                                      int wedge_offset_x, int wedge_offset_y,
 #endif  // CONFIG_SUPERTX
-#if CONFIG_COMPOUND_SEGMENT
+#if CONFIG_COMPOUND_SEGMENT || CONFIG_GLOBAL_MOTION
                                      int plane,
-#endif  // CONFIG_COMPOUND_SEGMENT
+#endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_GLOBAL_MOTION
+#if CONFIG_GLOBAL_MOTION
+                                     int is_global, int p_col, int p_row,
+                                     int ref,
+#endif  // CONFIG_GLOBAL_MOTION
                                      MACROBLOCKD *xd) {
   MODE_INFO *mi = xd->mi[0];
   INTERINTER_COMPOUND_DATA *comp_data = &mi->mbmi.interinter_compound_data;
@@ -627,8 +628,11 @@
                          ? CONVERT_TO_BYTEPTR(tmp_dst_)
                          : tmp_dst_;
   av1_make_inter_predictor(pre, pre_stride, tmp_dst, MAX_SB_SIZE, subpel_x,
-                           subpel_y, sf, w, h, &conv_params, tmp_ipf, xs, ys,
-                           xd);
+                           subpel_y, sf, w, h, &conv_params, tmp_ipf,
+#if CONFIG_GLOBAL_MOTION
+                           is_global, p_col, p_row, plane, ref,
+#endif  // CONFIG_GLOBAL_MOTION
+                           xs, ys, xd);
 #if CONFIG_SUPERTX
   if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
     build_masked_compound_wedge_extend_highbd(
@@ -664,8 +668,11 @@
 #else   // CONFIG_AOM_HIGHBITDEPTH
   DECLARE_ALIGNED(16, uint8_t, tmp_dst[MAX_SB_SQUARE]);
   av1_make_inter_predictor(pre, pre_stride, tmp_dst, MAX_SB_SIZE, subpel_x,
-                           subpel_y, sf, w, h, &conv_params, tmp_ipf, xs, ys,
-                           xd);
+                           subpel_y, sf, w, h, &conv_params, tmp_ipf,
+#if CONFIG_GLOBAL_MOTION
+                           is_global, p_col, p_row, plane, ref,
+#endif  // CONFIG_GLOBAL_MOTION
+                           xs, ys, xd);
 #if CONFIG_SUPERTX
   build_masked_compound_wedge_extend(dst, dst_stride, dst, dst_stride, tmp_dst,
                                      MAX_SB_SIZE, comp_data->wedge_index,
@@ -765,24 +772,18 @@
   const int is_compound = has_second_ref(&mi->mbmi);
   int ref;
 #if CONFIG_GLOBAL_MOTION
-  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]];
+    WarpedMotionParams *const wm = &xd->global_motion[mi->mbmi.ref_frame[ref]];
     is_global[ref] =
-        (get_y_mode(mi, block) == ZEROMV && gm[ref]->wmtype > TRANSLATION);
+        (get_y_mode(mi, block) == ZEROMV && wm->wmtype > TRANSLATION);
   }
-  // TODO(sarahparker) remove these once gm works with all experiments
-  (void)gm;
-  (void)is_global;
 #endif  // CONFIG_GLOBAL_MOTION
 
 #if CONFIG_CB4X4
   (void)block;
 #endif
 
-// TODO(sarahparker) enable the use of DUAL_FILTER in warped motion functions
-// in order to allow GLOBAL_MOTION and DUAL_FILTER to work together
 #if CONFIG_SUB8X8_MC
 #if CONFIG_MOTION_VAR
   if (mi->mbmi.sb_type < BLOCK_8X8 && plane > 0 && !build_for_obmc) {
@@ -859,13 +860,21 @@
 #if CONFIG_COMPOUND_SEGMENT
                 plane,
 #endif  // CONFIG_COMPOUND_SEGMENT
-                xd);
+#if CONFIG_GLOBAL_MOTION
+                is_global[ref], (mi_x >> pd->subsampling_x) + x,
+                (mi_y >> pd->subsampling_y) + y, ref
+#endif  // CONFIG_GLOBAL_MOTION
+                                                     xd);
           else
 #endif  // CONFIG_EXT_INTER
-            av1_make_inter_predictor(pre, pre_buf->stride, dst, dst_buf->stride,
-                                     subpel_x, subpel_y, sf, x_step, y_step,
-                                     &conv_params, mi->mbmi.interp_filter, xs,
-                                     ys, xd);
+            av1_make_inter_predictor(
+                pre, pre_buf->stride, dst, dst_buf->stride, subpel_x, subpel_y,
+                sf, x_step, y_step, &conv_params, mi->mbmi.interp_filter,
+#if CONFIG_GLOBAL_MOTION
+                is_global[ref], (mi_x >> pd->subsampling_x) + x,
+                (mi_y >> pd->subsampling_y) + y, plane, ref,
+#endif  // CONFIG_GLOBAL_MOTION
+                xs, ys, xd);
         }
       }
     }
@@ -950,31 +959,25 @@
 #if CONFIG_SUPERTX
             wedge_offset_x, wedge_offset_y,
 #endif  // CONFIG_SUPERTX
-#if CONFIG_COMPOUND_SEGMENT
+#if CONFIG_COMPOUND_SEGMENT || CONFIG_GLOBAL_MOTION
             plane,
 #endif  // CONFIG_COMPOUND_SEGMENT
+#if CONFIG_GLOBAL_MOTION || CONFIG_GLOBAL_MOTION
+            is_global[ref], (mi_x >> pd->subsampling_x) + x,
+            (mi_y >> pd->subsampling_y) + y, ref,
+#endif  // CONFIG_GLOBAL_MOTION
             xd);
       else
-#else  // CONFIG_EXT_INTER
-#if CONFIG_GLOBAL_MOTION
-      if (is_global[ref])
-        av1_warp_plane(gm[ref],
-#if CONFIG_AOM_HIGHBITDEPTH
-                       xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
-#endif  // CONFIG_AOM_HIGHBITDEPTH
-                       pre_buf->buf0, pre_buf->width, pre_buf->height,
-                       pre_buf->stride, dst, (mi_x >> pd->subsampling_x) + x,
-                       (mi_y >> pd->subsampling_y) + y, w, h, dst_buf->stride,
-                       pd->subsampling_x, pd->subsampling_y,
-                       subpel_params[ref].xs, subpel_params[ref].ys, ref);
-      else
-#endif  // CONFIG_GLOBAL_MOTION
 #endif  // CONFIG_EXT_INTER
         av1_make_inter_predictor(
             pre[ref], pre_buf->stride, dst, dst_buf->stride,
             subpel_params[ref].subpel_x, subpel_params[ref].subpel_y, sf, w, h,
-            &conv_params, mi->mbmi.interp_filter, subpel_params[ref].xs,
-            subpel_params[ref].ys, xd);
+            &conv_params, mi->mbmi.interp_filter,
+#if CONFIG_GLOBAL_MOTION
+            is_global[ref], (mi_x >> pd->subsampling_x) + x,
+            (mi_y >> pd->subsampling_y) + y, plane, ref,
+#endif  // CONFIG_GLOBAL_MOTION
+            subpel_params[ref].xs, subpel_params[ref].ys, xd);
     }
 
 #if CONVOLVE_POST_ROUNDING
@@ -2728,6 +2731,11 @@
   int xs, ys, subpel_x, subpel_y;
   const int is_scaled = av1_is_scaled(sf);
   ConvolveParams conv_params = get_conv_params(0);
+#if CONFIG_GLOBAL_MOTION
+  WarpedMotionParams *const wm = &xd->global_motion[mi->mbmi.ref_frame[ref]];
+  const int is_global =
+      (get_y_mode(mi, block) == ZEROMV && wm->wmtype > TRANSLATION);
+#endif  // CONFIG_GLOBAL_MOTION
 
   if (is_scaled) {
     pre = pre_buf->buf + scaled_buffer_offset(x, y, pre_buf->stride, sf);
@@ -2748,7 +2756,12 @@
 
   av1_make_inter_predictor(pre, pre_buf->stride, dst, ext_dst_stride, subpel_x,
                            subpel_y, sf, w, h, &conv_params,
-                           mi->mbmi.interp_filter, xs, ys, xd);
+                           mi->mbmi.interp_filter,
+#if CONFIG_GLOBAL_MOTION
+                           is_global, (mi_x >> pd->subsampling_x) + x,
+                           (mi_y >> pd->subsampling_y) + y, plane, ref,
+#endif  // CONFIG_GLOBAL_MOTION
+                           xs, ys, xd);
 }
 
 void av1_build_inter_predictors_for_planes_single_buf(
diff --git a/av1/common/reconinter.h b/av1/common/reconinter.h
index a5d5422..abe3096 100644
--- a/av1/common/reconinter.h
+++ b/av1/common/reconinter.h
@@ -15,6 +15,9 @@
 #include "av1/common/filter.h"
 #include "av1/common/onyxc_int.h"
 #include "av1/common/convolve.h"
+#if CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
+#include "av1/common/warped_motion.h"
+#endif  // CONFIG_GLOBAL_MOTION || CONFIG_WARPED_MOTION
 #include "aom/aom_integer.h"
 
 #ifdef __cplusplus
@@ -224,17 +227,38 @@
 #else
     const InterpFilter interp_filter,
 #endif
+#if CONFIG_GLOBAL_MOTION
+    int is_global, int p_col, int p_row, int plane, int ref,
+#endif  // CONFIG_GLOBAL_MOTION
     int xs, int ys, const MACROBLOCKD *xd) {
   (void)xd;
+#if CONFIG_GLOBAL_MOTION
+  if (is_global) {
+    const MODE_INFO *mi = xd->mi[0];
+    const struct macroblockd_plane *const pd = &xd->plane[plane];
+    const struct buf_2d *const pre_buf = &pd->pre[ref];
+    WarpedMotionParams *gm = &xd->global_motion[mi->mbmi.ref_frame[ref]];
+
+    av1_warp_plane(gm,
 #if CONFIG_AOM_HIGHBITDEPTH
-  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
+                   xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, xd->bd,
+#endif  // CONFIG_AOM_HIGHBITDEPTH
+                   pre_buf->buf0, pre_buf->width, pre_buf->height,
+                   pre_buf->stride, dst, p_col, p_row, w, h, dst_stride,
+                   pd->subsampling_x, pd->subsampling_y, xs, ys, ref);
+    return;
+  }
+#endif  // CONFIG_GLOBAL_MOTION
+#if CONFIG_AOM_HIGHBITDEPTH
+  if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
     highbd_inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y,
                            sf, w, h, conv_params->ref, interp_filter, xs, ys,
                            xd->bd);
-  else
+    return;
+  }
 #endif  // CONFIG_AOM_HIGHBITDEPTH
-    inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y, sf, w,
-                    h, conv_params, interp_filter, xs, ys);
+  inter_predictor(src, src_stride, dst, dst_stride, subpel_x, subpel_y, sf, w,
+                  h, conv_params, interp_filter, xs, ys);
 }
 
 #if CONFIG_EXT_INTER
@@ -252,9 +276,13 @@
 #if CONFIG_SUPERTX
                                      int wedge_offset_x, int wedge_offset_y,
 #endif  // CONFIG_SUPERTX
-#if CONFIG_COMPOUND_SEGMENT
+#if CONFIG_COMPOUND_SEGMENT || CONFIG_GLOBAL_MOTION
                                      int plane,
-#endif  // CONFIG_COMPOUND_SEGMENT
+#endif  // CONFIG_COMPOUND_SEGMENT || CONFIG_GLOBAL_MOTION
+#if CONFIG_GLOBAL_MOTION
+                                     int is_global, int p_col, int p_row,
+                                     int ref,
+#endif  // CONFIG_GLOBAL_MOTION
                                      MACROBLOCKD *xd);
 #endif  // CONFIG_EXT_INTER
 
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 6751434..15cdb58 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1458,8 +1458,17 @@
     }
     case ZERO_ZEROMV: {
       assert(is_compound);
+#if CONFIG_GLOBAL_MOTION
+      mv[0].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[0]],
+                                          cm->allow_high_precision_mv)
+                         .as_int;
+      mv[1].as_int = gm_get_motion_vector(&cm->global_motion[ref_frame[1]],
+                                          cm->allow_high_precision_mv)
+                         .as_int;
+#else
       mv[0].as_int = 0;
       mv[1].as_int = 0;
+#endif  // CONFIG_GLOBAL_MOTION
       break;
     }
 #endif  // CONFIG_EXT_INTER
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 6264d4c..5ca471e 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1007,16 +1007,19 @@
 #if CONFIG_GLOBAL_MOTION
 static void update_global_motion_used(PREDICTION_MODE mode, BLOCK_SIZE bsize,
                                       const MB_MODE_INFO *mbmi, AV1_COMP *cpi) {
-  if (mode == ZEROMV) {
+  if (mode == ZEROMV
+#if CONFIG_EXT_INTER
+      || mode == ZERO_ZEROMV
+#endif
+      ) {
     const int num_4x4s = bsize >= BLOCK_8X8
                              ? num_4x4_blocks_wide_lookup[bsize] *
                                    num_4x4_blocks_high_lookup[bsize]
                              : 1;
-    ++cpi->global_motion_used[mbmi->ref_frame[0]][0];
-    cpi->global_motion_used[mbmi->ref_frame[0]][1] += num_4x4s;
-    if (has_second_ref(mbmi)) {
-      ++cpi->global_motion_used[mbmi->ref_frame[1]][0];
-      cpi->global_motion_used[mbmi->ref_frame[1]][1] += num_4x4s;
+    int ref;
+    for (ref = 0; ref < 1 + has_second_ref(mbmi); ++ref) {
+      ++cpi->global_motion_used[mbmi->ref_frame[ref]][0];
+      cpi->global_motion_used[mbmi->ref_frame[ref]][1] += num_4x4s;
     }
   }
 }
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 1574422..a40fcf4 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -4990,25 +4990,22 @@
       if (is_compound)
         this_mv[1].as_int = frame_mv[mode][mbmi->ref_frame[1]].as_int;
       break;
-    case ZEROMV:
+    case ZEROMV: {
+      int ref;
+      for (ref = 0; ref < 1 + is_compound; ++ref) {
 #if CONFIG_GLOBAL_MOTION
-      this_mv[0].as_int =
-          gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[0]],
-                               cpi->common.allow_high_precision_mv)
-              .as_int;
-      thismvcost += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[0]);
-      if (is_compound) {
-        this_mv[1].as_int =
-            gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[1]],
-                                 cpi->common.allow_high_precision_mv)
+        this_mv[ref].as_int =
+            gm_get_motion_vector(
+                &cpi->common.global_motion[mbmi->ref_frame[ref]],
+                cpi->common.allow_high_precision_mv)
                 .as_int;
-        thismvcost += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[1]);
-      }
-#else   // CONFIG_GLOBAL_MOTION
-      this_mv[0].as_int = 0;
-      if (is_compound) this_mv[1].as_int = 0;
+        thismvcost += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[ref]);
+#else
+        this_mv[ref].as_int = 0;
 #endif  // CONFIG_GLOBAL_MOTION
+      }
       break;
+    }
 #if CONFIG_EXT_INTER
     case NEW_NEWMV:
       if (compound_seg_newmvs[0].as_int == INVALID_MV ||
@@ -5054,8 +5051,21 @@
       this_mv[1].as_int = frame_mv[mode][mbmi->ref_frame[1]].as_int;
       break;
     case ZERO_ZEROMV:
+#if CONFIG_GLOBAL_MOTION
+      this_mv[0].as_int =
+          gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[0]],
+                               cpi->common.allow_high_precision_mv)
+              .as_int;
+      this_mv[1].as_int =
+          gm_get_motion_vector(&cpi->common.global_motion[mbmi->ref_frame[1]],
+                               cpi->common.allow_high_precision_mv)
+              .as_int;
+      thismvcost += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[0]) +
+                    GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[1]);
+#else
       this_mv[0].as_int = 0;
       this_mv[1].as_int = 0;
+#endif  // CONFIG_GLOBAL_MOTION
       break;
 #endif  // CONFIG_EXT_INTER
     default: break;
@@ -5303,15 +5313,31 @@
 #endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
     int_mv frame_mv[MB_MODE_COUNT][TOTAL_REFS_PER_FRAME], int this_mode,
     const MV_REFERENCE_FRAME ref_frames[2], const BLOCK_SIZE bsize, int block) {
-
+  int_mv zeromv[2];
+  int comp_pred_mode = ref_frames[1] > INTRA_FRAME;
+  int cur_frm;
+  for (cur_frm = 0; cur_frm < 1 + comp_pred_mode; cur_frm++) {
+#if CONFIG_GLOBAL_MOTION
+    if (this_mode == ZEROMV
+#if CONFIG_EXT_INTER
+        || this_mode == ZERO_ZEROMV
+#endif  // CONFIG_EXT_INTER
+        )
+      zeromv[cur_frm].as_int =
+          gm_get_motion_vector(&cpi->common.global_motion[ref_frames[cur_frm]],
+                               cpi->common.allow_high_precision_mv)
+              .as_int;
+    else
+#endif  // CONFIG_GLOBAL_MOTION
+      zeromv[cur_frm].as_int = 0;
+  }
 #if !CONFIG_EXT_INTER
   assert(ref_frames[1] != INTRA_FRAME);  // Just sanity check
 #endif
-
   if ((this_mode == NEARMV || this_mode == NEARESTMV || this_mode == ZEROMV) &&
-      frame_mv[this_mode][ref_frames[0]].as_int == 0 &&
+      frame_mv[this_mode][ref_frames[0]].as_int == zeromv[0].as_int &&
       (ref_frames[1] <= INTRA_FRAME ||
-       frame_mv[this_mode][ref_frames[1]].as_int == 0)) {
+       frame_mv[this_mode][ref_frames[1]].as_int == zeromv[1].as_int)) {
 #if CONFIG_REF_MV
     int16_t rfc =
         av1_mode_context_analyzer(mode_context, ref_frames, bsize, block);
@@ -5356,8 +5382,8 @@
   else if ((this_mode == NEAREST_NEARESTMV || this_mode == NEAREST_NEARMV ||
             this_mode == NEAR_NEARESTMV || this_mode == NEAR_NEARMV ||
             this_mode == ZERO_ZEROMV) &&
-           frame_mv[this_mode][ref_frames[0]].as_int == 0 &&
-           frame_mv[this_mode][ref_frames[1]].as_int == 0) {
+           frame_mv[this_mode][ref_frames[0]].as_int == zeromv[0].as_int &&
+           frame_mv[this_mode][ref_frames[1]].as_int == zeromv[1].as_int) {
 #if CONFIG_REF_MV
     int16_t rfc = compound_mode_context[ref_frames[0]];
     int c1 = cost_mv_ref(cpi, NEAREST_NEARMV, 1, rfc);
@@ -5788,7 +5814,14 @@
                               &ref_mvs_sub8x8[0][ref], &ref_mvs_sub8x8[1][ref]);
 
         if (has_second_rf) {
+#if CONFIG_GLOBAL_MOTION
+          frame_mv[ZERO_ZEROMV][frame].as_int =
+              gm_get_motion_vector(&cm->global_motion[frame],
+                                   cm->allow_high_precision_mv)
+                  .as_int;
+#else
           frame_mv[ZERO_ZEROMV][frame].as_int = 0;
+#endif  // CONFIG_GLOBAL_MOTION
           frame_mv[NEAREST_NEARESTMV][frame].as_int =
               frame_mv[NEARESTMV][frame].as_int;
 
@@ -8848,7 +8881,11 @@
       single_skippable[this_mode][refs[0]] = rd_stats->skip;
 #endif  // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
 #if CONFIG_GLOBAL_MOTION
-    if (this_mode == ZEROMV) {
+    if (this_mode == ZEROMV
+#if CONFIG_EXT_INTER
+        || this_mode == ZERO_ZEROMV
+#endif  // CONFIG_EXT_INTER
+        ) {
       rd_stats->rate += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[0]);
       if (is_comp_pred)
         rd_stats->rate += GLOBAL_MOTION_RATE(cpi, mbmi->ref_frame[1]);
@@ -9496,7 +9533,14 @@
 #if CONFIG_EXT_INTER
     frame_mv[NEWFROMNEARMV][ref_frame].as_int = INVALID_MV;
     frame_mv[NEW_NEWMV][ref_frame].as_int = INVALID_MV;
+#if CONFIG_GLOBAL_MOTION
+    frame_mv[ZERO_ZEROMV][ref_frame].as_int =
+        gm_get_motion_vector(&cm->global_motion[ref_frame],
+                             cm->allow_high_precision_mv)
+            .as_int;
+#else   // CONFIG_GLOBAL_MOTION
     frame_mv[ZERO_ZEROMV][ref_frame].as_int = 0;
+#endif  // CONFIG_GLOBAL_MOTION
 #endif  // CONFIG_EXT_INTER
   }
 
@@ -10841,7 +10885,8 @@
       else if (nearmv[0].as_int == best_mbmode.mv[0].as_int &&
                nearmv[1].as_int == best_mbmode.mv[1].as_int)
         best_mbmode.mode = NEAR_NEARMV;
-      else if (best_mbmode.mv[0].as_int == 0 && best_mbmode.mv[1].as_int == 0)
+      else if (best_mbmode.mv[0].as_int == zeromv[0].as_int &&
+               best_mbmode.mv[1].as_int == zeromv[1].as_int)
         best_mbmode.mode = ZERO_ZEROMV;
 #else
         best_mbmode.mode = NEARESTMV;
@@ -10872,6 +10917,22 @@
         best_mbmode.mode = ZEROMV;
 #if CONFIG_EXT_INTER
     } else {
+      const MV_REFERENCE_FRAME refs[2] = { best_mbmode.ref_frame[0],
+                                           best_mbmode.ref_frame[1] };
+      int_mv zeromv[2];
+#if CONFIG_GLOBAL_MOTION
+      zeromv[0].as_int = gm_get_motion_vector(&cm->global_motion[refs[0]],
+                                              cm->allow_high_precision_mv)
+                             .as_int;
+      zeromv[1].as_int = comp_pred_mode
+                             ? gm_get_motion_vector(&cm->global_motion[refs[1]],
+                                                    cm->allow_high_precision_mv)
+                                   .as_int
+                             : 0;
+#else
+      zeromv[0].as_int = 0;
+      zeromv[1].as_int = 0;
+#endif  // CONFIG_GLOBAL_MOTION
       if (frame_mv[NEAREST_NEARESTMV][refs[0]].as_int ==
               best_mbmode.mv[0].as_int &&
           frame_mv[NEAREST_NEARESTMV][refs[1]].as_int ==
@@ -10892,7 +10953,8 @@
                frame_mv[NEAR_NEARMV][refs[1]].as_int ==
                    best_mbmode.mv[1].as_int)
         best_mbmode.mode = NEAR_NEARMV;
-      else if (best_mbmode.mv[0].as_int == 0 && best_mbmode.mv[1].as_int == 0)
+      else if (best_mbmode.mv[0].as_int == zeromv[0].as_int &&
+               best_mbmode.mv[1].as_int == zeromv[1].as_int)
         best_mbmode.mode = ZERO_ZEROMV;
     }
 #endif  // CONFIG_EXT_INTER
diff --git a/configure b/configure
index 0bb3e5d..9384a76 100755
--- a/configure
+++ b/configure
@@ -485,11 +485,6 @@
       log_echo "disabling reference_buffer"
       disable_feature reference_buffer
     fi
-    if enabled global_motion && (enabled ext_inter || enabled dual_filter); then
-      log_echo "global_motion currently not compatible with ext_inter"
-      log_echo "and dual_filter. Disabling global_motion."
-      disable_feature global_motion
-    fi
 }