Commit 940942ba authored by Rupert Swarbrick's avatar Rupert Swarbrick Committed by Debargha Mukherjee

Allow tile_rows/tile_cols to not be a power of 2

The example bitstream in bug 710 shows what might go on. This has a
frame with mi_cols=540 and log2_tile_cols=3. But 540/8 = 67.5, which
gets rounded up to give a tile_width of 5*16=80. However, 540/80 =
6.75 which means that the frame finishes somewhere in the middle of
tile 7 (and tile 8 is completely empty).

This patch clamps tile_rows/tile_cols to ensure that can't happen. The
bitstream still signals ceil(log2(tile_<rows/cols>)) so there's no
change there.

BUG=aomedia:710

Change-Id: Idfad658ef59cf71674100f5e74bd53dd192c6a84
parent 52884755
......@@ -3207,9 +3207,6 @@ static void read_tile_info(AV1Decoder *const pbi,
cm->loop_filter_across_tiles_enabled = aom_rb_read_bit(rb);
#endif // CONFIG_LOOPFILTERING_ACROSS_TILES
cm->tile_cols = 1 << cm->log2_tile_cols;
cm->tile_rows = 1 << cm->log2_tile_rows;
cm->tile_width = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
cm->tile_width >>= cm->log2_tile_cols;
cm->tile_height = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
......@@ -3219,6 +3216,12 @@ static void read_tile_info(AV1Decoder *const pbi,
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);
const int max_cols = (cm->mi_cols + cm->tile_width - 1) / cm->tile_width;
const int max_rows = (cm->mi_rows + cm->tile_height - 1) / cm->tile_height;
cm->tile_cols = AOMMIN(1 << cm->log2_tile_cols, max_cols);
cm->tile_rows = AOMMIN(1 << cm->log2_tile_rows, max_rows);
// tile size magnitude
pbi->tile_size_bytes = aom_rb_read_literal(rb, 2) + 1;
#if CONFIG_EXT_TILE
......
......@@ -896,9 +896,6 @@ static void set_tile_info(AV1_COMP *cpi) {
clamp(cpi->oxcf.tile_columns, min_log2_tile_cols, max_log2_tile_cols);
cm->log2_tile_rows = cpi->oxcf.tile_rows;
cm->tile_cols = 1 << cm->log2_tile_cols;
cm->tile_rows = 1 << cm->log2_tile_rows;
cm->tile_width = ALIGN_POWER_OF_TWO(cm->mi_cols, MAX_MIB_SIZE_LOG2);
cm->tile_width >>= cm->log2_tile_cols;
cm->tile_height = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
......@@ -907,6 +904,12 @@ static void set_tile_info(AV1_COMP *cpi) {
// round to integer multiples of max superblock size
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);
const int max_cols = (cm->mi_cols + cm->tile_width - 1) / cm->tile_width;
const int max_rows = (cm->mi_rows + cm->tile_height - 1) / cm->tile_height;
cm->tile_cols = AOMMIN(1 << cm->log2_tile_cols, max_cols);
cm->tile_rows = AOMMIN(1 << cm->log2_tile_rows, max_rows);
#if CONFIG_EXT_TILE
}
#endif // CONFIG_EXT_TILE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment