[FFmpeg-devel] [PATCH 2/2] raw VOX demuxer
Paul B Mahol
onemda at gmail.com
Fri Nov 23 12:02:43 CET 2012
Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
libavformat/Makefile | 1 +
libavformat/allformats.c | 1 +
libavformat/vox.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 libavformat/vox.c
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 136ada8..b25c54b 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -355,6 +355,7 @@ OBJS-$(CONFIG_VC1T_MUXER) += vc1testenc.o
OBJS-$(CONFIG_VMD_DEMUXER) += sierravmd.o
OBJS-$(CONFIG_VOC_DEMUXER) += vocdec.o voc.o
OBJS-$(CONFIG_VOC_MUXER) += vocenc.o voc.o
+OBJS-$(CONFIG_VOX_DEMUXER) += vox.o rawdec.o
OBJS-$(CONFIG_VQF_DEMUXER) += vqf.o
OBJS-$(CONFIG_W64_DEMUXER) += wavdec.o pcm.o
OBJS-$(CONFIG_WAV_DEMUXER) += wavdec.o pcm.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index eaeb51a..841fb44 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -252,6 +252,7 @@ void av_register_all(void)
REGISTER_MUXDEMUX (VC1T, vc1t);
REGISTER_DEMUXER (VMD, vmd);
REGISTER_MUXDEMUX (VOC, voc);
+ REGISTER_DEMUXER (VOX, vox);
REGISTER_DEMUXER (VQF, vqf);
REGISTER_DEMUXER (W64, w64);
REGISTER_MUXDEMUX (WAV, wav);
diff --git a/libavformat/vox.c b/libavformat/vox.c
new file mode 100644
index 0000000..9e82748
--- /dev/null
+++ b/libavformat/vox.c
@@ -0,0 +1,75 @@
+/*
+ * VOX raw demuxer
+ * Copyright (c) 2012 Paul B Mahol
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avassert.h"
+#include "avformat.h"
+#include "internal.h"
+#include "rawdec.h"
+
+typedef struct VoxDemuxContext {
+ AVClass *class;
+ int sample_rate;
+} VoxDemuxContext;
+
+static int vox_read_header(AVFormatContext *s)
+{
+ VoxDemuxContext *vox = s->priv_data;
+ AVStream *st;
+
+ st = avformat_new_stream(s, NULL);
+ if (!st)
+ return AVERROR(ENOMEM);
+
+ st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codec->sample_rate = vox->sample_rate;
+ // vox files store different codecs so user need to set codec id manually
+ st->codec->channels = 1;
+
+ st->codec->bits_per_coded_sample =
+ av_get_bits_per_sample(st->codec->codec_id);
+
+ avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate);
+ return 0;
+}
+
+#define OFFSET(x) offsetof(VoxDemuxContext, x)
+static const AVOption vox_options[] = {
+ { "sample_rate", "", OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64 = 8000 }, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { NULL },
+};
+
+static const AVClass vox_demuxer_class = {
+ .class_name = "vox demuxer",
+ .item_name = av_default_item_name,
+ .option = vox_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_vox_demuxer = {
+ .name = "vox",
+ .long_name = NULL_IF_CONFIG_SMALL("raw VOX"),
+ .priv_data_size = sizeof(VoxDemuxContext),
+ .read_header = vox_read_header,
+ .read_packet = ff_raw_read_partial_packet,
+ .flags = AVFMT_GENERIC_INDEX,
+ .extensions = "vox",
+ .priv_class = &vox_demuxer_class,
+};
--
1.7.11.4
More information about the ffmpeg-devel
mailing list