1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 20:27:34 +00:00

LibAudio: Read the full MP3 frame header when synchronizing to a frame

This makes the checks for a frame header more consistent, so if the
conditions for allowed frame headers change, there are less scattered
lines that will need to be changed.

`synchronize()` will now also properly scan the second byte of the hex
sequence `FF FF F0` as a sync code, where previously it would see
`FF F` and skip on to `F0`, ignoring its preceding `FF` that would
indicate that it is a sync code.
This commit is contained in:
Zaggy1024 2023-08-26 01:13:16 -05:00 committed by Tim Flynn
parent cbdf49de30
commit 88a9ff76b0
2 changed files with 36 additions and 50 deletions

View file

@ -44,7 +44,8 @@ private:
static MaybeLoaderError skip_id3(SeekableStream& stream);
static MaybeLoaderError synchronize(SeekableStream& stream, size_t sample_index);
static ErrorOr<MP3::Header, LoaderError> read_header(SeekableStream& stream, size_t sample_index);
MaybeLoaderError synchronize();
static ErrorOr<MP3::Header, LoaderError> synchronize_and_read_header(SeekableStream& stream, size_t sample_index);
ErrorOr<MP3::Header, LoaderError> synchronize_and_read_header();
MaybeLoaderError build_seek_table();
ErrorOr<MP3::MP3Frame, LoaderError> read_next_frame();
ErrorOr<MP3::MP3Frame, LoaderError> read_frame_data(MP3::Header const&);