[Scummvm-cvs-logs] scummvm master -> 5c7cc826f082a10fef1cd44766f2226bb66b9b2f

criezy criezy at scummvm.org
Sun Apr 5 22:40:02 CEST 2015


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
5c7cc826f0 AUDIO: Skip ID3 tag at start of mp3 files


Commit: 5c7cc826f082a10fef1cd44766f2226bb66b9b2f
    https://github.com/scummvm/scummvm/commit/5c7cc826f082a10fef1cd44766f2226bb66b9b2f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2015-04-05T21:17:06+01:00

Commit Message:
AUDIO: Skip ID3 tag at start of mp3 files

This fixes bug #6834 MP3: ScummVM doesn't skip ID3 tag at
beginning of file.

Changed paths:
    audio/decoders/mp3.cpp



diff --git a/audio/decoders/mp3.cpp b/audio/decoders/mp3.cpp
index c1b3faa..feb531f 100644
--- a/audio/decoders/mp3.cpp
+++ b/audio/decoders/mp3.cpp
@@ -246,6 +246,23 @@ void MP3Stream::initStream() {
 	_inStream->seek(0, SEEK_SET);
 	_curTime = mad_timer_zero;
 	_posInFrame = 0;
+	
+	// Skip ID3 TAG if any
+	// ID3v1 (beginning with with 'TAG') is located at the end of files. So we can ignore those.
+	// ID3v2 can be located at the start of files and begins with a 10 bytes header, the first 3 bytes being 'ID3'.
+	// The tag size is coded on the last 4 bytes of the 10 bytes header as a 32 bit synchsafe integer.
+	// See http://id3.org/id3v2.4.0-structure for details.
+	char data[10];
+	_inStream->read(data, 10);
+	if (data[0] == 'I' && data[1] == 'D' && data[2] == '3') {
+		uint32 size = data[9] + 128 * (data[8] + 128 * (data[7] + 128 * data[6]));
+		// This size does not include an optional 10 bytes footer. Check if it is present.
+		if (data[5] & 0x10)
+			size += 10;
+		debug("Skipping ID3 TAG (%d bytes)", size + 10);
+		_inStream->seek(size, SEEK_CUR);
+	} else
+		_inStream->seek(0, SEEK_SET);
 
 	// Update state
 	_state = MP3_STATE_READY;






More information about the Scummvm-git-logs mailing list