57 if (memcmp(&buf[1],
"vorbis", 6)) {
62 if (!(buf[29] & 0x1)) {
79 int got_framing_bit, mode_count, got_mode_header, last_mode_count = 0;
94 if (memcmp(&buf[1],
"vorbis", 6)) {
104 for (i = 0; i < buf_size; i++)
105 rev_buf[i] = buf[buf_size - 1 - i];
115 if (!got_framing_bit) {
137 if (
get_bits(&gb0, 6) + 1 == mode_count) {
139 last_mode_count = mode_count;
142 if (!got_mode_header) {
151 if (last_mode_count > 2) {
153 "%d modes (either a false positive or a " 154 "sample from an unknown encoder)",
159 if (last_mode_count > 63) {
174 for (i = mode_count - 1; i >= 0; i--) {
185 const uint8_t *extradata,
int extradata_size)
187 const uint8_t *header_start[3];
196 header_start, header_len)) < 0) {
214 int buf_size,
int *
flags)
219 int mode, current_blocksize;
230 else if (buf[0] == 3)
232 else if (buf[0] == 5)
257 duration = (previous_blocksize + current_blocksize) >> 2;
299 #if CONFIG_VORBIS_PARSER 301 typedef struct VorbisParseContext {
303 } VorbisParseContext;
306 const uint8_t **poutbuf,
int *poutbuf_size,
325 *poutbuf_size = buf_size;
337 .priv_data_size =
sizeof(VorbisParseContext),
338 .parser_parse = vorbis_parse,
339 .parser_close = vorbis_parser_close,
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int extradata_parsed
we have attempted to parse extradata
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define LIBAVUTIL_VERSION_INT
static void skip_bits_long(GetBitContext *s, int n)
Skips the specified number of bits.
int mode_count
number of modes
AVVorbisParseContext * av_vorbis_parse_init(const uint8_t *extradata, int extradata_size)
Allocate and initialize the Vorbis parser using headers in the extradata.
const char * av_default_item_name(void *ptr)
Return the context name.
int duration
Duration of the current frame.
int prev_mask
bitmask used to get the previous mode flag in each packet
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static av_cold int end(AVCodecContext *avctx)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int get_bits_count(const GetBitContext *s)
bitstream reader API header.
static int get_bits_left(GetBitContext *gb)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void av_vorbis_parse_free(AVVorbisParseContext **s)
Free the parser and everything associated with it.
int valid_extradata
extradata is valid, so we can calculate duration
static int vorbis_parse_init(AVVorbisParseContext *s, const uint8_t *extradata, int extradata_size)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
#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. ...
int previous_blocksize
previous window size
#define VORBIS_FLAG_COMMENT
int mode_mask
bitmask used to get the mode in each packet
AVCodecParser ff_vorbis_parser
#define VORBIS_FLAG_HEADER
main external API structure.
static unsigned int get_bits1(GetBitContext *s)
Describe the class of an AVClass context structure.
static void skip_bits(GetBitContext *s, int n)
static const AVClass vorbis_parser_class
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
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 blocksize[2]
short and long window sizes
static int parse_id_header(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
Get the duration for a Vorbis packet.
static int parse_setup_header(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
int mode_blocksize[64]
window size mapping for each mode
mode
Use these values in ebur128_init (or'ed).
void av_vorbis_parse_reset(AVVorbisParseContext *s)