]> granicus.if.org Git - libvpx/commitdiff
Fix above context pointers
authorJohn Koleszar <jkoleszar@google.com>
Tue, 16 Jul 2013 17:20:56 +0000 (10:20 -0700)
committerJohn Koleszar <jkoleszar@google.com>
Tue, 16 Jul 2013 17:26:56 +0000 (10:26 -0700)
In the prior code, the above context pointers used for entropy
decoding were initialized on the first frame, and not updated when
the frame size changed. The per-frame code which initializes the
contexts assumes that the contexts are contiguous, leading to an
incomplete initialization when the frame is smaller. This commit
updates the pointers so that the context is contigous whenever
the frame size changes.

Change-Id: I08b53e3a30c8289491212311682ff1b8028cff6c

vp9/common/vp9_alloccommon.c

index 96b27bf7c889ef0f37815a52a44485a42d71a483..bcc8645d486894e337720ae53782c8c8880d4ed5 100644 (file)
@@ -158,10 +158,6 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) {
   if (!oci->above_context[0])
     goto fail;
 
-  for (i = 1; i < MAX_MB_PLANE; i++)
-    oci->above_context[i] =
-        oci->above_context[0] + i * sizeof(ENTROPY_CONTEXT) * 2 * mi_cols;
-
   oci->above_seg_context = vpx_calloc(sizeof(PARTITION_CONTEXT) * mi_cols, 1);
   if (!oci->above_seg_context)
     goto fail;
@@ -197,9 +193,15 @@ void vp9_initialize_common() {
 }
 
 void vp9_update_frame_size(VP9_COMMON *cm) {
+  int i, mi_cols;
   const int aligned_width = ALIGN_POWER_OF_TWO(cm->width, LOG2_MI_SIZE);
   const int aligned_height = ALIGN_POWER_OF_TWO(cm->height, LOG2_MI_SIZE);
 
   set_mb_mi(cm, aligned_width, aligned_height);
   setup_mi(cm);
+
+  mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
+  for (i = 1; i < MAX_MB_PLANE; i++)
+    cm->above_context[i] =
+        cm->above_context[0] + i * sizeof(ENTROPY_CONTEXT) * 2 * mi_cols;
 }