Tile groups: ensure each tile in a TG has a length.

This ensures TGs can be decoded even if the whole
frame has not been received and the frame length
is not known.

Change-Id: If24837fcc3b5c46554751be792e91100de73e8d6
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ba11970..4fe9acb 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3277,13 +3277,15 @@
     for (tile_col = 0; tile_col < tile_cols; tile_col++) {
       TileBufferEnc *const buf = &tile_buffers[tile_row][tile_col];
       const int is_last_col = (tile_col == tile_cols - 1);
-      const int is_last_tile = is_last_col && is_last_row;
       unsigned int tile_size;
       const TOKENEXTRA *tok = tok_buffers[tile_row][tile_col];
       const TOKENEXTRA *tok_end = tok + cpi->tok_count[tile_row][tile_col];
-
-#if CONFIG_TILE_GROUPS
+#if !CONFIG_TILE_GROUPS
+      const int is_last_tile = is_last_col && is_last_row;
+#else
       const int tile_idx = tile_row * tile_cols + tile_col;
+      // All tiles in a tile group have a length
+      const int is_last_tile = 0;
       if (tile_count >= tg_size) {
         // Copy uncompressed header
         memcpy(dst + total_size, dst, uncompressed_hdr_size * sizeof(uint8_t));