Commit ab8bb8b8 authored by Dominic Symes's avatar Dominic Symes

Turn on the max_tile experiment

max_tile was provisionally adopted at the working group meeting 2017-Oct-10

This patch also enables support for 64x64 and 128x128 superblock size for max tile
(rather than assuming 128). There is also one fix for max_tile in combination of
loop restoration where the width/height was in the wrong units for max-tile specific code.

Change-Id: Icb862a2738fea5fc6215819396e1afa4eb86e461
parent 00bc4aac
......@@ -439,6 +439,9 @@ typedef struct AV1Common {
#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
......
......@@ -48,26 +48,6 @@ const sgr_params_type sgr_params[SGRPROJ_PARAMS] = {
#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
......@@ -87,30 +67,37 @@ void av1_alloc_restoration_struct(AV1_COMMON *cm, RestorationInfo *rsi,
// 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.
int max_sb_w = 0;
int max_sb_h = 0;
TileInfo tile;
int max_mi_w = 0;
int max_mi_h = 0;
int tile_col = 0;
int tile_row = 0;
for (int i = 0; i < cm->tile_cols; ++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);
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;
}
}
for (int i = 0; i < cm->tile_rows; ++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);
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;
}
}
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);
TileInfo tile_info;
av1_tile_init(&tile_info, cm, tile_row, tile_col);
#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
......@@ -1553,8 +1540,8 @@ void av1_foreach_rest_unit_in_frame(const struct AV1Common *cm, int plane,
// 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 sb_x = mi_x << MAX_MIB_SIZE_LOG2;
static int get_tile_idx(const int *tile_x_start_sb, int mi_x, int mib_log2) {
int sb_x = mi_x >> mib_log2;
for (int i = 0; i < MAX_TILE_COLS; ++i) {
if (tile_x_start_sb[i + 1] > sb_x) return i;
......@@ -1580,22 +1567,13 @@ int av1_loop_restoration_corners_in_sb(const struct AV1Common *cm, int plane,
// 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 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;
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);
#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);
......@@ -1606,7 +1584,6 @@ int av1_loop_restoration_corners_in_sb(const struct AV1Common *cm, int plane,
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
......
......@@ -49,10 +49,10 @@ static int tile_log2(int blk_size, int target) {
}
void av1_get_tile_limits(AV1_COMMON *const cm) {
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 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;
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_get_tile_limits(AV1_COMMON *const cm) {
}
void av1_calculate_tile_cols(AV1_COMMON *const cm) {
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 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 i;
if (cm->uniform_tile_spacing_flag) {
......@@ -85,7 +85,7 @@ void av1_calculate_tile_cols(AV1_COMMON *const cm) {
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 = 0;
int max_tile_width_sb = 1;
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_cols(AV1_COMMON *const cm) {
}
void av1_calculate_tile_rows(AV1_COMMON *const cm) {
int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, MAX_MIB_SIZE_LOG2);
int sb_rows = mi_rows >> MAX_MIB_SIZE_LOG2;
int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
int sb_rows = mi_rows >> cm->mib_size_log2;
int start_sb, size_sb, i;
if (cm->uniform_tile_spacing_flag) {
......@@ -131,16 +131,16 @@ void av1_calculate_tile_rows(AV1_COMMON *const cm) {
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] << MAX_MIB_SIZE_LOG2;
int mi_row_end = cm->tile_row_start_sb[row + 1] << MAX_MIB_SIZE_LOG2;
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;
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] << MAX_MIB_SIZE_LOG2;
int mi_col_end = cm->tile_col_start_sb[col + 1] << MAX_MIB_SIZE_LOG2;
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;
tile->mi_col_start = mi_col_start;
tile->mi_col_end = AOMMIN(mi_col_end, cm->mi_cols);
}
......
......@@ -1673,10 +1673,10 @@ static int rb_read_uniform(struct aom_read_bit_buffer *const rb, int n) {
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, 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 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 start_sb, size_sb, i;
av1_get_tile_limits(cm);
......
......@@ -48,8 +48,10 @@ int ifd_inspect(insp_frame_data *fd, void *decoder) {
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
......
......@@ -72,8 +72,10 @@ struct insp_frame_data {
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
......
......@@ -2826,10 +2826,10 @@ static void wb_write_uniform(struct aom_write_bit_buffer *wb, int n, int v) {
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, 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 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 size_sb, i;
aom_wb_write_bit(wb, cm->uniform_tile_spacing_flag);
......
......@@ -310,10 +310,14 @@ static BLOCK_SIZE select_sb_size(const AV1_COMP *const cpi) {
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,6 +882,11 @@ static void set_tile_info_max_tile(AV1_COMP *cpi) {
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
......@@ -886,8 +895,8 @@ static void set_tile_info_max_tile(AV1_COMP *cpi) {
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, MAX_MIB_SIZE_LOG2);
int sb_cols = mi_cols >> MAX_MIB_SIZE_LOG2;
int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->mib_size_log2);
int sb_cols = mi_cols >> cm->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++) {
......@@ -906,8 +915,8 @@ static void set_tile_info_max_tile(AV1_COMP *cpi) {
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, MAX_MIB_SIZE_LOG2);
int sb_rows = mi_rows >> MAX_MIB_SIZE_LOG2;
int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->mib_size_log2);
int sb_rows = mi_rows >> cm->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;
......
......@@ -164,7 +164,7 @@ set(CONFIG_LPF_DIRECT 0 CACHE NUMBER "AV1 experiment flag.")
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 0 CACHE NUMBER "AV1 experiment flag.")
set(CONFIG_MAX_TILE 1 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.")
......
......@@ -520,6 +520,7 @@ post_process_cmdline() {
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
......
......@@ -618,10 +618,12 @@ void inspect(void *pbi, void *data) {
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",
......
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