Commit 7b018e5c authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '84f2847d'

* commit '84f2847d':
  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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 61904467 84f2847d
......@@ -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;
......
This diff is collapsed.
......@@ -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;
}
}
......
......@@ -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);
......
......@@ -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;
......
......@@ -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) {
......
......@@ -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;
}
......
......@@ -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];
......
......@@ -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) {
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment