It is required by (at least) the ogg demuxer. Mark the current semi-public apriv API for removal.
Showing the changes to libavcodec (6 of 8 files). Show all
Unified · Split
| @@ -8,6 +8,7 @@ HEADERS = avcodec.h \ · 7 unmodified lines | |||
| 8 | vda.h \ | 8 | vda.h \ |
| 9 | vdpau.h \ | 9 | vdpau.h \ |
| 10 | version.h \ | 10 | version.h \ |
| 11 | vorbis_parser.h \ | ||
| 11 | xvmc.h \ | 12 | xvmc.h \ |
| 12 | 13 | ||
| 13 | OBJS = allcodecs.o \ | 14 | OBJS = allcodecs.o \ |
| @@ -25,6 +26,7 @@ OBJS = allcodecs.o \ · 11 unmodified lines | |||
| 25 | parser.o \ | 26 | parser.o \ |
| 26 | raw.o \ | 27 | raw.o \ |
| 27 | utils.o \ | 28 | utils.o \ |
| 29 | vorbis_parser.o \ | ||
| 28 | 30 | ||
| 29 | # subsystems | 31 | # subsystems |
| 30 | OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o | 32 | OBJS-$(CONFIG_AANDCTTABLES) += aandcttab.o |
| @@ -566,7 +568,7 @@ OBJS-$(CONFIG_ADTS_MUXER) += mpeg4audio.o · 535 unmodified lines | |||
| 566 | OBJS-$(CONFIG_CAF_DEMUXER) += mpeg4audio.o mpegaudiodata.o \ | 568 | OBJS-$(CONFIG_CAF_DEMUXER) += mpeg4audio.o mpegaudiodata.o \ |
| 567 | ac3tab.o | 569 | ac3tab.o |
| 568 | OBJS-$(CONFIG_FLAC_DEMUXER) += flac.o flacdata.o \ | 570 | OBJS-$(CONFIG_FLAC_DEMUXER) += flac.o flacdata.o \ |
| 569 | vorbis_parser.o xiph.o | 571 | xiph.o |
| 570 | OBJS-$(CONFIG_FLAC_MUXER) += flac.o flacdata.o | 572 | OBJS-$(CONFIG_FLAC_MUXER) += flac.o flacdata.o |
| 571 | OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o | 573 | OBJS-$(CONFIG_FLV_DEMUXER) += mpeg4audio.o |
| 572 | OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o | 574 | OBJS-$(CONFIG_GXF_DEMUXER) += mpeg12data.o |
| @@ -576,7 +578,7 @@ OBJS-$(CONFIG_LATM_MUXER) += mpeg4audio.o · 3 unmodified lines | |||
| 576 | OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o \ | 578 | OBJS-$(CONFIG_MATROSKA_AUDIO_MUXER) += xiph.o mpeg4audio.o \ |
| 577 | flac.o flacdata.o | 579 | flac.o flacdata.o |
| 578 | OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o \ | 580 | OBJS-$(CONFIG_MATROSKA_DEMUXER) += mpeg4audio.o mpegaudiodata.o \ |
| 579 | vorbis_parser.o xiph.o | 581 | xiph.o |
| 580 | OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o mpegaudiodata.o \ | 582 | OBJS-$(CONFIG_MATROSKA_MUXER) += mpeg4audio.o mpegaudiodata.o \ |
| 581 | flac.o flacdata.o xiph.o | 583 | flac.o flacdata.o xiph.o |
| 582 | OBJS-$(CONFIG_MP2_MUXER) += mpegaudiodata.o mpegaudiodecheader.o | 584 | OBJS-$(CONFIG_MP2_MUXER) += mpegaudiodata.o mpegaudiodecheader.o |
| @@ -587,7 +589,7 @@ OBJS-$(CONFIG_MPEGTS_MUXER) += mpeg4audio.o · 4 unmodified lines | |||
| 587 | OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o | 589 | OBJS-$(CONFIG_MPEGTS_DEMUXER) += mpeg4audio.o mpegaudiodata.o |
| 588 | OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o | 590 | OBJS-$(CONFIG_NUT_MUXER) += mpegaudiodata.o |
| 589 | OBJS-$(CONFIG_OGG_DEMUXER) += xiph.o flac.o flacdata.o \ | 591 | OBJS-$(CONFIG_OGG_DEMUXER) += xiph.o flac.o flacdata.o \ |
| 590 | mpeg12data.o vorbis_parser.o \ | 592 | mpeg12data.o \ |
| 591 | dirac.o | 593 | dirac.o |
| 592 | OBJS-$(CONFIG_OGG_MUXER) += xiph.o flac.o flacdata.o | 594 | OBJS-$(CONFIG_OGG_MUXER) += xiph.o flac.o flacdata.o |
| 593 | OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o xiph.o | 595 | OBJS-$(CONFIG_RTP_MUXER) += mpeg4audio.o xiph.o |
| @@ -630,7 +632,7 @@ OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o · 36 unmodified lines | |||
| 630 | OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o | 632 | OBJS-$(CONFIG_LIBVO_AACENC_ENCODER) += libvo-aacenc.o mpeg4audio.o |
| 631 | OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o | 633 | OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) += libvo-amrwbenc.o |
| 632 | OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o \ | 634 | OBJS-$(CONFIG_LIBVORBIS_ENCODER) += libvorbis.o \ |
| 633 | vorbis_data.o vorbis_parser.o | 635 | vorbis_data.o |
| 634 | OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o | 636 | OBJS-$(CONFIG_LIBVPX_VP8_DECODER) += libvpxdec.o |
| 635 | OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o | 637 | OBJS-$(CONFIG_LIBVPX_VP8_ENCODER) += libvpxenc.o |
| 636 | OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o | 638 | OBJS-$(CONFIG_LIBVPX_VP9_DECODER) += libvpxdec.o libvpx.o |
| @@ -681,7 +683,7 @@ OBJS-$(CONFIG_TAK_PARSER) += tak_parser.o tak.o · 44 unmodified lines | |||
| 681 | OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o vc1dsp.o \ | 683 | OBJS-$(CONFIG_VC1_PARSER) += vc1_parser.o vc1.o vc1data.o vc1dsp.o \ |
| 682 | msmpeg4.o msmpeg4data.o mpeg4video.o \ | 684 | msmpeg4.o msmpeg4data.o mpeg4video.o \ |
| 683 | h263.o | 685 | h263.o |
| 684 | OBJS-$(CONFIG_VORBIS_PARSER) += vorbis_parser.o xiph.o | 686 | OBJS-$(CONFIG_VORBIS_PARSER) += xiph.o |
| 685 | OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o | 687 | OBJS-$(CONFIG_VP3_PARSER) += vp3_parser.o |
| 686 | OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o | 688 | OBJS-$(CONFIG_VP8_PARSER) += vp8_parser.o |
| 687 | 689 | ||
| @@ -33,7 +33,7 @@ · 32 unmodified lines | |||
| 33 | #include "bytestream.h" | 33 | #include "bytestream.h" |
| 34 | #include "internal.h" | 34 | #include "internal.h" |
| 35 | #include "vorbis.h" | 35 | #include "vorbis.h" |
| 36 | #include "vorbis_parser.h" | 36 | #include "vorbis_parser_internal.h" |
| 37 | 37 | ||
| 38 | #undef NDEBUG | 38 | #undef NDEBUG |
| 39 | #include <assert.h> | 39 | #include <assert.h> |
| @@ -29,8 +29,8 @@ · 28 unmodified lines | |||
| 29 | #include "libavutil/version.h" | 29 | #include "libavutil/version.h" |
| 30 | 30 | ||
| 31 | #define LIBAVCODEC_VERSION_MAJOR 56 | 31 | #define LIBAVCODEC_VERSION_MAJOR 56 |
| 32 | #define LIBAVCODEC_VERSION_MINOR 5 | 32 | #define LIBAVCODEC_VERSION_MINOR 6 |
| 33 | #define LIBAVCODEC_VERSION_MICRO 2 | 33 | #define LIBAVCODEC_VERSION_MICRO 0 |
| 34 | 34 | ||
| 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ | 35 | #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ |
| 36 | LIBAVCODEC_VERSION_MINOR, \ | 36 | LIBAVCODEC_VERSION_MINOR, \ |
| @@ -30,7 +30,7 @@ · 29 unmodified lines | |||
| 30 | #include "get_bits.h" | 30 | #include "get_bits.h" |
| 31 | #include "parser.h" | 31 | #include "parser.h" |
| 32 | #include "xiph.h" | 32 | #include "xiph.h" |
| 33 | #include "vorbis_parser.h" | 33 | #include "vorbis_parser_internal.h" |
| 34 | 34 | ||
| 35 | static const AVClass vorbis_parser_class = { | 35 | static const AVClass vorbis_parser_class = { |
| 36 | .class_name = "Vorbis parser", | 36 | .class_name = "Vorbis parser", |
| @@ -181,7 +181,8 @@ bad_header: · 144 unmodified lines | |||
| 181 | return ret; | 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 | uint8_t *header_start[3]; | 187 | uint8_t *header_start[3]; |
| 187 | int header_len[3]; | 188 | int header_len[3]; |
| @@ -190,8 +191,8 @@ int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s · 2 unmodified lines | |||
| 190 | s->class = &vorbis_parser_class; | 191 | s->class = &vorbis_parser_class; |
| 191 | s->extradata_parsed = 1; | 192 | s->extradata_parsed = 1; |
| 192 | 193 | ||
| 193 | if ((ret = avpriv_split_xiph_headers(avctx->extradata, | 194 | if ((ret = avpriv_split_xiph_headers(extradata, |
| 194 | avctx->extradata_size, 30, | 195 | extradata_size, 30, |
| 195 | header_start, header_len)) < 0) { | 196 | header_start, header_len)) < 0) { |
| 196 | av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); | 197 | av_log(s, AV_LOG_ERROR, "Extradata corrupt.\n"); |
| 197 | return ret; | 198 | return ret; |
| @@ -209,8 +210,8 @@ int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s · 11 unmodified lines | |||
| 209 | return 0; | 210 | return 0; |
| 210 | } | 211 | } |
| 211 | 212 | ||
| 212 | int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, | 213 | int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
| 213 | int buf_size) | 214 | int buf_size) |
| 214 | { | 215 | { |
| 215 | int duration = 0; | 216 | int duration = 0; |
| 216 | 217 | ||
| @@ -242,12 +243,51 @@ int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, · 25 unmodified lines | |||
| 242 | return duration; | 243 | return duration; |
| 243 | } | 244 | } |
| 244 | 245 | ||
| 245 | void avpriv_vorbis_parse_reset(AVVorbisParseContext *s) | 246 | void av_vorbis_parse_reset(AVVorbisParseContext *s) |
| 246 | { | 247 | { |
| 247 | if (s->valid_extradata) | 248 | if (s->valid_extradata) |
| 248 | s->previous_blocksize = s->mode_blocksize[0]; | 249 | s->previous_blocksize = s->mode_blocksize[0]; |
| 249 | } | 250 | } |
| 250 | 251 | ||
| 252 | void av_vorbis_parse_free(AVVorbisParseContext **s) | ||
| 253 | { | ||
| 254 | av_freep(s); | ||
| 255 | } | ||
| 256 | |||
| 257 | AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, | ||
| 258 | int extradata_size) | ||
| 259 | { | ||
| 260 | AVVorbisParseContext *s = av_mallocz(sizeof(*s)); | ||
| 261 | int ret; | ||
| 262 | |||
| 263 | if (!s) | ||
| 264 | return NULL; | ||
| 265 | |||
| 266 | ret = vorbis_parse_init(s, extradata, extradata_size); | ||
| 267 | if (ret < 0) { | ||
| 268 | av_vorbis_parse_free(&s); | ||
| 269 | return NULL; | ||
| 270 | } | ||
| 271 | |||
| 272 | return s; | ||
| 273 | } | ||
| 274 | |||
| 275 | #if LIBAVCODEC_VERSION_MAJOR < 57 | ||
| 276 | int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s) | ||
| 277 | { | ||
| 278 | return vorbis_parse_init(s, avctx->extradata, avctx->extradata_size); | ||
| 279 | } | ||
| 280 | void avpriv_vorbis_parse_reset(AVVorbisParseContext *s) | ||
| 281 | { | ||
| 282 | av_vorbis_parse_reset(s); | ||
| 283 | } | ||
| 284 | int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, | ||
| 285 | int buf_size) | ||
| 286 | { | ||
| 287 | return av_vorbis_parse_frame(s, buf, buf_size); | ||
| 288 | } | ||
| 289 | #endif | ||
| 290 | |||
| 251 | #if CONFIG_VORBIS_PARSER | 291 | #if CONFIG_VORBIS_PARSER |
| 252 | static int vorbis_parse(AVCodecParserContext *s1, AVCodecContext *avctx, | 292 | static int vorbis_parse(AVCodecParserContext *s1, AVCodecContext *avctx, |
| 253 | const uint8_t **poutbuf, int *poutbuf_size, | 293 | const uint8_t **poutbuf, int *poutbuf_size, |
| @@ -1,5 +1,4 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2012 Justin Ruggles | ||
| 3 | * | 2 | * |
| 4 | * This file is part of Libav. | 3 | * This file is part of Libav. |
| 5 | * | 4 | * |
| @@ -20,49 +19,40 @@ · 14 unmodified lines | |||
| 20 | 19 | ||
| 21 | /** | 20 | /** |
| 22 | * @file | 21 | * @file |
| 23 | * Vorbis audio parser | 22 | * A public API for Vorbis parsing |
| 24 | * | 23 | * |
| 25 | * Determines the duration for each packet. | 24 | * Determines the duration for each packet. |
| 26 | */ | 25 | */ |
| 27 | 26 | ||
| 28 | #ifndef AVCODEC_VORBIS_PARSER_H | 27 | #ifndef AVCODEC_VORBIS_PARSE_H |
| 29 | #define AVCODEC_VORBIS_PARSER_H | 28 | #define AVCODEC_VORBIS_PARSE_H |
| 30 | 29 | ||
| 31 | #include "avcodec.h" | 30 | typedef struct AVVorbisParseContext AVVorbisParseContext; |
| 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; | ||
| 44 | 31 | ||
| 45 | /** | 32 | /** |
| 46 | * Initialize the Vorbis parser using headers in the extradata. | 33 | * Allocate and initialize the Vorbis parser using headers in the extradata. |
| 47 | * | 34 | * |
| 48 | * @param avctx codec context | 35 | * @param avctx codec context |
| 49 | * @param s Vorbis parser context | 36 | * @param s Vorbis parser context |
| 50 | */ | 37 | */ |
| 51 | int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s); | 38 | AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, |
| 39 | int extradata_size); | ||
| 40 | |||
| 41 | /** | ||
| 42 | * Free the parser and everything associated with it. | ||
| 43 | */ | ||
| 44 | void av_vorbis_parse_free(AVVorbisParseContext **s); | ||
| 52 | 45 | ||
| 53 | /** | 46 | /** |
| 54 | * Get the duration for a Vorbis packet. | 47 | * Get the duration for a Vorbis packet. |
| 55 | * | 48 | * |
| 56 | * avpriv_vorbis_parse_extradata() must have been successfully called prior to | ||
| 57 | * this in order for a correct duration to be returned. | ||
| 58 | * | ||
| 59 | * @param s Vorbis parser context | 49 | * @param s Vorbis parser context |
| 60 | * @param buf buffer containing a Vorbis frame | 50 | * @param buf buffer containing a Vorbis frame |
| 61 | * @param buf_size size of the buffer | 51 | * @param buf_size size of the buffer |
| 62 | */ | 52 | */ |
| 63 | int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, | 53 | int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, |
| 64 | int buf_size); | 54 | int buf_size); |
| 65 | 55 | ||
| 66 | void avpriv_vorbis_parse_reset(AVVorbisParseContext *s); | 56 | void av_vorbis_parse_reset(AVVorbisParseContext *s); |
| 67 | 57 | ||
| 68 | #endif /* AVCODEC_VORBIS_PARSER_H */ | 58 | #endif /* AVCODEC_VORBIS_PARSE_H */ |
| @@ -0,0 +1,71 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2012 Justin Ruggles | ||
| 3 | * | ||
| 4 | * This file is part of Libav. | ||
| 5 | * | ||
| 6 | * Libav is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU Lesser General Public | ||
| 8 | * License as published by the Free Software Foundation; either | ||
| 9 | * version 2.1 of the License, or (at your option) any later version. | ||
| 10 | * | ||
| 11 | * Libav is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 14 | * Lesser General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU Lesser General Public | ||
| 17 | * License along with Libav; if not, write to the Free Software | ||
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | */ | ||
| 20 | |||
| 21 | /** | ||
| 22 | * @file | ||
| 23 | * Vorbis audio parser | ||
| 24 | * | ||
| 25 | * Determines the duration for each packet. | ||
| 26 | */ | ||
| 27 | |||
| 28 | #ifndef AVCODEC_VORBIS_PARSER_H | ||
| 29 | #define AVCODEC_VORBIS_PARSER_H | ||
| 30 | |||
| 31 | #include "avcodec.h" | ||
| 32 | #include "vorbis_parser.h" | ||
| 33 | |||
| 34 | struct AVVorbisParseContext { | ||
| 35 | const AVClass *class; | ||
| 36 | int extradata_parsed; ///< we have attempted to parse extradata | ||
| 37 | int valid_extradata; ///< extradata is valid, so we can calculate duration | ||
| 38 | int blocksize[2]; ///< short and long window sizes | ||
| 39 | int previous_blocksize; ///< previous window size | ||
| 40 | int mode_blocksize[64]; ///< window size mapping for each mode | ||
| 41 | int mode_count; ///< number of modes | ||
| 42 | int mode_mask; ///< bitmask used to get the mode in each packet | ||
| 43 | int prev_mask; ///< bitmask used to get the previous mode flag in each packet | ||
| 44 | }; | ||
| 45 | |||
| 46 | #if LIBAVCODEC_VERSION_MAJOR < 57 | ||
| 47 | /** | ||
| 48 | * Initialize the Vorbis parser using headers in the extradata. | ||
| 49 | * | ||
| 50 | * @param avctx codec context | ||
| 51 | * @param s Vorbis parser context | ||
| 52 | */ | ||
| 53 | int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, AVVorbisParseContext *s); | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Get the duration for a Vorbis packet. | ||
| 57 | * | ||
| 58 | * avpriv_vorbis_parse_extradata() must have been successfully called prior to | ||
| 59 | * this in order for a correct duration to be returned. | ||
| 60 | * | ||
| 61 | * @param s Vorbis parser context | ||
| 62 | * @param buf buffer containing a Vorbis frame | ||
| 63 | * @param buf_size size of the buffer | ||
| 64 | */ | ||
| 65 | int avpriv_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, | ||
| 66 | int buf_size); | ||
| 67 | |||
| 68 | void avpriv_vorbis_parse_reset(AVVorbisParseContext *s); | ||
| 69 | #endif | ||
| 70 | |||
| 71 | #endif /* AVCODEC_VORBIS_PARSER_H */ | ||