[PATCH] ignore additional id3v2 tags at the beginning of mp3 =
David Byron none
dbyron
Tue Sep 7 13:28:18 CEST 2010
files=0A=
=0A=
---=0A=
Changelog | 1 +=0A=
libavformat/id3v2.c | 45 ++++++++++++++++++++++++++++++++-------------=0A=
2 files changed, 33 insertions(+), 13 deletions(-)=0A=
=0A=
diff --git a/Changelog b/Changelog=0A=
index 59d4339..7f3e1ca 100644=0A=
--- a/Changelog=0A=
+++ b/Changelog=0A=
@@ -4,6 +4,7 @@ releases are sorted from youngest to oldest.=0A=
=0A=
version <next>:=0A=
=0A=
+- skip additional id3v2 tags at the beginning of mp3 files=0A=
- WebM support in Matroska de/muxer=0A=
- low overhead Ogg muxing=0A=
- MMS-TCP support=0A=
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c=0A=
index f2515d5..3a0a4dd 100644=0A=
--- a/libavformat/id3v2.c=0A=
+++ b/libavformat/id3v2.c=0A=
@@ -53,20 +53,39 @@ void ff_id3v2_read(AVFormatContext *s, const char =
*magic)=0A=
{=0A=
int len, ret;=0A=
uint8_t buf[ID3v2_HEADER_SIZE];=0A=
+ int found_header;=0A=
+ int64_t off;=0A=
+ int num_headers;=0A=
=0A=
- ret =3D get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);=0A=
- if (ret !=3D ID3v2_HEADER_SIZE)=0A=
- return;=0A=
- if (ff_id3v2_match(buf, magic)) {=0A=
- /* parse ID3v2 header */=0A=
- len =3D ((buf[6] & 0x7f) << 21) |=0A=
- ((buf[7] & 0x7f) << 14) |=0A=
- ((buf[8] & 0x7f) << 7) |=0A=
- (buf[9] & 0x7f);=0A=
- ff_id3v2_parse(s, len, buf[3], buf[5]);=0A=
- } else {=0A=
- url_fseek(s->pb, 0, SEEK_SET);=0A=
- }=0A=
+ num_headers =3D 0;=0A=
+ do {=0A=
+ /* save the current offset in case there's nothing to read/skip =
*/=0A=
+ off =3D url_ftell(s->pb);=0A=
+=0A=
+ ret =3D get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);=0A=
+ if (ret !=3D ID3v2_HEADER_SIZE)=0A=
+ return;=0A=
+ found_header =3D ff_id3v2_match(buf, magic);=0A=
+ if (found_header) {=0A=
+ num_headers++;=0A=
+ len =3D ((buf[6] & 0x7f) << 21) |=0A=
+ ((buf[7] & 0x7f) << 14) |=0A=
+ ((buf[8] & 0x7f) << 7) |=0A=
+ (buf[9] & 0x7f);=0A=
+ if (num_headers =3D=3D 1) {=0A=
+ /* parse the first ID3v2 header */=0A=
+ ff_id3v2_parse(s, len, buf[3], buf[5]);=0A=
+ } else {=0A=
+ /* skip any additional ID3v2 headers */=0A=
+ av_log(s, AV_LOG_VERBOSE, "skipping additional id3v2 =
tag in "=0A=
+ "\"%s\"\n", s->filename);=0A=
+ url_fskip(s->pb, len);=0A=
+ }=0A=
+ } else {=0A=
+ /* no more ID3v2 headers, go back to where we were */=0A=
+ url_fseek(s->pb, off, SEEK_SET);=0A=
+ }=0A=
+ } while (found_header);=0A=
}=0A=
=0A=
static unsigned int get_size(ByteIOContext *s, int len)=0A=
-- =0A=
1.6.0.4=0A=
=0A=
------=_NextPart_000_01A2_01CB4E90.E74BE900--
More information about the ffmpeg-devel
mailing list