summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Voroshilov <voroshil@gmail.com>2008-08-17 08:43:37 +0000
committerVladimir Voroshilov <voroshil@gmail.com>2008-08-17 08:43:37 +0000
commit5209846850a2b00dc1c52fd1afb6986edcdb4dd8 (patch)
tree09a8e05920715ba90c859ba6800480dd44bbcaac
parent720d52c67874d138956ee7ce6e2370356778f55a (diff)
downloadffmpeg-5209846850a2b00dc1c52fd1afb6986edcdb4dd8.tar.gz
G.729 decoder main code
(just skeleton, contains only parts, explicitly ok'ed by Michael) Originally committed as revision 14800 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/g729.h52
-rw-r--r--libavcodec/g729dec.c52
2 files changed, 104 insertions, 0 deletions
diff --git a/libavcodec/g729.h b/libavcodec/g729.h
new file mode 100644
index 0000000000..820221299e
--- /dev/null
+++ b/libavcodec/g729.h
@@ -0,0 +1,52 @@
+/*
+ * G.729 decoder
+ * Copyright (c) 2008 Vladimir Voroshilov
+ *
+ * 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
+ */
+#ifndef FFMPEG_G729_H
+#define FFMPEG_G729_H
+
+#include <stdint.h>
+
+/// Moving Average (MA) prediction order
+#define MA_NP 4
+
+/**
+ * minimum quantized LSF value (3.2.4)
+ * 0.005 in Q13
+ */
+#define LSFQ_MIN 40
+
+/**
+ * maximum quantized LSF value (3.2.4)
+ * 3.135 in Q13
+ */
+#define LSFQ_MAX 25681
+
+/**
+ * minimum LSF distance (3.2.4)
+ * 0.0391 in Q13
+ */
+#define LSFQ_DIFF_MIN 321
+
+/**
+ * maximum possible subframe size
+ */
+#define MAX_SUBFRAME_SIZE 44
+
+#endif // FFMPEG_G729_H
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c
new file mode 100644
index 0000000000..987086453c
--- /dev/null
+++ b/libavcodec/g729dec.c
@@ -0,0 +1,52 @@
+/*
+ * G.729 decoder
+ * Copyright (c) 2008 Vladimir Voroshilov
+ *
+ * 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 <stdlib.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+#include <assert.h>
+
+#include "avcodec.h"
+#include "libavutil/avutil.h"
+#include "bitstream.h"
+
+/**
+ * \brief pseudo random number generator
+ */
+static inline uint16_t g729_random(uint16_t value)
+{
+ return 31821 * value + 13849;
+}
+
+AVCodec g729_decoder =
+{
+ "g729",
+ CODEC_TYPE_AUDIO,
+ CODEC_ID_G729,
+ sizeof(G729_Context),
+ ff_g729_decoder_init,
+ NULL,
+ NULL,
+ ff_g729_decode_frame,
+ .long_name = NULL_IF_CONFIG_SMALL("G.729"),
+};