Extend frame marker bits from 4 to 5

Although four bits are enough to represent current distances since
Golden Frame Group is 16, for flexibility, we use 5 bits and allow
frame distance up to 32.

BUG=aomedia:1072

Change-Id: I9f413baffd656eb8bd54333ba31a4e33faefd57a
diff --git a/av1/common/enums.h b/av1/common/enums.h
index d79540c..44e815c 100644
--- a/av1/common/enums.h
+++ b/av1/common/enums.h
@@ -86,6 +86,11 @@
 // MAX_PALETTE_BSIZE.
 #define PALETTE_BLOCK_SIZES (MAX_PALETTE_BSIZE - MIN_PALETTE_BSIZE + 1)
 
+#if CONFIG_FRAME_MARKER
+#define FRAME_OFFSET_BITS 5
+#define MAX_FRAME_DISTANCE ((1 << FRAME_OFFSET_BITS) - 1)
+#endif
+
 #if CONFIG_LOOPFILTER_LEVEL
 // 4 frame filter levels: y plane vertical, y plane horizontal,
 // u plane, and v plane
@@ -111,8 +116,6 @@
 #define USE_LOOP_FILTER_SUPERBLOCK 1
 #endif  // CONFIG_LPF_SB
 
-#define MAX_FRAME_DISTANCE (INT16_MAX - 1)
-
 #if CONFIG_JNT_COMP
 typedef enum COMPOUND_DIST_WEIGHT_MODE {
   DIST,
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index a60c17a..bd26aaa 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -2972,7 +2972,8 @@
 
 #if CONFIG_FRAME_MARKER
   if (cm->show_frame == 0) {
-    cm->frame_offset = cm->current_video_frame + aom_rb_read_literal(rb, 4);
+    cm->frame_offset =
+        cm->current_video_frame + aom_rb_read_literal(rb, FRAME_OFFSET_BITS);
   } else {
     cm->frame_offset = cm->current_video_frame;
   }
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 7b953c9..4b18e9a 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3840,7 +3840,7 @@
         cpi->twopass.gf_group.brf_src_offset[cpi->twopass.gf_group.index];
 
     arf_offset = AOMMIN((MAX_GF_INTERVAL - 1), arf_offset + brf_offset);
-    aom_wb_write_literal(wb, arf_offset, 4);
+    aom_wb_write_literal(wb, arf_offset, FRAME_OFFSET_BITS);
   }
 
 #if CONFIG_EXT_SKIP
@@ -4213,7 +4213,7 @@
         cpi->twopass.gf_group.brf_src_offset[cpi->twopass.gf_group.index];
 
     arf_offset = AOMMIN((MAX_GF_INTERVAL - 1), arf_offset + brf_offset);
-    aom_wb_write_literal(wb, arf_offset, 4);
+    aom_wb_write_literal(wb, arf_offset, FRAME_OFFSET_BITS);
   }
 #endif