bethsoftvideo: return proper consumed size for palette packets.

Also check for sufficient packet size.
This commit is contained in:
Anton Khirnov
2011-11-23 21:58:30 +01:00
parent 5872c78122
commit 3eedd29bd7
2 changed files with 78 additions and 73 deletions
+7 -3
View File
@@ -46,14 +46,19 @@ static av_cold int bethsoftvid_decode_init(AVCodecContext *avctx)
return 0;
}
static void set_palette(AVFrame * frame, const uint8_t * palette_buffer)
static int set_palette(AVFrame * frame, const uint8_t * palette_buffer, int buf_size)
{
uint32_t * palette = (uint32_t *)frame->data[1];
int a;
if (buf_size < 256*3)
return AVERROR_INVALIDDATA;
for(a = 0; a < 256; a++){
palette[a] = AV_RB24(&palette_buffer[a * 3]) * 4;
}
frame->palette_has_changed = 1;
return 256*3;
}
static int bethsoftvid_decode_frame(AVCodecContext *avctx,
@@ -80,8 +85,7 @@ static int bethsoftvid_decode_frame(AVCodecContext *avctx,
switch(block_type = *buf++){
case PALETTE_BLOCK:
set_palette(&vid->frame, buf);
return 0;
return set_palette(&vid->frame, buf, buf_size);
case VIDEO_YOFF_P_FRAME:
yoffset = bytestream_get_le16(&buf);
if(yoffset >= avctx->height)