diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 26ec57ec29fa58a7fc519929d6dd1cb8e73413f2..ea86bba4f08d3d8523a984827c68ee040db4c140 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -448,8 +448,8 @@ static void update_state(VP9_COMP *cpi,
       int i, j;
       for (j = 0; j < bh; ++j)
         for (i = 0; i < bw; ++i)
-          if ((xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)) + bw > j &&
-              (xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)) + bh > i)
+          if ((xd->mb_to_right_edge >> (3 + LOG2_MI_SIZE)) + bw > i &&
+              (xd->mb_to_bottom_edge >> (3 + LOG2_MI_SIZE)) + bh > j)
             xd->mode_info_context[mis * j + i].mbmi = *mbmi;
     }