[FFmpeg-cvslog] lavf: Raw G.729 demuxer
Vladimir Voroshilov
git at videolan.org
Thu Jun 23 12:26:50 CEST 2016
ffmpeg | branch: master | Vladimir Voroshilov <voroshil at gmail.com> | Sat Mar 19 17:48:39 2016 -0400| [d621b2f795684f7119057f986066060adbe84220] | committer: Vittorio Giovara
lavf: Raw G.729 demuxer
Signed-off-by: Vittorio Giovara <vittorio.giovara at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d621b2f795684f7119057f986066060adbe84220
---
Changelog | 1 +
libavformat/Makefile | 1 +
libavformat/allformats.c | 1 +
libavformat/g729dec.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++
libavformat/version.h | 4 +-
5 files changed, 110 insertions(+), 2 deletions(-)
diff --git a/Changelog b/Changelog
index 54b52a1..a2a9d46 100644
--- a/Changelog
+++ b/Changelog
@@ -56,6 +56,7 @@ version <next>:
- VAAPI-accelerate H.264/HEVC/MJPEG encoding
- Generic OpenMAX IL encoder with support for Raspberry Pi
- MMAL-accelerated MPEG-2 and VC-1 decoding
+- G.729 raw demuxer
version 11:
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 7f4a0be..48b66cf 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -140,6 +140,7 @@ OBJS-$(CONFIG_G722_DEMUXER) += g722.o rawdec.o
OBJS-$(CONFIG_G722_MUXER) += rawenc.o
OBJS-$(CONFIG_G723_1_DEMUXER) += g723_1.o
OBJS-$(CONFIG_G723_1_MUXER) += rawenc.o
+OBJS-$(CONFIG_G729_DEMUXER) += g729dec.o
OBJS-$(CONFIG_GIF_MUXER) += gif.o
OBJS-$(CONFIG_GSM_DEMUXER) += gsmdec.o
OBJS-$(CONFIG_GXF_DEMUXER) += gxf.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 687ae1b..f51c4e7 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -105,6 +105,7 @@ void av_register_all(void)
REGISTER_MUXER (FRAMEMD5, framemd5);
REGISTER_MUXDEMUX(G722, g722);
REGISTER_MUXDEMUX(G723_1, g723_1);
+ REGISTER_DEMUXER (G729, g729);
REGISTER_MUXER (GIF, gif);
REGISTER_DEMUXER (GSM, gsm);
REGISTER_MUXDEMUX(GXF, gxf);
diff --git a/libavformat/g729dec.c b/libavformat/g729dec.c
new file mode 100644
index 0000000..c2beb60
--- /dev/null
+++ b/libavformat/g729dec.c
@@ -0,0 +1,105 @@
+/*
+ * G.729 raw format demuxer
+ * Copyright (c) 2011 Vladimir Voroshilov
+ *
+ * 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 "libavutil/log.h"
+#include "libavutil/opt.h"
+
+#include "avformat.h"
+#include "internal.h"
+
+typedef struct G729DemuxerContext {
+ AVClass *class;
+
+ int bit_rate;
+} G729DemuxerContext;
+
+static int g729_read_header(AVFormatContext *s)
+{
+ AVStream* st;
+ G729DemuxerContext *s1 = s->priv_data;
+
+ st = avformat_new_stream(s, NULL);
+ if (!st)
+ return AVERROR(ENOMEM);
+
+ st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
+ st->codecpar->codec_id = AV_CODEC_ID_G729;
+ st->codecpar->sample_rate = 8000;
+ st->codecpar->channels = 1;
+
+ if (s1 && s1->bit_rate)
+ s->bit_rate = s1->bit_rate;
+
+ switch(s->bit_rate) {
+ case 6400:
+ st->codecpar->block_align = 8;
+ break;
+ case 8000:
+ st->codecpar->block_align = 10;
+ break;
+ default:
+ av_log(s, AV_LOG_ERROR, "Invalid bit_rate value %d. "
+ "Only 6400 and 8000 b/s are supported.", s->bit_rate);
+ return AVERROR(EINVAL);
+ }
+
+ avpriv_set_pts_info(st, st->codecpar->block_align << 3, 1,
+ st->codecpar->sample_rate);
+
+ return 0;
+}
+
+static int g729_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+ AVStream *st = s->streams[0];
+ int ret = av_get_packet(s->pb, pkt, st->codecpar->block_align);
+ if (ret < 0)
+ return ret;
+
+ pkt->stream_index = 0;
+ pkt->dts = pkt->pts = pkt->pos / st->codecpar->block_align;
+
+ return 0;
+}
+
+#define OFFSET(x) offsetof(G729DemuxerContext, x)
+static const AVOption g729_options[] = {
+ { "bit_rate", "", OFFSET(bit_rate), AV_OPT_TYPE_INT, { .i64 = 8000 }, 0, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
+ { NULL },
+};
+
+static const AVClass g729_demuxer_class = {
+ .class_name = "g729 demuxer",
+ .item_name = av_default_item_name,
+ .option = g729_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
+AVInputFormat ff_g729_demuxer = {
+ .name = "g729",
+ .long_name = NULL_IF_CONFIG_SMALL("G.729 raw format demuxer"),
+ .priv_data_size = sizeof(G729DemuxerContext),
+ .read_header = g729_read_header,
+ .read_packet = g729_read_packet,
+ .flags = AVFMT_GENERIC_INDEX,
+ .extensions = "g729",
+ .priv_class = &g729_demuxer_class,
+};
diff --git a/libavformat/version.h b/libavformat/version.h
index aae1e23..a50e443 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -30,8 +30,8 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 57
-#define LIBAVFORMAT_VERSION_MINOR 5
-#define LIBAVFORMAT_VERSION_MICRO 2
+#define LIBAVFORMAT_VERSION_MINOR 6
+#define LIBAVFORMAT_VERSION_MICRO 0
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \
More information about the ffmpeg-cvslog
mailing list