mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-06-19 19:03:00 +02:00
bethsoftvideo: return proper consumed size for palette packets.
Also check for sufficient packet size.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user