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);