summaryrefslogtreecommitdiff
path: root/libavcodec/vorbis_parser.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2014-10-29 15:04:23 +0100
committerAnton Khirnov <anton@khirnov.net>2014-11-06 08:51:25 +0100
commit5e80fb7ff226f136dbcf3fed00a2966bf8e9bd70 (patch)
treee82285e196430b371b6efc9c6f3e55c8a1acb220 /libavcodec/vorbis_parser.c
parent6896f95b2483e52e717e2c75a4fd24fcb0e14b67 (diff)
lavc: add a public API for parsing vorbis packets.
It is required by (at least) the ogg demuxer. Mark the current semi-public apriv API for removal.
Diffstat (limited to 'libavcodec/vorbis_parser.c')
-rw-r--r--libavcodec/vorbis_parser.c54
1 files changed, 47 insertions, 7 deletions
diff --git a/libavcodec/vorbis_parser.c b/libavcodec/vorbis_parser.c
index b08846518a..eec37322a8 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;
@@ -209,8 +210,8 @@ int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s
return 0;
}
-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)
{
int duration = 0;
@@ -242,12 +243,51 @@ int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf,
return duration;
}
-void avpriv_vorbis_parse_reset(AVVorbisParseContext *s)
+void av_vorbis_parse_reset(AVVorbisParseContext *s)
{
if (s->valid_extradata)
s->previous_blocksize = s->mode_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,