Skip to content

Commit f298507

Browse files
committed
avcodec/mm: decode raw chunk type and skip unknown audio chunk type
1 parent 66124bc commit f298507

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

libavcodec/mmvideo.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939

4040
#define MM_PREAMBLE_SIZE 6
4141

42+
#define MM_TYPE_RAW 0x2
4243
#define MM_TYPE_INTER 0x5
4344
#define MM_TYPE_INTRA 0x8
4445
#define MM_TYPE_INTRA_HH 0xc
@@ -76,6 +77,15 @@ static av_cold int mm_decode_init(AVCodecContext *avctx)
7677
return 0;
7778
}
7879

80+
static int mm_decode_raw(MmContext * s)
81+
{
82+
if (bytestream2_get_bytes_left(&s->gb) < s->avctx->width * s->avctx->height)
83+
return AVERROR_INVALIDDATA;
84+
for (int y = 0; y < s->avctx->height; y++)
85+
bytestream2_get_buffer(&s->gb, s->frame->data[0] + y*s->frame->linesize[0], s->avctx->width);
86+
return 0;
87+
}
88+
7989
static void mm_decode_pal(MmContext *s)
8090
{
8191
int start = bytestream2_get_le16(&s->gb);
@@ -202,6 +212,7 @@ static int mm_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
202212
return res;
203213

204214
switch(type) {
215+
case MM_TYPE_RAW : res = mm_decode_raw(s); break;
205216
case MM_TYPE_PALETTE : mm_decode_pal(s); return avpkt->size;
206217
case MM_TYPE_INTRA : res = mm_decode_intra(s, 0, 0); break;
207218
case MM_TYPE_INTRA_HH : res = mm_decode_intra(s, 1, 0); break;

libavformat/mm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@
4040
#define MM_PREAMBLE_SIZE 6
4141

4242
#define MM_TYPE_HEADER 0x0
43+
#define MM_TYPE_RAW 0x2
4344
#define MM_TYPE_INTER 0x5
4445
#define MM_TYPE_INTRA 0x8
4546
#define MM_TYPE_INTRA_HH 0xc
4647
#define MM_TYPE_INTER_HH 0xd
4748
#define MM_TYPE_INTRA_HHV 0xe
4849
#define MM_TYPE_INTER_HHV 0xf
50+
#define MM_TYPE_AUDIO2 0x14
4951
#define MM_TYPE_AUDIO 0x15
5052
#define MM_TYPE_PALETTE 0x31
5153

5254
#define MM_HEADER_LEN_V 0x16 /* video only */
5355
#define MM_HEADER_LEN_AV 0x18 /* video + audio */
56+
#define MM_HEADER_LEN_AV2 0x1a
5457

5558
#define MM_PALETTE_COUNT 128
5659
#define MM_PALETTE_SIZE (MM_PALETTE_COUNT*3)
@@ -68,7 +71,7 @@ static int probe(const AVProbeData *p)
6871
if (AV_RL16(&p->buf[0]) != MM_TYPE_HEADER)
6972
return 0;
7073
len = AV_RL32(&p->buf[2]);
71-
if (len != MM_HEADER_LEN_V && len != MM_HEADER_LEN_AV)
74+
if (len != MM_HEADER_LEN_V && len != MM_HEADER_LEN_AV && len != MM_HEADER_LEN_AV2)
7275
return 0;
7376
fps = AV_RL16(&p->buf[8]);
7477
w = AV_RL16(&p->buf[12]);
@@ -118,7 +121,7 @@ static int read_header(AVFormatContext *s)
118121
avpriv_set_pts_info(st, 64, 1, frame_rate);
119122

120123
/* audio stream */
121-
if (length == MM_HEADER_LEN_AV) {
124+
if (length >= MM_HEADER_LEN_AV) {
122125
st = avformat_new_stream(s, NULL);
123126
if (!st)
124127
return AVERROR(ENOMEM);
@@ -154,6 +157,7 @@ static int read_packet(AVFormatContext *s,
154157
length = AV_RL16(&preamble[2]);
155158

156159
switch(type) {
160+
case MM_TYPE_RAW :
157161
case MM_TYPE_PALETTE :
158162
case MM_TYPE_INTER :
159163
case MM_TYPE_INTRA :
@@ -186,6 +190,7 @@ static int read_packet(AVFormatContext *s,
186190

187191
default :
188192
av_log(s, AV_LOG_INFO, "unknown chunk type 0x%x\n", type);
193+
case MM_TYPE_AUDIO2 :
189194
avio_skip(pb, length);
190195
}
191196
}

0 commit comments

Comments
 (0)