From 380242ca50242c3f5db6471e636274d6c0b93a71 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 16 Nov 2012 11:45:34 +0100 Subject: [PATCH 1/7] pnm: return meaningful error codes. --- libavcodec/pnm.c | 22 +++++++++++----------- libavcodec/pnmdec.c | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c index 2a89a723f3..5d1365090e 100644 --- a/libavcodec/pnm.c +++ b/libavcodec/pnm.c @@ -65,7 +65,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) pnm_get(s, buf1, sizeof(buf1)); s->type= buf1[1]-'0'; if(buf1[0] != 'P') - return -1; + return AVERROR_INVALIDDATA; if (s->type==1 || s->type==4) { avctx->pix_fmt = AV_PIX_FMT_MONOWHITE; @@ -103,12 +103,12 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) } else if (!strcmp(buf1, "ENDHDR")) { break; } else { - return -1; + return AVERROR_INVALIDDATA; } } /* check that all tags are present */ if (w <= 0 || h <= 0 || maxval <= 0 || depth <= 0 || tuple_type[0] == '\0' || av_image_check_size(w, h, 0, avctx)) - return -1; + return AVERROR_INVALIDDATA; avctx->width = w; avctx->height = h; @@ -123,25 +123,25 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) } else { av_log(avctx, AV_LOG_ERROR, "16-bit components are only supported for grayscale\n"); avctx->pix_fmt = AV_PIX_FMT_NONE; - return -1; + return AVERROR_INVALIDDATA; } } else if (depth == 4) { avctx->pix_fmt = AV_PIX_FMT_RGB32; } else { - return -1; + return AVERROR_INVALIDDATA; } return 0; } else { - return -1; + return AVERROR_INVALIDDATA; } pnm_get(s, buf1, sizeof(buf1)); avctx->width = atoi(buf1); if (avctx->width <= 0) - return -1; + return AVERROR_INVALIDDATA; pnm_get(s, buf1, sizeof(buf1)); avctx->height = atoi(buf1); if(av_image_check_size(avctx->width, avctx->height, 0, avctx)) - return -1; + return AVERROR_INVALIDDATA; if (avctx->pix_fmt != AV_PIX_FMT_MONOWHITE) { pnm_get(s, buf1, sizeof(buf1)); s->maxval = atoi(buf1); @@ -160,7 +160,7 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) } else { av_log(avctx, AV_LOG_ERROR, "Unsupported pixel format\n"); avctx->pix_fmt = AV_PIX_FMT_NONE; - return -1; + return AVERROR_INVALIDDATA; } } }else @@ -168,10 +168,10 @@ int ff_pnm_decode_header(AVCodecContext *avctx, PNMContext * const s) /* more check if YUV420 */ if (avctx->pix_fmt == AV_PIX_FMT_YUV420P) { if ((avctx->width & 1) != 0) - return -1; + return AVERROR_INVALIDDATA; h = (avctx->height * 2); if ((h % 3) != 0) - return -1; + return AVERROR_INVALIDDATA; h /= 3; avctx->height = h; } diff --git a/libavcodec/pnmdec.c b/libavcodec/pnmdec.c index b4b042cdf8..b9897b9c1a 100644 --- a/libavcodec/pnmdec.c +++ b/libavcodec/pnmdec.c @@ -36,29 +36,29 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, AVFrame * const p = &s->picture; int i, j, n, linesize, h, upgrade = 0; unsigned char *ptr; - int components, sample_len; + int components, sample_len, ret; s->bytestream_start = s->bytestream = buf; s->bytestream_end = buf + buf_size; - if (ff_pnm_decode_header(avctx, s) < 0) - return -1; + if ((ret = ff_pnm_decode_header(avctx, s)) < 0) + return ret; if (p->data[0]) 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; switch (avctx->pix_fmt) { default: - return -1; + return AVERROR(EINVAL); case AV_PIX_FMT_RGB48BE: n = avctx->width * 6; components=3; @@ -93,7 +93,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, ptr = p->data[0]; linesize = p->linesize[0]; if (s->bytestream + n * avctx->height > s->bytestream_end) - return -1; + return AVERROR_INVALIDDATA; if(s->type < 4){ for (i=0; iheight; i++) { PutBitContext pb; @@ -104,7 +104,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, while(s->bytestream < s->bytestream_end && (*s->bytestream < '0' || *s->bytestream > '9' )) s->bytestream++; if(s->bytestream >= s->bytestream_end) - return -1; + return AVERROR_INVALIDDATA; do{ v= 10*v + c; c= (*s->bytestream++) - '0'; @@ -142,7 +142,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, ptr = p->data[0]; linesize = p->linesize[0]; if (s->bytestream + n * avctx->height * 3 / 2 > s->bytestream_end) - return -1; + return AVERROR_INVALIDDATA; for (i = 0; i < avctx->height; i++) { memcpy(ptr, s->bytestream, n); s->bytestream += n; @@ -166,7 +166,7 @@ static int pnm_decode_frame(AVCodecContext *avctx, void *data, ptr = p->data[0]; linesize = p->linesize[0]; if (s->bytestream + avctx->width * avctx->height * 4 > s->bytestream_end) - return -1; + return AVERROR_INVALIDDATA; for (i = 0; i < avctx->height; i++) { int j, r, g, b, a; From b61e0b99dfac9fdd4fdec305f4c60181184af1d6 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 16 Nov 2012 15:25:32 +0100 Subject: [PATCH 2/7] truemotion1: return meaningful error codes --- libavcodec/truemotion1.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/libavcodec/truemotion1.c b/libavcodec/truemotion1.c index c49f9fecbf..232ee2c2b8 100644 --- a/libavcodec/truemotion1.c +++ b/libavcodec/truemotion1.c @@ -308,7 +308,7 @@ static void gen_vector_table24(TrueMotion1Context *s, const uint8_t *sel_vector_ * there was an error while decoding the header */ static int truemotion1_decode_header(TrueMotion1Context *s) { - int i; + int i, ret; int width_shift = 0; int new_pix_fmt; struct frame_header header; @@ -319,7 +319,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) if (s->buf[0] < 0x10) { av_log(s->avctx, AV_LOG_ERROR, "invalid header size (%d)\n", s->buf[0]); - return -1; + return AVERROR_INVALIDDATA; } /* unscramble the header bytes with a XOR operation */ @@ -343,7 +343,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) if (header.header_type > 3) { av_log(s->avctx, AV_LOG_ERROR, "invalid header type (%d)\n", header.header_type); - return -1; + return AVERROR_INVALIDDATA; } else if ((header.header_type == 2) || (header.header_type == 3)) { s->flags = header.flags; if (!(s->flags & FLAG_INTERFRAME)) @@ -371,7 +371,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) if (header.compression >= 17) { av_log(s->avctx, AV_LOG_ERROR, "invalid compression type (%d)\n", header.compression); - return -1; + return AVERROR_INVALIDDATA; } if ((header.deltaset != s->last_deltaset) || @@ -385,7 +385,7 @@ static int truemotion1_decode_header(TrueMotion1Context *s) sel_vector_table = tables[header.vectable - 1]; else { av_log(s->avctx, AV_LOG_ERROR, "invalid vector table id (%d)\n", header.vectable); - return -1; + return AVERROR_INVALIDDATA; } } @@ -396,8 +396,8 @@ static int truemotion1_decode_header(TrueMotion1Context *s) new_pix_fmt = AV_PIX_FMT_RGB555; // RGB565 is supported as well s->w >>= width_shift; - if (av_image_check_size(s->w, s->h, 0, s->avctx) < 0) - return -1; + if ((ret = av_image_check_size(s->w, s->h, 0, s->avctx)) < 0) + return ret; if (s->w != s->avctx->width || s->h != s->avctx->height || new_pix_fmt != s->avctx->pix_fmt) { @@ -843,21 +843,21 @@ static int truemotion1_decode_frame(AVCodecContext *avctx, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; + int ret, buf_size = avpkt->size; TrueMotion1Context *s = avctx->priv_data; s->buf = buf; s->size = buf_size; - if (truemotion1_decode_header(s) == -1) - return -1; + if ((ret = truemotion1_decode_header(s)) < 0) + return ret; s->frame.reference = 1; s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, &s->frame) < 0) { + if ((ret = avctx->reget_buffer(avctx, &s->frame)) < 0) { av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - return -1; + return ret; } if (compression_types[s->compression].algorithm == ALGO_RGB24H) { From 0c19b23bd5530feca67f3643a3ac4c4ea7b64ec2 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 16 Nov 2012 18:24:55 +0100 Subject: [PATCH 3/7] dpx: return meaningful error codes. --- libavcodec/dpx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/libavcodec/dpx.c b/libavcodec/dpx.c index 7c01babb74..0ad17203a0 100644 --- a/libavcodec/dpx.c +++ b/libavcodec/dpx.c @@ -65,7 +65,7 @@ static int decode_frame(AVCodecContext *avctx, unsigned int offset; int magic_num, endian; - int x, y; + int x, y, ret; int w, h, stride, bits_per_color, descriptor, elements, target_packet_size, source_packet_size; unsigned int rgbBuffer; @@ -86,7 +86,7 @@ static int decode_frame(AVCodecContext *avctx, endian = 1; } else { av_log(avctx, AV_LOG_ERROR, "DPX marker not found\n"); - return -1; + return AVERROR_INVALIDDATA; } offset = read32(&buf, endian); @@ -121,7 +121,7 @@ static int decode_frame(AVCodecContext *avctx, break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported descriptor %d\n", descriptor); - return -1; + return AVERROR_INVALIDDATA; } switch (bits_per_color) { @@ -151,18 +151,18 @@ static int decode_frame(AVCodecContext *avctx, break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported color depth : %d\n", bits_per_color); - return -1; + return AVERROR_INVALIDDATA; } if (s->picture.data[0]) avctx->release_buffer(avctx, &s->picture); - if (av_image_check_size(w, h, 0, avctx)) - return -1; + 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); - 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; } // Move pointer to offset from start of file @@ -173,7 +173,7 @@ static int decode_frame(AVCodecContext *avctx, if (source_packet_size*avctx->width*avctx->height > buf_end - buf) { av_log(avctx, AV_LOG_ERROR, "Overread buffer. Invalid header?\n"); - return -1; + return AVERROR_INVALIDDATA; } switch (bits_per_color) { case 10: From f3fcb1a7b26a88a707e8853c65f3adeb0a291564 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 16 Nov 2012 18:35:31 +0100 Subject: [PATCH 4/7] wnv1: return meaningful error codes. --- libavcodec/wnv1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/wnv1.c b/libavcodec/wnv1.c index 1636f16510..0e727db418 100644 --- a/libavcodec/wnv1.c +++ b/libavcodec/wnv1.c @@ -67,24 +67,24 @@ static int decode_frame(AVCodecContext *avctx, int buf_size = avpkt->size; AVFrame * const p = &l->pic; unsigned char *Y,*U,*V; - int i, j; + int i, j, ret; int prev_y = 0, prev_u = 0, prev_v = 0; uint8_t *rbuf; rbuf = av_malloc(buf_size + FF_INPUT_BUFFER_PADDING_SIZE); if (!rbuf) { av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer\n"); - return -1; + return AVERROR(ENOMEM); } if (p->data[0]) 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"); av_free(rbuf); - return -1; + return ret; } p->key_frame = 1; From e1a7061d63312d44d489995398683583f1bb10da Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 16 Nov 2012 22:36:10 +0100 Subject: [PATCH 5/7] kmvc: return meaningful error codes. --- libavcodec/kmvc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libavcodec/kmvc.c b/libavcodec/kmvc.c index d9fbbb0d71..3ed01ad0e1 100644 --- a/libavcodec/kmvc.c +++ b/libavcodec/kmvc.c @@ -248,7 +248,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame, { KmvcContext *const ctx = avctx->priv_data; uint8_t *out, *src; - int i; + int i, ret; int header; int blocksize; const uint8_t *pal = av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL); @@ -259,9 +259,9 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame, ctx->pic.reference = 1; ctx->pic.buffer_hints = FF_BUFFER_HINTS_VALID; - if (ff_get_buffer(avctx, &ctx->pic) < 0) { + if ((ret = ff_get_buffer(avctx, &ctx->pic)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - return -1; + return ret; } header = bytestream2_get_byte(&ctx->g); @@ -309,7 +309,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame, if (blocksize != 8 && blocksize != 127) { av_log(avctx, AV_LOG_ERROR, "Block size = %i\n", blocksize); - return -1; + return AVERROR_INVALIDDATA; } memset(ctx->cur, 0, 320 * 200); switch (header & KMVC_METHOD) { @@ -325,7 +325,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame, break; default: av_log(avctx, AV_LOG_ERROR, "Unknown compression method %i\n", header & KMVC_METHOD); - return -1; + return AVERROR_INVALIDDATA; } out = ctx->pic.data[0]; @@ -366,7 +366,7 @@ static av_cold int decode_init(AVCodecContext * avctx) if (avctx->width > 320 || avctx->height > 200) { av_log(avctx, AV_LOG_ERROR, "KMVC supports frames <= 320x200\n"); - return -1; + return AVERROR(EINVAL); } c->frm0 = av_mallocz(320 * 200); From 405486c28bb4d953aa585be0f3742df984c16cb5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 16 Nov 2012 22:40:36 +0100 Subject: [PATCH 6/7] kgv1dec: return meaningful error codes. --- libavcodec/kgv1dec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/kgv1dec.c b/libavcodec/kgv1dec.c index fc99b21a58..01655a54b8 100644 --- a/libavcodec/kgv1dec.c +++ b/libavcodec/kgv1dec.c @@ -55,14 +55,14 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, int w, h, i, res; if (avpkt->size < 2) - return -1; + return AVERROR_INVALIDDATA; w = (buf[0] + 1) * 8; h = (buf[1] + 1) * 8; buf += 2; - if (av_image_check_size(w, h, 0, avctx)) - return -1; + if ((res = av_image_check_size(w, h, 0, avctx)) < 0) + return res; if (w != avctx->width || h != avctx->height) { if (c->prev.data[0]) From 57d11e5e28bfe0bc445ad78fc033aafa73068bb4 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 06:57:27 +0100 Subject: [PATCH 7/7] fraps: return meaningful error codes. --- libavcodec/fraps.c | 58 +++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c index ba2f32af2a..56153d1e54 100644 --- a/libavcodec/fraps.c +++ b/libavcodec/fraps.c @@ -87,7 +87,7 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w, int h, const uint8_t *src, int size, int Uoff, const int step) { - int i, j; + int i, j, ret; GetBitContext gb; VLC vlc; Node nodes[512]; @@ -95,9 +95,9 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w, for(i = 0; i < 256; i++) nodes[i].count = bytestream_get_le32(&src); size -= 1024; - if (ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp, - FF_HUFFMAN_FLAG_ZERO_COUNT) < 0) - return -1; + if ((ret = ff_huff_build_tree(s->avctx, &vlc, 256, nodes, huff_cmp, + FF_HUFFMAN_FLAG_ZERO_COUNT)) < 0) + return ret; /* we have built Huffman table and are ready to decode plane */ /* convert bits so they may be used by standard bitreader */ @@ -138,7 +138,7 @@ static int decode_frame(AVCodecContext *avctx, const uint32_t *buf32; uint32_t *luma1,*luma2,*cb,*cr; uint32_t offs[4]; - int i, j, is_chroma, planes; + int i, j, ret, is_chroma, planes; enum AVPixelFormat pix_fmt; header = AV_RL32(buf); @@ -149,7 +149,7 @@ static int decode_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "This file is encoded with Fraps version %d. " \ "This codec can only decode versions <= 5.\n", version); - return -1; + return AVERROR_PATCHWELCOME; } buf+=4; @@ -171,22 +171,22 @@ static int decode_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "Invalid frame length %d (should be %d)\n", buf_size, avctx->width*avctx->height*3/2+header_size); - return -1; + return AVERROR_INVALIDDATA; } if (( (avctx->width % 8) != 0) || ( (avctx->height % 2) != 0 )) { av_log(avctx, AV_LOG_ERROR, "Invalid frame size %dx%d\n", avctx->width, avctx->height); - return -1; + return AVERROR_INVALIDDATA; } f->reference = 1; f->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, f)) { + if ((ret = avctx->reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } /* bit 31 means same as previous pic */ f->pict_type = (header & (1U<<31))? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; @@ -218,16 +218,16 @@ static int decode_frame(AVCodecContext *avctx, av_log(avctx, AV_LOG_ERROR, "Invalid frame length %d (should be %d)\n", buf_size, avctx->width*avctx->height*3+header_size); - return -1; + return AVERROR_INVALIDDATA; } f->reference = 1; f->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, f)) { + if ((ret = avctx->reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } /* bit 31 means same as previous pic */ f->pict_type = (header & (1U<<31))? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I; @@ -252,9 +252,9 @@ static int decode_frame(AVCodecContext *avctx, f->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, f)) { + if ((ret = avctx->reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } /* skip frame */ if(buf_size == 8) { @@ -266,13 +266,13 @@ static int decode_frame(AVCodecContext *avctx, f->key_frame = 1; if ((AV_RL32(buf) != FPS_TAG)||(buf_size < (planes*1024 + 24))) { av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n"); - return -1; + return AVERROR_INVALIDDATA; } for(i = 0; i < planes; i++) { offs[i] = AV_RL32(buf + 4 + i * 4); if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) { av_log(avctx, AV_LOG_ERROR, "Fraps: plane %i offset is out of bounds\n", i); - return -1; + return AVERROR_INVALIDDATA; } } offs[planes] = buf_size; @@ -282,10 +282,13 @@ static int decode_frame(AVCodecContext *avctx, offs[i + 1] - offs[i] - 1024); if (!s->tmpbuf) return AVERROR(ENOMEM); - if(fraps2_decode_plane(s, f->data[i], f->linesize[i], avctx->width >> is_chroma, - avctx->height >> is_chroma, buf + offs[i], offs[i + 1] - offs[i], is_chroma, 1) < 0) { + if ((ret = fraps2_decode_plane(s, f->data[i], f->linesize[i], + avctx->width >> is_chroma, + avctx->height >> is_chroma, + buf + offs[i], offs[i + 1] - offs[i], + is_chroma, 1)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); - return -1; + return ret; } } break; @@ -297,9 +300,9 @@ static int decode_frame(AVCodecContext *avctx, f->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; - if (avctx->reget_buffer(avctx, f)) { + if ((ret = avctx->reget_buffer(avctx, f)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } /* skip frame */ if(buf_size == 8) { @@ -311,13 +314,13 @@ static int decode_frame(AVCodecContext *avctx, f->key_frame = 1; if ((AV_RL32(buf) != FPS_TAG)||(buf_size < (planes*1024 + 24))) { av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n"); - return -1; + return AVERROR_INVALIDDATA; } for(i = 0; i < planes; i++) { offs[i] = AV_RL32(buf + 4 + i * 4); if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) { av_log(avctx, AV_LOG_ERROR, "Fraps: plane %i offset is out of bounds\n", i); - return -1; + return AVERROR_INVALIDDATA; } } offs[planes] = buf_size; @@ -326,10 +329,11 @@ static int decode_frame(AVCodecContext *avctx, offs[i + 1] - offs[i] - 1024); if (!s->tmpbuf) return AVERROR(ENOMEM); - if(fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), -f->linesize[0], - avctx->width, avctx->height, buf + offs[i], offs[i + 1] - offs[i], 0, 3) < 0) { + if ((ret = fraps2_decode_plane(s, f->data[0] + i + (f->linesize[0] * (avctx->height - 1)), + -f->linesize[0], avctx->width, avctx->height, + buf + offs[i], offs[i + 1] - offs[i], 0, 3)) < 0) { av_log(avctx, AV_LOG_ERROR, "Error decoding plane %i\n", i); - return -1; + return ret; } } // convert pseudo-YUV into real RGB