1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Improved ID3 tag recognition in the MP3 decoder.

This commit is contained in:
jules 2011-11-30 14:43:48 +00:00
parent 5354dac0b5
commit b67c2ff240

View file

@ -1606,7 +1606,7 @@ struct MP3Stream
while (frameIndex >= frameStreamPositions.size() * storedStartPosInterval) while (frameIndex >= frameStreamPositions.size() * storedStartPosInterval)
{ {
int dummy = 0; int dummy = 0;
int result = decodeNextBlock (nullptr, nullptr, dummy); const int result = decodeNextBlock (nullptr, nullptr, dummy);
if (result < 0) if (result < 0)
return false; return false;
@ -3037,9 +3037,9 @@ public:
toSkip -= numReady; toSkip -= numReady;
} }
}
currentPosition = startSampleInFile; currentPosition = startSampleInFile;
}
} }
while (numSamples > 0) while (numSamples > 0)
@ -3108,25 +3108,27 @@ private:
void skipID3() void skipID3()
{ {
const int64 originalPosition = stream.stream.getPosition(); const int64 originalPosition = stream.stream.getPosition();
const uint8 major = stream.stream.readInt() & 0xff; const uint32 firstWord = stream.stream.readInt();
uint8 buffer[6];
if (major != 0xff if ((firstWord & 0xffffff) == 0x334449)
&& stream.stream.read (buffer, 6) == 6
&& buffer[0] != 0xff
&& ((buffer[2] | buffer[3] | buffer[4] | buffer[5]) & 0x80) == 0)
{ {
const int length = (((uint32) buffer[2]) << 21) uint8 buffer[6];
| (((uint32) buffer[3]) << 14)
| (((uint32) buffer[4]) << 7)
| ((uint32) buffer[5]);
stream.stream.skipNextBytes (length); if (stream.stream.read (buffer, 6) == 6
} && buffer[0] != 0xff
else && ((buffer[2] | buffer[3] | buffer[4] | buffer[5]) & 0x80) == 0)
{ {
stream.stream.setPosition (originalPosition); const int length = (((uint32) buffer[2]) << 21)
| (((uint32) buffer[3]) << 14)
| (((uint32) buffer[4]) << 7)
| ((uint32) buffer[5]);
stream.stream.skipNextBytes (length);
return;
}
} }
stream.stream.setPosition (originalPosition);
} }
int64 findLength (int64 streamStartPos) int64 findLength (int64 streamStartPos)