43 int i, cnum,
h,
m,
s, ms, keylen = strlen(key);
46 if (keylen < 9 || sscanf(key,
"CHAPTER%03d", &cnum) != 1)
50 if (sscanf(val,
"%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4)
54 ms + 1000 * (s + 60 * (m + 60 *
h)),
57 }
else if (!strcmp(key + keylen - 4,
"NAME")) {
100 s = bytestream_get_le32(&p);
102 if (end - p - 4 < s || s < 0)
107 n = bytestream_get_le32(&p);
109 while (end - p >= 4 && n > 0) {
113 s = bytestream_get_le32(&p);
115 if (end - p < s || s < 0)
122 v = memchr(t,
'=', s);
141 for (j = 0; j < tl; j++)
154 if (!strcmp(tt,
"METADATA_BLOCK_PICTURE") && parse_picture) {
191 "truncated comment header, %i comments not found\n", n);
229 len = priv->
len[0] + priv->
len[1] + priv->
len[2];
230 buf_len = len + len / 255 + 64;
234 memset(*buf,
'\0', buf_len);
240 for (i = 0; i < 3; i++) {
241 memcpy(&ptr[offset], priv->
packet[i], priv->
len[i]);
242 offset += priv->
len[i];
258 for (i = 0; i < 3; i++)
312 if (os->
psize < 1 || pkt_type > 5)
315 if (priv->
packet[pkt_type >> 1])
317 if (pkt_type > 1 && !priv->
packet[0] || pkt_type > 3 && !priv->
packet[1])
320 priv->
len[pkt_type >> 1] = os->
psize;
322 if (!priv->
packet[pkt_type >> 1])
327 unsigned blocksize, bs0, bs1;
334 if (bytestream_get_le32(&p) != 0)
337 channels = bytestream_get_byte(&p);
343 srate = bytestream_get_le32(&p);
348 blocksize = bytestream_get_byte(&p);
349 bs0 = blocksize & 15;
350 bs1 = blocksize >> 4;
354 if (bs0 < 6 || bs1 > 13)
357 if (bytestream_get_byte(&p) != 1)
377 if (new_len >= 16 && new_len < os->psize) {
379 priv->
packet[1][new_len - 1] = 1;
380 priv->
len[1] = new_len;
430 last_pkt = next_pkt = next_pkt + os->
psize;
431 for (; seg < os->
nsegs; seg++) {
437 }
else if (flags & VORBIS_FLAG_COMMENT) {
442 last_pkt = next_pkt + os->
segments[seg];
492 .
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)
const char const char void * val
#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.
AVVorbisParseContext * av_vorbis_parse_init(const uint8_t *extradata, int extradata_size)
Allocate and initialize the Vorbis parser using headers in the extradata.
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() or another memory allocation function...
static av_cold int end(AVCodecContext *avctx)
int id
unique ID to identify the chapter
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream ** streams
A list of all streams in the file.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
A public API for Vorbis parsing.
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
bitstream reader API header.
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)
#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.
#define PTRDIFF_SPECIFIER
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
static const uint8_t offset[127][2]
AVCodecContext * codec
Codec context associated with this stream.
int bit_rate
the average bitrate
unsigned int new_metadata_size
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
struct ogg_stream * streams
static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
#define AV_DICT_APPEND
If the entry already exists, append to it.
int ff_flac_parse_picture(AVFormatContext *s, uint8_t *buf, int buf_size)
static int vorbis_update_metadata(AVFormatContext *s, int idx)
#define VORBIS_FLAG_COMMENT
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
int sample_rate
samples per second
uint8_t * av_packet_pack_dictionary(AVDictionary *dict, int *size)
Pack a dictionary for use in side_data.
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
int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf, int buf_size, int *flags)
Get the duration for a Vorbis packet.
AVVorbisParseContext * vp
int64_t duration
Decoding: duration of the stream, in stream time base.
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
static int vorbis_packet(AVFormatContext *s, int idx)
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#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...
int channels
number of audio channels
void * priv_data
Format private data.
const struct ogg_codec ff_vorbis_codec
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
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)