Commit 5a010aac authored by Rupert Swarbrick's avatar Rupert Swarbrick

Move tile_cols/tile_rows calculation into common function

This is just a code cleanup, moving the calculation of cm->tile_rows
and cm->tile_cols into get_tile_size, which is already calculating
cm->tile_width and cm->tile_height. The patch also gets rid of a
spurious AOMMIN and replaces it with an assertion.

Change-Id: I46666c4a197ac26d4b3746d9ea6575dc4af0d570
parent 82529d22
......@@ -218,15 +218,27 @@ void av1_setup_frame_boundary_info(const AV1_COMMON *const cm) {
}
}
int get_tile_size(int frame_mi_size, int log2_tile_num) {
int get_tile_size(int mi_frame_size, int log2_tile_num, int *ntiles) {
// Round the frame up to a whole number of max superblocks
frame_mi_size = ALIGN_POWER_OF_TWO(frame_mi_size, MAX_MIB_SIZE_LOG2);
// Divide by the number of tiles, rounding up to the multiple of the max
// superblock size. To do this, shift right (and round up) to get the number
// of super-blocks and then shift left again to convert it to mi units.
const int shift = log2_tile_num + MAX_MIB_SIZE_LOG2;
const int round = (1 << shift) - 1;
return ((frame_mi_size + round) >> shift) << MAX_MIB_SIZE_LOG2;
mi_frame_size = ALIGN_POWER_OF_TWO(mi_frame_size, MAX_MIB_SIZE_LOG2);
// Divide by the signalled number of tiles, rounding up to the multiple of
// the max superblock size. To do this, shift right (and round up) to get the
// tile size in max super-blocks and then shift left again to convert it to
// mi units.
const int max_sb_tile_size =
ROUND_POWER_OF_TWO(mi_frame_size, log2_tile_num + MAX_MIB_SIZE_LOG2);
const int mi_tile_size = max_sb_tile_size << MAX_MIB_SIZE_LOG2;
// The actual number of tiles is the ceiling of the frame size in mi units
// divided by mi_size. This is at most 1 << log2_tile_num but might be
// strictly less if max_sb_tile_size got rounded up significantly.
if (ntiles) {
*ntiles = (mi_frame_size + mi_tile_size - 1) / mi_tile_size;
assert(*ntiles <= (1 << log2_tile_num));
}
return mi_tile_size;
}
#if CONFIG_LOOPFILTERING_ACROSS_TILES
......
......@@ -46,7 +46,7 @@ void av1_setup_frame_boundary_info(const struct AV1Common *const cm);
// Calculate the correct tile size (width or height) for (1 << log2_tile_num)
// tiles horizontally or vertically in the frame.
int get_tile_size(int frame_mi_size, int log2_tile_num);
int get_tile_size(int mi_frame_size, int log2_tile_num, int *ntiles);
#if CONFIG_LOOPFILTERING_ACROSS_TILES
void av1_setup_across_tile_boundary_info(const struct AV1Common *const cm,
......
......@@ -3352,14 +3352,11 @@ static void read_tile_info(AV1Decoder *const pbi,
cm->log2_tile_rows = aom_rb_read_bit(rb);
if (cm->log2_tile_rows) cm->log2_tile_rows += aom_rb_read_bit(rb);
cm->tile_width = get_tile_size(cm->mi_cols, cm->log2_tile_cols);
cm->tile_height = get_tile_size(cm->mi_rows, cm->log2_tile_rows);
cm->tile_width =
get_tile_size(cm->mi_cols, cm->log2_tile_cols, &cm->tile_cols);
cm->tile_height =
get_tile_size(cm->mi_rows, cm->log2_tile_rows, &cm->tile_rows);
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);
#endif // CONFIG_MAX_TILE
#if CONFIG_DEPENDENT_HORZTILES
if (cm->tile_rows > 1)
......
......@@ -969,14 +969,10 @@ 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_width = get_tile_size(cm->mi_cols, cm->log2_tile_cols);
cm->tile_height = get_tile_size(cm->mi_rows, cm->log2_tile_rows);
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);
cm->tile_width =
get_tile_size(cm->mi_cols, cm->log2_tile_cols, &cm->tile_cols);
cm->tile_height =
get_tile_size(cm->mi_rows, cm->log2_tile_rows, &cm->tile_rows);
#endif // CONFIG_MAX_TILE
#if 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