From 73cbff0e531aea1c25a3c004afdee130651b6396 Mon Sep 17 00:00:00 2001 From: Wan-Teh Chang Date: Tue, 20 Nov 2018 09:38:21 -0800 Subject: [PATCH] Declare buffer_alloc_sz and frame_size as size_t. Change-Id: Id632ddcbfb0bd3a4258aebdfb98f9dc2e4d04438 --- vpx_scale/generic/yv12config.c | 14 +++++++------- vpx_scale/yv12config.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index c66d885cf..7d4aa2a91 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -57,7 +57,7 @@ int vp8_yv12_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, * uv_stride == y_stride/2, so enforce this here. */ int uv_stride = y_stride >> 1; int uvplane_size = (uv_height + border) * uv_stride; - const int frame_size = yplane_size + 2 * uvplane_size; + const size_t frame_size = yplane_size + 2 * uvplane_size; if (!ybf->buffer_alloc) { ybf->buffer_alloc = (uint8_t *)vpx_memalign(32, frame_size); @@ -185,9 +185,9 @@ int vpx_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, uint8_t *buf = NULL; - // frame_size is stored in buffer_alloc_sz, which is an int. If it won't + // frame_size is stored in buffer_alloc_sz, which is a size_t. If it won't // fit, fail early. - if (frame_size > INT_MAX) { + if (frame_size > SIZE_MAX) { return -1; } @@ -211,10 +211,10 @@ int vpx_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, // 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, (int)frame_size); + memset(ybf->buffer_alloc, 0, (size_t)frame_size); #endif #endif - } else if (frame_size > (size_t)ybf->buffer_alloc_sz) { + } else if (frame_size > ybf->buffer_alloc_sz) { // Allocation to hold larger frame, or first allocation. vpx_free(ybf->buffer_alloc); ybf->buffer_alloc = NULL; @@ -222,7 +222,7 @@ int vpx_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, ybf->buffer_alloc = (uint8_t *)vpx_memalign(32, (size_t)frame_size); if (!ybf->buffer_alloc) return -1; - ybf->buffer_alloc_sz = (int)frame_size; + ybf->buffer_alloc_sz = (size_t)frame_size; // This memset is needed for fixing valgrind error from C loop filter // due to access uninitialized memory in frame border. It could be @@ -243,7 +243,7 @@ int vpx_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, ybf->uv_stride = uv_stride; ybf->border = border; - ybf->frame_size = (int)frame_size; + ybf->frame_size = (size_t)frame_size; ybf->subsampling_x = ss_x; ybf->subsampling_y = ss_y; diff --git a/vpx_scale/yv12config.h b/vpx_scale/yv12config.h index 53728af42..2cf18217f 100644 --- a/vpx_scale/yv12config.h +++ b/vpx_scale/yv12config.h @@ -49,9 +49,9 @@ typedef struct yv12_buffer_config { uint8_t *alpha_buffer; uint8_t *buffer_alloc; - int buffer_alloc_sz; + size_t buffer_alloc_sz; int border; - int frame_size; + size_t frame_size; int subsampling_x; int subsampling_y; unsigned int bit_depth; -- 2.40.0