Constrain motion vector projection range

Constrain the maximum motion vector projection range to be within
+/-32 pixels in the vertical direction and +/-64 pixels in the
horizontal direction.

Such constraints allow a fixed amount of reference motion vector
load to SRAM for each 64x64 block size, independent of the frame
size. The wider range in the horizontal direction can be stored in
the SRAM and reused by next 64x64 block. The compression performance
loss is 0.03% for lowres and 0.04% for midres.

Change-Id: I7f1c136363b136b1f2fa9f7c962a791c8e91a976
diff --git a/av1/common/mvref_common.c b/av1/common/mvref_common.c
index 016a3eb..3a78f13 100644
--- a/av1/common/mvref_common.c
+++ b/av1/common/mvref_common.c
@@ -1218,8 +1218,15 @@
   output->col = (int16_t)(ref.col * (double)num / den);
 }
 
+#define MAX_OFFSET_WIDTH 64
+#define MAX_OFFSET_HEIGHT 32
+
 INLINE int get_block_position(AV1_COMMON *cm, int *mi_r, int *mi_c, int blk_row,
                               int blk_col, MV mv, int sign_bias) {
+  if ((abs(mv.row) >> 3) > MAX_OFFSET_HEIGHT ||
+      (abs(mv.col) >> 3) > MAX_OFFSET_WIDTH)
+    return 0;
+
   int row = (sign_bias == 1) ? blk_row - (mv.row >> (3 + MI_SIZE_LOG2))
                              : blk_row + (mv.row >> (3 + MI_SIZE_LOG2));
   int col = (sign_bias == 1) ? blk_col - (mv.col >> (3 + MI_SIZE_LOG2))