From 8d028402d786f20c522ddfe73d267c73d9ab39ae Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 24 Apr 2013 12:28:27 -0700 Subject: [PATCH] Remove implicit assumption that mode_info_stride == mb_cols + 1. Change-Id: I3030d7adac73109aeaa1ecc0f78ac968c092d9aa --- vp9/common/vp9_alloccommon.c | 9 ++++++--- vp9/common/vp9_entropymode.c | 4 ++-- vp9/decoder/vp9_decodframe.c | 2 +- vp9/encoder/vp9_onyx_if.c | 8 ++++---- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c index 56fac12b4..b88a5d43e 100644 --- a/vp9/common/vp9_alloccommon.c +++ b/vp9/common/vp9_alloccommon.c @@ -33,15 +33,18 @@ void vp9_update_mode_info_border(VP9_COMMON *cpi, MODE_INFO *mi) { void vp9_update_mode_info_in_image(VP9_COMMON *cpi, MODE_INFO *mi) { int i, j; + MODE_INFO *ptr; // For each in image mode_info element set the in image flag to 1 for (i = 0; i < cpi->mb_rows; i++) { + ptr = mi; for (j = 0; j < cpi->mb_cols; j++) { - mi->mbmi.mb_in_image = 1; - mi++; // Next element in the row + ptr->mbmi.mb_in_image = 1; + ptr++; // Next element in the row } - mi++; // Step over border element at start of next row + // Step over border element at start of next row + mi += cpi->mode_info_stride; } } diff --git a/vp9/common/vp9_entropymode.c b/vp9/common/vp9_entropymode.c index 626c7d4cf..fbf4bdfc2 100644 --- a/vp9/common/vp9_entropymode.c +++ b/vp9/common/vp9_entropymode.c @@ -705,9 +705,9 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) { vpx_memcpy(&cm->frame_contexts[i], &cm->fc, sizeof(cm->fc)); vpx_memset(cm->prev_mip, 0, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + cm->mode_info_stride * (cm->mb_rows + 1)* sizeof(MODE_INFO)); vpx_memset(cm->mip, 0, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + cm->mode_info_stride * (cm->mb_rows + 1)* sizeof(MODE_INFO)); vp9_update_mode_info_border(cm, cm->mip); vp9_update_mode_info_in_image(cm, cm->mi); diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index 46ef07625..16d52a25d 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -1051,7 +1051,7 @@ static void update_frame_size(VP9D_COMP *pbi) { cm->MBs = cm->mb_rows * cm->mb_cols; cm->mode_info_stride = cm->mb_cols + 1; memset(cm->mip, 0, - (cm->mb_cols + 1) * (cm->mb_rows + 1) * sizeof(MODE_INFO)); + cm->mode_info_stride * (cm->mb_rows + 1) * sizeof(MODE_INFO)); vp9_update_mode_info_border(cm, cm->mip); vp9_update_mode_info_border(cm, cm->prev_mip); diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 706cf9ac9..0b64fe1d9 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -906,7 +906,7 @@ static void alloc_raw_frame_buffers(VP9_COMP *cpi) { static int alloc_partition_data(VP9_COMP *cpi) { vpx_free(cpi->mb.pip); - cpi->mb.pip = vpx_calloc((cpi->common.mb_cols + 1) * + cpi->mb.pip = vpx_calloc((cpi->common.mode_info_stride) * (cpi->common.mb_rows + 1), sizeof(PARTITION_INFO)); if (!cpi->mb.pip) @@ -991,7 +991,7 @@ static void update_frame_size(VP9_COMP *cpi) { cm->MBs = cm->mb_rows * cm->mb_cols; cm->mode_info_stride = cm->mb_cols + 1; memset(cm->mip, 0, - (cm->mb_cols + 1) * (cm->mb_rows + 1) * sizeof(MODE_INFO)); + cm->mode_info_stride * (cm->mb_rows + 1) * sizeof(MODE_INFO)); vp9_update_mode_info_border(cm, cm->mip); cm->mi = cm->mip + cm->mode_info_stride + 1; @@ -3668,10 +3668,10 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, if (cm->show_frame) { vpx_memcpy(cm->prev_mip, cm->mip, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + cm->mode_info_stride * (cm->mb_rows + 1) * sizeof(MODE_INFO)); } else { vpx_memset(cm->prev_mip, 0, - (cm->mb_cols + 1) * (cm->mb_rows + 1)* sizeof(MODE_INFO)); + cm->mode_info_stride * (cm->mb_rows + 1) * sizeof(MODE_INFO)); } } -- 2.40.0