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
45 #define SAME_HEADER_MASK \
46 (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))
71 int max_frames, first_frames = 0;
74 int framesizes, max_framesizes;
80 while(buf0 <
end && !*buf0)
94 if (
ret != 0 ||
end - buf2 <
h.frame_size)
97 framesizes +=
h.frame_size;
100 max_framesizes =
FFMAX(max_framesizes, framesizes);
103 if (buf2 ==
end +
sizeof(uint32_t))
114 else if(first_frames > 1 && whole_used)
return 5;
115 else if(max_frames>=1 && p->
buf_size < 10*max_framesizes)
return 1;
148 #define LAST_BITS(k, n) ((k) & ((1 << (n)) - 1))
149 #define MIDDLE_BITS(k, m, n) LAST_BITS((k) >> (m), ((n) - (m) + 1))
157 int32_t r_gain = INT32_MIN, a_gain = INT32_MIN;
160 static const int64_t
xing_offtbl[2][2] = {{32, 17}, {17,9}};
183 "invalid concatenated file detected - using bitrate for duration\n");
186 "filesize and duration do not match (growing file?)\n");
245 mp3-> end_pad = v&4095;
291 if (v ==
MKBETAG(
'V',
'B',
'R',
'I')) {
321 vbrtag_size =
c.frame_size;
325 spf =
c.lsf ? 576 : 1152;
356 s->metadata =
s->internal->id3v2_meta;
357 s->internal->id3v2_meta =
NULL;
388 for (
i = 0;
i < 64 * 1024;
i++) {
429 #define MP3_PACKET_SIZE 1024
455 #define SEEK_WINDOW 4096
479 return sd.frame_size;
486 int best_score,
i, j;
495 best_pos = target_pos;
498 int64_t pos = target_pos + (dir > 0 ?
i -
SEEK_WINDOW/4 : -
i);
499 int64_t candidate = -1;
515 if ((target_pos - pos)*dir <= 0 &&
FFABS(
MIN_VALID/2-j) < score) {
521 if (best_score > score && j ==
MIN_VALID) {
522 best_pos = candidate;
544 if (
size > 0 &&
size >
s->internal->data_offset)
545 filesize =
size -
s->internal->data_offset;
559 }
else if (fast_seek && st->
duration > 0 && filesize > 0) {
564 timestamp = av_clip64(timestamp, 0, st->
duration);
606 .extensions =
"mp2,mp3,m2a,mpa",
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
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_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 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.
static av_cold int end(AVCodecContext *avctx)
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_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
#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)
int64_t last_discard_sample
The sample after last sample that is intended to be discarded after first_discard_sample.
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.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
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.
enum AVStreamParseType need_parsing
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)
int64_t first_discard_sample
If not 0, the first audio sample that should be discarded from the stream.
@ AV_CLASS_CATEGORY_DEMUXER
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
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).
AVInputFormat ff_mp3_demuxer
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
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.
static int mp3_read_header(AVFormatContext *s)
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
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
#define MKBETAG(a, b, c, d)
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.
#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[]
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.