49 if (memcmp(&buf[1],
"vorbis", 6)) {
54 if (!(buf[29] & 0x1)) {
71 int got_framing_bit, mode_count, got_mode_header, last_mode_count = 0;
86 if (memcmp(&buf[1],
"vorbis", 6)) {
96 for (i = 0; i < buf_size; i++)
97 rev_buf[i] = buf[buf_size - 1 - i];
107 if (!got_framing_bit) {
129 if (
get_bits(&gb0, 6) + 1 == mode_count) {
131 last_mode_count = mode_count;
134 if (!got_mode_header) {
143 if (last_mode_count > 2) {
145 "%d modes (either a false positive or a "
146 "sample from an unknown encoder)",
151 if (last_mode_count > 63) {
166 for (i = mode_count - 1; i >= 0; i--) {
187 header_start, header_len)) < 0) {
192 if ((ret =
parse_id_header(avctx, s, header_start[0], header_len[0])) < 0)
210 int mode, current_blocksize;
230 duration = (previous_blocksize + current_blocksize) >> 2;
243 #if CONFIG_VORBIS_PARSER
245 const uint8_t **poutbuf,
int *poutbuf_size,
262 *poutbuf_size = buf_size;
269 .parser_parse = vorbis_parse,
int avpriv_vorbis_parse_frame(VorbisParseContext *s, const uint8_t *buf, int buf_size)
Get the duration for a Vorbis packet.
int mode_blocksize[64]
window size mapping for each mode
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
int blocksize[2]
short and long window sizes
static void skip_bits_long(GetBitContext *s, int n)
void avpriv_vorbis_parse_reset(VorbisParseContext *s)
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int duration
Duration of the current frame.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int prev_mask
bitmask used to get the previous mode flag in each packet
void void avpriv_request_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
int mode_count
number of modes
int valid_extradata
extradata is valid, so we can calculate duration
static av_cold int end(AVCodecContext *avctx)
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_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
static int parse_id_header(AVCodecContext *avctx, VorbisParseContext *s, const uint8_t *buf, int buf_size)
int mode_mask
bitmask used to get the mode in each packet
void * av_malloc(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int extradata_parsed
we have attempted to parse extradata
main external API structure.
static unsigned int get_bits1(GetBitContext *s)
static void skip_bits(GetBitContext *s, int n)
static int parse_setup_header(AVCodecContext *avctx, VorbisParseContext *s, const uint8_t *buf, int buf_size)
int previous_blocksize
previous window size
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
int avpriv_split_xiph_headers(uint8_t *extradata, int extradata_size, int first_header_size, uint8_t *header_start[3], int header_len[3])
Split a single extradata buffer into the three headers that most Xiph codecs use. ...
#define AVERROR_INVALIDDATA
int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, VorbisParseContext *s)
Initialize the Vorbis parser using headers in the extradata.
AVCodecContext * avctx
codec context