Construct ref_mv_stack selectively

Only process reference motion vector stack for the used reference
frames at the decoder. This improves the decoding speed by 15%.

Change-Id: I4f7c11d4607f9bcb756b6c375723d017ec6ece22
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 2c12f44..2c2d98a 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -1394,7 +1394,6 @@
   int16_t compound_inter_mode_ctx[MODE_CTX_REF_FRAMES];
 #endif  // CONFIG_REF_MV && CONFIG_EXT_INTER
   int16_t mode_ctx = 0;
-  MV_REFERENCE_FRAME ref_frame;
 
 #if CONFIG_PALETTE
   mbmi->palette_mode_info.palette_size[0] = 0;
@@ -1413,22 +1412,20 @@
       aom_internal_error(xd->error_info, AOM_CODEC_UNSUP_BITSTREAM,
                          "Reference frame has invalid dimensions");
     av1_setup_pre_planes(xd, ref, ref_buf->buf, mi_row, mi_col, &ref_buf->sf);
-  }
-
-  for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
-    av1_find_mv_refs(cm, xd, mi, ref_frame,
+    av1_find_mv_refs(cm, xd, mi, frame,
 #if CONFIG_REF_MV
-                     &xd->ref_mv_count[ref_frame], xd->ref_mv_stack[ref_frame],
+                     &xd->ref_mv_count[frame], xd->ref_mv_stack[frame],
 #if CONFIG_EXT_INTER
                      compound_inter_mode_ctx,
 #endif  // CONFIG_EXT_INTER
 #endif
-                     ref_mvs[ref_frame], mi_row, mi_col, fpm_sync, (void *)pbi,
+                     ref_mvs[frame], mi_row, mi_col, fpm_sync, (void *)pbi,
                      inter_mode_ctx);
   }
 
 #if CONFIG_REF_MV
-  for (; ref_frame < MODE_CTX_REF_FRAMES; ++ref_frame) {
+  if (is_compound) {
+    MV_REFERENCE_FRAME ref_frame = av1_ref_frame_type(mbmi->ref_frame);
     av1_find_mv_refs(cm, xd, mi, ref_frame, &xd->ref_mv_count[ref_frame],
                      xd->ref_mv_stack[ref_frame],
 #if CONFIG_EXT_INTER