37 #define XING_FLAG_FRAMES 0x01
38 #define XING_FLAG_SIZE 0x02
39 #define XING_FLAG_TOC 0x04
40 #define XING_FLAC_QSCALE 0x08
42 #define XING_TOC_COUNT 100
55 int max_frames, first_frames = 0;
56 int fsize, frames, sample_rate;
58 uint8_t *buf, *buf0, *buf2, *end;
66 while(buf0 < end && !*buf0)
72 for(; buf < end; buf= buf2+1) {
75 for(frames = 0; buf2 < end; frames++) {
78 &sample_rate, &sample_rate,
84 max_frames =
FFMAX(max_frames, frames);
91 if (first_frames >= 10)
93 if (first_frames >= 4)
98 unsigned int code = -1;
100 #define VIDEO_ID 0x000001e0
101 #define AUDIO_ID 0x000001c0
105 code = (code << 8) + p->
buf[i];
106 if ((code & 0xffffff00) == 0x100) {
107 if ((code & 0x1f0) ==
VIDEO_ID) pes++;
108 else if((code & 0x1e0) ==
AUDIO_ID) pes++;
113 max_frames = (max_frames + pes - 1) / pes;
117 else if (max_frames >= 1)
return 1;
147 #define LAST_BITS(k, n) ((k) & ((1 << (n)) - 1))
148 #define MIDDLE_BITS(k, m, n) LAST_BITS((k) >> (m), ((n) - (m)))
156 int32_t r_gain = INT32_MIN, a_gain = INT32_MIN;
159 const int64_t
xing_offtbl[2][2] = {{32, 17}, {17,9}};
162 avio_skip(s->
pb, xing_offtbl[c->lsf == 1][c->nb_channels == 1]);
183 memset(version, 0,
sizeof(version));
258 if (v ==
MKBETAG(
'V',
'B',
'R',
'I')) {
286 vbrtag_size = c.frame_size;
290 spf = c.lsf ? 576 : 1152;
347 #define MP3_PACKET_SIZE 1024
394 return (ret >= 0) ? 0 : ret;
410 .extensions =
"mp2,mp3,m2a,mpa",
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.
#define AV_LOG_WARNING
Something somehow does not look correct.
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)
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
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static const uint8_t xing_offtbl[2][2]
#define AVERROR_EOF
End of file.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int ff_replaygain_export(AVStream *st, AVDictionary *metadata)
Parse replaygain tags and export them as per-stream side data.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
AVDictionary * metadata
Metadata that applies to the whole file.
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,...)
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.
void ffio_init_checksum(AVIOContext *s, unsigned long(*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum)
int bit_rate
the average bitrate
unsigned int avio_rb24(AVIOContext *s)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static void mp3_parse_info_tag(AVFormatContext *s, AVStream *st, MPADecodeHeader *c, uint32_t spf)
unsigned long ff_crcA001_update(unsigned long checksum, const uint8_t *buf, unsigned int len)
static void mp3_parse_vbri_tag(AVFormatContext *s, AVStream *st, int64_t base)
if(ac->has_optimized_func)
static int mp3_read_probe(AVProbeData *p)
Libavcodec external API header.
enum AVMediaType codec_type
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
AVIOContext * pb
I/O context.
main external API structure.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
rational number numerator/denominator
unsigned long ffio_get_checksum(AVIOContext *s)
This structure contains the data a format has to probe a file.
int64_t duration
Decoding: duration of the stream, in stream time base.
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.
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
AVInputFormat ff_mp3_demuxer
#define MKBETAG(a, b, c, d)
#define MIDDLE_BITS(k, m, n)
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.
#define AV_DICT_IGNORE_SUFFIX
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.