diff options
-rw-r--r-- | libavcodec/mmvideo.c | 11 | ||||
-rw-r--r-- | libavformat/mm.c | 9 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libavcodec/mmvideo.c b/libavcodec/mmvideo.c index d339967702..7313507deb 100644 --- a/libavcodec/mmvideo.c +++ b/libavcodec/mmvideo.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; diff --git a/libavformat/mm.c b/libavformat/mm.c index a99feae6e9..74e2716926 100644 --- a/libavformat/mm.c +++ b/libavformat/mm.c @@ -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); } } |