diff options
author | Karol Kosek <krkk@krkk.ct8.pl> | 2021-08-03 18:01:22 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-08-31 16:35:37 +0200 |
commit | 1c65ee6edfcb3330f6c2abaf55de358725fabbab (patch) | |
tree | d6b7f17b2f8c21188f241ad90d69ab96de91694f /Userland/Libraries/LibAudio/FlacLoader.cpp | |
parent | a086be993b22ca45d53e8143b26b937182725d48 (diff) | |
download | serenity-1c65ee6edfcb3330f6c2abaf55de358725fabbab.zip |
LibAudio: Implement decoding verbatim blocks in FLAC
They're mostly used in literal random data, so it isn't like
there is a high demand for it, but it's cool to have more complete
implementation anyway. :^)
Diffstat (limited to 'Userland/Libraries/LibAudio/FlacLoader.cpp')
-rw-r--r-- | Userland/Libraries/LibAudio/FlacLoader.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Userland/Libraries/LibAudio/FlacLoader.cpp b/Userland/Libraries/LibAudio/FlacLoader.cpp index 1ac3f62cf7..134bd6755d 100644 --- a/Userland/Libraries/LibAudio/FlacLoader.cpp +++ b/Userland/Libraries/LibAudio/FlacLoader.cpp @@ -621,10 +621,17 @@ Vector<i32> FlacLoaderPlugin::parse_subframe(FlacSubframeHeader& subframe_header return resampler.resample(samples); } -// Decode a subframe that isn't actually encoded -Vector<i32> FlacLoaderPlugin::decode_verbatim([[maybe_unused]] FlacSubframeHeader& subframe, [[maybe_unused]] InputBitStream& bit_input) +// Decode a subframe that isn't actually encoded, usually seen in random data +Vector<i32> FlacLoaderPlugin::decode_verbatim(FlacSubframeHeader& subframe, InputBitStream& bit_input) { - TODO(); + Vector<i32> decoded; + decoded.ensure_capacity(m_current_frame->sample_count); + + for (size_t i = 0; i < m_current_frame->sample_count; ++i) { + decoded.unchecked_append(sign_extend(bit_input.read_bits_big_endian(subframe.bits_per_sample - subframe.wasted_bits_per_sample), subframe.bits_per_sample - subframe.wasted_bits_per_sample)); + } + + return decoded; } // Decode a subframe encoded with a custom linear predictor coding, i.e. the subframe provides the polynomial order and coefficients |