1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:17:35 +00:00

LibAudio: Skip ID3 tags before synchronizing to MP3 frames

Previously, we would just start from byte 0 and check individual bytes
of the file until we find two bytes starting with `FF F`, and then
assume that that was the MP3 frame sync code. However, some ID3v2 tags
do not have to be what is referred to as "unsynchronized", meaning that
they can contain that `FF F` sequence and cause our decoder to think it
has found a frame.

To avoid this happening, we can read a minimal amount of the ID3 header
to determine how many bytes to skip before attempting to find the MP3
frames.

This allows the recent podcast with Andreas to play here:

https://changelog.com/podcast/554
This commit is contained in:
Zaggy1024 2023-08-25 18:54:06 -05:00 committed by Tim Flynn
parent 2dc75a37d2
commit 49be09e5b2
2 changed files with 31 additions and 3 deletions

View file

@ -41,6 +41,7 @@ public:
private:
MaybeLoaderError initialize();
static MaybeLoaderError skip_id3(SeekableStream& stream);
static MaybeLoaderError synchronize(BigEndianInputBitStream& stream, size_t sample_index);
MaybeLoaderError synchronize();
MaybeLoaderError build_seek_table();