Moving tile_info upwards in the frame header

Change-Id: Idce7902ed4f0a283d8ae6643402a450f3e5caf9a
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index b5b6fb9..ef7b5a6 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -2957,6 +2957,10 @@
   }
 #endif  // CONFIG_INTRABC
 
+#if CONFIG_TILE_INFO_FIRST
+  read_tile_info(pbi, rb);
+#endif
+
   setup_loopfilter(cm, rb);
   setup_quantization(cm, rb);
   xd->bd = (int)cm->bit_depth;
@@ -3100,7 +3104,9 @@
 
   if (!frame_is_intra_only(cm)) read_global_motion(cm, rb);
 
+#if !CONFIG_TILE_INFO_FIRST
   read_tile_info(pbi, rb);
+#endif
 
   size_t sz;
   if (use_compressed_header(cm)) {
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 880cedb..50ded9f 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2808,6 +2808,11 @@
     aom_wb_write_bit(wb, cm->loop_filter_across_tiles_enabled);
 #endif  // CONFIG_LOOPFILTERING_ACROSS_TILES_EXT
 #endif  // CONFIG_LOOPFILTERING_ACROSS_TILES
+
+#if CONFIG_TILE_INFO_FIRST
+  // write the tile length code  (Always 4 bytes for now)
+  aom_wb_write_literal(wb, 3, 2);
+#endif
 }
 
 #if USE_GF16_MULTI_LAYER
@@ -3796,6 +3801,11 @@
 #if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
   aom_wb_write_literal(wb, cm->frame_context_idx, FRAME_CONTEXTS_LOG2);
 #endif
+
+#if CONFIG_TILE_INFO_FIRST
+  write_tile_info(cm, wb);
+#endif
+
   encode_loopfilter(cm, wb);
   encode_quantization(cm, wb);
   encode_segmentation(cm, xd, wb);
@@ -3865,7 +3875,9 @@
 
   if (!frame_is_intra_only(cm)) write_global_motion(cpi, wb);
 
+#if !CONFIG_TILE_INFO_FIRST
   write_tile_info(cm, wb);
+#endif
 }
 
 #else
@@ -4144,6 +4156,9 @@
 #if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
   aom_wb_write_literal(wb, cm->frame_context_idx, FRAME_CONTEXTS_LOG2);
 #endif
+#if CONFIG_TILE_INFO_FIRST
+  write_tile_info(cm, wb);
+#endif
   encode_loopfilter(cm, wb);
   encode_quantization(cm, wb);
   encode_segmentation(cm, xd, wb);
@@ -4217,7 +4232,9 @@
 
   if (!frame_is_intra_only(cm)) write_global_motion(cpi, wb);
 
+#if !CONFIG_TILE_INFO_FIRST
   write_tile_info(cm, wb);
+#endif
 }
 #endif  // CONFIG_OBU
 
@@ -4436,8 +4453,10 @@
     return total_size;
   }
 
+#if !CONFIG_TILE_INFO_FIRST
   // write the tile length code  (Always 4 bytes for now)
   aom_wb_write_literal(&wb, 3, 2);
+#endif
 
   if (!use_compressed_header(cm)) {
     uncompressed_hdr_size = aom_wb_bytes_written(&wb);
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 26f1f4e..6a8ee47 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -187,6 +187,7 @@
 set(CONFIG_SPATIAL_SEGMENTATION 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_STRIPED_LOOP_RESTORATION 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_TEMPMV_SIGNALING 1 CACHE NUMBER "AV1 experiment flag.")
+set(CONFIG_TILE_INFO_FIRST 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_TMV 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_TX64X64 1 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_TXK_SEL 0 CACHE NUMBER "AV1 experiment flag.")
diff --git a/configure b/configure
index 7db1af7..e67c960 100755
--- a/configure
+++ b/configure
@@ -332,6 +332,7 @@
     spatial_segmentation
     segment_pred_last
     obu_no_ivf
+    tile_info_first
 "
 CONFIG_LIST="
     dependency_tracking