27 #include "libavutil/avstring.h"
28 #include "libavutil/base64.h"
29 #include "libavutil/bswap.h"
30 #include "libavutil/dict.h"
42 int i, cnum, h,
m,
s, ms, keylen = strlen(key);
45 if (keylen < 9 || sscanf(key,
"CHAPTER%03d", &cnum) != 1)
49 if (sscanf(val,
"%02d:%02d:%02d.%03d", &h, &m, &s, &ms) < 4)
53 ms + 1000 * (s + 60 * (m + 60 * h)),
56 }
else if (!strcmp(key + keylen - 4,
"NAME")) {
85 s = bytestream_get_le32(&p);
87 if (end - p - 4 < s || s < 0)
92 n = bytestream_get_le32(&p);
94 while (end - p >= 4 && n > 0) {
98 s = bytestream_get_le32(&p);
100 if (end - p < s || s < 0)
107 v = memchr(t,
'=', s);
126 for (j = 0; j < tl; j++)
139 if (!strcmp(tt,
"METADATA_BLOCK_PICTURE")) {
167 "%ti bytes of comment header remain\n", end - p);
170 "truncated comment header, %i comments not found\n", n);
208 len = priv->
len[0] + priv->
len[1] + priv->
len[2];
209 buf_len = len + len / 255 + 64;
213 memset(*buf,
'\0', buf_len);
219 for (i = 0; i < 3; i++) {
220 memcpy(&ptr[offset], priv->
packet[i], priv->
len[i]);
221 offset += priv->
len[i];
236 for (i = 0; i < 3; i++)
257 if (os->
psize < 1 || pkt_type > 5)
262 if (priv->
packet[pkt_type >> 1])
264 if (pkt_type > 1 && !priv->
packet[0] || pkt_type > 3 && !priv->
packet[1])
267 priv->
len[pkt_type >> 1] = os->
psize;
269 if (!priv->
packet[pkt_type >> 1])
274 unsigned blocksize, bs0, bs1;
281 if (bytestream_get_le32(&p) != 0)
284 channels = bytestream_get_byte(&p);
290 srate = bytestream_get_le32(&p);
295 blocksize = bytestream_get_byte(&p);
296 bs0 = blocksize & 15;
297 bs1 = blocksize >> 4;
301 if (bs0 < 6 || bs1 > 13)
304 if (bytestream_get_byte(&p) != 1)
317 os->
psize - 8) >= 0) {
319 unsigned new_len = 7 + 4 +
AV_RL32(priv->
packet[1] + 7) + 4 + 1;
320 if (new_len >= 16 && new_len < os->psize) {
322 priv->
packet[1][new_len - 1] = 1;
323 priv->
len[1] = new_len;
368 last_pkt = next_pkt = next_pkt + os->
psize;
369 for (; seg < os->
nsegs; seg++) {
377 last_pkt = next_pkt + os->
segments[seg];
420 .
magic =
"\001vorbis",
unsigned int nb_chapters
Number of chapters in AVChapter array.
const char const char void * val
#define AVERROR_PATCHWELCOME
static int vorbis_header(AVFormatContext *s, int idx)
Copyright (C) 2005 Michael Ahlberg, Måns Rullgård.
int avpriv_vorbis_parse_frame(VorbisParseContext *s, const uint8_t *buf, int buf_size)
Get the duration for a Vorbis packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int fixup_vorbis_headers(AVFormatContext *as, struct oggvorbis_private *priv, uint8_t **buf)
AVCodecContext * codec
Codec context associated with this stream.
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...
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
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 *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static const uint8_t offset[511][2]
static av_cold int end(AVCodecContext *avctx)
int id
unique ID to identify the chapter
int av_reallocp(void *ptr, size_t size)
Allocate or reallocate a block of memory.
bitstream reader API header.
static void vorbis_cleanup(AVFormatContext *s, int idx)
int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size)
#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(). ...
void * priv_data
Format private data.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int bit_rate
the average bitrate
void * av_realloc(void *ptr, size_t size) 1(2)
Allocate or reallocate a block of memory.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() and chilren.
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 ...
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)
struct ogg_codec ff_vorbis_codec
#define AV_LOG_INFO
Standard information.
enum AVMediaType codec_type
int sample_rate
samples per second
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.
rational number numerator/denominator
int64_t duration
Decoding: duration of the stream, in stream time base.
static int av_toupper(int c)
Locale-independent conversion of ASCII characters to uppercase.
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 AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
#define AVERROR_INVALIDDATA
int channels
number of audio channels
int av_base64_decode(uint8_t *out, const char *in, int out_size)
Decode a base64-encoded string.
int avpriv_vorbis_parse_extradata(AVCodecContext *avctx, VorbisParseContext *s)
Initialize the Vorbis parser using headers in the extradata.
#define AV_NOPTS_VALUE
Undefined timestamp value.
void * av_mallocz(size_t size) av_malloc_attrib 1(1)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...