1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:57:44 +00:00

LibAudio: Improve FLAC seeking

"Improve" is an understatement, since this commit makes all FLAC files
seek without errors, mostly with high accuracy, and partially even fast:
- A new generic seek table type is introduced, which keeps an
  always-sorted list of seek points, which allows it to use binary
  search and fast insertion.
- Automatic seek points are inserted according to two heuristics
  (distance between seek points and minimum seek precision), which not
  only builds a seek table for already-played sections of the file, but
  improves seek precision even for files with an existing seek table.
- Manual seeking by skipping frames works properly now and is still used
  as a last resort.
This commit is contained in:
kleines Filmröllchen 2023-03-18 14:12:25 +01:00 committed by Linus Groh
parent c66f7f2e7c
commit 0cd0565abc
7 changed files with 164 additions and 25 deletions

View file

@ -87,6 +87,8 @@ private:
ALWAYS_INLINE ErrorOr<u32, LoaderError> convert_sample_rate_code(u8 sample_rate_code);
ALWAYS_INLINE ErrorOr<PcmSampleFormat, LoaderError> convert_bit_depth_code(u8 bit_depth_code);
bool should_insert_seekpoint_at(u64 sample_index) const;
// Data obtained directly from the FLAC metadata: many values have specific bit counts
u32 m_sample_rate { 0 }; // 20 bit
u8 m_num_channels { 0 }; // 3 bit
@ -105,7 +107,7 @@ private:
u64 m_data_start_location { 0 };
Optional<FlacFrameHeader> m_current_frame;
u64 m_current_sample_or_frame { 0 };
Vector<FlacSeekPoint> m_seektable;
SeekTable m_seektable;
};
}