From: Yunqing Wang Date: Tue, 30 Aug 2016 18:48:44 +0000 (-0700) Subject: Change buffer_alloc_sz and frame_size type to size_t X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a722a114d6f9d050fef39c841b1b7aaba9c39f65;p=libvpx Change buffer_alloc_sz and frame_size type to size_t 1. Changed buffer_alloc_sz and frame_size type to size_t. 2. Added a TODO for video resolution limits. On 32 bit systems, the maximum resolution supported in the encoder is 4k(3840x2160). The malloc() would fail if encoding >4k video on a 32 bit system. Change-Id: Ibd91b28fd63d1b04e8ac9a5270a17629f239188a --- diff --git a/test/hbd_metrics_test.cc b/test/hbd_metrics_test.cc index f8c051708..abe82beea 100644 --- a/test/hbd_metrics_test.cc +++ b/test/hbd_metrics_test.cc @@ -96,7 +96,7 @@ class HBDMetricsTestBase { void RunAccuracyCheck() { const int width = 1920; const int height = 1080; - int i = 0; + size_t i = 0; const uint8_t kPixFiller = 128; YV12_BUFFER_CONFIG lbd_src, lbd_dst; YV12_BUFFER_CONFIG hbd_src, hbd_dst; diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index 6ed4321e8..13fbd2860 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -99,17 +99,21 @@ int vpx_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, memset(ybf->buffer_alloc, 0, (int)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; if (frame_size != (size_t)frame_size) return -1; + // TODO(yunqingwang): On 32 bit systems, the maximum resolution supported + // in the encoder is 4k(3840x2160). The malloc() would fail if encoding + // >4k video on a 32 bit system. Later, maybe disable usage of up-sampled + // references to allow >4k video encoding on 32 bit platforms. 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 @@ -137,7 +141,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 6b72c7233..d581db98b 100644 --- a/vpx_scale/yv12config.h +++ b/vpx_scale/yv12config.h @@ -53,9 +53,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;