From 2ac954dfd2e47afd0df2a6dece14d1689644e30c Mon Sep 17 00:00:00 2001 From: Jerome Jiang Date: Fri, 9 Nov 2018 13:27:39 -0800 Subject: [PATCH] vp8: Init buffers and pred arrays for mt after allocation. Buffers and arrays used for prediction are not initialized after allocation. BUG=902691 Change-Id: Ic727e5dab7456e91ec9d6c80694f60a1a3600640 --- vp8/decoder/threading.c | 14 ++++++++++---- vpx_scale/generic/yv12config.c | 8 ++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/vp8/decoder/threading.c b/vp8/decoder/threading.c index 90e0f4d86..561922de3 100644 --- a/vp8/decoder/threading.c +++ b/vp8/decoder/threading.c @@ -15,8 +15,8 @@ #endif #include "onyxd_int.h" #include "vpx_mem/vpx_mem.h" +#include "vp8/common/common.h" #include "vp8/common/threading.h" - #include "vp8/common/loopfilter.h" #include "vp8/common/extend.h" #include "vpx_ports/vpx_timer.h" @@ -761,22 +761,28 @@ void vp8mt_alloc_temp_buffers(VP8D_COMP *pbi, int width, int prev_mb_rows) { /* Allocate memory for above_row buffers. */ CALLOC_ARRAY(pbi->mt_yabove_row, pc->mb_rows); - for (i = 0; i < pc->mb_rows; ++i) + for (i = 0; i < pc->mb_rows; ++i) { CHECK_MEM_ERROR(pbi->mt_yabove_row[i], vpx_memalign(16, sizeof(unsigned char) * (width + (VP8BORDERINPIXELS << 1)))); + vp8_zero_array(pbi->mt_yabove_row[i], width + (VP8BORDERINPIXELS << 1)); + } CALLOC_ARRAY(pbi->mt_uabove_row, pc->mb_rows); - for (i = 0; i < pc->mb_rows; ++i) + for (i = 0; i < pc->mb_rows; ++i) { CHECK_MEM_ERROR(pbi->mt_uabove_row[i], vpx_memalign(16, sizeof(unsigned char) * (uv_width + VP8BORDERINPIXELS))); + vp8_zero_array(pbi->mt_uabove_row[i], uv_width + VP8BORDERINPIXELS); + } CALLOC_ARRAY(pbi->mt_vabove_row, pc->mb_rows); - for (i = 0; i < pc->mb_rows; ++i) + for (i = 0; i < pc->mb_rows; ++i) { CHECK_MEM_ERROR(pbi->mt_vabove_row[i], vpx_memalign(16, sizeof(unsigned char) * (uv_width + VP8BORDERINPIXELS))); + vp8_zero_array(pbi->mt_vabove_row[i], uv_width + VP8BORDERINPIXELS); + } /* Allocate memory for left_col buffers. */ CALLOC_ARRAY(pbi->mt_yleft_col, pc->mb_rows); diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index db1db37ce..287a5a098 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -61,6 +61,14 @@ int vp8_yv12_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, if (!ybf->buffer_alloc) { ybf->buffer_alloc = (uint8_t *)vpx_memalign(32, frame_size); +#if defined(__has_feature) +#if __has_feature(memory_sanitizer) + // This memset is needed for fixing the issue of using uninitialized + // value in msan test. It will cause a perf loss, so only do this for + // msan test. + memset(ybf->buffer_alloc, 0, frame_size); +#endif +#endif ybf->buffer_alloc_sz = frame_size; } -- 2.40.0