* commit 'ade402804a0e811cd00862c90559121a793054a6': eatgv: return meaningful error codes. cyuv: return meaningful error codes. txd: return meaningful error codes. Conflicts: libavcodec/cyuv.c libavcodec/eatgv.c Merged-by: Michael Niedermayer <michaelni@gmx.at>tags/n1.2
@@ -52,7 +52,7 @@ static av_cold int cyuv_decode_init(AVCodecContext *avctx) | |||||
s->width = avctx->width; | s->width = avctx->width; | ||||
/* width needs to be divisible by 4 for this codec to work */ | /* width needs to be divisible by 4 for this codec to work */ | ||||
if (s->width & 0x3) | if (s->width & 0x3) | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
s->height = avctx->height; | s->height = avctx->height; | ||||
avcodec_get_frame_defaults(&s->frame); | avcodec_get_frame_defaults(&s->frame); | ||||
@@ -84,6 +84,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, | |||||
unsigned char cur_byte; | unsigned char cur_byte; | ||||
int pixel_groups; | int pixel_groups; | ||||
int rawsize = s->height * FFALIGN(s->width,2) * 2; | int rawsize = s->height * FFALIGN(s->width,2) * 2; | ||||
int ret; | |||||
if (avctx->codec_id == AV_CODEC_ID_AURA) { | if (avctx->codec_id == AV_CODEC_ID_AURA) { | ||||
y_table = u_table; | y_table = u_table; | ||||
@@ -100,7 +101,7 @@ static int cyuv_decode_frame(AVCodecContext *avctx, | |||||
} else { | } else { | ||||
av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n", | av_log(avctx, AV_LOG_ERROR, "got a buffer with %d bytes when %d were expected\n", | ||||
buf_size, 48 + s->height * (s->width * 3 / 4)); | buf_size, 48 + s->height * (s->width * 3 / 4)); | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
} | } | ||||
/* pixel data starts 48 bytes in, after 3x16-byte tables */ | /* pixel data starts 48 bytes in, after 3x16-byte tables */ | ||||
@@ -111,9 +112,9 @@ static int cyuv_decode_frame(AVCodecContext *avctx, | |||||
s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; | s->frame.buffer_hints = FF_BUFFER_HINTS_VALID; | ||||
s->frame.reference = 0; | s->frame.reference = 0; | ||||
if (ff_get_buffer(avctx, &s->frame) < 0) { | |||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 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; | |||||
} | } | ||||
y_plane = s->frame.data[0]; | y_plane = s->frame.data[0]; | ||||
@@ -75,7 +75,7 @@ static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst | |||||
src += 2; | src += 2; | ||||
if (src_end - src < 3) | if (src_end - src < 3) | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
size = AV_RB24(src); | size = AV_RB24(src); | ||||
src += 3; | src += 3; | ||||
@@ -148,7 +148,7 @@ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *b | |||||
const unsigned char *blocks_raw; | const unsigned char *blocks_raw; | ||||
if(buf_end - buf < 12) | if(buf_end - buf < 12) | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
num_mvs = AV_RL16(&buf[0]); | num_mvs = AV_RL16(&buf[0]); | ||||
num_blocks_raw = AV_RL16(&buf[2]); | num_blocks_raw = AV_RL16(&buf[2]); | ||||
@@ -177,7 +177,7 @@ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *b | |||||
mvbits = (num_mvs*2*10+31) & ~31; | mvbits = (num_mvs*2*10+31) & ~31; | ||||
if (buf_end - buf < (mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed) | if (buf_end - buf < (mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed) | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
init_get_bits(&gb, buf, mvbits); | init_get_bits(&gb, buf, mvbits); | ||||
for (i=0; i<num_mvs; i++) { | for (i=0; i<num_mvs; i++) { | ||||
@@ -202,7 +202,7 @@ static int tgv_decode_inter(TgvContext * s, const uint8_t *buf, const uint8_t *b | |||||
if (get_bits_left(&gb) < vector_bits * | if (get_bits_left(&gb) < vector_bits * | ||||
(s->avctx->height/4) * (s->avctx->width/4)) | (s->avctx->height/4) * (s->avctx->width/4)) | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
/* read vectors and build frame */ | /* read vectors and build frame */ | ||||
for(y=0; y<s->avctx->height/4; y++) | for(y=0; y<s->avctx->height/4; y++) | ||||
@@ -260,7 +260,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, | |||||
int buf_size = avpkt->size; | int buf_size = avpkt->size; | ||||
TgvContext *s = avctx->priv_data; | TgvContext *s = avctx->priv_data; | ||||
const uint8_t *buf_end = buf + buf_size; | const uint8_t *buf_end = buf + buf_size; | ||||
int chunk_type; | |||||
int chunk_type, ret; | |||||
if (buf_end - buf < EA_PREAMBLE_SIZE) | if (buf_end - buf < EA_PREAMBLE_SIZE) | ||||
return AVERROR_INVALIDDATA; | return AVERROR_INVALIDDATA; | ||||
@@ -272,7 +272,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, | |||||
int pal_count, i; | int pal_count, i; | ||||
if(buf_end - buf < 12) { | if(buf_end - buf < 12) { | ||||
av_log(avctx, AV_LOG_WARNING, "truncated header\n"); | av_log(avctx, AV_LOG_WARNING, "truncated header\n"); | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
} | } | ||||
s->width = AV_RL16(&buf[0]); | s->width = AV_RL16(&buf[0]); | ||||
@@ -291,8 +291,8 @@ static int tgv_decode_frame(AVCodecContext *avctx, | |||||
} | } | ||||
} | } | ||||
if (av_image_check_size(s->width, s->height, 0, avctx)) | |||||
return -1; | |||||
if ((ret = av_image_check_size(s->width, s->height, 0, avctx)) < 0) | |||||
return ret; | |||||
/* shuffle */ | /* shuffle */ | ||||
FFSWAP(AVFrame, s->frame, s->last_frame); | FFSWAP(AVFrame, s->frame, s->last_frame); | ||||
@@ -317,7 +317,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, | |||||
s->frame.pict_type = AV_PICTURE_TYPE_I; | s->frame.pict_type = AV_PICTURE_TYPE_I; | ||||
if (unpack(buf, buf_end, s->frame.data[0], s->avctx->width, s->avctx->height)<0) { | if (unpack(buf, buf_end, s->frame.data[0], s->avctx->width, s->avctx->height)<0) { | ||||
av_log(avctx, AV_LOG_WARNING, "truncated intra frame\n"); | av_log(avctx, AV_LOG_WARNING, "truncated intra frame\n"); | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
} | } | ||||
}else{ | }else{ | ||||
if (!s->last_frame.data[0]) { | if (!s->last_frame.data[0]) { | ||||
@@ -328,7 +328,7 @@ static int tgv_decode_frame(AVCodecContext *avctx, | |||||
s->frame.pict_type = AV_PICTURE_TYPE_P; | s->frame.pict_type = AV_PICTURE_TYPE_P; | ||||
if (tgv_decode_inter(s, buf, buf_end)<0) { | if (tgv_decode_inter(s, buf, buf_end)<0) { | ||||
av_log(avctx, AV_LOG_WARNING, "truncated inter frame\n"); | av_log(avctx, AV_LOG_WARNING, "truncated inter frame\n"); | ||||
return -1; | |||||
return AVERROR_INVALIDDATA; | |||||
} | } | ||||
} | } | ||||
@@ -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)) | |||||
return -1; | |||||
if ((ret = av_image_check_size(w, h, 0, avctx)) < 0) | |||||
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; | ||||
@@ -149,7 +150,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) { | ||||