diff options
author | Andreas Öman <andreas@lonelycoder.com> | 2007-10-24 04:56:22 +0000 |
---|---|---|
committer | Andreas Öman <andreas@lonelycoder.com> | 2007-10-24 04:56:22 +0000 |
commit | 8862fb41e0f1ce7d0dbb93008c2bedf659c40f15 (patch) | |
tree | dca40a6dff5ab7ba7c0f08e9eed7ebc45305f2b9 /libavformat | |
parent | 3a1d35882518300aac29aa621071b6dbe021560a (diff) | |
download | ffmpeg-streaming-8862fb41e0f1ce7d0dbb93008c2bedf659c40f15.zip ffmpeg-streaming-8862fb41e0f1ce7d0dbb93008c2bedf659c40f15.tar.gz |
add support for reading duration from VBRI-tag in mp3 files
Originally committed as revision 10851 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/mp3.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libavformat/mp3.c b/libavformat/mp3.c index 7781bd9..9a0b020 100644 --- a/libavformat/mp3.c +++ b/libavformat/mp3.c @@ -426,9 +426,9 @@ static int mp3_read_probe(AVProbeData *p) } /** - * Try to extract a xing tag from the stream and if found, decode it + * Try to find Xing/Info/VBRI tags and compute duration from info therein */ -static void mp3_parse_xing(AVFormatContext *s, AVStream *st) +static void mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, offset_t base) { uint32_t v, spf; int frames = -1; /* Total number of frames in file */ @@ -448,6 +448,18 @@ static void mp3_parse_xing(AVFormatContext *s, AVStream *st) frames = get_be32(&s->pb); } + /* Check for VBRI tag (always 32 bytes after end of mpegaudio header) */ + url_fseek(&s->pb, base + 4 + 32, SEEK_SET); + v = get_be32(&s->pb); + if(v == MKBETAG('V', 'B', 'R', 'I')) { + /* Check tag version */ + if(get_be16(&s->pb) == 1) { + /* skip delay, quality and total bytes */ + url_fseek(&s->pb, 8, SEEK_CUR); + frames = get_be32(&s->pb); + } + } + if(frames < 0) return; @@ -503,7 +515,7 @@ static int mp3_read_header(AVFormatContext *s, } off = url_ftell(&s->pb); - mp3_parse_xing(s, st); + mp3_parse_vbr_tags(s, st, off); url_fseek(&s->pb, off, SEEK_SET); /* the parameters will be extracted from the compressed bitstream */ |