diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-01-06 23:59:35 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-01-06 23:59:35 +0100 |
commit | 7b018e5c8d182b0272477322377b8daafa1c970f (patch) | |
tree | 8f526f00d6352279d84ff8c7bcfbb2f78f702bd1 | |
parent | 61904467458b16cf89530e2d0875f3786001dc11 (diff) | |
parent | 84f2847de394ac447f53306bd4dd73e1af6ea5e4 (diff) | |
download | ffmpeg-streaming-7b018e5c8d182b0272477322377b8daafa1c970f.zip ffmpeg-streaming-7b018e5c8d182b0272477322377b8daafa1c970f.tar.gz |
Merge commit '84f2847de394ac447f53306bd4dd73e1af6ea5e4'
* commit '84f2847de394ac447f53306bd4dd73e1af6ea5e4':
xl: return a meaningful error code.
xan: return a meaningful error code.
xxan: return meaningful error codes.
zmbv: return more meaningful error codes.
yop: use a meaningful error code.
c93: return meaningful error codes.
bmv: return meaningful error codes.
bmp: return meaningful error codes.
bink: operate with pointers to AVFrames instead of whole structs.
bink: return meaningful error codes.
bfi: return meaningful error codes.
bethsoftvideo: return meaningful error codes.
Conflicts:
libavcodec/c93.c
libavcodec/xl.c
libavcodec/xxan.c
libavcodec/yop.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/bfi.c | 12 | ||||
-rw-r--r-- | libavcodec/bink.c | 161 | ||||
-rw-r--r-- | libavcodec/bmp.c | 30 | ||||
-rw-r--r-- | libavcodec/bmv.c | 16 | ||||
-rw-r--r-- | libavcodec/c93.c | 12 | ||||
-rw-r--r-- | libavcodec/xan.c | 2 | ||||
-rw-r--r-- | libavcodec/xl.c | 2 | ||||
-rw-r--r-- | libavcodec/xxan.c | 2 | ||||
-rw-r--r-- | libavcodec/yop.c | 3 | ||||
-rw-r--r-- | libavcodec/zmbv.c | 4 |
10 files changed, 126 insertions, 118 deletions
diff --git a/libavcodec/bfi.c b/libavcodec/bfi.c index 70291b5..231ee62 100644 --- a/libavcodec/bfi.c +++ b/libavcodec/bfi.c @@ -57,16 +57,16 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data, uint8_t *src, *dst_offset, colour1, colour2; uint8_t *frame_end = bfi->dst + avctx->width * avctx->height; uint32_t *pal; - int i, j, height = avctx->height; + int i, j, ret, height = avctx->height; if (bfi->frame.data[0]) avctx->release_buffer(avctx, &bfi->frame); bfi->frame.reference = 3; - if (ff_get_buffer(avctx, &bfi->frame) < 0) { + if ((ret = ff_get_buffer(avctx, &bfi->frame)) < 0) { av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); - return -1; + return ret; } bytestream2_init(&g, avpkt->data, buf_size); @@ -78,7 +78,7 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data, /* Setting the palette */ if (avctx->extradata_size > 768) { av_log(NULL, AV_LOG_ERROR, "Palette is too large.\n"); - return -1; + return AVERROR_INVALIDDATA; } pal = (uint32_t *)bfi->frame.data[1]; for (i = 0; i < avctx->extradata_size / 3; i++) { @@ -109,7 +109,7 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data, if (!bytestream2_get_bytes_left(&g)) { av_log(avctx, AV_LOG_ERROR, "Input resolution larger than actual frame.\n"); - return -1; + return AVERROR_INVALIDDATA; } /* Get length and offset (if required) */ @@ -135,7 +135,7 @@ static int bfi_decode_frame(AVCodecContext *avctx, void *data, case 0: // normal chain if (length >= bytestream2_get_bytes_left(&g)) { av_log(avctx, AV_LOG_ERROR, "Frame larger than buffer.\n"); - return -1; + return AVERROR_INVALIDDATA; } bytestream2_get_buffer(&g, dst, length); dst += length; diff --git a/libavcodec/bink.c b/libavcodec/bink.c index 3e2bb71..2c28495 100644 --- a/libavcodec/bink.c +++ b/libavcodec/bink.c @@ -112,7 +112,7 @@ typedef struct BinkContext { AVCodecContext *avctx; DSPContext dsp; BinkDSPContext bdsp; - AVFrame pic, last; + AVFrame *pic, *last; int version; ///< internal Bink file version int has_alpha; int swap_planes; @@ -313,7 +313,7 @@ static int read_runs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b) dec_end = b->cur_dec + t; if (dec_end > b->data_end) { av_log(avctx, AV_LOG_ERROR, "Run value went out of bounds\n"); - return -1; + return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_bits(gb, 4); @@ -335,7 +335,7 @@ static int read_motion_values(AVCodecContext *avctx, GetBitContext *gb, Bundle * dec_end = b->cur_dec + t; if (dec_end > b->data_end) { av_log(avctx, AV_LOG_ERROR, "Too many motion values\n"); - return -1; + return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_bits(gb, 4); @@ -370,7 +370,7 @@ static int read_block_types(AVCodecContext *avctx, GetBitContext *gb, Bundle *b) dec_end = b->cur_dec + t; if (dec_end > b->data_end) { av_log(avctx, AV_LOG_ERROR, "Too many block type values\n"); - return -1; + return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_bits(gb, 4); @@ -386,7 +386,7 @@ static int read_block_types(AVCodecContext *avctx, GetBitContext *gb, Bundle *b) int run = bink_rlelens[v - 12]; if (dec_end - b->cur_dec < run) - return -1; + return AVERROR_INVALIDDATA; memset(b->cur_dec, last, run); b->cur_dec += run; } @@ -404,7 +404,7 @@ static int read_patterns(AVCodecContext *avctx, GetBitContext *gb, Bundle *b) dec_end = b->cur_dec + t; if (dec_end > b->data_end) { av_log(avctx, AV_LOG_ERROR, "Too many pattern values\n"); - return -1; + return AVERROR_INVALIDDATA; } while (b->cur_dec < dec_end) { v = GET_HUFF(gb, b->tree); @@ -424,7 +424,7 @@ static int read_colors(GetBitContext *gb, Bundle *b, BinkContext *c) dec_end = b->cur_dec + t; if (dec_end > b->data_end) { av_log(c->avctx, AV_LOG_ERROR, "Too many color values\n"); - return -1; + return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { c->col_lastval = GET_HUFF(gb, c->col_high[c->col_lastval]); @@ -470,13 +470,13 @@ static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b, v = (v ^ sign) - sign; } if (dst_end - dst < 1) - return -1; + return AVERROR_INVALIDDATA; *dst++ = v; len--; for (i = 0; i < len; i += 8) { len2 = FFMIN(len - i, 8); if (dst_end - dst < len2) - return -1; + return AVERROR_INVALIDDATA; bsize = get_bits(gb, 4); if (bsize) { for (j = 0; j < len2; j++) { @@ -489,7 +489,7 @@ static int read_dcs(AVCodecContext *avctx, GetBitContext *gb, Bundle *b, *dst++ = v; if (v < -32768 || v > 32767) { av_log(avctx, AV_LOG_ERROR, "DC value went out of bounds: %d\n", v); - return -1; + return AVERROR_INVALIDDATA; } } } else { @@ -545,7 +545,7 @@ static int binkb_read_bundle(BinkContext *c, GetBitContext *gb, int bundle_num) CHECK_READ_VAL(gb, b, len); if (b->data_end - b->cur_dec < len * (1 + (bits > 8))) - return -1; + return AVERROR_INVALIDDATA; if (bits <= 8) { if (!issigned) { for (i = 0; i < len; i++) @@ -798,7 +798,7 @@ static inline void put_pixels8x8_overlapped(uint8_t *dst, uint8_t *src, int stri static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, int is_key, int is_chroma) { - int blk; + int blk, ret; int i, j, bx, by; uint8_t *dst, *ref, *ref_start, *ref_end; int v, col[2]; @@ -810,24 +810,24 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, int ybias = is_key ? -15 : 0; int qp; - const int stride = c->pic.linesize[plane_idx]; + const int stride = c->pic->linesize[plane_idx]; int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3; int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3; binkb_init_bundles(c); - ref_start = c->pic.data[plane_idx]; - ref_end = c->pic.data[plane_idx] + (bh * c->pic.linesize[plane_idx] + bw) * 8; + ref_start = c->pic->data[plane_idx]; + ref_end = c->pic->data[plane_idx] + (bh * c->pic->linesize[plane_idx] + bw) * 8; for (i = 0; i < 64; i++) coordmap[i] = (i & 7) + (i >> 3) * stride; for (by = 0; by < bh; by++) { for (i = 0; i < BINKB_NB_SRC; i++) { - if (binkb_read_bundle(c, gb, i) < 0) - return -1; + if ((ret = binkb_read_bundle(c, gb, i)) < 0) + return ret; } - dst = c->pic.data[plane_idx] + 8*by*stride; + dst = c->pic->data[plane_idx] + 8*by*stride; for (bx = 0; bx < bw; bx++, dst += 8) { blk = binkb_get_value(c, BINKB_SRC_BLOCK_TYPES); switch (blk) { @@ -845,7 +845,7 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); - return -1; + return AVERROR_INVALIDDATA; } if (mode) { v = binkb_get_value(c, BINKB_SRC_COLORS); @@ -931,7 +931,7 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, break; default: av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk); - return -1; + return AVERROR_INVALIDDATA; } } } @@ -944,7 +944,7 @@ static int binkb_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, int is_chroma) { - int blk; + int blk, ret; int i, j, bx, by; uint8_t *dst, *prev, *ref, *ref_start, *ref_end; int v, col[2]; @@ -955,7 +955,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, LOCAL_ALIGNED_16(int32_t, dctblock, [64]); int coordmap[64]; - const int stride = c->pic.linesize[plane_idx]; + const int stride = c->pic->linesize[plane_idx]; int bw = is_chroma ? (c->avctx->width + 15) >> 4 : (c->avctx->width + 7) >> 3; int bh = is_chroma ? (c->avctx->height + 15) >> 4 : (c->avctx->height + 7) >> 3; int width = c->avctx->width >> is_chroma; @@ -964,39 +964,39 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, for (i = 0; i < BINK_NB_SRC; i++) read_bundle(gb, c, i); - ref_start = c->last.data[plane_idx] ? c->last.data[plane_idx] - : c->pic.data[plane_idx]; + ref_start = c->last->data[plane_idx] ? c->last->data[plane_idx] + : c->pic->data[plane_idx]; ref_end = ref_start - + (bw - 1 + c->last.linesize[plane_idx] * (bh - 1)) * 8; + + (bw - 1 + c->last->linesize[plane_idx] * (bh - 1)) * 8; for (i = 0; i < 64; i++) coordmap[i] = (i & 7) + (i >> 3) * stride; for (by = 0; by < bh; by++) { - if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES]) < 0) - return -1; - if (read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES]) < 0) - return -1; - if (read_colors(gb, &c->bundle[BINK_SRC_COLORS], c) < 0) - return -1; - if (read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN]) < 0) - return -1; - if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF]) < 0) - return -1; - if (read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF]) < 0) - return -1; - if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0) < 0) - return -1; - if (read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1) < 0) - return -1; - if (read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN]) < 0) - return -1; + if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_BLOCK_TYPES])) < 0) + return ret; + if ((ret = read_block_types(c->avctx, gb, &c->bundle[BINK_SRC_SUB_BLOCK_TYPES])) < 0) + return ret; + if ((ret = read_colors(gb, &c->bundle[BINK_SRC_COLORS], c)) < 0) + return ret; + if ((ret = read_patterns(c->avctx, gb, &c->bundle[BINK_SRC_PATTERN])) < 0) + return ret; + if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_X_OFF])) < 0) + return ret; + if ((ret = read_motion_values(c->avctx, gb, &c->bundle[BINK_SRC_Y_OFF])) < 0) + return ret; + if ((ret = read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTRA_DC], DC_START_BITS, 0)) < 0) + return ret; + if ((ret = read_dcs(c->avctx, gb, &c->bundle[BINK_SRC_INTER_DC], DC_START_BITS, 1)) < 0) + return ret; + if ((ret = read_runs(c->avctx, gb, &c->bundle[BINK_SRC_RUN])) < 0) + return ret; if (by == bh) break; - dst = c->pic.data[plane_idx] + 8*by*stride; - prev = (c->last.data[plane_idx] ? c->last.data[plane_idx] - : c->pic.data[plane_idx]) + 8*by*stride; + dst = c->pic->data[plane_idx] + 8*by*stride; + prev = (c->last->data[plane_idx] ? c->last->data[plane_idx] + : c->pic->data[plane_idx]) + 8*by*stride; for (bx = 0; bx < bw; bx++, dst += 8, prev += 8) { blk = get_value(c, BINK_SRC_BLOCK_TYPES); // 16x16 block type on odd line means part of the already decoded block, so skip it @@ -1022,7 +1022,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); - return -1; + return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_value(c, BINK_SRC_COLORS); @@ -1062,7 +1062,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, break; default: av_log(c->avctx, AV_LOG_ERROR, "Incorrect 16x16 block type %d\n", blk); - return -1; + return AVERROR_INVALIDDATA; } if (blk != FILL_BLOCK) c->bdsp.scale_block(ublock, dst, stride); @@ -1077,7 +1077,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, if (ref < ref_start || ref > ref_end) { av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", bx*8 + xoff, by*8 + yoff); - return -1; + return AVERROR_INVALIDDATA; } c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8); break; @@ -1090,7 +1090,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, i += run; if (i > 64) { av_log(c->avctx, AV_LOG_ERROR, "Run went out of bounds\n"); - return -1; + return AVERROR_INVALIDDATA; } if (get_bits1(gb)) { v = get_value(c, BINK_SRC_COLORS); @@ -1111,7 +1111,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, if (ref < ref_start || ref > ref_end) { av_log(c->avctx, AV_LOG_ERROR, "Copy out of bounds @%d, %d\n", bx*8 + xoff, by*8 + yoff); - return -1; + return AVERROR_INVALIDDATA; } c->dsp.put_pixels_tab[1][0](dst, ref, stride, 8); c->dsp.clear_block(block); @@ -1160,7 +1160,7 @@ static int bink_decode_plane(BinkContext *c, GetBitContext *gb, int plane_idx, break; default: av_log(c->avctx, AV_LOG_ERROR, "Unknown block type %d\n", blk); - return -1; + return AVERROR_INVALIDDATA; } } } @@ -1174,21 +1174,21 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac { BinkContext * const c = avctx->priv_data; GetBitContext gb; - int plane, plane_idx; + int plane, plane_idx, ret; int bits_count = pkt->size << 3; if (c->version > 'b') { - if(c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); + if(c->pic->data[0]) + avctx->release_buffer(avctx, c->pic); - 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; } } else { - if(avctx->reget_buffer(avctx, &c->pic) < 0){ + if ((ret = avctx->reget_buffer(avctx, c->pic)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); - return -1; + return ret; } } @@ -1196,8 +1196,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac if (c->has_alpha) { if (c->version >= 'i') skip_bits_long(&gb, 32); - if (bink_decode_plane(c, &gb, 3, 0) < 0) - return -1; + if ((ret = bink_decode_plane(c, &gb, 3, 0)) < 0) + return ret; } if (c->version >= 'i') skip_bits_long(&gb, 32); @@ -1206,11 +1206,11 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac plane_idx = (!plane || !c->swap_planes) ? plane : (plane ^ 3); if (c->version > 'b') { - if (bink_decode_plane(c, &gb, plane_idx, !!plane) < 0) - return -1; + if ((ret = bink_decode_plane(c, &gb, plane_idx, !!plane)) < 0) + return ret; } else { - if (binkb_decode_plane(c, &gb, plane_idx, !pkt->pts, !!plane) < 0) - return -1; + if ((ret = binkb_decode_plane(c, &gb, plane_idx, !pkt->pts, !!plane)) < 0) + return ret; } if (get_bits_count(&gb) >= bits_count) break; @@ -1218,10 +1218,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac emms_c(); *got_frame = 1; - *(AVFrame*)data = c->pic; + *(AVFrame*)data = *c->pic; if (c->version > 'b') - FFSWAP(AVFrame, c->pic, c->last); + FFSWAP(AVFrame*, c->pic, c->last); /* always report that the buffer was completely consumed */ return pkt->size; @@ -1264,13 +1264,13 @@ static av_cold int decode_init(AVCodecContext *avctx) BinkContext * const c = avctx->priv_data; static VLC_TYPE table[16 * 128][2]; static int binkb_initialised = 0; - int i; + int i, ret; int flags; c->version = avctx->codec_tag >> 24; if (avctx->extradata_size < 4) { av_log(avctx, AV_LOG_ERROR, "Extradata missing or too short\n"); - return -1; + return AVERROR_INVALIDDATA; } flags = AV_RL32(avctx->extradata); c->has_alpha = flags & BINK_FLAG_ALPHA; @@ -1287,12 +1287,17 @@ static av_cold int decode_init(AVCodecContext *avctx) } c->avctx = avctx; - c->pic.data[0] = NULL; - - if (av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) { - return 1; + c->pic = avcodec_alloc_frame(); + c->last = avcodec_alloc_frame(); + if (!c->pic || !c->last) { + avcodec_free_frame(&c->pic); + avcodec_free_frame(&c->last); + return AVERROR(ENOMEM); } + if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0) + return ret; + avctx->pix_fmt = c->has_alpha ? AV_PIX_FMT_YUVA420P : AV_PIX_FMT_YUV420P; avctx->idct_algo = FF_IDCT_BINK; @@ -1315,10 +1320,12 @@ static av_cold int decode_end(AVCodecContext *avctx) { BinkContext * const c = avctx->priv_data; - if (c->pic.data[0]) - avctx->release_buffer(avctx, &c->pic); - if (c->last.data[0]) - avctx->release_buffer(avctx, &c->last); + if (c->pic->data[0]) + avctx->release_buffer(avctx, c->pic); + if (c->last->data[0]) + avctx->release_buffer(avctx, c->last); + avcodec_free_frame(&c->pic); + avcodec_free_frame(&c->last); free_bundles(c); return 0; diff --git a/libavcodec/bmp.c b/libavcodec/bmp.c index 13f3c7e..ea221bc 100644 --- a/libavcodec/bmp.c +++ b/libavcodec/bmp.c @@ -49,7 +49,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, unsigned int depth; BiCompression comp; unsigned int ihsize; - int i, j, n, linesize; + int i, j, n, linesize, ret; uint32_t rgb[3]; uint32_t alpha = 0; uint8_t *ptr; @@ -59,13 +59,13 @@ static int bmp_decode_frame(AVCodecContext *avctx, if (buf_size < 14) { av_log(avctx, AV_LOG_ERROR, "buf size too small (%d)\n", buf_size); - return -1; + return AVERROR_INVALIDDATA; } if (bytestream_get_byte(&buf) != 'B' || bytestream_get_byte(&buf) != 'M') { av_log(avctx, AV_LOG_ERROR, "bad magic number\n"); - return -1; + return AVERROR_INVALIDDATA; } fsize = bytestream_get_le32(&buf); @@ -82,7 +82,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, ihsize = bytestream_get_le32(&buf); /* more header size */ if (ihsize + 14 > hsize) { av_log(avctx, AV_LOG_ERROR, "invalid header size %d\n", hsize); - return -1; + return AVERROR_INVALIDDATA; } /* sometimes file size is set to some headers size, set a real size in that case */ @@ -92,7 +92,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, if (fsize <= hsize) { av_log(avctx, AV_LOG_ERROR, "declared file size is less than header size (%d < %d)\n", fsize, hsize); - return -1; + return AVERROR_INVALIDDATA; } switch (ihsize) { @@ -110,13 +110,13 @@ static int bmp_decode_frame(AVCodecContext *avctx, break; default: av_log(avctx, AV_LOG_ERROR, "unsupported BMP file, patch welcome\n"); - return -1; + return AVERROR_PATCHWELCOME; } /* planes */ if (bytestream_get_le16(&buf) != 1) { av_log(avctx, AV_LOG_ERROR, "invalid BMP header\n"); - return -1; + return AVERROR_INVALIDDATA; } depth = bytestream_get_le16(&buf); @@ -129,7 +129,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, if (comp != BMP_RGB && comp != BMP_BITFIELDS && comp != BMP_RLE4 && comp != BMP_RLE8) { av_log(avctx, AV_LOG_ERROR, "BMP coding %d not supported\n", comp); - return -1; + return AVERROR_INVALIDDATA; } if (comp == BMP_BITFIELDS) { @@ -195,26 +195,26 @@ static int bmp_decode_frame(AVCodecContext *avctx, avctx->pix_fmt = AV_PIX_FMT_PAL8; } else { av_log(avctx, AV_LOG_ERROR, "Unknown palette for %d-colour BMP\n", 1<<depth); - return -1; + return AVERROR_INVALIDDATA; } break; default: av_log(avctx, AV_LOG_ERROR, "depth %d not supported\n", depth); - return -1; + return AVERROR_INVALIDDATA; } if (avctx->pix_fmt == AV_PIX_FMT_NONE) { av_log(avctx, AV_LOG_ERROR, "unsupported pixel format\n"); - return -1; + return AVERROR_INVALIDDATA; } 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; @@ -228,7 +228,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, if (n * avctx->height > dsize && comp != BMP_RLE4 && comp != BMP_RLE8) { av_log(avctx, AV_LOG_ERROR, "not enough data (%d < %d)\n", dsize, n * avctx->height); - return -1; + return AVERROR_INVALIDDATA; } // RLE may skip decoding some picture areas, so blank picture before decoding @@ -333,7 +333,7 @@ static int bmp_decode_frame(AVCodecContext *avctx, break; default: av_log(avctx, AV_LOG_ERROR, "BMP decoder is broken\n"); - return -1; + return AVERROR_INVALIDDATA; } } diff --git a/libavcodec/bmv.c b/libavcodec/bmv.c index defa1ab..715e6a3 100644 --- a/libavcodec/bmv.c +++ b/libavcodec/bmv.c @@ -68,7 +68,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, int i; if (src_len <= 0) - return -1; + return AVERROR_INVALIDDATA; if (forward) { src = source; @@ -92,7 +92,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, */ if (!mode || (tmplen == 4)) { if (src < source || src >= source_end) - return -1; + return AVERROR_INVALIDDATA; val = *src; read_two_nibbles = 1; } else { @@ -105,7 +105,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, return -1; if (!read_two_nibbles) { if (src < source || src >= source_end) - return -1; + return AVERROR_INVALIDDATA; shift += 2; val |= *src << shift; if (*src & 0xC) @@ -141,7 +141,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, if (mode >= 4) mode -= 3; if (FFABS(dst_end - dst) < len) - return -1; + return AVERROR_INVALIDDATA; switch (mode) { case 1: if (forward) { @@ -149,7 +149,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, dst - frame + SCREEN_WIDE + frame_off < 0 || frame_end - dst < frame_off + len || frame_end - dst < len) - return -1; + return AVERROR_INVALIDDATA; for (i = 0; i < len; i++) dst[i] = dst[frame_off + i]; dst += len; @@ -159,7 +159,7 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, dst - frame + SCREEN_WIDE + frame_off < 0 || frame_end - dst < frame_off + len || frame_end - dst < len) - return -1; + return AVERROR_INVALIDDATA; for (i = len - 1; i >= 0; i--) dst[i] = dst[frame_off + i]; } @@ -167,13 +167,13 @@ static int decode_bmv_frame(const uint8_t *source, int src_len, uint8_t *frame, case 2: if (forward) { if (source + src_len - src < len) - return -1; + return AVERROR_INVALIDDATA; memcpy(dst, src, len); dst += len; src += len; } else { if (src - source < len) - return -1; + return AVERROR_INVALIDDATA; dst -= len; src -= len; memcpy(dst, src, len); diff --git a/libavcodec/c93.c b/libavcodec/c93.c index 9f3bf8b..e5f371b 100644 --- a/libavcodec/c93.c +++ b/libavcodec/c93.c @@ -134,7 +134,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, newpic->reference = 3; newpic->buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE | FF_BUFFER_HINTS_READABLE; - if ((ret = avctx->reget_buffer(avctx, newpic))) { + if ((ret = avctx->reget_buffer(avctx, newpic)) < 0) { av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n"); return ret; } @@ -166,8 +166,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, switch (block_type) { case C93_8X8_FROM_PREV: offset = bytestream2_get_le16(&gb); - if (copy_block(avctx, out, copy_from, offset, 8, stride)) - return AVERROR_INVALIDDATA; + if ((ret = copy_block(avctx, out, copy_from, offset, 8, stride)) < 0) + return ret; break; case C93_4X4_FROM_CURR: @@ -176,9 +176,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, for (j = 0; j < 8; j += 4) { for (i = 0; i < 8; i += 4) { offset = bytestream2_get_le16(&gb); - if (copy_block(avctx, &out[j*stride+i], - copy_from, offset, 4, stride)) - return AVERROR_INVALIDDATA; + if ((ret = copy_block(avctx, &out[j*stride+i], + copy_from, offset, 4, stride)) < 0) + return ret; } } break; diff --git a/libavcodec/xan.c b/libavcodec/xan.c index 899c1f1..3a559e9 100644 --- a/libavcodec/xan.c +++ b/libavcodec/xan.c @@ -116,7 +116,7 @@ static int xan_huffman_decode(unsigned char *dest, int dest_len, while (val != 0x16) { unsigned idx = val - 0x17 + get_bits1(&gb) * byte; if (idx >= 2 * byte) - return -1; + return AVERROR_INVALIDDATA; val = src[idx]; if (val < 0x16) { diff --git a/libavcodec/xl.c b/libavcodec/xl.c index df35489..e2701d6 100644 --- a/libavcodec/xl.c +++ b/libavcodec/xl.c @@ -69,7 +69,7 @@ static int decode_frame(AVCodecContext *avctx, avctx->release_buffer(avctx, p); p->reference = 0; - if ((ret = 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 ret; } diff --git a/libavcodec/xxan.c b/libavcodec/xxan.c index ed18217..3476dcc 100644 --- a/libavcodec/xxan.c +++ b/libavcodec/xxan.c @@ -186,7 +186,7 @@ static int xan_decode_chroma(AVCodecContext *avctx, unsigned chroma_off) dec_size = xan_unpack(s, s->scratch_buffer, s->buffer_size); if (dec_size < 0) { av_log(avctx, AV_LOG_ERROR, "Chroma unpacking failed\n"); - return AVERROR_INVALIDDATA; + return dec_size; } U = s->pic.data[1]; diff --git a/libavcodec/yop.c b/libavcodec/yop.c index 337fb88..c47f5ec 100644 --- a/libavcodec/yop.c +++ b/libavcodec/yop.c @@ -85,7 +85,8 @@ static av_cold int yop_decode_init(AVCodecContext *avctx) if (avctx->width & 1 || avctx->height & 1 || av_image_check_size(avctx->width, avctx->height, 0, avctx) < 0) { - return -1; + av_log(avctx, AV_LOG_ERROR, "YOP has invalid dimensions\n"); + return AVERROR_INVALIDDATA; } if (!avctx->extradata) { diff --git a/libavcodec/zmbv.c b/libavcodec/zmbv.c index 83743c5..a2d804a 100644 --- a/libavcodec/zmbv.c +++ b/libavcodec/zmbv.c @@ -485,7 +485,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPac 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->cur = av_realloc_f(c->cur, avctx->width * avctx->height, (c->bpp / 8)); @@ -642,7 +642,7 @@ static av_cold int decode_init(AVCodecContext *avctx) zret = inflateInit(&c->zstream); if (zret != Z_OK) { av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); - return -1; + return AVERROR_UNKNOWN; } return 0; |