Port an out of range motion vector bug fix in joint motion search

Ported a bug fix from VP9.
(https://bugs.chromium.org/p/webm/issues/detail?id=1354)

Change-Id: Ib712b6dfb6aa86631f4b2a403c8364dbe1104f21
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index e7d8c58..b874bc6 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -2202,11 +2202,14 @@
   const struct buf_2d *const in_what = &xd->plane[0].pre[0];
   const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
   MV *best_mv = &x->best_mv.as_mv;
-  unsigned int best_sad =
+  unsigned int best_sad = INT_MAX;
+  int i, j;
+
+  clamp_mv(best_mv, x->mv_col_min, x->mv_col_max, x->mv_row_min, x->mv_row_max);
+  best_sad =
       fn_ptr->sdaf(what->buf, what->stride, get_buf_from_mv(in_what, best_mv),
                    in_what->stride, second_pred) +
       mvsad_err_cost(x, best_mv, &fcenter_mv, error_per_bit);
-  int i, j;
 
   for (i = 0; i < search_range; ++i) {
     int best_site = -1;