mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-13 21:28:01 +02:00
eatgv: return meaningful error codes.
This commit is contained in:
parent
0859eaa012
commit
ade402804a
@ -73,7 +73,7 @@ static int unpack(const uint8_t *src, const uint8_t *src_end, unsigned char *dst
|
|||||||
src += 2;
|
src += 2;
|
||||||
|
|
||||||
if (src+3>src_end)
|
if (src+3>src_end)
|
||||||
return -1;
|
return AVERROR_INVALIDDATA;
|
||||||
size = AV_RB24(src);
|
size = AV_RB24(src);
|
||||||
src += 3;
|
src += 3;
|
||||||
|
|
||||||
@ -146,7 +146,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+12>buf_end)
|
if(buf+12>buf_end)
|
||||||
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]);
|
||||||
@ -175,7 +175,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+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end)
|
if (buf+(mvbits>>3)+16*num_blocks_raw+8*num_blocks_packed>buf_end)
|
||||||
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++) {
|
||||||
@ -200,7 +200,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++)
|
||||||
@ -256,7 +256,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;
|
||||||
|
|
||||||
chunk_type = AV_RL32(&buf[0]);
|
chunk_type = AV_RL32(&buf[0]);
|
||||||
buf += EA_PREAMBLE_SIZE;
|
buf += EA_PREAMBLE_SIZE;
|
||||||
@ -265,7 +265,7 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
|||||||
int pal_count, i;
|
int pal_count, i;
|
||||||
if(buf+12>buf_end) {
|
if(buf+12>buf_end) {
|
||||||
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]);
|
||||||
@ -284,8 +284,8 @@ static int tgv_decode_frame(AVCodecContext *avctx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (av_image_check_size(s->width, s->height, 0, avctx))
|
if ((ret = av_image_check_size(s->width, s->height, 0, avctx)) < 0)
|
||||||
return -1;
|
return ret;
|
||||||
|
|
||||||
/* shuffle */
|
/* shuffle */
|
||||||
FFSWAP(AVFrame, s->frame, s->last_frame);
|
FFSWAP(AVFrame, s->frame, s->last_frame);
|
||||||
@ -310,7 +310,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]) {
|
||||||
@ -321,7 +321,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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user