1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

txd: return meaningful error codes.

This commit is contained in:
Anton Khirnov 2012-11-20 07:48:01 +01:00
parent 69c25c9284
commit 6837bd6e49

View File

@ -51,6 +51,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
unsigned int y, v; unsigned int y, v;
uint8_t *ptr; uint8_t *ptr;
uint32_t *pal; uint32_t *pal;
int ret;
bytestream2_init(&gb, avpkt->data, avpkt->size); bytestream2_init(&gb, avpkt->data, avpkt->size);
version = bytestream2_get_le32(&gb); version = bytestream2_get_le32(&gb);
@ -65,7 +66,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
if (version < 8 || version > 9) { if (version < 8 || version > 9) {
av_log(avctx, AV_LOG_ERROR, "texture data version %i is unsupported\n", av_log(avctx, AV_LOG_ERROR, "texture data version %i is unsupported\n",
version); version);
return -1; return AVERROR_PATCHWELCOME;
} }
if (depth == 8) { if (depth == 8) {
@ -74,19 +75,19 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
avctx->pix_fmt = AV_PIX_FMT_RGB32; avctx->pix_fmt = AV_PIX_FMT_RGB32;
} else { } else {
av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth); av_log(avctx, AV_LOG_ERROR, "depth of %i is unsupported\n", depth);
return -1; return AVERROR_PATCHWELCOME;
} }
if (p->data[0]) if (p->data[0])
avctx->release_buffer(avctx, p); avctx->release_buffer(avctx, p);
if (av_image_check_size(w, h, 0, avctx)) if ((ret = av_image_check_size(w, h, 0, avctx)) < 0)
return -1; return ret;
if (w != avctx->width || h != avctx->height) if (w != avctx->width || h != avctx->height)
avcodec_set_dimensions(avctx, w, h); 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"); av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return -1; return ret;
} }
p->pict_type = AV_PICTURE_TYPE_I; p->pict_type = AV_PICTURE_TYPE_I;
@ -141,7 +142,7 @@ static int txd_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
unsupported: unsupported:
av_log(avctx, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", d3d_format); av_log(avctx, AV_LOG_ERROR, "unsupported d3d format (%08x)\n", d3d_format);
return -1; return AVERROR_PATCHWELCOME;
} }
static av_cold int txd_end(AVCodecContext *avctx) { static av_cold int txd_end(AVCodecContext *avctx) {