avcodec/mm: decode raw chunk type and skip unknown audio chunk type

pull/391/head
Peter Ross 7 months ago
parent 66124bc368
commit f298507323
  1. 11
      libavcodec/mmvideo.c
  2. 9
      libavformat/mm.c

@ -39,6 +39,7 @@
#define MM_PREAMBLE_SIZE 6
#define MM_TYPE_RAW 0x2
#define MM_TYPE_INTER 0x5
#define MM_TYPE_INTRA 0x8
#define MM_TYPE_INTRA_HH 0xc
@ -76,6 +77,15 @@ static av_cold int mm_decode_init(AVCodecContext *avctx)
return 0;
}
static int mm_decode_raw(MmContext * s)
{
if (bytestream2_get_bytes_left(&s->gb) < s->avctx->width * s->avctx->height)
return AVERROR_INVALIDDATA;
for (int y = 0; y < s->avctx->height; y++)
bytestream2_get_buffer(&s->gb, s->frame->data[0] + y*s->frame->linesize[0], s->avctx->width);
return 0;
}
static void mm_decode_pal(MmContext *s)
{
int start = bytestream2_get_le16(&s->gb);
@ -202,6 +212,7 @@ static int mm_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
return res;
switch(type) {
case MM_TYPE_RAW : res = mm_decode_raw(s); break;
case MM_TYPE_PALETTE : mm_decode_pal(s); return avpkt->size;
case MM_TYPE_INTRA : res = mm_decode_intra(s, 0, 0); break;
case MM_TYPE_INTRA_HH : res = mm_decode_intra(s, 1, 0); break;

@ -40,17 +40,20 @@
#define MM_PREAMBLE_SIZE 6
#define MM_TYPE_HEADER 0x0
#define MM_TYPE_RAW 0x2
#define MM_TYPE_INTER 0x5
#define MM_TYPE_INTRA 0x8
#define MM_TYPE_INTRA_HH 0xc
#define MM_TYPE_INTER_HH 0xd
#define MM_TYPE_INTRA_HHV 0xe
#define MM_TYPE_INTER_HHV 0xf
#define MM_TYPE_AUDIO2 0x14
#define MM_TYPE_AUDIO 0x15
#define MM_TYPE_PALETTE 0x31
#define MM_HEADER_LEN_V 0x16 /* video only */
#define MM_HEADER_LEN_AV 0x18 /* video + audio */
#define MM_HEADER_LEN_AV2 0x1a
#define MM_PALETTE_COUNT 128
#define MM_PALETTE_SIZE (MM_PALETTE_COUNT*3)
@ -68,7 +71,7 @@ static int probe(const AVProbeData *p)
if (AV_RL16(&p->buf[0]) != MM_TYPE_HEADER)
return 0;
len = AV_RL32(&p->buf[2]);
if (len != MM_HEADER_LEN_V && len != MM_HEADER_LEN_AV)
if (len != MM_HEADER_LEN_V && len != MM_HEADER_LEN_AV && len != MM_HEADER_LEN_AV2)
return 0;
fps = AV_RL16(&p->buf[8]);
w = AV_RL16(&p->buf[12]);
@ -118,7 +121,7 @@ static int read_header(AVFormatContext *s)
avpriv_set_pts_info(st, 64, 1, frame_rate);
/* audio stream */
if (length == MM_HEADER_LEN_AV) {
if (length >= MM_HEADER_LEN_AV) {
st = avformat_new_stream(s, NULL);
if (!st)
return AVERROR(ENOMEM);
@ -154,6 +157,7 @@ static int read_packet(AVFormatContext *s,
length = AV_RL16(&preamble[2]);
switch(type) {
case MM_TYPE_RAW :
case MM_TYPE_PALETTE :
case MM_TYPE_INTER :
case MM_TYPE_INTRA :
@ -186,6 +190,7 @@ static int read_packet(AVFormatContext *s,
default :
av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
case MM_TYPE_AUDIO2 :
avio_skip(pb, length);
}
}

Loading…
Cancel
Save