summaryrefslogtreecommitdiff
path: root/vp9/decoder
diff options
context:
space:
mode:
authorAdrian Grange <agrange@google.com>2014-08-12 11:24:24 -0700
committerAdrian Grange <agrange@google.com>2014-08-14 08:59:15 -0700
commit4e30565a9ff3740f20314501d4190541052240e3 (patch)
tree8f1f7a8157c3c9fcf450e30d319727bed4acde2e /vp9/decoder
parent82481405ab7db2f2b0bd720d966f14c682308c92 (diff)
downloadlibvpx-4e30565a9ff3740f20314501d4190541052240e3.tar
libvpx-4e30565a9ff3740f20314501d4190541052240e3.tar.gz
libvpx-4e30565a9ff3740f20314501d4190541052240e3.tar.bz2
libvpx-4e30565a9ff3740f20314501d4190541052240e3.zip
Fix bug 837: realloc mode info buffers on resize
The test to determine if the mode info buffers need to be resized when the frame size changes was incorrect, as per bug 837. By storing the size of the allocated data structure, a simple test determines whether to allocate more memory when the frame size changes. Change-Id: I1544698f2882cf958fc672485614f2f46e9719bd
Diffstat (limited to 'vp9/decoder')
-rw-r--r--vp9/decoder/vp9_decodeframe.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index 07971687c..a0fff458c 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -627,16 +627,14 @@ 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 ||
- aligned_width > cm->width ||
- aligned_width * aligned_height > cm->width * cm->height) {
+ const int new_rows = ALIGN_POWER_OF_TWO(height,
+ MI_SIZE_LOG2) >> MI_SIZE_LOG2;
+ const int new_cols = ALIGN_POWER_OF_TWO(width,
+ MI_SIZE_LOG2) >> MI_SIZE_LOG2;
+ if (calc_mi_size(new_rows) * calc_mi_size(new_cols) > cm->mi_alloc_size) {
if (vp9_alloc_context_buffers(cm, width, height))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate frame buffers");
+ "Failed to allocate context buffers");
} else {
vp9_set_mb_mi(cm, width, height);
}