aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-11-06 11:21:47 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-11-06 11:21:47 +0100
commit44fa2671e0db0bb1a92c365fb3c9c2d1cd7199ca (patch)
tree3eede210817e4cd60b1a868cfc74ccf6955495a7 /libavcodec
parent5f7887ca8d056d2debdd2c3b205ada7305d9ac07 (diff)
parent5e80fb7ff226f136dbcf3fed00a2966bf8e9bd70 (diff)
downloadffmpeg-44fa2671e0db0bb1a92c365fb3c9c2d1cd7199ca.tar.gz
Merge commit '5e80fb7ff226f136dbcf3fed00a2966bf8e9bd70'
* commit '5e80fb7ff226f136dbcf3fed00a2966bf8e9bd70': lavc: add a public API for parsing vorbis packets. Conflicts: doc/APIchanges libavcodec/Makefile libavcodec/version.h libavcodec/vorbis_parser.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/Makefile14
-rw-r--r--libavcodec/libvorbisenc.c2
-rw-r--r--libavcodec/version.h4
-rw-r--r--libavcodec/vorbis_parser.c54
-rw-r--r--libavcodec/vorbis_parser.h42
-rw-r--r--libavcodec/vorbis_parser_internal.h71
6 files changed, 145 insertions, 42 deletions
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 1a0072a00a..75c1008269 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -11,6 +11,7 @@ HEADERS = avcodec.h \
vda.h \
vdpau.h \
version.h \
+ vorbis_parser.h \
xvmc.h \
OBJS = allcodecs.o \
@@ -31,6 +32,7 @@ OBJS = allcodecs.o \
resample.o \
resample2.o \
utils.o \
+ vorbis_parser.o \
# subsystems
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o
@@ -677,7 +679,7 @@ OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_CAF_DEMUXER) += mpeg4audio.o mpegaudiodata.o \
ac3tab.o
OBJS-$(CONFIG_FLAC_DEMUXER) += flac.o flacdata.o vorbis_data.o \
- vorbis_parser.o xiph.o
+ xiph.o
OBJS-$(CONFIG_FLAC_MUXER) += flac.o flacdata.o vorbis_data.o
OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o
OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o
@@ -687,7 +689,7 @@ OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o
OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o vorbis_data.o \
flac.o flacdata.o
OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o \
- vorbis_parser.o xiph.o
+ xiph.o
OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o mpegaudiodata.o \
flac.o flacdata.o vorbis_data.o xiph.o
OBJS-$(CONFIG_MP2_MUXER) += mpegaudiodata.o mpegaudiodecheader.o
@@ -700,7 +702,7 @@ OBJS-$(CONFIG_MXF_MUXER) += dnxhddata.o
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o
OBJS-$(CONFIG_OGA_MUXER) += xiph.o flac.o flacdata.o
OBJS-$(CONFIG_OGG_DEMUXER) += xiph.o flac.o flacdata.o \
- mpeg12data.o vorbis_parser.o \
+ mpeg12data.o \
dirac.o vorbis_data.o
OBJS-$(CONFIG_OGG_MUXER) += xiph.o flac.o flacdata.o \
vorbis_data.o
@@ -712,7 +714,7 @@ OBJS-$(CONFIG_TAK_DEMUXER) += tak.o
OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o mpegaudiodata.o \
xiph.o flac.o flacdata.o \
vorbis_data.o
-OBJS-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER) += vorbis_parser.o xiph.o
+OBJS-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER) += xiph.o
OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o
# libavfilter dependencies
@@ -756,7 +758,7 @@ OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o
OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o
OBJS-$(CONFIG_LIBVORBIS_DECODER) += libvorbisdec.o
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbisenc.o \
- vorbis_data.o vorbis_parser.o xiph.o
+ vorbis_data.o xiph.o
OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o
OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o
OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o
@@ -812,7 +814,7 @@ OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o
OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o vc1dsp.o \
msmpeg4.o msmpeg4data.o mpeg4video.o \
h263.o
-OBJS-$(CONFIG_VORBIS_PARSER) += vorbis_parser.o xiph.o
+OBJS-$(CONFIG_VORBIS_PARSER) += xiph.o
OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o
OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o
OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o
diff --git a/libavcodec/libvorbisenc.c b/libavcodec/libvorbisenc.c
index 0feb6813b8..197f863c7b 100644
--- a/libavcodec/libvorbisenc.c
+++ b/libavcodec/libvorbisenc.c
@@ -27,7 +27,7 @@
#include "audio_frame_queue.h"
#include "internal.h"
#include "vorbis.h"
-#include "vorbis_parser.h"
+#include "vorbis_parser_internal.h"
/* Number of samples the user should send in each call.
diff --git a/libavcodec/version.h b/libavcodec/version.h
index c0fd2595ec..28ceb4d7a8 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,8 +29,8 @@
#include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 56
-#define LIBAVCODEC_VERSION_MINOR 10
-#define LIBAVCODEC_VERSION_MICRO 102
+#define LIBAVCODEC_VERSION_MINOR 11
+#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
diff --git a/libavcodec/vorbis_parser.c b/libavcodec/vorbis_parser.c
index 30843294cf..0c93e31dca 100644
--- a/libavcodec/vorbis_parser.c
+++ b/libavcodec/vorbis_parser.c
@@ -30,7 +30,7 @@
#include "get_bits.h"
#include "parser.h"
#include "xiph.h"
-#include "vorbis_parser.h"
+#include "vorbis_parser_internal.h"
static const AVClass vorbis_parser_class = {
.class_name = "Vorbis parser",
@@ -181,7 +181,8 @@ bad_header:
return ret;
}
-int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s)
+static int vorbis_parse_init(AVVorbisParseContext *s,
+ const uint8_t *extradata, int extradata_size)
{
uint8_t *header_start[3];
int header_len[3];
@@ -190,8 +191,8 @@ int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s
s->class = &vorbis_parser_class;
s->extradata_parsed = 1;
- if ((ret = avpriv_split_xiph_headers(avctx->extradata,
- avctx->extradata_size, 30,
+ if ((ret = avpriv_split_xiph_headers(extradata,
+ extradata_size, 30,
header_start, header_len)) < 0) {
av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n");
return ret;
@@ -258,18 +259,57 @@ bad_packet:
return duration;
}
-int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
- int buf_size)
+int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
+ int buf_size)
{
return avpriv_vorbis_parse_frame_flags(s, buf, buf_size, NULL);
}
-void avpriv_vorbis_parse_reset(AVVorbisParseContext *s)
+void av_vorbis_parse_reset(AVVorbisParseContext *s)
{
if (s->valid_extradata)
s->previous_blocksize = s->blocksize[0];
}
+void av_vorbis_parse_free(AVVorbisParseContext **s)
+{
+ av_freep(s);
+}
+
+AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata,
+ int extradata_size)
+{
+ AVVorbisParseContext *s = av_mallocz(sizeof(*s));
+ int ret;
+
+ if (!s)
+ return NULL;
+
+ ret = vorbis_parse_init(s, extradata, extradata_size);
+ if (ret < 0) {
+ av_vorbis_parse_free(&s);
+ return NULL;
+ }
+
+ return s;
+}
+
+#if LIBAVCODEC_VERSION_MAJOR < 57
+int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s)
+{
+ return vorbis_parse_init(s, avctx->extradata, avctx->extradata_size);
+}
+void avpriv_vorbis_parse_reset(AVVorbisParseContext *s)
+{
+ av_vorbis_parse_reset(s);
+}
+int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
+ int buf_size)
+{
+ return av_vorbis_parse_frame(s, buf, buf_size);
+}
+#endif
+
#if CONFIG_VORBIS_PARSER
static int vorbis_parse(AVCodecParserContext *s1, AVCodecContext *avctx,
const uint8_t **poutbuf, int *poutbuf_size,
diff --git a/libavcodec/vorbis_parser.h b/libavcodec/vorbis_parser.h
index 6e9a319e50..4af60cf827 100644
--- a/libavcodec/vorbis_parser.h
+++ b/libavcodec/vorbis_parser.h
@@ -1,5 +1,4 @@
/*
- * Copyright (c) 2012 Justin Ruggles
*
* This file is part of FFmpeg.
*
@@ -20,35 +19,29 @@
/**
* @file
- * Vorbis audio parser
+ * A public API for Vorbis parsing
*
* Determines the duration for each packet.
*/
-#ifndef AVCODEC_VORBIS_PARSER_H
-#define AVCODEC_VORBIS_PARSER_H
+#ifndef AVCODEC_VORBIS_PARSE_H
+#define AVCODEC_VORBIS_PARSE_H
-#include "avcodec.h"
-
-typedef struct AVVorbisParseContext {
- const AVClass *class;
- int extradata_parsed; ///< we have attempted to parse extradata
- int valid_extradata; ///< extradata is valid, so we can calculate duration
- int blocksize[2]; ///< short and long window sizes
- int previous_blocksize; ///< previous window size
- int mode_blocksize[64]; ///< window size mapping for each mode
- int mode_count; ///< number of modes
- int mode_mask; ///< bitmask used to get the mode in each packet
- int prev_mask; ///< bitmask used to get the previous mode flag in each packet
-} AVVorbisParseContext;
+typedef struct AVVorbisParseContext AVVorbisParseContext;
/**
- * Initialize the Vorbis parser using headers in the extradata.
+ * Allocate and initialize the Vorbis parser using headers in the extradata.
*
* @param avctx codec context
* @param s Vorbis parser context
*/
-int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s);
+AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata,
+ int extradata_size);
+
+/**
+ * Free the parser and everything associated with it.
+ */
+void av_vorbis_parse_free(AVVorbisParseContext **s);
#define VORBIS_FLAG_HEADER 0x00000001
#define VORBIS_FLAG_COMMENT 0x00000002
@@ -71,16 +64,13 @@ int avpriv_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf,
/**
* Get the duration for a Vorbis packet.
*
- * avpriv_vorbis_parse_extradata() must have been successfully called prior to
- * this in order for a correct duration to be returned.
- *
* @param s Vorbis parser context
* @param buf buffer containing a Vorbis frame
* @param buf_size size of the buffer
*/
-int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
- int buf_size);
+int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
+ int buf_size);
-void avpriv_vorbis_parse_reset(AVVorbisParseContext *s);
+void av_vorbis_parse_reset(AVVorbisParseContext *s);
-#endif /* AVCODEC_VORBIS_PARSER_H */
+#endif /* AVCODEC_VORBIS_PARSE_H */
diff --git a/libavcodec/vorbis_parser_internal.h b/libavcodec/vorbis_parser_internal.h
new file mode 100644
index 0000000000..885793ff52
--- /dev/null
+++ b/libavcodec/vorbis_parser_internal.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2012 Justin Ruggles
+ *
+ * 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
+ */
+
+/**
+ * @file
+ * Vorbis audio parser
+ *
+ * Determines the duration for each packet.
+ */
+
+#ifndef AVCODEC_VORBIS_PARSER_H
+#define AVCODEC_VORBIS_PARSER_H
+
+#include "avcodec.h"
+#include "vorbis_parser.h"
+
+struct AVVorbisParseContext {
+ const AVClass *class;
+ int extradata_parsed; ///< we have attempted to parse extradata
+ int valid_extradata; ///< extradata is valid, so we can calculate duration
+ int blocksize[2]; ///< short and long window sizes
+ int previous_blocksize; ///< previous window size
+ int mode_blocksize[64]; ///< window size mapping for each mode
+ int mode_count; ///< number of modes
+ int mode_mask; ///< bitmask used to get the mode in each packet
+ int prev_mask; ///< bitmask used to get the previous mode flag in each packet
+};
+
+#if LIBAVCODEC_VERSION_MAJOR < 57
+/**
+ * Initialize the Vorbis parser using headers in the extradata.
+ *
+ * @param avctx codec context
+ * @param s Vorbis parser context
+ */
+int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s);
+
+/**
+ * Get the duration for a Vorbis packet.
+ *
+ * avpriv_vorbis_parse_extradata() must have been successfully called prior to
+ * this in order for a correct duration to be returned.
+ *
+ * @param s Vorbis parser context
+ * @param buf buffer containing a Vorbis frame
+ * @param buf_size size of the buffer
+ */
+int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
+ int buf_size);
+
+void avpriv_vorbis_parse_reset(AVVorbisParseContext *s);
+#endif
+
+#endif /* AVCODEC_VORBIS_PARSER_H */