Fix a bug in global-motion + ref-mv
Fix a case in rdopt where a block's mode would be set to ZEROMV but
its motion vector would not be set to the global motion vector.
This caused future inter frames' lists of candidate mvs to become
desynchronized between the encoder and the decoder.
Change-Id: I1bdc619f155c70ca8a1a3fe6eea1baee15dc2c33
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index 85a90d7..b15b88a 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -9900,7 +9900,18 @@
mode_ctx &= (mbmi_ext->mode_context[best_mbmode.ref_frame[1]] | 0x00ff);
#endif // !CONFIG_EXT_INTER
- if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) best_mbmode.mode = ZEROMV;
+ if (mode_ctx & (1 << ALL_ZERO_FLAG_OFFSET)) {
+ best_mbmode.mode = ZEROMV;
+#if CONFIG_GLOBAL_MOTION
+ best_mbmode.mv[0].as_int =
+ gm_get_motion_vector(&cm->global_motion[best_mbmode.ref_frame[0]])
+ .as_int;
+ if (best_mbmode.ref_frame[1] != NONE)
+ best_mbmode.mv[1].as_int =
+ gm_get_motion_vector(&cm->global_motion[best_mbmode.ref_frame[1]])
+ .as_int;
+#endif
+ }
}
#endif