]> granicus.if.org Git - taglib/commitdiff
Avoid reading an entire ID3v2 tag when skipping it.
authorTsuda Kageyu <tsuda.kageyu@gmail.com>
Wed, 22 Oct 2014 23:14:10 +0000 (08:14 +0900)
committerTsuda Kageyu <tsuda.kageyu@gmail.com>
Wed, 22 Oct 2014 23:14:10 +0000 (08:14 +0900)
taglib/mpeg/mpegfile.cpp

index 5f953ccb2f036228924419d455746453d4ee637d..0ac87d10f9a6d7359c854c5b7fde816c26915be0 100644 (file)
@@ -434,18 +434,18 @@ long MPEG::File::firstFrameOffset()
   long position = 0;
 
   if(ID3v2Tag()) {
+    position = d->ID3v2Location + ID3v2Tag()->header()->completeTagSize();
 
     // Skip duplicate ID3v2 tags.
 
     // Workaround for some faulty files that have duplicate ID3v2 tags.
     // Combination of EAC and LAME creates such files when configured incorrectly.
 
-    position = d->ID3v2Location + ID3v2Tag()->header()->completeTagSize();
-
     long location;
     while((location = findID3v2(position)) >= 0) {
-      ID3v2::Tag dupTag(this, location);
-      position = location + dupTag.header()->completeTagSize();
+      seek(location);
+      const ID3v2::Header header(readBlock(ID3v2::Header::size()));
+      position = location + header.completeTagSize();
 
       debug("MPEG::File::firstFrameOffset() - Duplicate ID3v2 tag found.");
     }