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 f8c0517..abe82be 100644
--- a/test/hbd_metrics_test.cc
+++ b/test/hbd_metrics_test.cc
@@ -96,7 +96,7 @@
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 6ed4321..13fbd28 100644
--- a/vpx_scale/generic/yv12config.c
+++ b/vpx_scale/generic/yv12config.c
@@ -99,17 +99,21 @@
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 @@
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 6b72c72..d581db9 100644
--- a/vpx_scale/yv12config.h
+++ b/vpx_scale/yv12config.h
@@ -53,9 +53,9 @@
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;