Fix various test failures with ext-partition

Change-Id: Ia6731231f860c3ca689240c777463d8b232b3901
diff --git a/av1/encoder/aq_variance.c b/av1/encoder/aq_variance.c
index ab9b379..84d9672 100644
--- a/av1/encoder/aq_variance.c
+++ b/av1/encoder/aq_variance.c
@@ -151,8 +151,8 @@
       (xd->mb_to_bottom_edge < 0) ? ((-xd->mb_to_bottom_edge) >> 3) : 0;
 
   if (right_overflow || bottom_overflow) {
-    const int bw = 8 * mi_size_wide[bs] - right_overflow;
-    const int bh = 8 * mi_size_high[bs] - bottom_overflow;
+    const int bw = MI_SIZE * mi_size_wide[bs] - right_overflow;
+    const int bh = MI_SIZE * mi_size_high[bs] - bottom_overflow;
     int avg;
 #if CONFIG_HIGHBITDEPTH
     if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
diff --git a/av1/encoder/mcomp.c b/av1/encoder/mcomp.c
index eb32edd..6c8503d 100644
--- a/av1/encoder/mcomp.c
+++ b/av1/encoder/mcomp.c
@@ -1124,6 +1124,7 @@
   int thissad;
   int k = -1;
   const MV fcenter_mv = { center_mv->row >> 3, center_mv->col >> 3 };
+  assert(search_param < MAX_MVSEARCH_STEPS);
   int best_init_s = search_param_to_steps[search_param];
   // adjust ref_mv to make sure it is within MV range
   clamp_mv(start_mv, x->mv_limits.col_min, x->mv_limits.col_max,
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index b4b5c92..47badf9 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -7131,7 +7131,10 @@
     int bhl = b_height_log2_lookup[bsize];
     int tlevel = x->pred_mv_sad[ref] >> (bwl + bhl + 4);
 
-    if (tlevel < 5) step_param += 2;
+    if (tlevel < 5) {
+      step_param += 2;
+      step_param = AOMMIN(step_param, MAX_MVSEARCH_STEPS - 1);
+    }
 
     // prev_mv_sad is not setup for dynamically scaled frames.
     if (cpi->oxcf.resize_mode != RESIZE_RANDOM) {