Add encoder/decoder support for var-refs

Check the availability of the reference frames at the frame level at
both encoder and decoder, and if a reference frame is not available
for a specific video frame, remove the signaling of such reference
frame info at the block level.

This patch adds the consideration of the bit saving inside the RD
optimization loop.

Change-Id: I4c22f1b843b21c7d2b47e118c99c3ad615a3d4e4
diff --git a/av1/common/blockd.h b/av1/common/blockd.h
index 3f0f812..e134548 100644
--- a/av1/common/blockd.h
+++ b/av1/common/blockd.h
@@ -567,6 +567,11 @@
   int idx;
   YV12_BUFFER_CONFIG *buf;
   struct scale_factors sf;
+#if CONFIG_VAR_REFS
+  // TODO(zoeliu): To evaluate whether "is_valid" is needed or the use of it can
+  // be simply replaced by checking the "idx".
+  int is_valid;
+#endif  // CONFIG_VAR_REFS
 } RefBuffer;
 
 #if CONFIG_ADAPT_SCAN