]> granicus.if.org Git - libvpx/commitdiff
Allocate tile data adaptively to accommodate the frame size increase
authorYunqing Wang <yunqingwang@google.com>
Thu, 11 Jun 2015 18:30:18 +0000 (11:30 -0700)
committerYunqing Wang <yunqingwang@google.com>
Thu, 11 Jun 2015 18:30:18 +0000 (11:30 -0700)
If the frame size increases, the tile data buffer needs to be
re-allocated according to the number of tiles existing in current
frame. This patch makes the multi-tile encoding work in spatial
SVC usage case, and partially solved WebM issue 1018.

Change-Id: I1ad6f33058cf5ce6f60ed5024455a709ca80c5ad

vp9/encoder/vp9_encodeframe.c
vp9/encoder/vp9_encoder.h

index 49e8887687de34b4ab66403b2ebad58195ba45fb..7c91da1f2f880a73a04352b85fb95f351c5a48b1 100644 (file)
@@ -3785,9 +3785,13 @@ void vp9_init_tile_data(VP9_COMP *cpi) {
   TOKENEXTRA *pre_tok = cpi->tile_tok[0][0];
   int tile_tok = 0;
 
-  if (cpi->tile_data == NULL) {
+  if (cpi->tile_data == NULL || cpi->allocated_tiles < tile_cols * tile_rows) {
+    if (cpi->tile_data != NULL)
+      vpx_free(cpi->tile_data);
     CHECK_MEM_ERROR(cm, cpi->tile_data,
         vpx_malloc(tile_cols * tile_rows * sizeof(*cpi->tile_data)));
+    cpi->allocated_tiles = tile_cols * tile_rows;
+
     for (tile_row = 0; tile_row < tile_rows; ++tile_row)
       for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
         TileDataEnc *tile_data =
index 6ce4a67cdd154e74194d9c078d326ed216849383..4d2a186e8ccf34cd8f89e40da46fa0eeeb2e34d3 100644 (file)
@@ -306,6 +306,7 @@ typedef struct VP9_COMP {
   YV12_BUFFER_CONFIG scaled_last_source;
 
   TileDataEnc *tile_data;
+  int allocated_tiles;  // Keep track of memory allocated for tiles.
 
   // For a still frame, this flag is set to 1 to skip partition search.
   int partition_search_skippable_frame;