]> granicus.if.org Git - libvpx/commitdiff
Fix allocation of context buffers on frame resize
authorAdrian Grange <agrange@google.com>
Thu, 24 Jul 2014 20:37:47 +0000 (13:37 -0700)
committerAdrian Grange <agrange@google.com>
Thu, 24 Jul 2014 21:07:45 +0000 (14:07 -0700)
The patch:
https://gerrit.chromium.org/gerrit/#/c/70814/
changed the test that determined whether the context
frame buffers needed to be reallocated or not.

The code checked for a change in total frame area
to signal the need to reallocate context buffers.
However, the above_context buffer needs to be
resized i:xf only the width of the frame has increased.

Change-Id: Ib89d75651af252908144cf662578d84f16cf30e6

vp9/decoder/vp9_decodeframe.c

index 28c674a386082d737bc5555bcb173552136f3a35..4a6277397610b6810e0be4edc18aa2afa650e548 100644 (file)
@@ -627,9 +627,13 @@ static void resize_context_buffers(VP9_COMMON *cm, int width, int height) {
                        "Width and height beyond allowed size.");
 #endif
   if (cm->width != width || cm->height != height) {
+    const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2);
+    const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2);
+
     // Change in frame size (assumption: color format does not change).
     if (cm->width == 0 || cm->height == 0 ||
-        width * height > cm->width * cm->height) {
+        aligned_width > cm->width ||
+        aligned_width * aligned_height > cm->width * cm->height) {
       if (vp9_alloc_context_buffers(cm, width, height))
         vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
                            "Failed to allocate frame buffers");