From: Jingning Han Date: Wed, 20 May 2015 17:15:25 +0000 (-0700) Subject: Refactor internal tile_info variables to support 1024 tiles X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=225097a7eda0ad17d60c5e02d48c2969c91ec547;p=libvpx Refactor internal tile_info variables to support 1024 tiles Move the 2D tile info arrays as global variables. This resolves the local function stack overflow issue due to excessively large tile info variables. This allows the internal operation to support up to 1024 row and column tiles. Change-Id: I6644cc929e5d3a778a5c03a712ebfc0b8729f576 --- diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index 468a0536a..4fc0f58ce 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -1893,12 +1893,6 @@ static void setup_tile_info(VP9_COMMON *cm, struct vp9_read_bit_buffer *rb) { #endif } -typedef struct TileBuffer { - const uint8_t *data; - size_t size; - int col; // only used with multi-threaded decoding -} TileBuffer; - // Reads the next tile returning its size and adjusting '*data' accordingly // based on 'is_last'. static void get_tile_buffer(const uint8_t *const data_end, @@ -1939,7 +1933,7 @@ static void get_tile_buffer(const uint8_t *const data_end, static void get_tile_buffers(VP9Decoder *pbi, const uint8_t *data, const uint8_t *data_end, int tile_cols, int tile_rows, - TileBuffer (*tile_buffers)[1 << 6]) { + TileBuffer (*tile_buffers)[1024]) { int r, c; for (r = 0; r < tile_rows; ++r) { @@ -1962,9 +1956,9 @@ static const uint8_t *decode_tiles(VP9Decoder *pbi, const int tile_cols = 1 << cm->log2_tile_cols; const int tile_rows = 1 << cm->log2_tile_rows; #if CONFIG_ROW_TILE - TileBuffer tile_buffers[64][64]; + TileBuffer (*tile_buffers)[1024] = pbi->tile_buffers; #else - TileBuffer tile_buffers[4][1 << 6]; + TileBuffer tile_buffers[4][1024]; #endif int tile_row, tile_col; int mi_row, mi_col; @@ -2138,6 +2132,8 @@ static int compare_tile_buffers(const void *a, const void *b) { } } +// TODO(jingning): Multi-thread tile decoding is not supporting +// arbitrary row/column tile numbers yet. static const uint8_t *decode_tiles_mt(VP9Decoder *pbi, const uint8_t *data, const uint8_t *data_end) { @@ -2148,7 +2144,7 @@ static const uint8_t *decode_tiles_mt(VP9Decoder *pbi, const int tile_cols = 1 << cm->log2_tile_cols; const int tile_rows = 1 << cm->log2_tile_rows; const int num_workers = MIN(pbi->max_threads & ~1, tile_cols); - TileBuffer tile_buffers[1][1 << 6]; + TileBuffer tile_buffers[1][1024]; int n; int final_worker = -1; diff --git a/vp9/decoder/vp9_decoder.h b/vp9/decoder/vp9_decoder.h index 4f52bb9c4..3f4e53e85 100644 --- a/vp9/decoder/vp9_decoder.h +++ b/vp9/decoder/vp9_decoder.h @@ -33,6 +33,12 @@ typedef struct TileData { DECLARE_ALIGNED(16, MACROBLOCKD, xd); } TileData; +typedef struct TileBuffer { + const uint8_t *data; + size_t size; + int col; // only used with multi-threaded decoding +} TileBuffer; + typedef struct VP9Decoder { DECLARE_ALIGNED(16, MACROBLOCKD, mb); @@ -59,6 +65,10 @@ typedef struct VP9Decoder { int max_threads; int inv_tile_order; int need_resync; // wait for key/intra-only frame + +#if CONFIG_ROW_TILE + TileBuffer tile_buffers[1024][1024]; +#endif } VP9Decoder; int vp9_receive_compressed_data(struct VP9Decoder *pbi, diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 0bf8167ca..dd013cc8f 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -4537,8 +4537,8 @@ static void encode_tiles(VP9_COMP *cpi) { int tile_col, tile_row; #if CONFIG_ROW_TILE - TileInfo tile[64][64]; - TOKENEXTRA *tok[64][64]; + TileInfo (*tile)[1024] = cpi->tile_info; + TOKENEXTRA *(*tok)[1024] = cpi->tile_tok; #else TileInfo tile[4][1 << 6]; TOKENEXTRA *tok[4][1 << 6]; diff --git a/vp9/encoder/vp9_encoder.h b/vp9/encoder/vp9_encoder.h index e1c184247..e2a818a1f 100644 --- a/vp9/encoder/vp9_encoder.h +++ b/vp9/encoder/vp9_encoder.h @@ -426,6 +426,11 @@ typedef struct VP9_COMP { int multi_arf_enabled; int multi_arf_last_grp_enabled; +#if CONFIG_ROW_TILE + TileInfo tile_info[1024][1024]; + TOKENEXTRA *tile_tok[1024][1024]; +#endif + #if CONFIG_VP9_TEMPORAL_DENOISING VP9_DENOISER denoiser; #endif