Go to the documentation of this file.
28 #include "config_components.h"
44 const uint8_t *buf,
int buf_size)
59 if (memcmp(&buf[1],
"vorbis", 6)) {
64 if (!(buf[29] & 0x1)) {
69 s->blocksize[0] = 1 << (buf[28] & 0xF);
70 s->blocksize[1] = 1 << (buf[28] >> 4);
76 const uint8_t *buf,
int buf_size)
81 int got_framing_bit, mode_count, got_mode_header, last_mode_count = 0;
96 if (memcmp(&buf[1],
"vorbis", 6)) {
106 for (
i = 0;
i < buf_size;
i++)
107 rev_buf[
i] = buf[buf_size - 1 -
i];
117 if (!got_framing_bit) {
139 if (
get_bits(&gb0, 6) + 1 == mode_count) {
141 last_mode_count = mode_count;
144 if (!got_mode_header) {
153 if (last_mode_count > 2) {
155 "%d modes (either a false positive or a "
156 "sample from an unknown encoder)",
161 if (last_mode_count > 63) {
167 s->mode_count = mode_count = last_mode_count;
170 s->mode_mask = ((1 << (
av_log2(mode_count - 1) + 1)) - 1) << 1;
172 s->prev_mask = (
s->mode_mask | 0x1) + 1;
176 for (
i = mode_count - 1;
i >= 0;
i--) {
187 const uint8_t *extradata,
int extradata_size)
189 const uint8_t *header_start[3];
194 s->extradata_parsed = 1;
198 header_start, header_len)) < 0) {
209 s->valid_extradata = 1;
210 s->previous_blocksize =
s->blocksize[
s->mode_blocksize[0]];
216 int buf_size,
int *
flags)
220 if (
s->valid_extradata && buf_size > 0) {
221 int mode, current_blocksize;
222 int previous_blocksize =
s->previous_blocksize;
232 else if (buf[0] == 3)
234 else if (buf[0] == 5)
247 if (
s->mode_count == 1)
250 mode = (buf[0] &
s->mode_mask) >> 1;
251 if (
mode >=
s->mode_count) {
255 if(
s->mode_blocksize[
mode]){
256 int flag = !!(buf[0] &
s->prev_mask);
257 previous_blocksize =
s->blocksize[
flag];
259 current_blocksize =
s->blocksize[
s->mode_blocksize[
mode]];
260 duration = (previous_blocksize + current_blocksize) >> 2;
261 s->previous_blocksize = current_blocksize;
275 if (
s->valid_extradata)
276 s->previous_blocksize =
s->blocksize[0];
302 #if CONFIG_VORBIS_PARSER
304 typedef struct VorbisParseContext {
306 } VorbisParseContext;
309 const uint8_t **poutbuf,
int *poutbuf_size,
310 const uint8_t *buf,
int buf_size)
328 *poutbuf_size = buf_size;
340 .priv_data_size =
sizeof(VorbisParseContext),
341 .parser_parse = vorbis_parse,
342 .parser_close = vorbis_parser_close,
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
void av_vorbis_parse_free(AVVorbisParseContext **s)
Free the parser and everything associated with it.
static int get_bits_left(GetBitContext *gb)
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf, int buf_size, int *flags)
Get the duration for a Vorbis packet.
int duration
Duration of the current frame.
static int get_bits_count(const GetBitContext *s)
#define AV_LOG_VERBOSE
Detailed information.
int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
Get the duration for a Vorbis packet.
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
static void skip_bits(GetBitContext *s, int n)
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define VORBIS_FLAG_COMMENT
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
static int parse_id_header(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
#define VORBIS_FLAG_HEADER
const char * av_default_item_name(void *ptr)
Return the context name.
static unsigned int get_bits1(GetBitContext *s)
static const AVClass vorbis_parser_class
#define i(width, name, range_min, range_max)
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static int vorbis_parse_init(AVVorbisParseContext *s, const uint8_t *extradata, int extradata_size)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
AVVorbisParseContext * av_vorbis_parse_init(const uint8_t *extradata, int extradata_size)
Allocate and initialize the Vorbis parser using headers in the extradata.
main external API structure.
#define VORBIS_FLAG_SETUP
int avpriv_split_xiph_headers(const uint8_t *extradata, int extradata_size, int first_header_size, const uint8_t *header_start[3], int header_len[3])
Split a single extradata buffer into the three headers that most Xiph codecs use.
const AVCodecParser ff_vorbis_parser
void av_vorbis_parse_reset(AVVorbisParseContext *s)
#define avpriv_request_sample(...)
#define flags(name, subs,...)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int parse_setup_header(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
void * priv_data
Format private data.