summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-01-14 15:04:58 +0100
committerMichael Niedermayer <michaelni@gmx.at>2013-01-14 15:04:58 +0100
commit8943925d1f68316218a9722c3f275ae1ae29b325 (patch)
tree455f017242d1ab01e0eb2e4ae981b79e986e2015 /libavcodec
parent329675cfd71fab29e47ea9c64f3560f0305dbf36 (diff)
parent688b132b881d423877e38dc82f17e23a604be676 (diff)
Merge commit '688b132b881d423877e38dc82f17e23a604be676'
* commit '688b132b881d423877e38dc82f17e23a604be676': qdrw: return meaningful error codes. qtrle: return a meaningful error code. gifdec: return meaningful error codes. interplayvideo: remove a static variable. interplayvideo: return meaningful error codes. lcldec: return meaningful error codes. targa: return meaningful error codes. qpeg: return a meaningful error code. nuv: return meaningful error codes. Conflicts: libavcodec/gifdec.c libavcodec/interplayvideo.c libavcodec/nuv.c libavcodec/qpeg.c libavcodec/targa.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/gifdec.c3
-rw-r--r--libavcodec/interplayvideo.c15
-rw-r--r--libavcodec/lcldec.c27
-rw-r--r--libavcodec/nuv.c32
-rw-r--r--libavcodec/qdrw.c8
-rw-r--r--libavcodec/qpeg.c6
-rw-r--r--libavcodec/qtrle.c5
-rw-r--r--libavcodec/targa.c3
8 files changed, 51 insertions, 48 deletions
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index e5e84aea12..b0254decd1 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -410,10 +410,11 @@ static int gif_read_header1(GifState *s)
static int gif_parse_next_image(GifState *s, int *got_picture)
{
- int ret;
+
*got_picture = 1;
while (bytestream2_get_bytes_left(&s->gb)) {
int code = bytestream2_get_byte(&s->gb);
+ int ret;
av_dlog(s->avctx, "code=%02x '%c'\n", code, code);
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index f1a2a3856a..3285578a70 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -74,11 +74,11 @@ static int copy_from(IpvideoContext *s, AVFrame *src, int delta_x, int delta_y)
+ delta_x * (1 + s->is_16bpp);
if (motion_offset < 0) {
av_log(s->avctx, AV_LOG_ERROR, "motion offset < 0 (%d)\n", motion_offset);
- return -1;
+ return AVERROR_INVALIDDATA;
} else if (motion_offset > s->upper_motion_limit_offset) {
av_log(s->avctx, AV_LOG_ERROR, "motion offset above limit (%d >= %d)\n",
motion_offset, s->upper_motion_limit_offset);
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (src->data[0] == NULL) {
av_log(s->avctx, AV_LOG_ERROR, "Invalid decode type, corrupted header?\n");
@@ -882,12 +882,8 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
int x, y;
unsigned char opcode;
int ret;
- static int frame = 0;
GetBitContext gb;
- av_dlog(s->avctx, "frame %d\n", frame);
- frame++;
-
bytestream2_skip(&s->stream_ptr, 14); /* data starts 14 bytes in */
if (!s->is_16bpp) {
/* this is PAL8, so make the palette available */
@@ -923,7 +919,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
}
if (ret != 0) {
av_log(s->avctx, AV_LOG_ERROR, "decode problem on frame %d, @ block (%d, %d)\n",
- frame, x, y);
+ s->avctx->frame_number, x, y);
return;
}
}
@@ -963,6 +959,7 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
IpvideoContext *s = avctx->priv_data;
+ int ret;
/* decoding map contains 4 bits of information per 8x8 block */
s->decoding_map_size = avctx->width * avctx->height / (8 * 8 * 2);
@@ -977,9 +974,9 @@ static int ipvideo_decode_frame(AVCodecContext *avctx,
buf_size - s->decoding_map_size);
s->current_frame.reference = 3;
- if (ff_get_buffer(avctx, &s->current_frame)) {
+ if ((ret = ff_get_buffer(avctx, &s->current_frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ return ret;
}
if (!s->is_16bpp) {
diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c
index 5708a12d3d..159e0a1401 100644
--- a/libavcodec/lcldec.c
+++ b/libavcodec/lcldec.c
@@ -138,7 +138,7 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i
int zret = inflateReset(&c->zstream);
if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
- return -1;
+ return AVERROR_UNKNOWN;
}
c->zstream.next_in = (uint8_t *)src;
c->zstream.avail_in = src_len;
@@ -147,12 +147,12 @@ static int zlib_decomp(AVCodecContext *avctx, const uint8_t *src, int src_len, i
zret = inflate(&c->zstream, Z_FINISH);
if (zret != Z_OK && zret != Z_STREAM_END) {
av_log(avctx, AV_LOG_ERROR, "Inflate error: %d\n", zret);
- return -1;
+ return AVERROR_UNKNOWN;
}
if (expected != (unsigned int)c->zstream.total_out) {
av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %lu)\n",
expected, c->zstream.total_out);
- return -1;
+ return AVERROR_UNKNOWN;
}
return c->zstream.total_out;
}
@@ -178,7 +178,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
unsigned int height = avctx->height; // Real image height
unsigned int mszh_dlen;
unsigned char yq, y1q, uq, vq;
- int uqvq;
+ int uqvq, ret;
unsigned int mthread_inlen, mthread_outlen;
unsigned int len = buf_size;
@@ -187,9 +187,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
c->pic.reference = 0;
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");
- return -1;
+ return ret;
}
outptr = c->pic.data[0]; // Output image pointer
@@ -210,14 +210,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
if (mthread_outlen != mszh_dlen) {
av_log(avctx, AV_LOG_ERROR, "Mthread1 decoded size differs (%d != %d)\n",
mthread_outlen, mszh_dlen);
- return -1;
+ return AVERROR_INVALIDDATA;
}
mszh_dlen = mszh_decomp(encoded + 8 + mthread_inlen, len - 8 - mthread_inlen,
c->decomp_buf + mthread_outlen, c->decomp_size - mthread_outlen);
if (mthread_outlen != mszh_dlen) {
av_log(avctx, AV_LOG_ERROR, "Mthread2 decoded size differs (%d != %d)\n",
mthread_outlen, mszh_dlen);
- return -1;
+ return AVERROR_INVALIDDATA;
}
encoded = c->decomp_buf;
len = c->decomp_size;
@@ -226,7 +226,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
if (c->decomp_size != mszh_dlen) {
av_log(avctx, AV_LOG_ERROR, "Decoded size differs (%d != %d)\n",
c->decomp_size, mszh_dlen);
- return -1;
+ return AVERROR_INVALIDDATA;
}
encoded = c->decomp_buf;
len = mszh_dlen;
@@ -257,7 +257,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
}
default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown MSZH compression in frame decoder.\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
break;
#if CONFIG_ZLIB_DECODER
@@ -274,7 +274,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
break;
}
} else if (c->flags & FLAG_MULTITHREAD) {
- int ret;
mthread_inlen = AV_RL32(encoded);
mthread_inlen = FFMIN(mthread_inlen, len - 8);
mthread_outlen = AV_RL32(encoded+4);
@@ -294,7 +293,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
#endif
default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown codec in frame decoder compression switch.\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
@@ -378,7 +377,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
break;
default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in pngfilter switch.\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
}
@@ -466,7 +465,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac
break;
default:
av_log(avctx, AV_LOG_ERROR, "BUG! Unknown imagetype in image decoder.\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
*got_frame = 1;
diff --git a/libavcodec/nuv.c b/libavcodec/nuv.c
index ff11d007c4..10dce6a549 100644
--- a/libavcodec/nuv.c
+++ b/libavcodec/nuv.c
@@ -88,7 +88,7 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c, const uint8_t *buf,
int i;
if (size < 2 * 64 * 4) {
av_log(avctx, AV_LOG_ERROR, "insufficient rtjpeg quant data\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
for (i = 0; i < 64; i++, buf += 4)
c->lq[i] = AV_RL32(buf);
@@ -114,6 +114,8 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
int quality)
{
NuvContext *c = avctx->priv_data;
+ int ret;
+
width = FFALIGN(width, 2);
height = FFALIGN(height, 2);
if (quality >= 0)
@@ -121,9 +123,10 @@ static int codec_reinit(AVCodecContext *avctx, int width, int height,
if (width != c->width || height != c->height) {
// also reserve space for a possible additional header
int buf_size = 24 + height * width * 3 / 2 + AV_LZO_OUTPUT_PADDING;
- if (av_image_check_size(height, width, 0, avctx) < 0 ||
- buf_size > INT_MAX/8)
+ if (buf_size > INT_MAX/8)
return -1;
+ if ((ret = av_image_check_size(height, width, 0, avctx)) < 0)
+ return ret;
avctx->width = c->width = width;
avctx->height = c->height = height;
av_fast_malloc(&c->decomp_buf, &c->decomp_size,
@@ -165,7 +168,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (buf_size < 12) {
av_log(avctx, AV_LOG_ERROR, "coded frame too small\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
// codec data (rtjpeg quant tables)
@@ -184,7 +187,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (buf_size < 12 || buf[0] != 'V') {
av_log(avctx, AV_LOG_ERROR, "not a nuv video frame\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
comptype = buf[1];
switch (comptype) {
@@ -227,16 +230,15 @@ retry:
w = AV_RL16(&buf[6]);
h = AV_RL16(&buf[8]);
q = buf[10];
- res = codec_reinit(avctx, w, h, q);
- if (res < 0)
- return res;
- if (res) {
+ if ((result = codec_reinit(avctx, w, h, q)) < 0)
+ return result;
+ if (result) {
buf = avpkt->data;
buf_size = avpkt->size;
size_change = 1;
goto retry;
}
- buf = &buf[RTJPEG_HEADER_SIZE];
+ buf = &buf[RTJPEG_HEADER_SIZE];
buf_size -= RTJPEG_HEADER_SIZE;
}
@@ -248,7 +250,7 @@ retry:
result = avctx->reget_buffer(avctx, &c->pic);
if (result < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ return result;
}
c->pic.pict_type = keyframe ? AV_PICTURE_TYPE_I : AV_PICTURE_TYPE_P;
@@ -280,7 +282,7 @@ retry:
break;
default:
av_log(avctx, AV_LOG_ERROR, "unknown compression\n");
- return -1;
+ return AVERROR_INVALIDDATA;
}
*picture = c->pic;
@@ -291,6 +293,8 @@ retry:
static av_cold int decode_init(AVCodecContext *avctx)
{
NuvContext *c = avctx->priv_data;
+ int ret;
+
avctx->pix_fmt = AV_PIX_FMT_YUV420P;
c->pic.data[0] = NULL;
c->decomp_buf = NULL;
@@ -305,8 +309,8 @@ static av_cold int decode_init(AVCodecContext *avctx)
ff_dsputil_init(&c->dsp, avctx);
- if (codec_reinit(avctx, avctx->width, avctx->height, -1) < 0)
- return 1;
+ if ((ret = codec_reinit(avctx, avctx->width, avctx->height, -1)) < 0)
+ return ret;
return 0;
}
diff --git a/libavcodec/qdrw.c b/libavcodec/qdrw.c
index 2be6e04b64..71fe48aea6 100644
--- a/libavcodec/qdrw.c
+++ b/libavcodec/qdrw.c
@@ -45,7 +45,7 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * const p = &a->pic;
uint8_t* outdata;
int colors;
- int i;
+ int i, ret;
uint32_t *pal;
int r, g, b;
@@ -53,9 +53,9 @@ static int decode_frame(AVCodecContext *avctx,
avctx->release_buffer(avctx, p);
p->reference= 0;
- if(ff_get_buffer(avctx, p) < 0){
+ if ((ret = ff_get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ return ret;
}
p->pict_type= AV_PICTURE_TYPE_I;
p->key_frame= 1;
@@ -70,7 +70,7 @@ static int decode_frame(AVCodecContext *avctx,
if(colors < 0 || colors > 256) {
av_log(avctx, AV_LOG_ERROR, "Error color count - %i(0x%X)\n", colors, colors);
- return -1;
+ return AVERROR_INVALIDDATA;
}
if (buf_end - buf < (colors + 1) * 8)
return AVERROR_INVALIDDATA;
diff --git a/libavcodec/qpeg.c b/libavcodec/qpeg.c
index 105ac69600..73d652e5d8 100644
--- a/libavcodec/qpeg.c
+++ b/libavcodec/qpeg.c
@@ -258,7 +258,7 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * p = &a->pic;
AVFrame * ref= &a->ref;
uint8_t* outdata;
- int delta;
+ int delta, ret;
const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL);
if (avpkt->size < 0x86) {
@@ -273,9 +273,9 @@ static int decode_frame(AVCodecContext *avctx,
FFSWAP(AVFrame, *ref, *p);
p->reference= 3;
- if(ff_get_buffer(avctx, p) < 0){
+ if ((ret = ff_get_buffer(avctx, p)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
+ return ret;
}
outdata = a->pic.data[0];
bytestream2_skip(&a->buffer, 4);
diff --git a/libavcodec/qtrle.c b/libavcodec/qtrle.c
index 41fda4b3b6..5acd2eb3ae 100644
--- a/libavcodec/qtrle.c
+++ b/libavcodec/qtrle.c
@@ -407,14 +407,15 @@ static int qtrle_decode_frame(AVCodecContext *avctx,
int header, start_line;
int height, row_ptr;
int has_palette = 0;
+ int ret;
bytestream2_init(&s->g, avpkt->data, avpkt->size);
s->frame.reference = 3;
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE;
- if (avctx->reget_buffer(avctx, &s->frame)) {
+ if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) {
av_log (s->avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
- return -1;
+ return ret;
}
/* check if this frame is even supposed to change */
diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 18ad21d036..11a8f213fd 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -178,7 +178,7 @@ static int decode_frame(AVCodecContext *avctx,
return AVERROR_INVALIDDATA;
}
- if ((ret = av_image_check_size(w, h, 0, avctx)))
+ if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
return ret;
if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h);
@@ -200,6 +200,7 @@ static int decode_frame(AVCodecContext *avctx,
if (colors) {
int pal_size, pal_sample_size;
+
switch (csize) {
case 32: pal_sample_size = 4; break;
case 24: pal_sample_size = 3; break;