1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
12 #ifndef AOM_AV1_COMMON_TILE_COMMON_H_
13 #define AOM_AV1_COMMON_TILE_COMMON_H_
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 #include "config/aom_config.h"
20 
21 struct AV1Common;
22 
23 #define DEFAULT_MAX_NUM_TG 1
24 
25 typedef struct TileInfo {
26   int mi_row_start, mi_row_end;
27   int mi_col_start, mi_col_end;
28   int tg_horz_boundary;
29   int tile_row;
30   int tile_col;
31 } TileInfo;
32 
33 // initializes 'tile->mi_(row|col)_(start|end)' for (row, col) based on
34 // 'cm->log2_tile_(rows|cols)' & 'cm->mi_(rows|cols)'
35 void av1_tile_init(TileInfo *tile, const struct AV1Common *cm, int row,
36                    int col);
37 
38 void av1_tile_set_row(TileInfo *tile, const struct AV1Common *cm, int row);
39 void av1_tile_set_col(TileInfo *tile, const struct AV1Common *cm, int col);
40 void av1_get_tile_n_bits(int mi_cols, int *min_log2_tile_cols,
41                          int *max_log2_tile_cols);
42 
43 // Calculate the correct tile size (width or height) for (1 << log2_tile_num)
44 // tiles horizontally or vertically in the frame.
45 int get_tile_size(int mi_frame_size, int log2_tile_num, int *ntiles);
46 
47 int av1_get_sb_rows_in_tile(struct AV1Common *cm, TileInfo tile);
48 int av1_get_sb_cols_in_tile(struct AV1Common *cm, TileInfo tile);
49 
50 typedef struct {
51   int left, top, right, bottom;
52 } AV1PixelRect;
53 
54 // Return the pixel extents of the given tile
55 AV1PixelRect av1_get_tile_rect(const TileInfo *tile_info,
56                                const struct AV1Common *cm, int is_uv);
57 
58 // Define tile maximum width and area
59 // There is no maximum height since height is limited by area and width limits
60 // The minimum tile width or height is fixed at one superblock
61 #define MAX_TILE_WIDTH (4096)        // Max Tile width in pixels
62 #define MAX_TILE_AREA (4096 * 2304)  // Maximum tile area in pixels
63 
64 void av1_get_tile_limits(struct AV1Common *const cm);
65 void av1_calculate_tile_cols(struct AV1Common *const cm);
66 void av1_calculate_tile_rows(struct AV1Common *const cm);
67 
68 #ifdef __cplusplus
69 }  // extern "C"
70 #endif
71 
72 #endif  // AOM_AV1_COMMON_TILE_COMMON_H_
73