Disable GM for frames at 0 distance

In some rare cases, we may end up wanting to search global motion
where the source and ref frames are at the same temporal instant.
An example would be coding a "real" frame against a temporally
filtered version of the same frame.

In practice this only arises in exceptional conditions, but the code
still needs to handle this case. However, in all such cases we expect
that the best global motion model will be no motion (IDENTITY).

By explicitly disabling global motion when the temporal distance is 0,
we can simplify the logic in a few places without changing results

Change-Id: I718eb6fe927dde1c6a01fc4bdb150189195120bc
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 00e9a0c..4fd00e5 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -2248,7 +2248,6 @@
 
   while (1) {
     int ref_buf_idx = -1;
-    int ref_frame_idx = -1;
 
 #if CONFIG_MULTITHREAD
     pthread_mutex_lock(gm_mt_mutex_);
@@ -2262,11 +2261,6 @@
       switch_direction(cpi, &ref_buf_idx, &cur_dir);
     }
 
-    // 'ref_frame_idx' holds the index of the current reference frame type in
-    // gm_info->reference_frames. job_info->next_frame_to_process will be
-    // incremented in get_next_gm_job() and hence subtracting by 1.
-    ref_frame_idx = job_info->next_frame_to_process[cur_dir] - 1;
-
 #if CONFIG_MULTITHREAD
     pthread_mutex_unlock(gm_mt_mutex_);
 #endif
@@ -2284,14 +2278,10 @@
 #if CONFIG_MULTITHREAD
     pthread_mutex_lock(gm_mt_mutex_);
 #endif
-    assert(ref_frame_idx != -1);
     // If global motion w.r.t. current ref frame is
     // INVALID/TRANSLATION/IDENTITY, skip the evaluation of global motion w.r.t
-    // the remaining ref frames in that direction. The below exit is disabled
-    // when ref frame distance w.r.t. current frame is zero. E.g.:
-    // source_alt_ref_frame w.r.t. ARF frames.
+    // the remaining ref frames in that direction.
     if (cpi->sf.gm_sf.prune_ref_frame_for_gm_search &&
-        gm_info->reference_frames[cur_dir][ref_frame_idx].distance != 0 &&
         cpi->common.global_motion[ref_buf_idx].wmtype != ROTZOOM)
       job_info->early_exit[cur_dir] = 1;