Go to the documentation of this file.
38 #define XING_FLAG_FRAMES 0x01
39 #define XING_FLAG_SIZE 0x02
40 #define XING_FLAG_TOC 0x04
41 #define XING_FLAC_QSCALE 0x08
43 #define XING_TOC_COUNT 100
69 int max_frames, first_frames = 0;
72 int framesizes, max_framesizes;
74 const uint8_t *buf, *buf0, *buf2, *buf3, *end;
78 while (buf0 < end && !*buf0)
85 for (; buf < end; buf = buf2+1) {
98 for (buf3 = buf2 + 4; buf3 < buf2 +
available; buf3++) {
99 uint32_t next_sync =
AV_RB32(buf3);
104 framesizes +=
h.frame_size;
109 buf2 +=
h.frame_size;
112 max_framesizes =
FFMAX(max_framesizes, framesizes);
115 if (buf2 == end +
sizeof(uint32_t))
126 else if (first_frames > 1 && whole_used)
return 5;
127 else if (max_frames>=1 && p->
buf_size < 10*max_framesizes)
return 1;
160 #define LAST_BITS(k, n) ((k) & ((1 << (n)) - 1))
161 #define MIDDLE_BITS(k, m, n) LAST_BITS((k) >> (m), ((n) - (m) + 1))
170 int32_t r_gain = INT32_MIN, a_gain = INT32_MIN;
173 static const int64_t
xing_offtbl[2][2] = {{32, 17}, {17,9}};
197 "invalid concatenated file detected - using bitrate for duration\n");
200 "filesize and duration do not match (growing file?)\n");
259 mp3-> end_pad = v&4095;
305 if (v ==
MKBETAG(
'V',
'B',
'R',
'I')) {
335 vbrtag_size =
c.frame_size;
339 spf =
c.lsf ? 576 : 1152;
405 for (
i = 0;
i < 64 * 1024;
i++) {
447 #define MP3_PACKET_SIZE 1024
473 #define SEEK_WINDOW 4096
478 uint8_t header_buf[4];
497 return sd.frame_size;
504 int best_score,
i, j;
513 best_pos = target_pos;
517 int64_t candidate = -1;
539 if (best_score > score && j ==
MIN_VALID) {
540 best_pos = candidate;
579 }
else if (fast_seek && st->
duration > 0 && filesize > 0) {
626 .extensions =
"mp2,mp3,m2a,mpa",
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
static const uint8_t xing_offtbl[2][2]
enum AVMediaType codec_type
General type of the encoded data.
static av_always_inline FFIOContext * ffiocontext(AVIOContext *ctx)
static const AVClass demuxer_class
static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
#define AVERROR_EOF
End of file.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
int64_t first_discard_sample
If not 0, the first audio sample that should be discarded from the stream.
int ff_replaygain_export_raw(AVStream *st, int32_t tg, uint32_t tp, int32_t ag, uint32_t ap)
Export already decoded replaygain values as per-stream side data.
void ff_id3v1_read(AVFormatContext *s)
Read an ID3v1 tag.
#define AV_LOG_VERBOSE
Detailed information.
int buf_size
Size of buf except extra allocated bytes.
int64_t avio_size(AVIOContext *s)
Get the filesize.
unsigned long ffio_get_checksum(AVIOContext *s)
#define MIDDLE_BITS(k, m, n)
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
if it could not because there are no more frames
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
int64_t duration
Decoding: duration of the stream, in stream time base.
static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration)
unsigned int avio_rb32(AVIOContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int64_t data_offset
offset of the first packet
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static int64_t fsize(FILE *f)
@ AV_CLASS_CATEGORY_DEMUXER
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
enum AVStreamParseType need_parsing
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
This structure contains the data a format has to probe a file.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
int64_t maxsize
max filesize, used to limit allocations
AVDictionary * id3v2_meta
ID3v2 tag useful for MP3 demuxing.
static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
Try to find Xing/Info/VBRI tags and compute duration from info therein.
unsigned int avio_rb24(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const AVInputFormat ff_mp3_demuxer
int64_t last_discard_sample
The sample after last sample that is intended to be discarded after first_discard_sample.
static int mp3_read_header(AVFormatContext *s)
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
#define MKBETAG(a, b, c, d)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
static const uint8_t header[24]
int avio_r8(AVIOContext *s)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int flags
A combination of AV_PKT_FLAG values.
int64_t start_skip_samples
If not 0, the number of samples that should be skipped from the start of the stream (the samples are ...
#define AV_LOG_INFO
Standard information.
#define i(width, name, range_min, range_max)
static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st, MPADecodeHeader *c, uint32_t spf)
static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static int64_t mp3_sync(AVFormatContext *s, int64_t target_pos, int flags)
static int mp3_read_probe(const AVProbeData *p)
unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
unsigned int avio_rb16(AVIOContext *s)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static void mp3_parse_vbri_tag(AVFormatContext *s, AVStream *st, int64_t base)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static const AVOption options[]
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
static int check(AVIOContext *pb, int64_t pos, uint32_t *header)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed 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.
#define flags(name, subs,...)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
int ff_id3v2_match(const uint8_t *buf, const char *magic)
Detect ID3v2 Header.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.