Return error code for buffer allocation.
Change-Id: I863a9ead3bbb634dc802cefd30f5916d16ef7b29
diff --git a/aom_scale/generic/yv12config.c b/aom_scale/generic/yv12config.c
index da5115e..493663e 100644
--- a/aom_scale/generic/yv12config.c
+++ b/aom_scale/generic/yv12config.c
@@ -27,7 +27,6 @@
(void *)(((size_t)(addr) + ((align)-1)) & (size_t) - (align))
// TODO(jkoleszar): Maybe replace this with struct aom_image
-
int aom_free_frame_buffer(YV12_BUFFER_CONFIG *ybf) {
if (ybf) {
if (ybf->buffer_alloc_sz > 0) {
@@ -39,11 +38,9 @@
u_buffer and v_buffer point to buffer_alloc and are used. Clear out
all of this so that a freed pointer isn't inadvertently used */
memset(ybf, 0, sizeof(YV12_BUFFER_CONFIG));
- } else {
- return -1;
}
- return 0;
+ return AOM_CODEC_MEM_ERROR;
}
static int realloc_frame_buffer_aligned(
@@ -69,7 +66,8 @@
// The decoder may allocate REF_FRAMES frame buffers in the frame buffer
// pool. Bound the total amount of allocated memory as if these REF_FRAMES
// frame buffers were allocated in a single allocation.
- if (alloc_size > AOM_MAX_ALLOCABLE_MEMORY / REF_FRAMES) return -1;
+ if (alloc_size > AOM_MAX_ALLOCABLE_MEMORY / REF_FRAMES)
+ return AOM_CODEC_MEM_ERROR;
#endif
if (cb != NULL) {
@@ -78,12 +76,15 @@
assert(fb != NULL);
- if (external_frame_size != (size_t)external_frame_size) return -1;
+ if (external_frame_size != (size_t)external_frame_size)
+ return AOM_CODEC_MEM_ERROR;
// Allocation to hold larger frame, or first allocation.
- if (cb(cb_priv, (size_t)external_frame_size, fb) < 0) return -1;
+ if (cb(cb_priv, (size_t)external_frame_size, fb) < 0)
+ return AOM_CODEC_MEM_ERROR;
- if (fb->data == NULL || fb->size < external_frame_size) return -1;
+ if (fb->data == NULL || fb->size < external_frame_size)
+ return AOM_CODEC_MEM_ERROR;
ybf->buffer_alloc = (uint8_t *)yv12_align_addr(fb->data, 32);
@@ -101,10 +102,10 @@
ybf->buffer_alloc = NULL;
ybf->buffer_alloc_sz = 0;
- if (frame_size != (size_t)frame_size) return -1;
+ if (frame_size != (size_t)frame_size) return AOM_CODEC_MEM_ERROR;
ybf->buffer_alloc = (uint8_t *)aom_memalign(32, (size_t)frame_size);
- if (!ybf->buffer_alloc) return -1;
+ if (!ybf->buffer_alloc) return AOM_CODEC_MEM_ERROR;
ybf->buffer_alloc_sz = (size_t)frame_size;
@@ -155,7 +156,7 @@
if (use_highbitdepth) {
if (ybf->y_buffer_8bit) aom_free(ybf->y_buffer_8bit);
ybf->y_buffer_8bit = (uint8_t *)aom_memalign(32, (size_t)yplane_size);
- if (!ybf->y_buffer_8bit) return -1;
+ if (!ybf->y_buffer_8bit) return AOM_CODEC_MEM_ERROR;
} else {
if (ybf->y_buffer_8bit) {
aom_free(ybf->y_buffer_8bit);
@@ -167,7 +168,7 @@
ybf->corrupted = 0; /* assume not corrupted by errors */
return 0;
}
- return -2;
+ return AOM_CODEC_MEM_ERROR;
}
static int calc_stride_and_planesize(const int ss_x, const int ss_y,
@@ -182,7 +183,7 @@
* the start of the chroma rows without introducing an arbitrary gap
* between planes, which would break the semantics of things like
* aom_img_set_rect(). */
- if (border & 0x1f) return -3;
+ if (border & 0x1f) return AOM_CODEC_MEM_ERROR;
*y_stride = ((aligned_width + 2 * border) + 31) & ~31;
*yplane_size =
(aligned_height + 2 * border) * (uint64_t)(*y_stride) + byte_alignment;
@@ -199,7 +200,8 @@
aom_codec_frame_buffer_t *fb,
aom_get_frame_buffer_cb_fn_t cb, void *cb_priv) {
#if CONFIG_SIZE_LIMIT
- if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT) return -1;
+ if (width > DECODE_WIDTH_LIMIT || height > DECODE_HEIGHT_LIMIT)
+ return AOM_CODEC_MEM_ERROR;
#endif
if (ybf) {
@@ -224,7 +226,7 @@
aligned_width, aligned_height, uv_width, uv_height, uv_stride,
uv_border_w, uv_border_h);
}
- return -2;
+ return AOM_CODEC_MEM_ERROR;
}
// TODO(anyone): This function allocates memory for