Remove the CONFIG_TILE_GROUPS experimental flag.

Tile groups are now an integral part of the codec.

Change-Id: I620a88ec7a44b057d5cce0bf6cf602822a3339a9
diff --git a/aomenc.c b/aomenc.c
index 74fb60c..478bd1f 100644
--- a/aomenc.c
+++ b/aomenc.c
@@ -418,14 +418,12 @@
 static const arg_def_t qm_max = ARG_DEF(
     NULL, "qm-max", 1, "Max quant matrix flatness (0..15), default is 16");
 #endif
-#if CONFIG_TILE_GROUPS
 static const arg_def_t num_tg = ARG_DEF(
     NULL, "num-tile-groups", 1, "Maximum number of tile groups, default is 1");
 static const arg_def_t mtu_size =
     ARG_DEF(NULL, "mtu-size", 1,
             "MTU size for a tile group, default is 0 (no MTU targeting), "
             "overrides maximum number of tile groups");
-#endif
 #if CONFIG_TEMPMV_SIGNALING
 static const arg_def_t disable_tempmv = ARG_DEF(
     NULL, "disable-tempmv", 1, "Disable temporal mv prediction (default is 0)");
@@ -581,10 +579,8 @@
 #if CONFIG_EXT_PARTITION
                                        &superblock_size,
 #endif  // CONFIG_EXT_PARTITION
-#if CONFIG_TILE_GROUPS
                                        &num_tg,
                                        &mtu_size,
-#endif
 #if CONFIG_TEMPMV_SIGNALING
                                        &disable_tempmv,
 #endif
@@ -639,10 +635,8 @@
 #if CONFIG_EXT_PARTITION
                                         AV1E_SET_SUPERBLOCK_SIZE,
 #endif  // CONFIG_EXT_PARTITION
-#if CONFIG_TILE_GROUPS
                                         AV1E_SET_NUM_TG,
                                         AV1E_SET_MTU,
-#endif
 #if CONFIG_TEMPMV_SIGNALING
                                         AV1E_SET_DISABLE_TEMPMV,
 #endif
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 1475a91..81fffd1 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -55,10 +55,8 @@
   unsigned int qm_min;
   unsigned int qm_max;
 #endif
-#if CONFIG_TILE_GROUPS
   unsigned int num_tg;
   unsigned int mtu_size;
-#endif
 #if CONFIG_TEMPMV_SIGNALING
   unsigned int disable_tempmv;
 #endif
@@ -121,10 +119,8 @@
   DEFAULT_QM_FIRST,  // qm_min
   DEFAULT_QM_LAST,   // qm_max
 #endif
-#if CONFIG_TILE_GROUPS
   1,  // max number of tile groups
   0,  // mtu_size
-#endif
 #if CONFIG_TEMPMV_SIGNALING
   0,  // disable temporal mv prediction
 #endif
@@ -482,14 +478,12 @@
   oxcf->qm_maxlevel = extra_cfg->qm_max;
 #endif
 
-#if CONFIG_TILE_GROUPS
   oxcf->num_tile_groups = extra_cfg->num_tg;
 #if CONFIG_EXT_TILE
   // In large-scale tile encoding mode, num_tile_groups is always 1.
   if (cfg->large_scale_tile) oxcf->num_tile_groups = 1;
 #endif  // CONFIG_EXT_TILE
   oxcf->mtu = extra_cfg->mtu_size;
-#endif
 
 #if CONFIG_TEMPMV_SIGNALING
   oxcf->disable_tempmv = extra_cfg->disable_tempmv;
@@ -869,7 +863,6 @@
 }
 #endif
 
-#if CONFIG_TILE_GROUPS
 static aom_codec_err_t ctrl_set_num_tg(aom_codec_alg_priv_t *ctx,
                                        va_list args) {
   struct av1_extracfg extra_cfg = ctx->extra_cfg;
@@ -882,7 +875,6 @@
   extra_cfg.mtu_size = CAST(AV1E_SET_MTU, args);
   return update_extra_cfg(ctx, &extra_cfg);
 }
-#endif
 #if CONFIG_TEMPMV_SIGNALING
 static aom_codec_err_t ctrl_set_disable_tempmv(aom_codec_alg_priv_t *ctx,
                                                va_list args) {
@@ -1545,10 +1537,8 @@
   { AV1E_SET_QM_MIN, ctrl_set_qm_min },
   { AV1E_SET_QM_MAX, ctrl_set_qm_max },
 #endif
-#if CONFIG_TILE_GROUPS
   { AV1E_SET_NUM_TG, ctrl_set_num_tg },
   { AV1E_SET_MTU, ctrl_set_mtu },
-#endif
 #if CONFIG_TEMPMV_SIGNALING
   { AV1E_SET_DISABLE_TEMPMV, ctrl_set_disable_tempmv },
 #endif
diff --git a/av1/common/mvref_common.h b/av1/common/mvref_common.h
index bc33a21..8caa745 100644
--- a/av1/common/mvref_common.h
+++ b/av1/common/mvref_common.h
@@ -196,11 +196,7 @@
   const int dependent_horz_tile_flag = 0;
   (void)cm;
 #endif
-#if CONFIG_TILE_GROUPS
   if (dependent_horz_tile_flag && !tile->tg_horz_boundary) {
-#else
-  if (dependent_horz_tile_flag) {
-#endif
     return !(mi_row + mi_pos->row < 0 ||
              mi_col + mi_pos->col < tile->mi_col_start ||
              mi_row + mi_pos->row >= mi_rows ||
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index 07aa859..8647e11 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -365,11 +365,9 @@
 
 #if CONFIG_DEPENDENT_HORZTILES
   int dependent_horz_tiles;
-#if CONFIG_TILE_GROUPS
   int tile_group_start_row[MAX_TILE_ROWS][MAX_TILE_COLS];
   int tile_group_start_col[MAX_TILE_ROWS][MAX_TILE_COLS];
 #endif
-#endif
 #if CONFIG_LOOPFILTERING_ACROSS_TILES
   int loop_filter_across_tiles_enabled;
 #endif  // CONFIG_LOOPFILTERING_ACROSS_TILES
@@ -427,9 +425,7 @@
   int delta_lf_res;
 #endif
 #endif
-#if CONFIG_TILE_GROUPS
   int num_tg;
-#endif
 #if CONFIG_REFERENCE_BUFFER
   int current_frame_id;
   int ref_frame_id[REF_FRAMES];
@@ -654,11 +650,7 @@
 
 #if CONFIG_DEPENDENT_HORZTILES
   if (dependent_horz_tile_flag) {
-#if CONFIG_TILE_GROUPS
     xd->up_available = (mi_row > tile->mi_row_start) || !tile->tg_horz_boundary;
-#else
-    xd->up_available = (mi_row > 0);
-#endif  // CONFIG_TILE_GROUPS
   } else {
 #endif  // CONFIG_DEPENDENT_HORZTILES
     // Are edges available for intra prediction?
diff --git a/av1/common/tile_common.c b/av1/common/tile_common.c
index c4ffc26..3bff53c 100644
--- a/av1/common/tile_common.c
+++ b/av1/common/tile_common.c
@@ -23,7 +23,7 @@
   tile->mi_col_end = AOMMIN(tile->mi_col_start + cm->tile_width, cm->mi_cols);
 }
 
-#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
+#if CONFIG_DEPENDENT_HORZTILES
 void av1_tile_set_tg_boundary(TileInfo *tile, const AV1_COMMON *const cm,
                               int row, int col) {
   if (row < cm->tile_rows - 1) {
@@ -41,7 +41,7 @@
 void av1_tile_init(TileInfo *tile, const AV1_COMMON *cm, int row, int col) {
   av1_tile_set_row(tile, cm, row);
   av1_tile_set_col(tile, cm, col);
-#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
+#if CONFIG_DEPENDENT_HORZTILES
   av1_tile_set_tg_boundary(tile, cm, row, col);
 #endif
 }
@@ -119,11 +119,7 @@
     int row, col;
 
 #if CONFIG_DEPENDENT_HORZTILES
-#if CONFIG_TILE_GROUPS
     if (!cm->dependent_horz_tiles || tile_info->tg_horz_boundary)
-#else
-    if (!cm->dependent_horz_tiles)
-#endif  // CONFIG_TILE_GROUPS
 #endif  // CONFIG_DEPENDENT_HORZTILES
     {
       mi = mi_start;
diff --git a/av1/common/tile_common.h b/av1/common/tile_common.h
index 27eaee7..e5b8a0b 100644
--- a/av1/common/tile_common.h
+++ b/av1/common/tile_common.h
@@ -20,9 +20,7 @@
 
 struct AV1Common;
 
-#if CONFIG_TILE_GROUPS
 #define DEFAULT_MAX_NUM_TG 1
-#endif
 
 typedef struct TileInfo {
   int mi_row_start, mi_row_end;
@@ -37,7 +35,7 @@
 
 void av1_tile_set_row(TileInfo *tile, const struct AV1Common *cm, int row);
 void av1_tile_set_col(TileInfo *tile, const struct AV1Common *cm, int col);
-#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
+#if CONFIG_DEPENDENT_HORZTILES
 void av1_tile_set_tg_boundary(TileInfo *tile, const struct AV1Common *const cm,
                               int row, int col);
 #endif
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 429e1fa..dce0eaa 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -3361,16 +3361,12 @@
     cm->tile_width = ALIGN_POWER_OF_TWO(cm->tile_width, MAX_MIB_SIZE_LOG2);
     cm->tile_height = ALIGN_POWER_OF_TWO(cm->tile_height, MAX_MIB_SIZE_LOG2);
 
-// tile size magnitude
-#if !CONFIG_TILE_GROUPS
-    if (cm->tile_rows > 1 || cm->tile_cols > 1)
-#endif
-      pbi->tile_size_bytes = aom_rb_read_literal(rb, 2) + 1;
+    // tile size magnitude
+    pbi->tile_size_bytes = aom_rb_read_literal(rb, 2) + 1;
 #if CONFIG_EXT_TILE
   }
 #endif  // CONFIG_EXT_TILE
 
-#if CONFIG_TILE_GROUPS
   // Store an index to the location of the tile group information
   pbi->tg_size_bit_offset = rb->bit_offset;
   pbi->tg_size = 1 << (cm->log2_tile_rows + cm->log2_tile_cols);
@@ -3380,7 +3376,6 @@
     pbi->tg_size =
         1 + aom_rb_read_literal(rb, cm->log2_tile_rows + cm->log2_tile_cols);
   }
-#endif
 }
 
 static int mem_get_varsize(const uint8_t *src, int sz) {
@@ -3581,7 +3576,6 @@
     AV1Decoder *pbi, const uint8_t *data, const uint8_t *data_end,
     TileBufferDec (*const tile_buffers)[MAX_TILE_COLS]) {
   AV1_COMMON *const cm = &pbi->common;
-#if CONFIG_TILE_GROUPS
   int r, c;
   const int tile_cols = cm->tile_cols;
   const int tile_rows = cm->tile_rows;
@@ -3628,21 +3622,6 @@
 #endif
     }
   }
-#else
-  int r, c;
-  const int tile_cols = cm->tile_cols;
-  const int tile_rows = cm->tile_rows;
-
-  for (r = 0; r < tile_rows; ++r) {
-    for (c = 0; c < tile_cols; ++c) {
-      const int is_last = (r == tile_rows - 1) && (c == tile_cols - 1);
-      TileBufferDec *const buf = &tile_buffers[r][c];
-      buf->col = c;
-      get_tile_buffer(data_end, pbi->tile_size_bytes, is_last, &cm->error,
-                      &data, pbi->decrypt_cb, pbi->decrypt_state, buf);
-    }
-  }
-#endif
 }
 
 #if CONFIG_PVQ
@@ -3853,13 +3832,9 @@
       av1_tile_set_col(&tile_info, cm, col);
 
 #if CONFIG_DEPENDENT_HORZTILES
-#if CONFIG_TILE_GROUPS
       av1_tile_set_tg_boundary(&tile_info, cm, tile_row, tile_col);
       if (!cm->dependent_horz_tiles || tile_row == 0 ||
           tile_info.tg_horz_boundary) {
-#else
-      if (!cm->dependent_horz_tiles || tile_row == 0) {
-#endif
         av1_zero_above_context(cm, tile_info.mi_col_start,
                                tile_info.mi_col_end);
       }
@@ -4004,11 +3979,7 @@
   tile_data->error_info.setjmp = 1;
   tile_data->xd.error_info = &tile_data->error_info;
 #if CONFIG_DEPENDENT_HORZTILES
-#if CONFIG_TILE_GROUPS
   if (!cm->dependent_horz_tiles || tile->tg_horz_boundary) {
-#else
-  if (!cm->dependent_horz_tiles) {
-#endif
     av1_zero_above_context(&pbi->common, tile->mi_col_start, tile->mi_col_end);
   }
 #else
@@ -5253,10 +5224,8 @@
   }
 #endif  // CONFIG_EXT_TILE
 
-#if CONFIG_TILE_GROUPS
   pbi->first_partition_size = first_partition_size;
   pbi->uncomp_hdr_size = aom_rb_bytes_read(&rb);
-#endif
   new_fb = get_frame_new_buffer(cm);
   xd->cur_buf = new_fb;
 #if CONFIG_INTRABC
diff --git a/av1/decoder/decoder.h b/av1/decoder/decoder.h
index 7a6e7cd..5e6afc2 100644
--- a/av1/decoder/decoder.h
+++ b/av1/decoder/decoder.h
@@ -135,11 +135,9 @@
 #endif
   size_t uncomp_hdr_size;       // Size of the uncompressed header
   size_t first_partition_size;  // Size of the compressed header
-#if CONFIG_TILE_GROUPS
-  int tg_size;   // Number of tiles in the current tilegroup
-  int tg_start;  // First tile in the current tilegroup
+  int tg_size;                  // Number of tiles in the current tilegroup
+  int tg_start;                 // First tile in the current tilegroup
   int tg_size_bit_offset;
-#endif
 #if CONFIG_REFERENCE_BUFFER
   SequenceHeader seq_params;
 #endif
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 8704469..69d16d1 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -452,11 +452,7 @@
 static void update_inter_mode_probs(AV1_COMMON *cm, aom_writer *w,
                                     FRAME_COUNTS *counts) {
   int i;
-#if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
-#else
-  const int probwt = 1;
-#endif
   for (i = 0; i < NEWMV_MODE_CONTEXTS; ++i)
     av1_cond_prob_diff_update(w, &cm->fc->newmv_prob[i], counts->newmv_mode[i],
                               probwt);
@@ -628,11 +624,7 @@
 static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
                               FRAME_COUNTS *counts) {
   int k;
-#if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
-#else
-  const int probwt = 1;
-#endif
   for (k = 0; k < SKIP_CONTEXTS; ++k) {
     av1_cond_prob_diff_update(w, &cm->fc->skip_probs[k], counts->skip[k],
                               probwt);
@@ -3127,12 +3119,8 @@
   int mi_row, mi_col;
 
 #if CONFIG_DEPENDENT_HORZTILES
-#if CONFIG_TILE_GROUPS
   if (!cm->dependent_horz_tiles || mi_row_start == 0 ||
       tile->tg_horz_boundary) {
-#else
-  if (!cm->dependent_horz_tiles || mi_row_start == 0) {
-#endif
     av1_zero_above_context(cm, mi_col_start, mi_col_end);
   }
 #else
@@ -3736,7 +3724,6 @@
   const int tile_rows = cm->tile_rows;
   unsigned int tile_size = 0;
   const int have_tiles = tile_cols * tile_rows > 1;
-#if CONFIG_TILE_GROUPS
   struct aom_write_bit_buffer wb = { dst, 0 };
   const int n_log2_tiles = cm->log2_tile_rows + cm->log2_tile_cols;
   uint32_t comp_hdr_size;
@@ -3761,7 +3748,6 @@
   int mtu_size = cpi->oxcf.mtu;
   int curr_tg_data_size = 0;
   int hdr_size;
-#endif
 
   *max_tile_size = 0;
   *max_tile_col_size = 0;
@@ -3862,7 +3848,6 @@
     }
   } else {
 #endif  // CONFIG_EXT_TILE
-#if CONFIG_TILE_GROUPS
     write_uncompressed_header(cpi, &wb);
 
 #if CONFIG_EXT_REFS
@@ -3893,7 +3878,6 @@
     aom_wb_overwrite_literal(&comp_hdr_len_wb, (int)(comp_hdr_size), 16);
     hdr_size = uncompressed_hdr_size + comp_hdr_size;
     total_size += hdr_size;
-#endif
 
     for (tile_row = 0; tile_row < tile_rows; tile_row++) {
       TileInfo tile_info;
@@ -3908,64 +3892,63 @@
         const TOKENEXTRA *tok_end = tok + cpi->tok_count[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;
-#if !CONFIG_TILE_GROUPS
-        (void)tile_idx;
-#else
 
-      if ((!mtu_size && tile_count > tg_size) ||
-          (mtu_size && tile_count && curr_tg_data_size >= mtu_size)) {
-        // New tile group
-        tg_count++;
-        // We've exceeded the packet size
-        if (tile_count > 1) {
-          /* The last tile exceeded the packet size. The tile group size
-             should therefore be tile_count-1.
-             Move the last tile and insert headers before it
-           */
-          uint32_t old_total_size = total_size - tile_size - 4;
-          memmove(dst + old_total_size + hdr_size, dst + old_total_size,
-                  (tile_size + 4) * sizeof(uint8_t));
-          // Copy uncompressed header
-          memmove(dst + old_total_size, dst,
-                  uncompressed_hdr_size * sizeof(uint8_t));
-          // Write the number of tiles in the group into the last uncompressed
-          // header before the one we've just inserted
-          aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
-                                   n_log2_tiles);
-          aom_wb_overwrite_literal(&tg_params_wb, tile_count - 2, n_log2_tiles);
-          // Update the pointer to the last TG params
-          tg_params_wb.bit_offset = saved_offset + 8 * old_total_size;
-          // Copy compressed header
-          memmove(dst + old_total_size + uncompressed_hdr_size,
-                  dst + uncompressed_hdr_size, comp_hdr_size * sizeof(uint8_t));
-          total_size += hdr_size;
-          tile_count = 1;
-          curr_tg_data_size = hdr_size + tile_size + 4;
-
-        } else {
-          // We exceeded the packet size in just one tile
-          // Copy uncompressed header
-          memmove(dst + total_size, dst,
-                  uncompressed_hdr_size * sizeof(uint8_t));
-          // Write the number of tiles in the group into the last uncompressed
-          // header
-          aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
-                                   n_log2_tiles);
-          aom_wb_overwrite_literal(&tg_params_wb, tile_count - 1, n_log2_tiles);
-          tg_params_wb.bit_offset = saved_offset + 8 * total_size;
-          // Copy compressed header
-          memmove(dst + total_size + uncompressed_hdr_size,
-                  dst + uncompressed_hdr_size, comp_hdr_size * sizeof(uint8_t));
-          total_size += hdr_size;
-          tile_count = 0;
-          curr_tg_data_size = hdr_size;
+        if ((!mtu_size && tile_count > tg_size) ||
+            (mtu_size && tile_count && curr_tg_data_size >= mtu_size)) {
+          // New tile group
+          tg_count++;
+          // We've exceeded the packet size
+          if (tile_count > 1) {
+            /* The last tile exceeded the packet size. The tile group size
+               should therefore be tile_count-1.
+               Move the last tile and insert headers before it
+             */
+            uint32_t old_total_size = total_size - tile_size - 4;
+            memmove(dst + old_total_size + hdr_size, dst + old_total_size,
+                    (tile_size + 4) * sizeof(uint8_t));
+            // Copy uncompressed header
+            memmove(dst + old_total_size, dst,
+                    uncompressed_hdr_size * sizeof(uint8_t));
+            // Write the number of tiles in the group into the last uncompressed
+            // header before the one we've just inserted
+            aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
+                                     n_log2_tiles);
+            aom_wb_overwrite_literal(&tg_params_wb, tile_count - 2,
+                                     n_log2_tiles);
+            // Update the pointer to the last TG params
+            tg_params_wb.bit_offset = saved_offset + 8 * old_total_size;
+            // Copy compressed header
+            memmove(dst + old_total_size + uncompressed_hdr_size,
+                    dst + uncompressed_hdr_size,
+                    comp_hdr_size * sizeof(uint8_t));
+            total_size += hdr_size;
+            tile_count = 1;
+            curr_tg_data_size = hdr_size + tile_size + 4;
+          } else {
+            // We exceeded the packet size in just one tile
+            // Copy uncompressed header
+            memmove(dst + total_size, dst,
+                    uncompressed_hdr_size * sizeof(uint8_t));
+            // Write the number of tiles in the group into the last uncompressed
+            // header
+            aom_wb_overwrite_literal(&tg_params_wb, tile_idx - tile_count,
+                                     n_log2_tiles);
+            aom_wb_overwrite_literal(&tg_params_wb, tile_count - 1,
+                                     n_log2_tiles);
+            tg_params_wb.bit_offset = saved_offset + 8 * total_size;
+            // Copy compressed header
+            memmove(dst + total_size + uncompressed_hdr_size,
+                    dst + uncompressed_hdr_size,
+                    comp_hdr_size * sizeof(uint8_t));
+            total_size += hdr_size;
+            tile_count = 0;
+            curr_tg_data_size = hdr_size;
+          }
         }
-      }
-      tile_count++;
-#endif
+        tile_count++;
         av1_tile_set_col(&tile_info, cm, tile_col);
 
-#if CONFIG_DEPENDENT_HORZTILES && CONFIG_TILE_GROUPS
+#if CONFIG_DEPENDENT_HORZTILES
         av1_tile_set_tg_boundary(&tile_info, cm, tile_row, tile_col);
 #endif
         buf->data = dst + total_size;
@@ -4003,9 +3986,7 @@
 
         assert(tile_size > 0);
 
-#if CONFIG_TILE_GROUPS
         curr_tg_data_size += tile_size + 4;
-#endif
         buf->size = tile_size;
 
         if (!is_last_tile) {
@@ -4017,7 +3998,6 @@
         total_size += tile_size;
       }
     }
-#if CONFIG_TILE_GROUPS
     // Write the final tile group size
     if (n_log2_tiles) {
       aom_wb_overwrite_literal(&tg_params_wb, (1 << n_log2_tiles) - tile_count,
@@ -4035,7 +4015,6 @@
       aom_wb_overwrite_literal(&tile_size_bytes_wb, tile_size_bytes - 1, 2);
     }
 
-#endif
 #if CONFIG_EXT_TILE
   }
 #endif  // CONFIG_EXT_TILE
@@ -4585,11 +4564,7 @@
   int j;
 #endif
 
-#if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
-#else
-  const int probwt = 1;
-#endif
   (void)probwt;
   (void)i;
   (void)fc;
@@ -4898,7 +4873,7 @@
 void av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
   uint8_t *data = dst;
   uint32_t data_size;
-#if (!CONFIG_TILE_GROUPS) || (CONFIG_TILE_GROUPS && CONFIG_EXT_TILE)
+#if CONFIG_EXT_TILE
   AV1_COMMON *const cm = &cpi->common;
   uint32_t compressed_header_size = 0;
   uint32_t uncompressed_header_size;
@@ -4907,7 +4882,7 @@
   const int have_tiles = cm->tile_cols * cm->tile_rows > 1;
   int tile_size_bytes;
   int tile_col_size_bytes;
-#endif  // (!CONFIG_TILE_GROUPS) || (CONFIG_TILE_GROUPS && CONFIG_EXT_TILE)
+#endif  // CONFIG_EXT_TILE
   unsigned int max_tile_size;
   unsigned int max_tile_col_size;
 
@@ -4915,47 +4890,6 @@
   bitstream_queue_reset_write();
 #endif
 
-#if !CONFIG_TILE_GROUPS
-  // Write the uncompressed header
-  write_uncompressed_header(cpi, &wb);
-
-#if CONFIG_EXT_REFS
-  if (cm->show_existing_frame) {
-    *size = aom_wb_bytes_written(&wb);
-    return;
-  }
-#endif  // CONFIG_EXT_REFS
-
-  // We do not know these in advance. Output placeholder bit.
-  saved_wb = wb;
-  // Write tile size magnitudes
-  if (have_tiles) {
-// Note that the last item in the uncompressed header is the data
-// describing tile configuration.
-#if CONFIG_EXT_TILE
-    if (cm->large_scale_tile) {
-      // Number of bytes in tile column size - 1
-      aom_wb_write_literal(&wb, 0, 2);
-    }
-#endif  // CONFIG_EXT_TILE
-    // Number of bytes in tile size - 1
-    aom_wb_write_literal(&wb, 0, 2);
-  }
-  // Size of compressed header
-  aom_wb_write_literal(&wb, 0, 16);
-
-  uncompressed_header_size = (uint32_t)aom_wb_bytes_written(&wb);
-  data += uncompressed_header_size;
-
-  aom_clear_system_state();
-
-  // Write the compressed header
-  compressed_header_size = write_compressed_header(cpi, data);
-  data += compressed_header_size;
-
-  // Write the encoded tile data
-  data_size = write_tiles(cpi, data, &max_tile_size, &max_tile_col_size);
-#else
 #if CONFIG_EXT_TILE
   if (cm->large_scale_tile) {
     // Write the uncompressed header
@@ -5000,31 +4934,6 @@
 #if CONFIG_EXT_TILE
   }
 #endif  // CONFIG_EXT_TILE
-#endif
-#if !CONFIG_TILE_GROUPS
-  if (have_tiles) {
-    data_size =
-        remux_tiles(cm, data, data_size, max_tile_size, max_tile_col_size,
-                    &tile_size_bytes, &tile_col_size_bytes);
-  }
-
-  data += data_size;
-
-  // Now fill in the gaps in the uncompressed header.
-  if (have_tiles) {
-#if CONFIG_EXT_TILE
-    if (cm->large_scale_tile) {
-      assert(tile_col_size_bytes >= 1 && tile_col_size_bytes <= 4);
-      aom_wb_write_literal(&saved_wb, tile_col_size_bytes - 1, 2);
-    }
-#endif  // CONFIG_EXT_TILE
-    assert(tile_size_bytes >= 1 && tile_size_bytes <= 4);
-    aom_wb_write_literal(&saved_wb, tile_size_bytes - 1, 2);
-  }
-  // TODO(jbb): Figure out what to do if compressed_header_size > 16 bits.
-  assert(compressed_header_size <= 0xffff);
-  aom_wb_write_literal(&saved_wb, compressed_header_size, 16);
-#else
 #if CONFIG_EXT_TILE
   if (cm->large_scale_tile) {
     if (have_tiles) {
@@ -5052,7 +4961,6 @@
 #if CONFIG_EXT_TILE
   }
 #endif  // CONFIG_EXT_TILE
-#endif
 #if CONFIG_ANS && ANS_REVERSE
   // Avoid aliasing the superframe index
   *data++ = 0;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 71d55a7..f23449e 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4774,12 +4774,8 @@
   int mi_row;
 
 #if CONFIG_DEPENDENT_HORZTILES
-#if CONFIG_TILE_GROUPS
   if ((!cm->dependent_horz_tiles) || (tile_row == 0) ||
       tile_info->tg_horz_boundary) {
-#else
-  if ((!cm->dependent_horz_tiles) || (tile_row == 0)) {
-#endif
     av1_zero_above_context(cm, tile_info->mi_col_start, tile_info->mi_col_end);
   }
 #else
diff --git a/av1/encoder/encodemv.c b/av1/encoder/encodemv.c
index a15173c..5b9a7c8 100644
--- a/av1/encoder/encodemv.c
+++ b/av1/encoder/encodemv.c
@@ -140,14 +140,10 @@
 static void update_mv(aom_writer *w, const unsigned int ct[2], aom_prob *cur_p,
                       aom_prob upd_p) {
   (void)upd_p;
-#if CONFIG_TILE_GROUPS
   // Just use the default maximum number of tile groups to avoid passing in the
   // actual
   // number
   av1_cond_prob_diff_update(w, cur_p, ct, DEFAULT_MAX_NUM_TG);
-#else
-  av1_cond_prob_diff_update(w, cur_p, ct, 1);
-#endif
 }
 
 void av1_write_nmv_probs(AV1_COMMON *cm, int usehp, aom_writer *w,
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 7658708..c74a696 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -827,7 +827,7 @@
 
 static void set_tile_info(AV1_COMP *cpi) {
   AV1_COMMON *const cm = &cpi->common;
-#if CONFIG_TILE_GROUPS && CONFIG_DEPENDENT_HORZTILES
+#if CONFIG_DEPENDENT_HORZTILES
   int tile_row, tile_col, num_tiles_in_tg;
   int tg_row_start, tg_col_start;
 #endif
@@ -901,7 +901,6 @@
   }
 #endif  // CONFIG_EXT_TILE
 
-#if CONFIG_TILE_GROUPS
 #if CONFIG_EXT_TILE
   if (!cm->large_scale_tile) {
 #endif  // CONFIG_EXT_TILE
@@ -930,7 +929,6 @@
   }
 #endif  // CONFIG_EXT_TILE
 #endif
-#endif
 
 #if CONFIG_LOOPFILTERING_ACROSS_TILES
   cm->loop_filter_across_tiles_enabled =
@@ -4733,7 +4731,6 @@
       cm->reset_frame_context = RESET_FRAME_CONTEXT_CURRENT;
     }
   }
-#if CONFIG_TILE_GROUPS
   if (cpi->oxcf.mtu == 0) {
     cm->num_tg = cpi->oxcf.num_tile_groups;
   } else {
@@ -4741,7 +4738,6 @@
     // updates
     cm->num_tg = DEFAULT_MAX_NUM_TG;
   }
-#endif
 
 #if CONFIG_EXT_TILE
   cm->large_scale_tile = cpi->oxcf.large_scale_tile;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index c7bef26..43e8ef0 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -202,10 +202,8 @@
   int qm_minlevel;
   int qm_maxlevel;
 #endif
-#if CONFIG_TILE_GROUPS
   unsigned int num_tile_groups;
   unsigned int mtu;
-#endif
 
 #if CONFIG_TEMPMV_SIGNALING
   unsigned int disable_tempmv;
diff --git a/av1/encoder/segmentation.c b/av1/encoder/segmentation.c
index 46f042c..b61df43 100644
--- a/av1/encoder/segmentation.c
+++ b/av1/encoder/segmentation.c
@@ -300,11 +300,7 @@
   int t_pred_cost = INT_MAX;
 
   int tile_col, tile_row, mi_row, mi_col;
-#if CONFIG_TILE_GROUPS
   const int probwt = cm->num_tg;
-#else
-  const int probwt = 1;
-#endif
 
   unsigned(*temporal_predictor_count)[2] = cm->counts.seg.pred;
   unsigned *no_pred_segcounts = cm->counts.seg.tree_total;
@@ -329,7 +325,7 @@
     for (tile_col = 0; tile_col < cm->tile_cols; tile_col++) {
       MODE_INFO **mi_ptr;
       av1_tile_set_col(&tile_info, cm, tile_col);
-#if CONFIG_TILE_GROUPS && CONFIG_DEPENDENT_HORZTILES
+#if CONFIG_DEPENDENT_HORZTILES
       av1_tile_set_tg_boundary(&tile_info, cm, tile_row, tile_col);
 #endif
       mi_ptr = cm->mi_grid_visible + tile_info.mi_row_start * cm->mi_stride +
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index 1f3cb51..250dc9e 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -139,7 +139,6 @@
 set(CONFIG_FILTER_7BIT 1 CACHE NUMBER "Internal flag.")
 set(CONFIG_PARALLEL_DEBLOCKING 1 CACHE NUMBER "Internal flag.")
 set(CONFIG_LOOPFILTERING_ACROSS_TILES 1 CACHE NUMBER "Internal flag.")
-set(CONFIG_TILE_GROUPS 1 CACHE NUMBER "Internal flag.")
 set(CONFIG_TEMPMV_SIGNALING 1 CACHE NUMBER "Internal flag.")
 set(CONFIG_RD_DEBUG 0 CACHE NUMBER "Internal flag.")
 set(CONFIG_REFERENCE_BUFFER 1 CACHE NUMBER "Internal flag.")
diff --git a/configure b/configure
index f77fbe2..f8191b9 100755
--- a/configure
+++ b/configure
@@ -304,7 +304,6 @@
     filter_7bit
     parallel_deblocking
     loopfiltering_across_tiles
-    tile_groups
     tempmv_signaling
     rd_debug
     reference_buffer
@@ -444,7 +443,6 @@
     highbitdepth
     experimental
     colorspace_headers
-    tile_groups
 "
 
 process_cmdline() {
@@ -496,7 +494,6 @@
     soft_enable filter_7bit
     soft_enable reference_buffer
     soft_enable delta_q
-    soft_enable tile_groups
     soft_enable rect_tx
     soft_enable global_motion
     soft_enable ext_tx
diff --git a/third_party/libwebm/common/file_util.h b/third_party/libwebm/common/file_util.h
index 0e71eac..ed89ef3 100644
--- a/third_party/libwebm/common/file_util.h
+++ b/third_party/libwebm/common/file_util.h
@@ -38,4 +38,4 @@
 
 }  // namespace libwebm
 
-#endif  // LIBWEBM_COMMON_FILE_UTIL_H_
\ No newline at end of file
+#endif  // LIBWEBM_COMMON_FILE_UTIL_H_