44 int i, cnum, h, m, s, ms, keylen = strlen(key);
47 if (keylen < 9 || sscanf(key,
"CHAPTER%03d", &cnum) != 1)
51 if (sscanf(val,
"%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4)
55 ms + 1000 * (s + 60 * (m + 60 * h)),
58 }
else if (!strcmp(key + keylen - 4,
"NAME")) {
101 s = bytestream_get_le32(&p);
103 if (end - p - 4 < s || s < 0)
108 n = bytestream_get_le32(&p);
110 while (end - p >= 4 && n > 0) {
114 s = bytestream_get_le32(&p);
116 if (end - p < s || s < 0)
123 v = memchr(t,
'=', s);
142 for (j = 0; j < tl; j++)
155 if (!strcmp(tt,
"METADATA_BLOCK_PICTURE") && parse_picture) {
184 "%ti bytes of comment header remain\n", end - p);
187 "truncated comment header, %i comments not found\n", n);
221 int i, offset,
len, err;
224 len = priv->
len[0] + priv->
len[1] + priv->
len[2];
225 ptr = *buf =
av_mallocz(len + len / 255 + 64);
233 for (i = 0; i < 3; i++) {
234 memcpy(&ptr[offset], priv->
packet[i], priv->
len[i]);
235 offset += priv->
len[i];
251 for (i = 0; i < 3; i++)
273 if (os->
psize < 1 || pkt_type > 5)
278 if (priv->
packet[pkt_type >> 1])
280 if (pkt_type > 1 && !priv->
packet[0] || pkt_type > 3 && !priv->
packet[1])
283 priv->
len[pkt_type >> 1] = os->
psize;
285 if (!priv->
packet[pkt_type >> 1])
290 unsigned blocksize, bs0, bs1;
296 if (bytestream_get_le32(&p) != 0)
300 srate = bytestream_get_le32(&p);
305 blocksize = bytestream_get_byte(&p);
306 bs0 = blocksize & 15;
307 bs1 = blocksize >> 4;
311 if (bs0 < 6 || bs1 > 13)
314 if (bytestream_get_byte(&p) != 1)
327 os->
psize - 8) >= 0) {
336 if (new_len >= 16 && new_len < os->psize) {
338 priv->
packet[1][new_len - 1] = 1;
339 priv->
len[1] = new_len;
379 int first_duration = 0;
383 for (seg = 0; seg < os->
nsegs; seg++) {
393 last_pkt = next_pkt + os->
segments[seg];
435 .
magic =
"\001vorbis",
unsigned int nb_chapters
Number of chapters in AVChapter array.
int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st, const uint8_t *buf, int size)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int vorbis_header(AVFormatContext *s, int idx)
Copyright (C) 2005 Michael Ahlberg, Måns Rullgård.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int fixup_vorbis_headers(AVFormatContext *as, struct oggvorbis_private *priv, uint8_t **buf)
int event_flags
Flags for the user to detect events happening on the stream.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVVorbisParseContext * av_vorbis_parse_init(const uint8_t *extradata, int extradata_size)
Allocate and initialize the Vorbis parser using headers in the extradata.
av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (%s)\, len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic ? ac->func_descr_generic :ac->func_descr)
int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, const uint8_t *buf, int size, int parse_picture)
unsigned char * packet[3]
#define AV_DICT_DONT_STRDUP_KEY
Take ownership of a key that's been allocated with av_malloc() and children.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
int id
unique ID to identify the chapter
AVStream ** streams
A list of all streams in the file.
A public API for Vorbis parsing.
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
static void vorbis_cleanup(AVFormatContext *s, int idx)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void av_vorbis_parse_free(AVVorbisParseContext **s)
Free the parser and everything associated with it.
enum AVMediaType codec_type
General type of the encoded data.
int extradata_size
Size of the extradata content in bytes.
int bit_rate
The average bitrate of the encoded data (in bits per second).
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() and children.
struct ogg_stream * streams
static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
#define AV_LOG_INFO
Standard information.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
static av_const int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
rational number numerator/denominator
AVVorbisParseContext * vp
int64_t duration
Decoding: duration of the stream, in stream time base.
int sample_rate
Audio only.
int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, int buf_size)
Get the duration for a Vorbis packet.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
static int vorbis_packet(AVFormatContext *s, int idx)
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void * priv_data
Format private data.
const struct ogg_codec ff_vorbis_codec
int av_base64_decode(uint8_t *out, const char *in, int out_size)
Decode a base64-encoded string.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
AVCodecParameters * codecpar
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AV_NOPTS_VALUE
Undefined timestamp value.
void av_vorbis_parse_reset(AVVorbisParseContext *s)