32 #define XING_FLAG_FRAMES 0x01
33 #define XING_FLAG_SIZE 0x02
34 #define XING_FLAG_TOC 0x04
36 #define XING_TOC_COUNT 100
46 int max_frames, first_frames = 0;
47 int fsize, frames, sample_rate;
49 uint8_t *buf, *buf0, *buf2, *end;
54 while(buf0 < end && !*buf0)
60 for(; buf < end; buf= buf2+1) {
63 for(frames = 0; buf2 < end; frames++) {
70 max_frames =
FFMAX(max_frames, frames);
80 unsigned int code = -1;
82 #define VIDEO_ID 0x000001e0
83 #define AUDIO_ID 0x000001c0
87 code = (code << 8) + p->
buf[i];
88 if ((code & 0xffffff00) == 0x100) {
89 if ((code & 0x1f0) ==
VIDEO_ID) pes++;
90 else if((code & 0x1e0) ==
AUDIO_ID) pes++;
95 max_frames = (max_frames + pes - 1) / pes;
99 else if (max_frames >= 1)
return 1;
134 const int64_t
xing_offtbl[2][2] = {{32, 17}, {17,9}};
144 vbrtag_size = c.frame_size;
148 spf = c.lsf ? 576 : 1152;
151 avio_skip(s->
pb, xing_offtbl[c.lsf == 1][c.nb_channels == 1]);
153 is_cbr = v ==
MKBETAG(
'I',
'n',
'f',
'o');
154 if (v ==
MKBETAG(
'X',
'i',
'n',
'g') || is_cbr) {
168 if(v ==
MKBETAG(
'V',
'B',
'R',
'I')) {
187 if (size && frames && !is_cbr)
222 #define MP3_PACKET_SIZE 1024
269 return (ret >= 0) ? 0 : ret;
285 .extensions =
"mp2,mp3,m2a",
int64_t avio_size(AVIOContext *s)
Get the filesize.
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.
void ff_id3v1_read(AVFormatContext *s)
Read an ID3v1 tag.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
static void read_xing_toc(AVFormatContext *s, int64_t filesize, int64_t duration)
unsigned int avio_rb16(AVIOContext *s)
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static int mp3_read_packet(AVFormatContext *s, AVPacket *pkt)
unsigned int avio_rb32(AVIOContext *s)
static int mp3_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
enum AVStreamParseType need_parsing
static const uint8_t xing_offtbl[2][2]
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
#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)
preferred ID for decoding MPEG audio layer 1, 2 or 3
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
int bit_rate
the average bitrate
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static int mp3_read_probe(AVProbeData *p)
enum AVMediaType codec_type
AVIOContext * pb
I/O context.
main external API structure.
#define AV_DICT_IGNORE_SUFFIX
#define MKBETAG(a, b, c, d)
rational number numerator/denominator
This structure contains the data a format has to probe a file.
struct MP3DecContext MP3DecContext
int64_t duration
Decoding: duration of the stream, in stream time base.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
AVInputFormat ff_mp3_demuxer
#define AVPROBE_SCORE_MAX
int eof_reached
true if eof reached
void * priv_data
Format private data.
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.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
This structure stores compressed data.
#define AVFMT_GENERIC_INDEX
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)