bfi: return meaningful error codes.

This commit is contained in:
Anton Khirnov 2012-11-14 16:09:39 +01:00
parent fc2a94c15e
commit 86e09b9e60
1 changed files with 6 additions and 6 deletions

View File

@ -55,16 +55,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 = 1;
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);
@ -76,7 +76,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++) {
@ -104,7 +104,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) */
@ -130,7 +130,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;