summaryrefslogtreecommitdiff
path: root/media/libaom/src/av1/common/tile_common.c
diff options
context:
space:
mode:
Diffstat (limited to 'media/libaom/src/av1/common/tile_common.c')
-rw-r--r--media/libaom/src/av1/common/tile_common.c196
1 files changed, 114 insertions, 82 deletions
diff --git a/media/libaom/src/av1/common/tile_common.c b/media/libaom/src/av1/common/tile_common.c
index 1b413487f0..1b11bd7606 100644
--- a/media/libaom/src/av1/common/tile_common.c
+++ b/media/libaom/src/av1/common/tile_common.c
@@ -9,9 +9,9 @@
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
-#include "av1/common/tile_common.h"
-#include "av1/common/onyxc_int.h"
+#include "av1/common/av1_common_int.h"
#include "av1/common/resize.h"
+#include "av1/common/tile_common.h"
#include "aom_dsp/aom_dsp_common.h"
void av1_tile_init(TileInfo *tile, const AV1_COMMON *cm, int row, int col) {
@@ -28,102 +28,126 @@ 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, cm->seq_params.mib_size_log2);
- int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->seq_params.mib_size_log2);
- int sb_cols = mi_cols >> cm->seq_params.mib_size_log2;
- int sb_rows = mi_rows >> cm->seq_params.mib_size_log2;
-
- int sb_size_log2 = cm->seq_params.mib_size_log2 + MI_SIZE_LOG2;
- cm->max_tile_width_sb = MAX_TILE_WIDTH >> sb_size_log2;
- int max_tile_area_sb = MAX_TILE_AREA >> (2 * sb_size_log2);
-
- cm->min_log2_tile_cols = tile_log2(cm->max_tile_width_sb, sb_cols);
- cm->max_log2_tile_cols = tile_log2(1, AOMMIN(sb_cols, MAX_TILE_COLS));
- cm->max_log2_tile_rows = tile_log2(1, AOMMIN(sb_rows, MAX_TILE_ROWS));
- cm->min_log2_tiles = tile_log2(max_tile_area_sb, sb_cols * sb_rows);
- cm->min_log2_tiles = AOMMAX(cm->min_log2_tiles, cm->min_log2_tile_cols);
+ const SequenceHeader *const seq_params = &cm->seq_params;
+ CommonTileParams *const tiles = &cm->tiles;
+ const int mi_cols =
+ ALIGN_POWER_OF_TWO(cm->mi_params.mi_cols, seq_params->mib_size_log2);
+ const int mi_rows =
+ ALIGN_POWER_OF_TWO(cm->mi_params.mi_rows, seq_params->mib_size_log2);
+ const int sb_cols = mi_cols >> seq_params->mib_size_log2;
+ const int sb_rows = mi_rows >> seq_params->mib_size_log2;
+
+ const int sb_size_log2 = seq_params->mib_size_log2 + MI_SIZE_LOG2;
+ tiles->max_width_sb = MAX_TILE_WIDTH >> sb_size_log2;
+ const int max_tile_area_sb = MAX_TILE_AREA >> (2 * sb_size_log2);
+
+ tiles->min_log2_cols = tile_log2(tiles->max_width_sb, sb_cols);
+ tiles->max_log2_cols = tile_log2(1, AOMMIN(sb_cols, MAX_TILE_COLS));
+ tiles->max_log2_rows = tile_log2(1, AOMMIN(sb_rows, MAX_TILE_ROWS));
+ tiles->min_log2 = tile_log2(max_tile_area_sb, sb_cols * sb_rows);
+ tiles->min_log2 = AOMMAX(tiles->min_log2, tiles->min_log2_cols);
}
-void av1_calculate_tile_cols(AV1_COMMON *const cm) {
- int mi_cols = ALIGN_POWER_OF_TWO(cm->mi_cols, cm->seq_params.mib_size_log2);
- int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->seq_params.mib_size_log2);
- int sb_cols = mi_cols >> cm->seq_params.mib_size_log2;
- int sb_rows = mi_rows >> cm->seq_params.mib_size_log2;
+void av1_calculate_tile_cols(const SequenceHeader *const seq_params,
+ int cm_mi_rows, int cm_mi_cols,
+ CommonTileParams *const tiles) {
+ int mi_cols = ALIGN_POWER_OF_TWO(cm_mi_cols, seq_params->mib_size_log2);
+ int mi_rows = ALIGN_POWER_OF_TWO(cm_mi_rows, seq_params->mib_size_log2);
+ int sb_cols = mi_cols >> seq_params->mib_size_log2;
+ int sb_rows = mi_rows >> seq_params->mib_size_log2;
int i;
- if (cm->uniform_tile_spacing_flag) {
+ // This will be overridden if there is at least two columns of tiles
+ // (otherwise there is no inner tile width)
+ tiles->min_inner_width = -1;
+
+ if (tiles->uniform_spacing) {
int start_sb;
- int size_sb = ALIGN_POWER_OF_TWO(sb_cols, cm->log2_tile_cols);
- size_sb >>= cm->log2_tile_cols;
+ int size_sb = ALIGN_POWER_OF_TWO(sb_cols, tiles->log2_cols);
+ size_sb >>= tiles->log2_cols;
assert(size_sb > 0);
for (i = 0, start_sb = 0; start_sb < sb_cols; i++) {
- cm->tile_col_start_sb[i] = start_sb;
+ tiles->col_start_sb[i] = start_sb;
start_sb += size_sb;
}
- cm->tile_cols = i;
- cm->tile_col_start_sb[i] = sb_cols;
- cm->min_log2_tile_rows = AOMMAX(cm->min_log2_tiles - cm->log2_tile_cols, 0);
- cm->max_tile_height_sb = sb_rows >> cm->min_log2_tile_rows;
-
- cm->tile_width = size_sb << cm->seq_params.mib_size_log2;
- cm->tile_width = AOMMIN(cm->tile_width, cm->mi_cols);
+ tiles->cols = i;
+ tiles->col_start_sb[i] = sb_cols;
+ tiles->min_log2_rows = AOMMAX(tiles->min_log2 - tiles->log2_cols, 0);
+ tiles->max_height_sb = sb_rows >> tiles->min_log2_rows;
+
+ tiles->width = size_sb << seq_params->mib_size_log2;
+ tiles->width = AOMMIN(tiles->width, cm_mi_cols);
+ if (tiles->cols > 1) {
+ tiles->min_inner_width = tiles->width;
+ }
} else {
int max_tile_area_sb = (sb_rows * sb_cols);
int widest_tile_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];
+ int narrowest_inner_tile_sb = 65536;
+ tiles->log2_cols = tile_log2(1, tiles->cols);
+ for (i = 0; i < tiles->cols; i++) {
+ int size_sb = tiles->col_start_sb[i + 1] - tiles->col_start_sb[i];
widest_tile_sb = AOMMAX(widest_tile_sb, size_sb);
+ // ignore the rightmost tile in frame for determining the narrowest
+ if (i < tiles->cols - 1)
+ narrowest_inner_tile_sb = AOMMIN(narrowest_inner_tile_sb, size_sb);
}
- if (cm->min_log2_tiles) {
- max_tile_area_sb >>= (cm->min_log2_tiles + 1);
+ if (tiles->min_log2) {
+ max_tile_area_sb >>= (tiles->min_log2 + 1);
+ }
+ tiles->max_height_sb = AOMMAX(max_tile_area_sb / widest_tile_sb, 1);
+ if (tiles->cols > 1) {
+ tiles->min_inner_width = narrowest_inner_tile_sb
+ << seq_params->mib_size_log2;
}
- cm->max_tile_height_sb = AOMMAX(max_tile_area_sb / widest_tile_sb, 1);
}
}
-void av1_calculate_tile_rows(AV1_COMMON *const cm) {
- int mi_rows = ALIGN_POWER_OF_TWO(cm->mi_rows, cm->seq_params.mib_size_log2);
- int sb_rows = mi_rows >> cm->seq_params.mib_size_log2;
+void av1_calculate_tile_rows(const SequenceHeader *const seq_params,
+ int cm_mi_rows, CommonTileParams *const tiles) {
+ int mi_rows = ALIGN_POWER_OF_TWO(cm_mi_rows, seq_params->mib_size_log2);
+ int sb_rows = mi_rows >> seq_params->mib_size_log2;
int start_sb, size_sb, i;
- if (cm->uniform_tile_spacing_flag) {
- size_sb = ALIGN_POWER_OF_TWO(sb_rows, cm->log2_tile_rows);
- size_sb >>= cm->log2_tile_rows;
+ if (tiles->uniform_spacing) {
+ size_sb = ALIGN_POWER_OF_TWO(sb_rows, tiles->log2_rows);
+ size_sb >>= tiles->log2_rows;
assert(size_sb > 0);
for (i = 0, start_sb = 0; start_sb < sb_rows; i++) {
- cm->tile_row_start_sb[i] = start_sb;
+ tiles->row_start_sb[i] = start_sb;
start_sb += size_sb;
}
- cm->tile_rows = i;
- cm->tile_row_start_sb[i] = sb_rows;
+ tiles->rows = i;
+ tiles->row_start_sb[i] = sb_rows;
- cm->tile_height = size_sb << cm->seq_params.mib_size_log2;
- cm->tile_height = AOMMIN(cm->tile_height, cm->mi_rows);
+ tiles->height = size_sb << seq_params->mib_size_log2;
+ tiles->height = AOMMIN(tiles->height, cm_mi_rows);
} else {
- cm->log2_tile_rows = tile_log2(1, cm->tile_rows);
+ tiles->log2_rows = tile_log2(1, tiles->rows);
}
}
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->seq_params.mib_size_log2;
- int mi_row_end = cm->tile_row_start_sb[row + 1]
+ assert(row < cm->tiles.rows);
+ int mi_row_start = cm->tiles.row_start_sb[row]
+ << cm->seq_params.mib_size_log2;
+ int mi_row_end = cm->tiles.row_start_sb[row + 1]
<< cm->seq_params.mib_size_log2;
tile->tile_row = row;
tile->mi_row_start = mi_row_start;
- tile->mi_row_end = AOMMIN(mi_row_end, cm->mi_rows);
+ tile->mi_row_end = AOMMIN(mi_row_end, cm->mi_params.mi_rows);
assert(tile->mi_row_end > tile->mi_row_start);
}
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->seq_params.mib_size_log2;
- int mi_col_end = cm->tile_col_start_sb[col + 1]
+ assert(col < cm->tiles.cols);
+ int mi_col_start = cm->tiles.col_start_sb[col]
+ << cm->seq_params.mib_size_log2;
+ int mi_col_end = cm->tiles.col_start_sb[col + 1]
<< cm->seq_params.mib_size_log2;
tile->tile_col = col;
tile->mi_col_start = mi_col_start;
- tile->mi_col_end = AOMMIN(mi_col_end, cm->mi_cols);
+ tile->mi_col_end = AOMMIN(mi_col_end, cm->mi_params.mi_cols);
assert(tile->mi_col_end > tile->mi_col_start);
}
@@ -143,30 +167,6 @@ int av1_get_sb_cols_in_tile(AV1_COMMON *cm, TileInfo tile) {
return sb_cols;
}
-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
- 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 shift = log2_tile_num + MAX_MIB_SIZE_LOG2;
- const int max_sb_tile_size =
- ALIGN_POWER_OF_TWO(mi_frame_size, shift) >> shift;
- 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;
-}
-
AV1PixelRect av1_get_tile_rect(const TileInfo *tile_info, const AV1_COMMON *cm,
int is_uv) {
AV1PixelRect r;
@@ -205,3 +205,35 @@ AV1PixelRect av1_get_tile_rect(const TileInfo *tile_info, const AV1_COMMON *cm,
return r;
}
+
+void av1_get_uniform_tile_size(const AV1_COMMON *cm, int *w, int *h) {
+ const CommonTileParams *const tiles = &cm->tiles;
+ if (tiles->uniform_spacing) {
+ *w = tiles->width;
+ *h = tiles->height;
+ } else {
+ for (int i = 0; i < tiles->cols; ++i) {
+ const int tile_width_sb =
+ tiles->col_start_sb[i + 1] - tiles->col_start_sb[i];
+ const int tile_w = tile_width_sb * cm->seq_params.mib_size;
+ assert(i == 0 || tile_w == *w); // ensure all tiles have same dimension
+ *w = tile_w;
+ }
+
+ for (int i = 0; i < tiles->rows; ++i) {
+ const int tile_height_sb =
+ tiles->row_start_sb[i + 1] - tiles->row_start_sb[i];
+ const int tile_h = tile_height_sb * cm->seq_params.mib_size;
+ assert(i == 0 || tile_h == *h); // ensure all tiles have same dimension
+ *h = tile_h;
+ }
+ }
+}
+
+int av1_is_min_tile_width_satisfied(const AV1_COMMON *cm) {
+ // Disable check if there is a single tile col in the frame
+ if (cm->tiles.cols == 1) return 1;
+
+ return ((cm->tiles.min_inner_width << MI_SIZE_LOG2) >=
+ (64 << av1_superres_scaled(cm)));
+}