diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2025-04-25 02:35:14 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2025-04-25 02:35:14 +0000 |
| commit | c49787657cc81b465a22fecedaec5e20fd963168 (patch) | |
| tree | a0b2466eca0885c166f1643360f2e3cd850f7573 /src/codecs/sample.cpp | |
| parent | 79c9f0b6ccfec97f23563010f134d842c4240582 (diff) | |
| parent | 2b4ed254c60c576fc6889cf6e3b2cc2068e29fbf (diff) | |
| download | tangara-fw-c49787657cc81b465a22fecedaec5e20fd963168.tar.gz | |
Merge pull request 'WavPack decoding and seeking speed improvements' (#342) from ayumi/tangara-fw:wavpack into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/342
Diffstat (limited to 'src/codecs/sample.cpp')
| -rw-r--r-- | src/codecs/sample.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/codecs/sample.cpp b/src/codecs/sample.cpp index 63d14203..faf8b0f9 100644 --- a/src/codecs/sample.cpp +++ b/src/codecs/sample.cpp @@ -13,13 +13,17 @@ namespace sample { -static uint64_t sSeed1{0}; -static uint64_t sSeed2{0}; - auto shiftWithDither(int64_t src, uint_fast8_t bits) -> Sample { // FIXME: Use a better dither. - int16_t noise = static_cast<int16_t>(komirand(&sSeed1, &sSeed2) & 1); - return (src >> bits) ^ noise; + static uint64_t sSeed1{0}; + static uint64_t sSeed2{0}; + static uint64_t noise; + static uint_fast8_t pos = 0; + if (pos++ % 64 == 0) + noise = komirand(&sSeed1, &sSeed2); + else + noise >>= 1; + return (src >> bits) ^ (noise & 1); } } // namespace sample |
