From 8f089cbd2ec3899127817c21f137b03844b2e519 Mon Sep 17 00:00:00 2001 From: Yaowu Xu Date: Mon, 3 Aug 2015 10:46:12 -0700 Subject: Correct the allocation size for ssim_vars Ssim_vars is used to accumulate stats based 4x4 pixel blocks, this commit changes the allocations size to be based on mi_rows and mi_cols to avoid out-of-bound memory access for larger size videos. The hard coded 720x480 can only work for image size up to 2880x1920. Change-Id: Id9d07f3f777385b448ac88a6034b7472e4cf3c79 --- vp9/encoder/vp9_encoder.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'vp9/encoder/vp9_encoder.c') diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c index 53e747c26..4abf0ee2b 100644 --- a/vp9/encoder/vp9_encoder.c +++ b/vp9/encoder/vp9_encoder.c @@ -1708,7 +1708,8 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf, } if (cpi->b_calculate_consistency) { - cpi->ssim_vars = vpx_malloc(sizeof(*cpi->ssim_vars)*720*480); + cpi->ssim_vars = vpx_malloc(sizeof(*cpi->ssim_vars) * + 4 * cpi->common.mi_rows * cpi->common.mi_cols); cpi->worst_consistency = 100.0; } -- cgit v1.2.3