Revert "Turn on the max_tile experiment"

This reverts commit ab8bb8b813d4eae626c59b42383453baf64484c9.

The reverted breaks many nightly run tests, reverting this temporarily
to allow nightly tests to detect other failures. Once the issues are
fixed, we can reenable the change in the reverted commit.

BUG=aomedia:1012
BUG=aomedia:1013
BUG=aomedia:1014

Change-Id: I2503fe78e47c7a08bb6cfdfff2c295cec0b6497d
diff --git a/av1/common/onyxc_int.h b/av1/common/onyxc_int.h
index dd08ac6..1df7abd 100644
--- a/av1/common/onyxc_int.h
+++ b/av1/common/onyxc_int.h
@@ -439,9 +439,6 @@
 #if CONFIG_DEPENDENT_HORZTILES
   int tile_row_independent[MAX_TILE_ROWS];  // valid for 0 <= i <  tile_rows
 #endif
-#if CONFIG_EXT_TILE
-  int tile_width, tile_height;  // In MI units
-#endif
 #else
   int log2_tile_cols, log2_tile_rows;  // Used in non-large_scale_tile_coding.
   int tile_width, tile_height;         // In MI units
diff --git a/av1/common/restoration.c b/av1/common/restoration.c
index 1532c15..11b72fd 100644
--- a/av1/common/restoration.c
+++ b/av1/common/restoration.c
@@ -48,6 +48,26 @@
 #endif
 };
 
+#if CONFIG_MAX_TILE
+static void tile_width_and_height(const AV1_COMMON *cm, int is_uv, int sb_w,
+                                  int sb_h, int *px_w, int *px_h) {
+  const int scaled_sb_w = sb_w << MAX_MIB_SIZE_LOG2;
+  const int scaled_sb_h = sb_h << MAX_MIB_SIZE_LOG2;
+
+  const int ss_x = is_uv && cm->subsampling_x;
+  const int ss_y = is_uv && cm->subsampling_y;
+
+  *px_w = (scaled_sb_w + ss_x) >> ss_x;
+  *px_h = (scaled_sb_h + ss_y) >> ss_y;
+#if CONFIG_FRAME_SUPERRES
+  if (!av1_superres_unscaled(cm)) {
+    av1_calculate_unscaled_superres_size(px_w, px_h,
+                                         cm->superres_scale_denominator);
+  }
+#endif  // CONFIG_FRAME_SUPERRES
+}
+#endif  // CONFIG_MAX_TILE
+
 // Count horizontal or vertical units per tile (use a width or height for
 // tile_size, respectively). We basically want to divide the tile size by the
 // size of a restoration unit. Rather than rounding up unconditionally as you
@@ -67,37 +87,30 @@
   // top-left and we can use av1_get_tile_rect. With CONFIG_MAX_TILE, we have
   // to do the computation ourselves, iterating over the tiles and keeping
   // track of the largest width and height, then upscaling.
-  TileInfo tile;
-  int max_mi_w = 0;
-  int max_mi_h = 0;
-  int tile_col = 0;
-  int tile_row = 0;
+  int max_sb_w = 0;
+  int max_sb_h = 0;
   for (int i = 0; i < cm->tile_cols; ++i) {
-    av1_tile_set_col(&tile, cm, i);
-    if (tile.mi_col_end - tile.mi_col_start > max_mi_w) {
-      max_mi_w = tile.mi_col_end - tile.mi_col_start;
-      tile_col = i;
-    }
+    const int sb_w = cm->tile_col_start_sb[i + 1] - cm->tile_col_start_sb[i];
+    max_sb_w = AOMMAX(max_sb_w, sb_w);
   }
   for (int i = 0; i < cm->tile_rows; ++i) {
-    av1_tile_set_row(&tile, cm, i);
-    if (tile.mi_row_end - tile.mi_row_start > max_mi_h) {
-      max_mi_h = tile.mi_row_end - tile.mi_row_start;
-      tile_row = i;
-    }
+    const int sb_h = cm->tile_row_start_sb[i + 1] - cm->tile_row_start_sb[i];
+    max_sb_h = AOMMAX(max_sb_h, sb_h);
   }
-  TileInfo tile_info;
-  av1_tile_init(&tile_info, cm, tile_row, tile_col);
+
+  int max_tile_w, max_tile_h;
+  tile_width_and_height(cm, is_uv, max_sb_w, max_sb_h, &max_tile_w,
+                        &max_tile_h);
 #else
   TileInfo tile_info;
   av1_tile_init(&tile_info, cm, 0, 0);
-#endif  // CONFIG_MAX_TILE
 
   const AV1PixelRect tile_rect = av1_get_tile_rect(&tile_info, cm, is_uv);
   assert(tile_rect.left == 0 && tile_rect.top == 0);
 
   const int max_tile_w = tile_rect.right;
   const int max_tile_h = tile_rect.bottom;
+#endif  // CONFIG_MAX_TILE
 
   // To calculate hpertile and vpertile (horizontal and vertical units per
   // tile), we basically want to divide the largest tile width or height by the
@@ -1649,8 +1662,8 @@
 // For a vertical index, mi_x should be the block's top row and tile_x_start_sb
 // should be cm->tile_row_start_sb. The return value will be "tile_row" for the
 // tile containing the block.
-static int get_tile_idx(const int *tile_x_start_sb, int mi_x, int mib_log2) {
-  int sb_x = mi_x >> mib_log2;
+static int get_tile_idx(const int *tile_x_start_sb, int mi_x) {
+  int sb_x = mi_x << MAX_MIB_SIZE_LOG2;
 
   for (int i = 0; i < MAX_TILE_COLS; ++i) {
     if (tile_x_start_sb[i + 1] > sb_x) return i;
@@ -1676,13 +1689,22 @@
 // Which tile contains the superblock? Find that tile's top-left in mi-units,
 // together with the tile's size in pixels.
 #if CONFIG_MAX_TILE
-  const int mib_log2 = cm->mib_size_log2;
-  const int tile_row = get_tile_idx(cm->tile_row_start_sb, mi_row, mib_log2);
-  const int tile_col = get_tile_idx(cm->tile_col_start_sb, mi_col, mib_log2);
+  const int tile_row = get_tile_idx(cm->tile_row_start_sb, mi_row);
+  const int tile_col = get_tile_idx(cm->tile_col_start_sb, mi_col);
+
+  const int sb_t = cm->tile_row_start_sb[tile_row];
+  const int sb_l = cm->tile_col_start_sb[tile_col];
+  const int sb_b = cm->tile_row_start_sb[tile_row + 1];
+  const int sb_r = cm->tile_col_start_sb[tile_col + 1];
+
+  int tile_w, tile_h;
+  tile_width_and_height(cm, is_uv, sb_r - sb_l, sb_t - sb_b, &tile_w, &tile_h);
+
+  const int mi_top = sb_t << MAX_MIB_SIZE_LOG2;
+  const int mi_left = sb_l << MAX_MIB_SIZE_LOG2;
 #else
   const int tile_row = mi_row / cm->tile_height;
   const int tile_col = mi_col / cm->tile_width;
-#endif  // CONFIG_MAX_TILE
 
   TileInfo tile_info;
   av1_tile_init(&tile_info, cm, tile_row, tile_col);
@@ -1693,6 +1715,7 @@
 
   const int mi_top = tile_info.mi_row_start;
   const int mi_left = tile_info.mi_col_start;
+#endif  // CONFIG_MAX_TILE
 
   // Compute the mi-unit corners of the superblock relative to the top-left of
   // the tile
diff --git a/av1/common/tile_common.c b/av1/common/tile_common.c
index 60b8e39..64e9ee6 100644
--- a/av1/common/tile_common.c
+++ b/av1/common/tile_common.c
@@ -49,10 +49,10 @@
 }
 
 void av1_get_tile_limits(AV1_COMMON *const cm) {
-  int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
-  int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
-  int sb_cols = mi_cols >> cm->mib_size_log2;
-  int sb_rows = mi_rows >> cm->mib_size_log2;
+  int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
+  int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
+  int sb_cols = mi_cols >> MAX_MIB_SIZE_LOG2;
+  int sb_rows = mi_rows >> MAX_MIB_SIZE_LOG2;
 
   cm->min_log2_tile_cols = tile_log2(MAX_TILE_WIDTH_SB, sb_cols);
   cm->max_log2_tile_cols = tile_log2(1, AOMMIN(sb_cols, MAX_TILE_COLS));
@@ -64,10 +64,10 @@
 }
 
 void av1_calculate_tile_cols(AV1_COMMON *const cm) {
-  int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
-  int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
-  int sb_cols = mi_cols >> cm->mib_size_log2;
-  int sb_rows = mi_rows >> cm->mib_size_log2;
+  int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
+  int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
+  int sb_cols = mi_cols >> MAX_MIB_SIZE_LOG2;
+  int sb_rows = mi_rows >> MAX_MIB_SIZE_LOG2;
   int i;
 
   if (cm->uniform_tile_spacing_flag) {
@@ -85,7 +85,7 @@
     cm->max_tile_height_sb = sb_rows >> cm->min_log2_tile_rows;
   } else {
     int max_tile_area_sb = (sb_rows * sb_cols);
-    int max_tile_width_sb = 1;
+    int max_tile_width_sb = 0;
     cm->log2_tile_cols = tile_log2(1, cm->tile_cols);
     for (i = 0; i < cm->tile_cols; i++) {
       int size_sb = cm->tile_col_start_sb[i + 1] - cm->tile_col_start_sb[i];
@@ -99,8 +99,8 @@
 }
 
 void av1_calculate_tile_rows(AV1_COMMON *const cm) {
-  int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
-  int sb_rows = mi_rows >> cm->mib_size_log2;
+  int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
+  int sb_rows = mi_rows >> MAX_MIB_SIZE_LOG2;
   int start_sb, size_sb, i;
 
   if (cm->uniform_tile_spacing_flag) {
@@ -131,16 +131,16 @@
 
 void av1_tile_set_row(TileInfo *tile, const AV1_COMMON *cm, int row) {
   assert(row < cm->tile_rows);
-  int mi_row_start = cm->tile_row_start_sb[row] << cm->mib_size_log2;
-  int mi_row_end = cm->tile_row_start_sb[row + 1] << cm->mib_size_log2;
+  int mi_row_start = cm->tile_row_start_sb[row] << MAX_MIB_SIZE_LOG2;
+  int mi_row_end = cm->tile_row_start_sb[row + 1] << MAX_MIB_SIZE_LOG2;
   tile->mi_row_start = mi_row_start;
   tile->mi_row_end = AOMMIN(mi_row_end, cm->mi_rows);
 }
 
 void av1_tile_set_col(TileInfo *tile, const AV1_COMMON *cm, int col) {
   assert(col < cm->tile_cols);
-  int mi_col_start = cm->tile_col_start_sb[col] << cm->mib_size_log2;
-  int mi_col_end = cm->tile_col_start_sb[col + 1] << cm->mib_size_log2;
+  int mi_col_start = cm->tile_col_start_sb[col] << MAX_MIB_SIZE_LOG2;
+  int mi_col_end = cm->tile_col_start_sb[col + 1] << MAX_MIB_SIZE_LOG2;
   tile->mi_col_start = mi_col_start;
   tile->mi_col_end = AOMMIN(mi_col_end, cm->mi_cols);
 }
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 2f4f5a1..bf54993 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1672,10 +1672,10 @@
 
 static void read_tile_info_max_tile(AV1_COMMON *const cm,
                                     struct aom_read_bit_buffer *const rb) {
-  int width_mi = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
-  int height_mi = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
-  int width_sb = width_mi >> cm->mib_size_log2;
-  int height_sb = height_mi >> cm->mib_size_log2;
+  int width_mi = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
+  int height_mi = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
+  int width_sb = width_mi >> MAX_MIB_SIZE_LOG2;
+  int height_sb = height_mi >> MAX_MIB_SIZE_LOG2;
   int start_sb, size_sb, i;
 
   av1_get_tile_limits(cm);
diff --git a/av1/decoder/inspection.c b/av1/decoder/inspection.c
index beb6db7..56e0c28 100644
--- a/av1/decoder/inspection.c
+++ b/av1/decoder/inspection.c
@@ -48,10 +48,8 @@
   fd->show_frame = cm->show_frame;
   fd->frame_type = cm->frame_type;
   fd->base_qindex = cm->base_qindex;
-#if !CONFIG_MAX_TILE
   fd->tile_mi_cols = cm->tile_width;
   fd->tile_mi_rows = cm->tile_height;
-#endif
   fd->delta_q_present_flag = cm->delta_q_present_flag;
   fd->delta_q_res = cm->delta_q_res;
 #if CONFIG_ACCOUNTING
diff --git a/av1/decoder/inspection.h b/av1/decoder/inspection.h
index c9e5c19..bd9d87a 100644
--- a/av1/decoder/inspection.h
+++ b/av1/decoder/inspection.h
@@ -72,10 +72,8 @@
   int base_qindex;
   int mi_rows;
   int mi_cols;
-#if !CONFIG_MAX_TILE
   int tile_mi_rows;
   int tile_mi_cols;
-#endif
   int16_t y_dequant[MAX_SEGMENTS][2];
   int16_t uv_dequant[MAX_SEGMENTS][2];
 #if CONFIG_CDEF
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 22d282d..9a43666 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -2823,10 +2823,10 @@
 
 static void write_tile_info_max_tile(const AV1_COMMON *const cm,
                                      struct aom_write_bit_buffer *wb) {
-  int width_mi = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
-  int height_mi = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
-  int width_sb = width_mi >> cm->mib_size_log2;
-  int height_sb = height_mi >> cm->mib_size_log2;
+  int width_mi = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
+  int height_mi = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
+  int width_sb = width_mi >> MAX_MIB_SIZE_LOG2;
+  int height_sb = height_mi >> MAX_MIB_SIZE_LOG2;
   int size_sb, i;
 
   aom_wb_write_bit(wb, cm->uniform_tile_spacing_flag);
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index c55aa20..c7789a3 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -310,14 +310,10 @@
 
   assert(cpi->oxcf.superblock_size == AOM_SUPERBLOCK_SIZE_DYNAMIC);
 
-#if !CONFIG_MAX_TILE
-  // for the max_tile experiment there is no common tile_width, tile_height
-  // max_tile assumes tile dimensions are in superblocks (not 64x64 units)
   assert(IMPLIES(cpi->common.tile_cols > 1,
                  cpi->common.tile_width % MAX_MIB_SIZE == 0));
   assert(IMPLIES(cpi->common.tile_rows > 1,
                  cpi->common.tile_height % MAX_MIB_SIZE == 0));
-#endif
 
   // TODO(any): Possibly could improve this with a heuristic.
   return BLOCK_128X128;
@@ -878,11 +874,6 @@
   AV1_COMMON *const cm = &cpi->common;
   int i, start_sb;
 
-  // Ensure superblock size is set before we read tile size in superblocks
-  if (cm->frame_type == KEY_FRAME) {
-    set_sb_size(cm, select_sb_size(cpi));
-  }
-
   av1_get_tile_limits(cm);
 
   // configure tile columns
@@ -891,8 +882,8 @@
     cm->log2_tile_cols = AOMMAX(cpi->oxcf.tile_columns, cm->min_log2_tile_cols);
     cm->log2_tile_cols = AOMMIN(cm->log2_tile_cols, cm->max_log2_tile_cols);
   } else {
-    int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
-    int sb_cols = mi_cols >> cm->mib_size_log2;
+    int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
+    int sb_cols = mi_cols >> MAX_MIB_SIZE_LOG2;
     int size_sb, j = 0;
     cm->uniform_tile_spacing_flag = 0;
     for (i = 0, start_sb = 0; start_sb < sb_cols && i < MAX_TILE_COLS; i++) {
@@ -911,8 +902,8 @@
     cm->log2_tile_rows = AOMMAX(cpi->oxcf.tile_rows, cm->min_log2_tile_rows);
     cm->log2_tile_rows = AOMMIN(cm->log2_tile_rows, cm->max_log2_tile_rows);
   } else {
-    int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
-    int sb_rows = mi_rows >> cm->mib_size_log2;
+    int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
+    int sb_rows = mi_rows >> MAX_MIB_SIZE_LOG2;
     int size_sb, j = 0;
     for (i = 0, start_sb = 0; start_sb < sb_rows && i < MAX_TILE_ROWS; i++) {
       cm->tile_row_start_sb[i] = start_sb;
diff --git a/build/cmake/aom_config_defaults.cmake b/build/cmake/aom_config_defaults.cmake
index d3d7f21..9f65fbb 100644
--- a/build/cmake/aom_config_defaults.cmake
+++ b/build/cmake/aom_config_defaults.cmake
@@ -163,7 +163,7 @@
 set(CONFIG_LPF_SB 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_LV_MAP 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_MASKED_TX 0 CACHE NUMBER "AV1 experiment flag.")
-set(CONFIG_MAX_TILE 1 CACHE NUMBER "AV1 experiment flag.")
+set(CONFIG_MAX_TILE 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_MFMV 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_MRC_TX 0 CACHE NUMBER "AV1 experiment flag.")
 set(CONFIG_MV_COMPRESS 1 CACHE NUMBER "AV1 experiment flag.")
diff --git a/configure b/configure
index 6f716f4..f7c7ae1 100755
--- a/configure
+++ b/configure
@@ -519,7 +519,6 @@
       soft_enable ext_delta_q
       soft_enable parallel_deblocking
       soft_enable simple_bwd_adapt
-      soft_enable max_tile
       soft_enable loopfilter_level
       soft_enable cfl
       soft_enable deblock_13tap
diff --git a/examples/inspect.c b/examples/inspect.c
index 8912a18..fa1dcaf 100644
--- a/examples/inspect.c
+++ b/examples/inspect.c
@@ -618,12 +618,10 @@
                   frame_data.frame_type);
   buf += snprintf(buf, MAX_BUFFER, "  \"baseQIndex\": %d,\n",
                   frame_data.base_qindex);
-#if !CONFIG_MAX_TILE
   buf += snprintf(buf, MAX_BUFFER, "  \"tileCols\": %d,\n",
                   frame_data.tile_mi_cols);
   buf += snprintf(buf, MAX_BUFFER, "  \"tileRows\": %d,\n",
                   frame_data.tile_mi_rows);
-#endif
   buf += snprintf(buf, MAX_BUFFER, "  \"deltaQPresentFlag\": %d,\n",
                   frame_data.delta_q_present_flag);
   buf += snprintf(buf, MAX_BUFFER, "  \"deltaQRes\": %d,\n",