mirror of
https://github.com/librespot-org/librespot.git
synced 2025-10-05 10:49:40 +02:00
perf(playback): optimize audio conversion with 16-bit dithering and bit shifts
Since Spotify audio is always 16-bit depth, optimize the conversion pipeline: - Always dither at 16-bit level regardless of output format - Preserve fractional precision until final rounding for better requantization - Replace floating-point multiplication with compile-time bit shifts - Add comprehensive inlining to eliminate function call overhead - Specialize 24-bit clamping to remove runtime branching This maintains proper dithering of the original 16-bit quantization artifacts while maximizing performance through bit-shift operations and eliminating unnecessary runtime calculations.
This commit is contained in:
parent
218eced556
commit
f59766af7e
3 changed files with 61 additions and 38 deletions
|
@ -64,6 +64,7 @@ impl Ditherer for TriangularDitherer {
|
|||
Self::NAME
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn noise(&mut self) -> f64 {
|
||||
self.distribution.sample(&mut self.cached_rng)
|
||||
}
|
||||
|
@ -98,6 +99,7 @@ impl Ditherer for GaussianDitherer {
|
|||
Self::NAME
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn noise(&mut self) -> f64 {
|
||||
self.distribution.sample(&mut self.cached_rng)
|
||||
}
|
||||
|
@ -130,6 +132,7 @@ impl Ditherer for HighPassDitherer {
|
|||
Self::NAME
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn noise(&mut self) -> f64 {
|
||||
let new_noise = self.distribution.sample(&mut self.cached_rng);
|
||||
let high_passed_noise = new_noise - self.previous_noises[self.active_channel];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue