45 int i, cnum,
h, m,
s, ms, keylen = strlen(
key);
52 if (sscanf(
val,
"%02d:%02d:%02d.%03d", &
h, &m, &
s, &ms) < 4)
56 ms + 1000 * (
s + 60 * (m + 60 *
h)),
75 const uint8_t *buf,
int size)
92 const uint8_t *buf, uint32_t
size,
93 int *updates,
int parse_picture)
95 char *t = (
char*)buf, *v = memchr(t,
'=',
size);
120 if (!
av_strcasecmp(t,
"METADATA_BLOCK_PICTURE") && parse_picture) {
150 const uint8_t *buf,
int size,
153 const uint8_t *p = buf;
154 const uint8_t *end = buf +
size;
163 s = bytestream_get_le32(&p);
165 if (end - p - 4 <
s ||
s < 0)
170 n = bytestream_get_le32(&p);
172 while (end - p >= 4 && n > 0) {
173 s = bytestream_get_le32(&p);
175 if (end - p <
s ||
s < 0)
187 "%td bytes of comment header remain\n", end - p);
190 "truncated comment header, %i comments not found\n", n);
240 total_len = (uint64_t)priv->
len[0] + priv->
len[1] + priv->
len[2];
241 if (total_len + total_len / 255 + 64 > INT_MAX)
245 buf_len =
len +
len / 255 + 64;
253 memset(*buf,
'\0', buf_len);
259 for (
i = 0;
i < 3;
i++) {
271 struct ogg *
ogg =
s->priv_data;
277 for (
i = 0;
i < 3;
i++)
283 const uint8_t *buf,
int size)
285 struct ogg *
ogg =
s->priv_data;
309 const uint8_t *p,
unsigned int psize)
311 unsigned blocksize, bs0, bs1;
320 if (bytestream_get_le32(&p) != 0)
330 srate = bytestream_get_le32(&p);
335 blocksize = bytestream_get_byte(&p);
336 bs0 = blocksize & 15;
337 bs1 = blocksize >> 4;
341 if (bs0 < 6 || bs1 > 13)
344 if (bytestream_get_byte(&p) != 1)
366 struct ogg *
ogg =
s->priv_data;
379 struct ogg *
ogg =
s->priv_data;
405 if (priv->
packet[pkt_type >> 1])
407 if (pkt_type > 1 && !priv->
packet[0] || pkt_type > 3 && !priv->
packet[1])
410 priv->
len[pkt_type >> 1] = os->
psize;
412 if (!priv->
packet[pkt_type >> 1])
427 if (new_len >= 16 && new_len < os->psize) {
429 priv->
packet[1][new_len - 1] = 1;
430 priv->
len[1] = new_len;
479 error =
"data packet before the setup header";
483 error =
"identification header before the setup header";
487 error =
"comment header without identification header";
491 error =
"setup header without comment header";
497 "Invalid chained stream headers: %s, discarding them\n",
error);
500 for (
int i = 0;
i < 3;
i++)
509 struct ogg *
ogg =
s->priv_data;
513 int bos, skip_packet = 0;
553 s->streams[idx]->start_time = os->
lastpts;
555 s->streams[idx]->duration -=
s->streams[idx]->start_time;
565 uint8_t *next_pkt = last_pkt;
567 for (seg = os->
segp; seg < os->nsegs; seg++) {
569 if (os->
segments[seg] < 255 && next_pkt != last_pkt) {
695 .magic =
"\001vorbis",
static double val(void *priv, double ch)
static void BS_FUNC skip(BSCTX *bc, unsigned int n)
Skip n bits in the buffer.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
AVChapter * avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
int ff_flac_parse_picture(AVFormatContext *s, uint8_t **bufp, int buf_size, int truncate_workaround)
Parse a FLAC METADATA_BLOCK_PICTURE.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
uint8_t * av_packet_pack_dictionary(const AVDictionary *dict, size_t *size)
Pack a dictionary for use in side_data.
#define AV_BASE64_DECODE_SIZE(x)
Calculate the output size in bytes needed to decode a base64 string with length x to a data buffer.
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
#define AV_DICT_APPEND
If the entry already exists, append to it.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_reallocp(void *ptr, size_t size)
Allocate, reallocate, or free a block of memory through a pointer to a pointer.
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
#define AV_NOPTS_VALUE
Undefined timestamp value.
Memory handling functions.
const struct ogg_codec ff_vorbis_codec
int ff_vorbis_update_metadata(AVFormatContext *s, AVStream *st, const uint8_t *buf, int size)
Parse Vorbis comments, add metadata to an AVStream.
static int vorbis_parse_header(AVFormatContext *s, AVStream *st, const uint8_t *p, unsigned int psize)
static int vorbis_check_packet_order(AVFormatContext *s, struct oggvorbis_private *priv, enum VorbisPacketType type)
Check that a packet follows the identification, comment, setup order of a chained stream's headers,...
int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st, const uint8_t *buf, int size)
Parse Vorbis comments and add metadata to an AVStream.
static int fixup_vorbis_headers(AVFormatContext *as, struct oggvorbis_private *priv, uint8_t **buf)
static void vorbis_cleanup(AVFormatContext *s, int idx)
static int ogm_chapter(AVFormatContext *as, const uint8_t *key, const uint8_t *val)
static int vorbis_update_metadata(AVFormatContext *s, int idx)
int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, const uint8_t *buf, int size, int parse_picture)
Parse Vorbis comments.
static int vorbis_parse_single_comment(AVFormatContext *as, AVDictionary **m, const uint8_t *buf, uint32_t size, int *updates, int parse_picture)
This function temporarily modifies the (const qualified) input buffer and reverts its changes before ...
static int vorbis_packet(AVFormatContext *s, int idx)
static int vorbis_header(AVFormatContext *s, int idx)
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
int nb_channels
Number of channels in this layout.
int64_t id
unique ID to identify the chapter
int extradata_size
Size of the extradata content in bytes.
AVChannelLayout ch_layout
The channel layout and number of channels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
unsigned int nb_chapters
Number of chapters in AVChapter array.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int index
stream index in AVFormatContext
int event_flags
Flags indicating events happening on the stream, a combination of AVSTREAM_EVENT_FLAG_*.
Copyright (C) 2005 Michael Ahlberg, Måns Rullgård.
size_t new_extradata_size
int end_trimming
set the number of packets to drop from the end
int page_start
current packet is the first one starting in the page
int64_t page_pos
file offset of the current page
struct ogg_stream * streams
unsigned char * packet[3]
AVVorbisParseContext * vp
enum VorbisPacketType last_packet
type of the last packet seen by vorbis_packet()
int64_t last_page_granule
static void error(const char *err)
void av_vorbis_parse_free(AVVorbisParseContext **s)
Free the parser and everything associated with it.
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 * av_vorbis_parse_init(const uint8_t *extradata, int extradata_size)
Allocate and initialize the Vorbis parser using headers in the extradata.
void av_vorbis_parse_reset(AVVorbisParseContext *s)
A public API for Vorbis parsing.
#define VORBIS_FLAG_SETUP
#define VORBIS_FLAG_COMMENT
#define VORBIS_FLAG_HEADER