summaryrefslogtreecommitdiff
path: root/libavcodec/libopenjpegdec.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2012-03-26 02:22:34 +0000
committerMichael Niedermayer <michaelni@gmx.at>2012-03-26 05:04:59 +0200
commit3dc0b9d6dae6c533018e1750a8dd34ca57a69e0e (patch)
tree70e23cb06d8c86cbb41e422166e5dd30da820ca7 /libavcodec/libopenjpegdec.c
parent02fb320adadacfc8446a1278582351078a024dee (diff)
libopenjpegdec: refactor some code and fix memory leaks
Signed-off-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/libopenjpegdec.c')
-rw-r--r--libavcodec/libopenjpegdec.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index fced76d47d..d6a381c76e 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -278,7 +278,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
if(ff_thread_get_buffer(avctx, picture) < 0){
av_log(avctx, AV_LOG_ERROR, "ff_thread_get_buffer() failed\n");
- return -1;
+ goto done;
}
ctx->dec_params.cp_limit_decoding = NO_LIMITATION;
@@ -288,17 +288,16 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
stream = opj_cio_open((opj_common_ptr)dec, buf, buf_size);
if(!stream) {
av_log(avctx, AV_LOG_ERROR, "Codestream could not be opened for reading.\n");
- opj_destroy_decompress(dec);
- return -1;
+ goto done;
}
+ opj_image_destroy(image);
// Decode the codestream
image = opj_decode_with_info(dec, stream, NULL);
opj_cio_close(stream);
if(!image) {
av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
- opj_destroy_decompress(dec);
- return -1;
+ goto done;
}
pixel_size = av_pix_fmt_descriptors[avctx->pix_fmt].comp[0].step_minus1 + 1;