shithub: libvpx

Download patch

ref: d5bec522daf09568e9446e4658268cc60ed4e8f7
parent: 0eef1acbefe1eb935f6c757cfb62b24941a58b60
author: Adrian Grange <[email protected]>
date: Fri Aug 9 12:21:27 EDT 2013

Added resizing & initialization of last frame segment map

When the frame size changes the last frame segment map must
be resized to match and initialized to 0.

Change-Id: Idc10de109f55dbe9af3a6caae355a2974712243d

--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -58,6 +58,7 @@
   vpx_free(oci->mip);
   vpx_free(oci->prev_mip);
   vpx_free(oci->above_seg_context);
+  vpx_free(oci->last_frame_seg_map);
 
   vpx_free(oci->above_context[0]);
   for (i = 0; i < MAX_MB_PLANE; i++)
@@ -65,6 +66,7 @@
   oci->mip = NULL;
   oci->prev_mip = NULL;
   oci->above_seg_context = NULL;
+  oci->last_frame_seg_map = NULL;
 }
 
 static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) {
@@ -157,6 +159,11 @@
   if (!oci->above_seg_context)
     goto fail;
 
+  // Create the segmentation map structure and set to 0.
+  oci->last_frame_seg_map = vpx_calloc(oci->mi_rows * oci->mi_cols, 1);
+  if (!oci->last_frame_seg_map)
+    goto fail;
+
   return 0;
 
  fail:
@@ -198,4 +205,8 @@
   for (i = 1; i < MAX_MB_PLANE; i++)
     cm->above_context[i] =
         cm->above_context[0] + i * sizeof(ENTROPY_CONTEXT) * 2 * mi_cols;
+
+  // Initialize the previous frame segment map to 0.
+  if (cm->last_frame_seg_map)
+    vpx_memset(cm->last_frame_seg_map, 0, cm->mi_rows * cm->mi_cols);
 }
--- a/vp9/decoder/vp9_decodframe.c
+++ b/vp9/decoder/vp9_decodframe.c
@@ -989,11 +989,6 @@
 
   new_fb->corrupted |= read_compressed_header(pbi, data, first_partition_size);
 
-  // Create the segmentation map structure and set to 0
-  if (!pc->last_frame_seg_map)
-    CHECK_MEM_ERROR(pc, pc->last_frame_seg_map,
-                    vpx_calloc((pc->mi_rows * pc->mi_cols), 1));
-
   setup_block_dptrs(xd, pc->subsampling_x, pc->subsampling_y);
 
   // clear out the coeff buffer
--- a/vp9/decoder/vp9_onyxd_if.c
+++ b/vp9/decoder/vp9_onyxd_if.c
@@ -160,9 +160,6 @@
   if (!pbi)
     return;
 
-  if (pbi->common.last_frame_seg_map)
-    vpx_free(pbi->common.last_frame_seg_map);
-
   vp9_remove_common(&pbi->common);
   vp9_worker_end(&pbi->lf_worker);
   vpx_free(pbi->lf_worker.data1);