From c04c64c08ecc27a1eea55972153bcaba2bb5fe03 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 08:11:30 +0100 Subject: [PATCH 1/7] indeo2: cosmetics, reformat --- libavcodec/indeo2.c | 66 +++++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/libavcodec/indeo2.c b/libavcodec/indeo2.c index 46d582f7af..1b4d51b6b1 100644 --- a/libavcodec/indeo2.c +++ b/libavcodec/indeo2.c @@ -47,8 +47,8 @@ static inline int ir2_get_code(GetBitContext *gb) return get_vlc2(gb, ir2_vlc.table, CODE_VLC_BITS, 1) + 1; } -static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, - const uint8_t *table) +static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst, + int stride, const uint8_t *table) { int i; int j; @@ -56,15 +56,15 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst int c; int t; - if(width&1) + if (width & 1) return AVERROR_INVALIDDATA; /* first line contain absolute values, other lines contain deltas */ - while (out < width){ + while (out < width) { c = ir2_get_code(&ctx->gb); - if(c >= 0x80) { /* we have a run */ + if (c >= 0x80) { /* we have a run */ c -= 0x7F; - if(out + c*2 > width) + if (out + c*2 > width) return AVERROR_INVALIDDATA; for (i = 0; i < c * 2; i++) dst[out++] = 0x80; @@ -75,25 +75,25 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst } dst += stride; - for (j = 1; j < height; j++){ + for (j = 1; j < height; j++) { out = 0; - while (out < width){ + while (out < width) { c = ir2_get_code(&ctx->gb); - if(c >= 0x80) { /* we have a skip */ + if (c >= 0x80) { /* we have a skip */ c -= 0x7F; - if(out + c*2 > width) + if (out + c*2 > width) return AVERROR_INVALIDDATA; for (i = 0; i < c * 2; i++) { dst[out] = dst[out - stride]; out++; } } else { /* add two deltas from table */ - t = dst[out - stride] + (table[c * 2] - 128); - t= av_clip_uint8(t); + t = dst[out - stride] + (table[c * 2] - 128); + t = av_clip_uint8(t); dst[out] = t; out++; - t = dst[out - stride] + (table[(c * 2) + 1] - 128); - t= av_clip_uint8(t); + t = dst[out - stride] + (table[(c * 2) + 1] - 128); + t = av_clip_uint8(t); dst[out] = t; out++; } @@ -103,31 +103,31 @@ static int ir2_decode_plane(Ir2Context *ctx, int width, int height, uint8_t *dst return 0; } -static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, int stride, - const uint8_t *table) +static int ir2_decode_plane_inter(Ir2Context *ctx, int width, int height, uint8_t *dst, + int stride, const uint8_t *table) { int j; int out = 0; int c; int t; - if(width&1) + if (width & 1) return AVERROR_INVALIDDATA; - for (j = 0; j < height; j++){ + for (j = 0; j < height; j++) { out = 0; - while (out < width){ + while (out < width) { c = ir2_get_code(&ctx->gb); - if(c >= 0x80) { /* we have a skip */ - c -= 0x7F; + if (c >= 0x80) { /* we have a skip */ + c -= 0x7F; out += c * 2; } else { /* add two deltas from table */ - t = dst[out] + (((table[c * 2] - 128)*3) >> 2); - t= av_clip_uint8(t); + t = dst[out] + (((table[c * 2] - 128)*3) >> 2); + t = av_clip_uint8(t); dst[out] = t; out++; - t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); - t= av_clip_uint8(t); + t = dst[out] + (((table[(c * 2) + 1] - 128)*3) >> 2); + t = av_clip_uint8(t); dst[out] = t; out++; } @@ -141,14 +141,14 @@ static int ir2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { - const uint8_t *buf = avpkt->data; - int buf_size = avpkt->size; Ir2Context * const s = avctx->priv_data; - AVFrame *picture = data; - AVFrame * const p = &s->picture; + const uint8_t *buf = avpkt->data; + int buf_size = avpkt->size; + AVFrame *picture = data; + AVFrame * const p = &s->picture; int start, ret; - if(p->data[0]) + if (p->data[0]) avctx->release_buffer(avctx, p); p->reference = 1; @@ -212,7 +212,8 @@ static int ir2_decode_frame(AVCodecContext *avctx, return buf_size; } -static av_cold int ir2_decode_init(AVCodecContext *avctx){ +static av_cold int ir2_decode_init(AVCodecContext *avctx) +{ Ir2Context * const ic = avctx->priv_data; static VLC_TYPE vlc_tables[1 << CODE_VLC_BITS][2]; @@ -235,7 +236,8 @@ static av_cold int ir2_decode_init(AVCodecContext *avctx){ return 0; } -static av_cold int ir2_decode_end(AVCodecContext *avctx){ +static av_cold int ir2_decode_end(AVCodecContext *avctx) +{ Ir2Context * const ic = avctx->priv_data; AVFrame *pic = &ic->picture; From f0547c9bd0b1aa6fb9e0a0b52630bfdf6e8970d5 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 08:14:34 +0100 Subject: [PATCH 2/7] v210dec: return meaningful error codes --- libavcodec/v210dec.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/v210dec.c b/libavcodec/v210dec.c index 6c53e362ba..2a6aa61376 100644 --- a/libavcodec/v210dec.c +++ b/libavcodec/v210dec.c @@ -31,7 +31,7 @@ static av_cold int decode_init(AVCodecContext *avctx) { if (avctx->width & 1) { av_log(avctx, AV_LOG_ERROR, "v210 needs even width\n"); - return -1; + return AVERROR_INVALIDDATA; } avctx->pix_fmt = AV_PIX_FMT_YUV422P10; avctx->bits_per_raw_sample = 10; @@ -46,7 +46,7 @@ static av_cold int decode_init(AVCodecContext *avctx) static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt) { - int h, w; + int h, w, ret; AVFrame *pic = avctx->coded_frame; const uint8_t *psrc = avpkt->data; uint16_t *y, *u, *v; @@ -58,12 +58,12 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (avpkt->size < stride * avctx->height) { av_log(avctx, AV_LOG_ERROR, "packet too small\n"); - return -1; + return AVERROR_INVALIDDATA; } pic->reference = 0; - if (ff_get_buffer(avctx, pic) < 0) - return -1; + if ((ret = ff_get_buffer(avctx, pic)) < 0) + return ret; y = (uint16_t*)pic->data[0]; u = (uint16_t*)pic->data[1]; From edfe05ddf19bbb282ce0837e4987db8215d88541 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 09:04:48 +0100 Subject: [PATCH 3/7] mss2: return meaningful error codes. --- libavcodec/mss2.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c index 9746335132..f608652c66 100644 --- a/libavcodec/mss2.c +++ b/libavcodec/mss2.c @@ -163,7 +163,7 @@ static int decode_pal_v2(MSS12Context *ctx, const uint8_t *buf, int buf_size) ncol = *buf++; if (ncol > ctx->free_colours || buf_size < 2 + ncol * 3) - return -1; + return AVERROR_INVALIDDATA; for (i = 0; i < ncol; i++) *pal++ = AV_RB24(buf + 3 * i); @@ -189,7 +189,7 @@ static int decode_555(GetByteContext *gB, uint16_t *dst, int stride, READ_PAIR(y, endy) if (endx >= w || endy >= h || x > endx || y > endy) - return -1; + return AVERROR_INVALIDDATA; dst += x + stride * y; w = endx - x + 1; h = endy - y + 1; @@ -373,13 +373,14 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; AVFrame *f; + int ret; ff_mpeg_flush(avctx); if (s->current_picture_ptr == NULL || s->current_picture_ptr->f.data[0]) { int i = ff_find_unused_picture(s, 0); if (i < 0) - return -1; + return i; s->current_picture_ptr = &s->picture[i]; } @@ -399,10 +400,10 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size, avctx->pix_fmt = AV_PIX_FMT_YUV420P; - if (ff_MPV_frame_start(s, avctx) < 0) { + if ((ret = ff_MPV_frame_start(s, avctx)) < 0) { av_log(v->s.avctx, AV_LOG_ERROR, "ff_MPV_frame_start error\n"); avctx->pix_fmt = AV_PIX_FMT_RGB24; - return -1; + return ret; } ff_er_frame_start(s); @@ -617,7 +618,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, ctx->last_pic.linesize[0] * (avctx->height - 1); } else { av_log(avctx, AV_LOG_ERROR, "Missing keyframe\n"); - return -1; + return AVERROR_INVALIDDATA; } } else { if (ctx->last_pic.data[0]) @@ -753,6 +754,7 @@ static int mss2_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, static av_cold int wmv9_init(AVCodecContext *avctx) { VC1Context *v = avctx->priv_data; + int ret; v->s.avctx = avctx; avctx->flags |= CODEC_FLAG_EMU_EDGE; @@ -761,8 +763,8 @@ static av_cold int wmv9_init(AVCodecContext *avctx) if (avctx->idct_algo == FF_IDCT_AUTO) avctx->idct_algo = FF_IDCT_WMV2; - if (ff_vc1_init_common(v) < 0) - return -1; + if ((ret = ff_vc1_init_common(v)) < 0) + return ret; ff_vc1dsp_init(&v->vc1dsp); v->profile = PROFILE_MAIN; @@ -802,9 +804,9 @@ static av_cold int wmv9_init(AVCodecContext *avctx) ff_vc1_init_transposed_scantables(v); - if (ff_msmpeg4_decode_init(avctx) < 0 || - ff_vc1_decode_init_alloc_tables(v) < 0) - return -1; + if ((ret = ff_msmpeg4_decode_init(avctx)) < 0 || + (ret = ff_vc1_decode_init_alloc_tables(v)) < 0) + return ret; /* error concealment */ v->s.me.qpel_put = v->s.dsp.put_qpel_pixels_tab; From 26a161a1664007a794de78ef4e7e4f4b3c0b7805 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 08:35:45 +0100 Subject: [PATCH 4/7] vqavideo: return meaningful error codes. --- libavcodec/vqavideo.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c index 182f2ce997..22b024c3d6 100644 --- a/libavcodec/vqavideo.c +++ b/libavcodec/vqavideo.c @@ -122,7 +122,7 @@ typedef struct VqaContext { static av_cold int vqa_decode_init(AVCodecContext *avctx) { VqaContext *s = avctx->priv_data; - int i, j, codebook_index; + int i, j, codebook_index, ret; s->avctx = avctx; avctx->pix_fmt = AV_PIX_FMT_PAL8; @@ -130,16 +130,16 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) /* make sure the extradata made it */ if (s->avctx->extradata_size != VQA_HEADER_SIZE) { av_log(s->avctx, AV_LOG_ERROR, " VQA video: expected extradata size of %d\n", VQA_HEADER_SIZE); - return -1; + return AVERROR(EINVAL); } /* load up the VQA parameters from the header */ s->vqa_version = s->avctx->extradata[0]; s->width = AV_RL16(&s->avctx->extradata[6]); s->height = AV_RL16(&s->avctx->extradata[8]); - if(av_image_check_size(s->width, s->height, 0, avctx)){ + if ((ret = av_image_check_size(s->width, s->height, 0, avctx)) < 0) { s->width= s->height= 0; - return -1; + return ret; } s->vector_width = s->avctx->extradata[10]; s->vector_height = s->avctx->extradata[11]; @@ -149,7 +149,7 @@ static av_cold int vqa_decode_init(AVCodecContext *avctx) if ((s->vector_width != 4) || ((s->vector_height != 2) && (s->vector_height != 4))) { /* return without further initialization */ - return -1; + return AVERROR_INVALIDDATA; } if (s->width & (s->vector_width - 1) || @@ -589,9 +589,9 @@ static int vqa_decode_frame(AVCodecContext *avctx, if (s->frame.data[0]) avctx->release_buffer(avctx, &s->frame); - if (ff_get_buffer(avctx, &s->frame)) { + if ((res = ff_get_buffer(avctx, &s->frame)) < 0) { av_log(s->avctx, AV_LOG_ERROR, " VQA Video: get_buffer() failed\n"); - return -1; + return res; } bytestream2_init(&s->gb, avpkt->data, avpkt->size); From b2a7b81b9c576c470a459f0e6f8ad0351097d575 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 13:40:37 +0100 Subject: [PATCH 5/7] tiff: return meaningful error codes. --- libavcodec/tiff.c | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 8c40006aa5..dd25190ecf 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -112,7 +112,7 @@ static int tiff_uncompress(uint8_t *dst, unsigned long *len, const uint8_t *src, static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, const uint8_t *src, int size, int lines) { - int c, line, pixels, code; + int c, line, pixels, code, ret; const uint8_t *ssrc = src; int width = ((s->width * s->bpp) + 7) >> 3; @@ -134,7 +134,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, "Uncompressing failed (%lu of %lu) with error %d\n", outlen, (unsigned long)width * lines, ret); av_free(zbuf); - return -1; + return AVERROR_UNKNOWN; } src = zbuf; for (line = 0; line < lines; line++) { @@ -147,9 +147,9 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, } #endif if (s->compr == TIFF_LZW) { - if (ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF) < 0) { + if ((ret = ff_lzw_decode_init(s->lzw, 8, src, size, FF_LZW_TIFF)) < 0) { av_log(s->avctx, AV_LOG_ERROR, "Error initializing LZW decoder\n"); - return -1; + return ret; } } if (s->compr == TIFF_CCITT_RLE || s->compr == TIFF_G3 @@ -167,7 +167,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, av_log(s->avctx, AV_LOG_ERROR, "Uncompressed fax mode is not supported (yet)\n"); av_free(src2); - return -1; + return AVERROR_INVALIDDATA; } if (!s->fill_order) { memcpy(src2, src, size); @@ -190,7 +190,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, for (line = 0; line < lines; line++) { if (src - ssrc > size) { av_log(s->avctx, AV_LOG_ERROR, "Source data overread\n"); - return -1; + return AVERROR_INVALIDDATA; } switch (s->compr) { case TIFF_RAW: @@ -213,7 +213,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, if (pixels + code > width) { av_log(s->avctx, AV_LOG_ERROR, "Copy went out of bounds\n"); - return -1; + return AVERROR_INVALIDDATA; } memcpy(dst + pixels, src, code); src += code; @@ -223,7 +223,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, if (pixels + code > width) { av_log(s->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); - return -1; + return AVERROR_INVALIDDATA; } c = *src++; memset(dst + pixels, c, code); @@ -236,7 +236,7 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t *dst, int stride, if (pixels < width) { av_log(s->avctx, AV_LOG_ERROR, "Decoded only %i bytes of %i\n", pixels, width); - return -1; + return AVERROR_INVALIDDATA; } break; } @@ -308,7 +308,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *rp, *gp, *bp; if (end_buf - buf < 12) - return -1; + return AVERROR_INVALIDDATA; tag = tget_short(&buf, s->le); type = tget_short(&buf, s->le); count = tget_long(&buf, s->le); @@ -352,7 +352,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, if (buf && (buf < start || buf > end_buf)) { av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); - return -1; + return AVERROR_INVALIDDATA; } switch (tag) { @@ -368,7 +368,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count); - return -1; + return AVERROR_INVALIDDATA; } if (count == 1) s->bpp = value; @@ -418,17 +418,17 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, break; #else av_log(s->avctx, AV_LOG_ERROR, "Deflate: ZLib not compiled in\n"); - return -1; + return AVERROR(ENOSYS); #endif case TIFF_JPEG: case TIFF_NEWJPEG: av_log(s->avctx, AV_LOG_ERROR, "JPEG compression is not supported\n"); - return -1; + return AVERROR_PATCHWELCOME; default: av_log(s->avctx, AV_LOG_ERROR, "Unknown compression method %i\n", s->compr); - return -1; + return AVERROR_INVALIDDATA; } break; case TIFF_ROWSPERSTRIP: @@ -437,7 +437,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, if (value < 1) { av_log(s->avctx, AV_LOG_ERROR, "Incorrect value of rows per strip\n"); - return -1; + return AVERROR_INVALIDDATA; } s->rps = value; break; @@ -454,7 +454,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, if (s->stripdata > end_buf) { av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); - return -1; + return AVERROR_INVALIDDATA; } break; case TIFF_STRIP_SIZE: @@ -470,7 +470,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, if (s->stripsizes > end_buf) { av_log(s->avctx, AV_LOG_ERROR, "Tag referencing position outside the image\n"); - return -1; + return AVERROR_INVALIDDATA; } break; case TIFF_PREDICTOR: @@ -490,7 +490,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, default: av_log(s->avctx, AV_LOG_ERROR, "Color mode %d is not supported\n", value); - return -1; + return AVERROR_INVALIDDATA; } break; case TIFF_FILL_ORDER: @@ -505,7 +505,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, pal = (uint32_t *) s->palette; off = type_sizes[type]; if (count / 3 > 256 || end_buf - buf < count / 3 * off * 3) - return -1; + return AVERROR_INVALIDDATA; rp = buf; gp = buf + count / 3 * off; bp = buf + count / 3 * off * 2; @@ -521,7 +521,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, case TIFF_PLANAR: if (value == 2) { av_log(s->avctx, AV_LOG_ERROR, "Planar format is not supported\n"); - return -1; + return AVERROR_PATCHWELCOME; } break; case TIFF_T4OPTIONS: @@ -566,7 +566,7 @@ static int decode_frame(AVCodecContext *avctx, le = 0; else { av_log(avctx, AV_LOG_ERROR, "TIFF header not found\n"); - return -1; + return AVERROR_INVALIDDATA; } s->le = le; s->invert = 0; @@ -577,7 +577,7 @@ static int decode_frame(AVCodecContext *avctx, if (tget_short(&buf, le) != 42) { av_log(avctx, AV_LOG_ERROR, "The answer to life, universe and everything is not correct!\n"); - return -1; + return AVERROR_INVALIDDATA; } // Reset these pointers so we can tell if they were set this frame s->stripsizes = s->stripdata = NULL; @@ -590,13 +590,13 @@ static int decode_frame(AVCodecContext *avctx, buf = orig_buf + off; entries = tget_short(&buf, le); for (i = 0; i < entries; i++) { - if (tiff_decode_tag(s, orig_buf, buf, end_buf) < 0) - return -1; + if ((ret = tiff_decode_tag(s, orig_buf, buf, end_buf)) < 0) + return ret; buf += 12; } if (!s->stripdata && !s->stripoff) { av_log(avctx, AV_LOG_ERROR, "Image data is missing\n"); - return -1; + return AVERROR_INVALIDDATA; } /* now we have the data and may start decoding */ if ((ret = init_image(s)) < 0) @@ -625,7 +625,7 @@ static int decode_frame(AVCodecContext *avctx, if (soff > buf_size || ssize > buf_size - soff) { av_log(avctx, AV_LOG_ERROR, "Invalid strip size/offset\n"); - return -1; + return AVERROR_INVALIDDATA; } if (tiff_unpack_strip(s, dst, stride, orig_buf + soff, ssize, FFMIN(s->rps, s->height - i)) < 0) From a0ffcee1ee813977b6e0834c265846a092373379 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 13:46:51 +0100 Subject: [PATCH 6/7] ptx: return meaningful error codes. --- libavcodec/ptx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/ptx.c b/libavcodec/ptx.c index d4cd963e46..e8f8bdd72c 100644 --- a/libavcodec/ptx.c +++ b/libavcodec/ptx.c @@ -46,6 +46,7 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVFrame *picture = data; AVFrame * const p = &s->picture; unsigned int offset, w, h, y, stride, bytes_per_pixel; + int ret; uint8_t *ptr; if (buf_end - buf < 14) @@ -72,13 +73,13 @@ static int ptx_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if (p->data[0]) avctx->release_buffer(avctx, p); - 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; } p->pict_type = AV_PICTURE_TYPE_I; From 9dbbda235d93d628777b986e502213f1ed390973 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 17 Nov 2012 15:17:34 +0100 Subject: [PATCH 7/7] vb: return meaningful error codes. --- libavcodec/vb.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/vb.c b/libavcodec/vb.c index 1e241e7d5a..4f2b7648b8 100644 --- a/libavcodec/vb.c +++ b/libavcodec/vb.c @@ -123,7 +123,7 @@ static int vb_decode_framedata(VBDecContext *c, int offset) if(!t){ //raw block if (bytestream2_get_bytes_left(&g) < 16) { av_log(c->avctx, AV_LOG_ERROR, "Insufficient data\n"); - return -1; + return AVERROR_INVALIDDATA; } for(y = 0; y < 4; y++) bytestream2_get_buffer(&g, cur + y * width, 4); @@ -168,7 +168,7 @@ static int vb_decode_framedata(VBDecContext *c, int offset) break; case 3: av_log(c->avctx, AV_LOG_ERROR, "Invalid opcode seen @%d\n",blk); - return -1; + return AVERROR_INVALIDDATA; } break; } @@ -190,7 +190,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, { VBDecContext * const c = avctx->priv_data; uint8_t *outptr, *srcptr; - int i, j; + int i, j, ret; int flags; uint32_t size; int offset = 0; @@ -200,9 +200,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, if(c->pic.data[0]) avctx->release_buffer(avctx, &c->pic); c->pic.reference = 1; - 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; } flags = bytestream2_get_le16(&c->stream);