* 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>
... | ... |
@@ -15,6 +15,9 @@ libavutil: 2014-08-09 |
15 | 15 |
|
16 | 16 |
API changes, most recent first: |
17 | 17 |
|
18 |
+2014-11-xx - xxxxxxx - lavc 56.6.0 - vorbis_parser.h |
|
19 |
+ Add a public API for parsing vorbis packets. |
|
20 |
+ |
|
18 | 21 |
2014-10-xx - xxxxxxx - lavc 56.5.0 - avcodec.h |
19 | 22 |
Replace AVCodecContext.time_base used for decoding |
20 | 23 |
with AVCodecContext.framerate. |
... | ... |
@@ -11,6 +11,7 @@ HEADERS = avcodec.h \ |
11 | 11 |
vda.h \ |
12 | 12 |
vdpau.h \ |
13 | 13 |
version.h \ |
14 |
+ vorbis_parser.h \ |
|
14 | 15 |
xvmc.h \ |
15 | 16 |
|
16 | 17 |
OBJS = allcodecs.o \ |
... | ... |
@@ -31,6 +32,7 @@ OBJS = allcodecs.o \ |
31 | 31 |
resample.o \ |
32 | 32 |
resample2.o \ |
33 | 33 |
utils.o \ |
34 |
+ vorbis_parser.o \ |
|
34 | 35 |
|
35 | 36 |
# subsystems |
36 | 37 |
OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o |
... | ... |
@@ -677,7 +679,7 @@ OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o |
677 | 677 |
OBJS-$(CONFIG_CAF_DEMUXER) += mpeg4audio.o mpegaudiodata.o \ |
678 | 678 |
ac3tab.o |
679 | 679 |
OBJS-$(CONFIG_FLAC_DEMUXER) += flac.o flacdata.o vorbis_data.o \ |
680 |
- vorbis_parser.o xiph.o |
|
680 |
+ xiph.o |
|
681 | 681 |
OBJS-$(CONFIG_FLAC_MUXER) += flac.o flacdata.o vorbis_data.o |
682 | 682 |
OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o |
683 | 683 |
OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o |
... | ... |
@@ -687,7 +689,7 @@ OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o |
687 | 687 |
OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o vorbis_data.o \ |
688 | 688 |
flac.o flacdata.o |
689 | 689 |
OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o \ |
690 |
- vorbis_parser.o xiph.o |
|
690 |
+ xiph.o |
|
691 | 691 |
OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o mpegaudiodata.o \ |
692 | 692 |
flac.o flacdata.o vorbis_data.o xiph.o |
693 | 693 |
OBJS-$(CONFIG_MP2_MUXER) += mpegaudiodata.o mpegaudiodecheader.o |
... | ... |
@@ -700,7 +702,7 @@ OBJS-$(CONFIG_MXF_MUXER) += dnxhddata.o |
700 | 700 |
OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o |
701 | 701 |
OBJS-$(CONFIG_OGA_MUXER) += xiph.o flac.o flacdata.o |
702 | 702 |
OBJS-$(CONFIG_OGG_DEMUXER) += xiph.o flac.o flacdata.o \ |
703 |
- mpeg12data.o vorbis_parser.o \ |
|
703 |
+ mpeg12data.o \ |
|
704 | 704 |
dirac.o vorbis_data.o |
705 | 705 |
OBJS-$(CONFIG_OGG_MUXER) += xiph.o flac.o flacdata.o \ |
706 | 706 |
vorbis_data.o |
... | ... |
@@ -712,7 +714,7 @@ OBJS-$(CONFIG_TAK_DEMUXER) += tak.o |
712 | 712 |
OBJS-$(CONFIG_WEBM_MUXER) += mpeg4audio.o mpegaudiodata.o \ |
713 | 713 |
xiph.o flac.o flacdata.o \ |
714 | 714 |
vorbis_data.o |
715 |
-OBJS-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER) += vorbis_parser.o xiph.o |
|
715 |
+OBJS-$(CONFIG_WEBM_DASH_MANIFEST_DEMUXER) += xiph.o |
|
716 | 716 |
OBJS-$(CONFIG_WTV_DEMUXER) += mpeg4audio.o mpegaudiodata.o |
717 | 717 |
|
718 | 718 |
# libavfilter dependencies |
... | ... |
@@ -756,7 +758,7 @@ OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o |
756 | 756 |
OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o |
757 | 757 |
OBJS-$(CONFIG_LIBVORBIS_DECODER) += libvorbisdec.o |
758 | 758 |
OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbisenc.o \ |
759 |
- vorbis_data.o vorbis_parser.o xiph.o |
|
759 |
+ vorbis_data.o xiph.o |
|
760 | 760 |
OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o |
761 | 761 |
OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o |
762 | 762 |
OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o |
... | ... |
@@ -812,7 +814,7 @@ OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o |
812 | 812 |
OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o vc1dsp.o \ |
813 | 813 |
msmpeg4.o msmpeg4data.o mpeg4video.o \ |
814 | 814 |
h263.o |
815 |
-OBJS-$(CONFIG_VORBIS_PARSER) += vorbis_parser.o xiph.o |
|
815 |
+OBJS-$(CONFIG_VORBIS_PARSER) += xiph.o |
|
816 | 816 |
OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o |
817 | 817 |
OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o |
818 | 818 |
OBJS-$(CONFIG_VP9_PARSER) += vp9_parser.o |
... | ... |
@@ -29,8 +29,8 @@ |
29 | 29 |
#include "libavutil/version.h" |
30 | 30 |
|
31 | 31 |
#define LIBAVCODEC_VERSION_MAJOR 56 |
32 |
-#define LIBAVCODEC_VERSION_MINOR 10 |
|
33 |
-#define LIBAVCODEC_VERSION_MICRO 102 |
|
32 |
+#define LIBAVCODEC_VERSION_MINOR 11 |
|
33 |
+#define LIBAVCODEC_VERSION_MICRO 100 |
|
34 | 34 |
|
35 | 35 |
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
36 | 36 |
LIBAVCODEC_VERSION_MINOR, \ |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
#include "get_bits.h" |
31 | 31 |
#include "parser.h" |
32 | 32 |
#include "xiph.h" |
33 |
-#include "vorbis_parser.h" |
|
33 |
+#include "vorbis_parser_internal.h" |
|
34 | 34 |
|
35 | 35 |
static const AVClass vorbis_parser_class = { |
36 | 36 |
.class_name = "Vorbis parser", |
... | ... |
@@ -181,7 +181,8 @@ bad_header: |
181 | 181 |
return ret; |
182 | 182 |
} |
183 | 183 |
|
184 |
-int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s) |
|
184 |
+static int vorbis_parse_init(AVVorbisParseContext *s, |
|
185 |
+ const uint8_t *extradata, int extradata_size) |
|
185 | 186 |
{ |
186 | 187 |
uint8_t *header_start[3]; |
187 | 188 |
int header_len[3]; |
... | ... |
@@ -190,8 +191,8 @@ int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s |
190 | 190 |
s->class = &vorbis_parser_class; |
191 | 191 |
s->extradata_parsed = 1; |
192 | 192 |
|
193 |
- if ((ret = avpriv_split_xiph_headers(avctx->extradata, |
|
194 |
- avctx->extradata_size, 30, |
|
193 |
+ if ((ret = avpriv_split_xiph_headers(extradata, |
|
194 |
+ extradata_size, 30, |
|
195 | 195 |
header_start, header_len)) < 0) { |
196 | 196 |
av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); |
197 | 197 |
return ret; |
... | ... |
@@ -258,18 +259,57 @@ bad_packet: |
258 | 258 |
return duration; |
259 | 259 |
} |
260 | 260 |
|
261 |
-int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
|
262 |
- int buf_size) |
|
261 |
+int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
|
262 |
+ int buf_size) |
|
263 | 263 |
{ |
264 | 264 |
return avpriv_vorbis_parse_frame_flags(s, buf, buf_size, NULL); |
265 | 265 |
} |
266 | 266 |
|
267 |
-void avpriv_vorbis_parse_reset(AVVorbisParseContext *s) |
|
267 |
+void av_vorbis_parse_reset(AVVorbisParseContext *s) |
|
268 | 268 |
{ |
269 | 269 |
if (s->valid_extradata) |
270 | 270 |
s->previous_blocksize = s->blocksize[0]; |
271 | 271 |
} |
272 | 272 |
|
273 |
+void av_vorbis_parse_free(AVVorbisParseContext **s) |
|
274 |
+{ |
|
275 |
+ av_freep(s); |
|
276 |
+} |
|
277 |
+ |
|
278 |
+AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, |
|
279 |
+ int extradata_size) |
|
280 |
+{ |
|
281 |
+ AVVorbisParseContext *s = av_mallocz(sizeof(*s)); |
|
282 |
+ int ret; |
|
283 |
+ |
|
284 |
+ if (!s) |
|
285 |
+ return NULL; |
|
286 |
+ |
|
287 |
+ ret = vorbis_parse_init(s, extradata, extradata_size); |
|
288 |
+ if (ret < 0) { |
|
289 |
+ av_vorbis_parse_free(&s); |
|
290 |
+ return NULL; |
|
291 |
+ } |
|
292 |
+ |
|
293 |
+ return s; |
|
294 |
+} |
|
295 |
+ |
|
296 |
+#if LIBAVCODEC_VERSION_MAJOR < 57 |
|
297 |
+int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s) |
|
298 |
+{ |
|
299 |
+ return vorbis_parse_init(s, avctx->extradata, avctx->extradata_size); |
|
300 |
+} |
|
301 |
+void avpriv_vorbis_parse_reset(AVVorbisParseContext *s) |
|
302 |
+{ |
|
303 |
+ av_vorbis_parse_reset(s); |
|
304 |
+} |
|
305 |
+int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
|
306 |
+ int buf_size) |
|
307 |
+{ |
|
308 |
+ return av_vorbis_parse_frame(s, buf, buf_size); |
|
309 |
+} |
|
310 |
+#endif |
|
311 |
+ |
|
273 | 312 |
#if CONFIG_VORBIS_PARSER |
274 | 313 |
static int vorbis_parse(AVCodecParserContext *s1, AVCodecContext *avctx, |
275 | 314 |
const uint8_t **poutbuf, int *poutbuf_size, |
... | ... |
@@ -1,5 +1,4 @@ |
1 | 1 |
/* |
2 |
- * Copyright (c) 2012 Justin Ruggles |
|
3 | 2 |
* |
4 | 3 |
* This file is part of FFmpeg. |
5 | 4 |
* |
... | ... |
@@ -20,35 +19,29 @@ |
20 | 20 |
|
21 | 21 |
/** |
22 | 22 |
* @file |
23 |
- * Vorbis audio parser |
|
23 |
+ * A public API for Vorbis parsing |
|
24 | 24 |
* |
25 | 25 |
* Determines the duration for each packet. |
26 | 26 |
*/ |
27 | 27 |
|
28 |
-#ifndef AVCODEC_VORBIS_PARSER_H |
|
29 |
-#define AVCODEC_VORBIS_PARSER_H |
|
28 |
+#ifndef AVCODEC_VORBIS_PARSE_H |
|
29 |
+#define AVCODEC_VORBIS_PARSE_H |
|
30 | 30 |
|
31 |
-#include "avcodec.h" |
|
32 |
- |
|
33 |
-typedef struct AVVorbisParseContext { |
|
34 |
- const AVClass *class; |
|
35 |
- int extradata_parsed; ///< we have attempted to parse extradata |
|
36 |
- int valid_extradata; ///< extradata is valid, so we can calculate duration |
|
37 |
- int blocksize[2]; ///< short and long window sizes |
|
38 |
- int previous_blocksize; ///< previous window size |
|
39 |
- int mode_blocksize[64]; ///< window size mapping for each mode |
|
40 |
- int mode_count; ///< number of modes |
|
41 |
- int mode_mask; ///< bitmask used to get the mode in each packet |
|
42 |
- int prev_mask; ///< bitmask used to get the previous mode flag in each packet |
|
43 |
-} AVVorbisParseContext; |
|
31 |
+typedef struct AVVorbisParseContext AVVorbisParseContext; |
|
44 | 32 |
|
45 | 33 |
/** |
46 |
- * Initialize the Vorbis parser using headers in the extradata. |
|
34 |
+ * Allocate and initialize the Vorbis parser using headers in the extradata. |
|
47 | 35 |
* |
48 | 36 |
* @param avctx codec context |
49 | 37 |
* @param s Vorbis parser context |
50 | 38 |
*/ |
51 |
-int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s); |
|
39 |
+AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, |
|
40 |
+ int extradata_size); |
|
41 |
+ |
|
42 |
+/** |
|
43 |
+ * Free the parser and everything associated with it. |
|
44 |
+ */ |
|
45 |
+void av_vorbis_parse_free(AVVorbisParseContext **s); |
|
52 | 46 |
|
53 | 47 |
#define VORBIS_FLAG_HEADER 0x00000001 |
54 | 48 |
#define VORBIS_FLAG_COMMENT 0x00000002 |
... | ... |
@@ -71,16 +64,13 @@ int avpriv_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf, |
71 | 71 |
/** |
72 | 72 |
* Get the duration for a Vorbis packet. |
73 | 73 |
* |
74 |
- * avpriv_vorbis_parse_extradata() must have been successfully called prior to |
|
75 |
- * this in order for a correct duration to be returned. |
|
76 |
- * |
|
77 | 74 |
* @param s Vorbis parser context |
78 | 75 |
* @param buf buffer containing a Vorbis frame |
79 | 76 |
* @param buf_size size of the buffer |
80 | 77 |
*/ |
81 |
-int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
|
82 |
- int buf_size); |
|
78 |
+int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
|
79 |
+ int buf_size); |
|
83 | 80 |
|
84 |
-void avpriv_vorbis_parse_reset(AVVorbisParseContext *s); |
|
81 |
+void av_vorbis_parse_reset(AVVorbisParseContext *s); |
|
85 | 82 |
|
86 |
-#endif /* AVCODEC_VORBIS_PARSER_H */ |
|
83 |
+#endif /* AVCODEC_VORBIS_PARSE_H */ |
87 | 84 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,71 @@ |
0 |
+/* |
|
1 |
+ * Copyright (c) 2012 Justin Ruggles |
|
2 |
+ * |
|
3 |
+ * This file is part of FFmpeg. |
|
4 |
+ * |
|
5 |
+ * FFmpeg is free software; you can redistribute it and/or |
|
6 |
+ * modify it under the terms of the GNU Lesser General Public |
|
7 |
+ * License as published by the Free Software Foundation; either |
|
8 |
+ * version 2.1 of the License, or (at your option) any later version. |
|
9 |
+ * |
|
10 |
+ * FFmpeg is distributed in the hope that it will be useful, |
|
11 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 |
+ * Lesser General Public License for more details. |
|
14 |
+ * |
|
15 |
+ * You should have received a copy of the GNU Lesser General Public |
|
16 |
+ * License along with FFmpeg; if not, write to the Free Software |
|
17 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
18 |
+ */ |
|
19 |
+ |
|
20 |
+/** |
|
21 |
+ * @file |
|
22 |
+ * Vorbis audio parser |
|
23 |
+ * |
|
24 |
+ * Determines the duration for each packet. |
|
25 |
+ */ |
|
26 |
+ |
|
27 |
+#ifndef AVCODEC_VORBIS_PARSER_H |
|
28 |
+#define AVCODEC_VORBIS_PARSER_H |
|
29 |
+ |
|
30 |
+#include "avcodec.h" |
|
31 |
+#include "vorbis_parser.h" |
|
32 |
+ |
|
33 |
+struct AVVorbisParseContext { |
|
34 |
+ const AVClass *class; |
|
35 |
+ int extradata_parsed; ///< we have attempted to parse extradata |
|
36 |
+ int valid_extradata; ///< extradata is valid, so we can calculate duration |
|
37 |
+ int blocksize[2]; ///< short and long window sizes |
|
38 |
+ int previous_blocksize; ///< previous window size |
|
39 |
+ int mode_blocksize[64]; ///< window size mapping for each mode |
|
40 |
+ int mode_count; ///< number of modes |
|
41 |
+ int mode_mask; ///< bitmask used to get the mode in each packet |
|
42 |
+ int prev_mask; ///< bitmask used to get the previous mode flag in each packet |
|
43 |
+}; |
|
44 |
+ |
|
45 |
+#if LIBAVCODEC_VERSION_MAJOR < 57 |
|
46 |
+/** |
|
47 |
+ * Initialize the Vorbis parser using headers in the extradata. |
|
48 |
+ * |
|
49 |
+ * @param avctx codec context |
|
50 |
+ * @param s Vorbis parser context |
|
51 |
+ */ |
|
52 |
+int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s); |
|
53 |
+ |
|
54 |
+/** |
|
55 |
+ * Get the duration for a Vorbis packet. |
|
56 |
+ * |
|
57 |
+ * avpriv_vorbis_parse_extradata() must have been successfully called prior to |
|
58 |
+ * this in order for a correct duration to be returned. |
|
59 |
+ * |
|
60 |
+ * @param s Vorbis parser context |
|
61 |
+ * @param buf buffer containing a Vorbis frame |
|
62 |
+ * @param buf_size size of the buffer |
|
63 |
+ */ |
|
64 |
+int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
|
65 |
+ int buf_size); |
|
66 |
+ |
|
67 |
+void avpriv_vorbis_parse_reset(AVVorbisParseContext *s); |
|
68 |
+#endif |
|
69 |
+ |
|
70 |
+#endif /* AVCODEC_VORBIS_PARSER_H */ |
... | ... |
@@ -30,7 +30,7 @@ |
30 | 30 |
#include "libavutil/dict.h" |
31 | 31 |
#include "libavcodec/bytestream.h" |
32 | 32 |
#include "libavcodec/get_bits.h" |
33 |
-#include "libavcodec/vorbis_parser.h" |
|
33 |
+#include "libavcodec/vorbis_parser_internal.h" |
|
34 | 34 |
#include "avformat.h" |
35 | 35 |
#include "flac_picture.h" |
36 | 36 |
#include "internal.h" |