aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/libopenjpegdec.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-10-27 10:28:45 +0100
committerAnton Khirnov <anton@khirnov.net>2013-10-30 08:42:41 +0100
commit5c0a09839c707f10e5dba59460e219e989c1da93 (patch)
tree2c370f6a9e48bd5ac8296f41bb10c63161575aa1 /libavcodec/libopenjpegdec.c
parent8fbb0979da8e42c65a1c5de1279165f6abb2b153 (diff)
downloadffmpeg-5c0a09839c707f10e5dba59460e219e989c1da93.tar.gz
libopenjpegdec: return meaningful error codes
Diffstat (limited to 'libavcodec/libopenjpegdec.c')
-rw-r--r--libavcodec/libopenjpegdec.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libavcodec/libopenjpegdec.c b/libavcodec/libopenjpegdec.c
index ca824c659b..006270108d 100644
--- a/libavcodec/libopenjpegdec.c
+++ b/libavcodec/libopenjpegdec.c
@@ -257,7 +257,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
opj_dinfo_t *dec;
opj_cio_t *stream;
opj_image_t *image;
- int width, height, ret = -1;
+ int width, height, ret;
int pixel_size = 0;
int ispacked = 0;
int i;
@@ -279,7 +279,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
if (!dec) {
av_log(avctx, AV_LOG_ERROR, "Error initializing decoder.\n");
- return -1;
+ return AVERROR_UNKNOWN;
}
opj_set_event_mgr((opj_common_ptr)dec, NULL, NULL);
@@ -294,7 +294,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR,
"Codestream could not be opened for reading.\n");
opj_destroy_decompress(dec);
- return -1;
+ return AVERROR_UNKNOWN;
}
// Decode the header only.
@@ -304,7 +304,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
if (!image) {
av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
opj_destroy_decompress(dec);
- return -1;
+ return AVERROR_UNKNOWN;
}
width = image->x1 - image->x0;
@@ -315,7 +315,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
height = (height + (1 << ctx->lowres) - 1) >> ctx->lowres;
}
- if (av_image_check_size(width, height, 0, avctx) < 0) {
+ if ((ret = av_image_check_size(width, height, 0, avctx)) < 0) {
av_log(avctx, AV_LOG_ERROR,
"%dx%d dimension invalid.\n", width, height);
goto done;
@@ -340,7 +340,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
if (image->comps[i].prec > avctx->bits_per_raw_sample)
avctx->bits_per_raw_sample = image->comps[i].prec;
- if (ff_thread_get_buffer(avctx, &frame, 0) < 0) {
+ if ((ret = ff_thread_get_buffer(avctx, &frame, 0)) < 0) {
av_log(avctx, AV_LOG_ERROR, "ff_thread_get_buffer() failed\n");
goto done;
}
@@ -352,6 +352,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
if (!stream) {
av_log(avctx, AV_LOG_ERROR,
"Codestream could not be opened for reading.\n");
+ ret = AVERROR_UNKNOWN;
goto done;
}
@@ -362,6 +363,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
if (!image) {
av_log(avctx, AV_LOG_ERROR, "Error decoding codestream.\n");
+ ret = AVERROR_UNKNOWN;
goto done;
}
@@ -398,6 +400,7 @@ static int libopenjpeg_decode_frame(AVCodecContext *avctx,
break;
default:
av_log(avctx, AV_LOG_ERROR, "unsupported pixel size %d\n", pixel_size);
+ ret = AVERROR_PATCHWELCOME;
goto done;
}