From: Mike Melanson <[email protected]>
---
Changelog | 1 +
doc/general.texi | 1 +
libavformat/Makefile | 1 +
libavformat/allformats.c | 1 +
libavformat/mgsvp3.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++
libavformat/version.h | 2 +-
6 files changed, 97 insertions(+), 1 deletions(-)
create mode 100755 libavformat/mgsvp3.c
diff --git a/Changelog b/Changelog
index b098203..5f49551 100644
--- a/Changelog
+++ b/Changelog
@@ -118,6 +118,7 @@ easier to use. The changes are:
- Simple segmenting muxer
- Indeo 4 decoder
- SMJPEG demuxer
+- Demuxer for VP3 video files from Metal Gear Solid: The Twin Snakes
version 0.7:
diff --git a/doc/general.texi b/doc/general.texi
index 65d65bb..b1cc59a 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -188,6 +188,7 @@ library:
@item MAXIS XA @tab @tab X
@tab Used in Sim City 3000; file extension .xa.
@item MD Studio @tab @tab X
+@item MGS VP3 @tab @tab X
@item Mobotix .mxg @tab @tab X
@item Monkey's Audio @tab @tab X
@item Motion Pixels MVI @tab @tab X
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 37e9ece..776aa05 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -127,6 +127,7 @@ OBJS-$(CONFIG_MATROSKA_MUXER) += matroskaenc.o
matroska.o \
riff.o isom.o avc.o \
flacenc_header.o avlanguage.o
OBJS-$(CONFIG_MD5_MUXER) += md5enc.o
+OBJS-$(CONFIG_MGSVP3_DEMUXER) += mgsvp3.o
OBJS-$(CONFIG_MJPEG_DEMUXER) += rawdec.o
OBJS-$(CONFIG_MJPEG_MUXER) += rawenc.o
OBJS-$(CONFIG_MLP_DEMUXER) += rawdec.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 364e320..3e96c39 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -122,6 +122,7 @@ void av_register_all(void)
REGISTER_MUXER (MD5, md5);
REGISTER_MUXDEMUX (MATROSKA, matroska);
REGISTER_MUXER (MATROSKA_AUDIO, matroska_audio);
+ REGISTER_DEMUXER (MGSVP3, mgsvp3);
REGISTER_MUXDEMUX (MJPEG, mjpeg);
REGISTER_MUXDEMUX (MLP, mlp);
REGISTER_DEMUXER (MM, mm);
diff --git a/libavformat/mgsvp3.c b/libavformat/mgsvp3.c
new file mode 100755
index 0000000..5d501ed
--- /dev/null
+++ b/libavformat/mgsvp3.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2011 Mike Melanson
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "avformat.h"
+#include "riff.h"
+#include "libavutil/intfloat.h"
+#include "libavutil/intreadwrite.h"
+
+#define PACKET_HEADER_SIZE 16
+#define PACKET_SIGNATURE 0x0000000E
+
+static int64_t counter = 0;
+
+static int probe(AVProbeData *p)
+{
+ if (AV_RB32(p->buf) == PACKET_SIGNATURE)
+ return AVPROBE_SCORE_MAX-2;
+
+ return 0;
+}
+
+static int read_header(AVFormatContext *s, AVFormatParameters *ap)
+{
+ AVStream *st;
+
+ st = avformat_new_stream(s, 0);
+ if (!st)
+ return AVERROR(ENOMEM);
+
+ st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
+ st->codec->codec_id = CODEC_ID_VP3;
+ avio_skip(s->pb, 28);
+ st->duration = avio_rb32(s->pb);
+ avpriv_set_pts_info(st, 32, 1, av_int2float(avio_rb32(s->pb))); /*
framerate is a float */
+ st->codec->width = avio_rb32(s->pb);
+ st->codec->height = avio_rb32(s->pb);
+ avio_skip(s->pb, 12);
+ st->codec->codec_tag = avio_rb32(s->pb); /* read it backwards so it's in
the right order */
+ st->codec->pix_fmt = PIX_FMT_YUV420P;
+ avio_skip(s->pb, 20);
+
+ return 0;
+}
+
+static int read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ int ret;
+ int header;
+ int packet_size;
+ int payload_size;
+
+ header = avio_rb32(s->pb);
+ packet_size = avio_rb32(s->pb);
+ avio_rb32(s->pb);
+ payload_size = avio_rb32(s->pb);
+
+ if (header != PACKET_SIGNATURE)
+ ret = AVERROR_INVALIDDATA;
+
+ pkt->pos = avio_tell(s->pb);
+ ret = av_get_packet(s->pb, pkt, payload_size);
+ pkt->stream_index = 0;
+ pkt->pts = counter++;
+ avio_skip(s->pb, packet_size - payload_size - PACKET_HEADER_SIZE);
+
+ return ret;
+}
+
+AVInputFormat ff_mgsvp3_demuxer = {
+ .name = "MGS VP3",
+ .long_name = NULL_IF_CONFIG_SMALL("Metal Gear Solid VP3"),
+ .read_probe = probe,
+ .read_header = read_header,
+ .read_packet = read_packet,
+};
diff --git a/libavformat/version.h b/libavformat/version.h
index e113a24..a4e7368 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,7 +30,7 @@
#include "libavutil/avutil.h"
#define LIBAVFORMAT_VERSION_MAJOR 53
-#define LIBAVFORMAT_VERSION_MINOR 19
+#define LIBAVFORMAT_VERSION_MINOR 20
#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
--
1.7.4.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel