diff options
author | Yunqing Wang <yunqingwang@google.com> | 2012-10-11 08:46:23 -0700 |
---|---|---|
committer | Yunqing Wang <yunqingwang@google.com> | 2012-10-11 08:46:23 -0700 |
commit | 52bddd44c0f8e4788e2073186816b9b2c032ad16 (patch) | |
tree | e45ff06f9aaf6c156b3f4502b093c0739ba3a24d /vp8/common | |
parent | f6886c4b93283ed9ef11f4688b5af25ebe9aca6a (diff) | |
download | libvpx-52bddd44c0f8e4788e2073186816b9b2c032ad16.tar libvpx-52bddd44c0f8e4788e2073186816b9b2c032ad16.tar.gz libvpx-52bddd44c0f8e4788e2073186816b9b2c032ad16.tar.bz2 libvpx-52bddd44c0f8e4788e2073186816b9b2c032ad16.zip |
Clean up error return code in alloccommon.c
Clean up the duplicate code as Pascal suggested.
Change-Id: I685fcbb488502e969f6cb73a46db3ea79b90910d
Diffstat (limited to 'vp8/common')
-rw-r--r-- | vp8/common/alloccommon.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/vp8/common/alloccommon.c b/vp8/common/alloccommon.c index 86a0971ac..a03f882dc 100644 --- a/vp8/common/alloccommon.c +++ b/vp8/common/alloccommon.c @@ -63,10 +63,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->fb_idx_ref_cnt[i] = 0; oci->yv12_fb[i].flags = 0; if (vp8_yv12_alloc_frame_buffer(&oci->yv12_fb[i], width, height, VP8BORDERINPIXELS) < 0) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; } oci->new_fb_idx = 0; @@ -80,10 +77,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->fb_idx_ref_cnt[3] = 1; if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame, width, 16, VP8BORDERINPIXELS) < 0) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; oci->mb_rows = height >> 4; oci->mb_cols = width >> 4; @@ -92,10 +86,7 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO)); if (!oci->mip) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; oci->mi = oci->mip + oci->mode_info_stride + 1; @@ -105,17 +96,11 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) oci->above_context = vpx_calloc(sizeof(ENTROPY_CONTEXT_PLANES) * oci->mb_cols, 1); if (!oci->above_context) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; #if CONFIG_POSTPROC if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, VP8BORDERINPIXELS) < 0) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; oci->post_proc_buffer_int_used = 0; vpx_memset(&oci->postproc_state, 0, sizeof(oci->postproc_state)); @@ -125,14 +110,16 @@ int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height) /* Allocate buffer to store post-processing filter coefficients. */ oci->pp_limits_buffer = vpx_memalign(16, 24 * oci->mb_cols); if (!oci->pp_limits_buffer) - { - vp8_de_alloc_frame_buffers(oci); - return 1; - } + goto allocation_fail; #endif return 0; + +allocation_fail: + vp8_de_alloc_frame_buffers(oci); + return 1; } + void vp8_setup_version(VP8_COMMON *cm) { switch (cm->version) |