Commit 14cf33e9 authored by Anton Khirnov's avatar Anton Khirnov

lcldec: return meaningful error codes.

parent 01cbc6f6
...@@ -132,7 +132,7 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i ...@@ -132,7 +132,7 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i
int zret = inflateReset(&c->zstream); int zret = inflateReset(&c->zstream);
if (zret != Z_OK) { if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret); av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
return -1; return AVERROR_UNKNOWN;
} }
c->zstream.next_in = src; c->zstream.next_in = src;
c->zstream.avail_in = src_len; c->zstream.avail_in = src_len;
...@@ -141,12 +141,12 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i ...@@ -141,12 +141,12 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i
zret = inflate(&c->zstream, Z_FINISH); zret = inflate(&c->zstream, Z_FINISH);
if (zret != Z_OK && zret != Z_STREAM_END) { if (zret != Z_OK && zret != Z_STREAM_END) {
av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret); av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);
return -1; return AVERROR_UNKNOWN;
} }
if (expected != (unsigned int)c->zstream.total_out) { if (expected != (unsigned int)c->zstream.total_out) {
av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n", av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",
expected, c->zstream.total_out); expected, c->zstream.total_out);
return -1; return AVERROR_UNKNOWN;
} }
return c->zstream.total_out; return c->zstream.total_out;
} }
...@@ -172,7 +172,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -172,7 +172,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
unsigned int height = avctx->height; // Real image height unsigned int height = avctx->height; // Real image height
unsigned int mszh_dlen; unsigned int mszh_dlen;
unsigned char yq, y1q, uq, vq; unsigned char yq, y1q, uq, vq;
int uqvq; int uqvq, ret;
unsigned int mthread_inlen, mthread_outlen; unsigned int mthread_inlen, mthread_outlen;
unsigned int len = buf_size; unsigned int len = buf_size;
...@@ -181,9 +181,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -181,9 +181,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
c->pic.reference = 0; c->pic.reference = 0;
c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; c->pic.buffer_hints = FF_BUFFER_HINTS_VALID;
if(ff_get_buffer(avctx, &c->pic) < 0){ if ((ret = ff_get_buffer(avctx, &c->pic)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1; return ret;
} }
outptr = c->pic.data[0]; // Output image pointer outptr = c->pic.data[0]; // Output image pointer
...@@ -202,14 +202,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -202,14 +202,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
if (mthread_outlen != mszh_dlen) { if (mthread_outlen != mszh_dlen) {
av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n", av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
mthread_outlen, mszh_dlen); mthread_outlen, mszh_dlen);
return -1; return AVERROR_INVALIDDATA;
} }
mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - 8 - mthread_inlen, mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - 8 - mthread_inlen,
c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen); c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen);
if (mthread_outlen != mszh_dlen) { if (mthread_outlen != mszh_dlen) {
av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n", av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n",
mthread_outlen, mszh_dlen); mthread_outlen, mszh_dlen);
return -1; return AVERROR_INVALIDDATA;
} }
encoded = c->decomp_buf; encoded = c->decomp_buf;
len = c->decomp_size; len = c->decomp_size;
...@@ -218,7 +218,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -218,7 +218,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
if (c->decomp_size != mszh_dlen) { if (c->decomp_size != mszh_dlen) {
av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n", av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n",
c->decomp_size, mszh_dlen); c->decomp_size, mszh_dlen);
return -1; return AVERROR_INVALIDDATA;
} }
encoded = c->decomp_buf; encoded = c->decomp_buf;
len = mszh_dlen; len = mszh_dlen;
...@@ -249,7 +249,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -249,7 +249,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
} }
default: default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n"); av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n");
return -1; return AVERROR_INVALIDDATA;
} }
break; break;
#if CONFIG_ZLIB_DECODER #if CONFIG_ZLIB_DECODER
...@@ -266,7 +266,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -266,7 +266,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
break; break;
} }
} else if (c->flags & FLAG_MULTITHREAD) { } else if (c->flags & FLAG_MULTITHREAD) {
int ret;
mthread_inlen = AV_RL32(encoded); mthread_inlen = AV_RL32(encoded);
mthread_inlen = FFMIN(mthread_inlen, len - 8); mthread_inlen = FFMIN(mthread_inlen, len - 8);
mthread_outlen = AV_RL32(encoded+4); mthread_outlen = AV_RL32(encoded+4);
...@@ -286,7 +285,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -286,7 +285,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
#endif #endif
default: default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n"); av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n");
return -1; return AVERROR_INVALIDDATA;
} }
...@@ -370,7 +369,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -370,7 +369,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
break; break;
default: default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n"); av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n");
return -1; return AVERROR_INVALIDDATA;
} }
} }
...@@ -458,7 +457,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac ...@@ -458,7 +457,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
break; break;
default: default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n"); av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n");
return -1; return AVERROR_INVALIDDATA;
} }
*got_frame = 1; *got_frame = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment