diff options
author | Chris Robinson <[email protected]> | 2023-12-20 21:47:58 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-12-20 21:47:58 -0800 |
commit | 10693d306340dfc4c6c7ee7c71aa73a31f0b8ea9 (patch) | |
tree | 2bdd55cf34770c94a59ef26fbb45773a46e0f26b /alc/alu.cpp | |
parent | 959fac15dda2c8522265e092f2826e2514102587 (diff) |
Avoid using a couple C limits macros
Diffstat (limited to 'alc/alu.cpp')
-rw-r--r-- | alc/alu.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index 1a740d6f..a660b7bd 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -2068,11 +2068,12 @@ void ApplyDistanceComp(const al::span<FloatBufferLine> Samples, const size_t Sam void ApplyDither(const al::span<FloatBufferLine> Samples, uint *dither_seed, const float quant_scale, const size_t SamplesToDo) { + static constexpr double invRNGRange{1.0 / std::numeric_limits<uint>::max()}; ASSUME(SamplesToDo > 0); /* Dithering. Generate whitenoise (uniform distribution of random values * between -1 and +1) and add it to the sample values, after scaling up to - * the desired quantization depth amd before rounding. + * the desired quantization depth and before rounding. */ const float invscale{1.0f / quant_scale}; uint seed{*dither_seed}; @@ -2081,7 +2082,7 @@ void ApplyDither(const al::span<FloatBufferLine> Samples, uint *dither_seed, float val{sample * quant_scale}; uint rng0{dither_rng(&seed)}; uint rng1{dither_rng(&seed)}; - val += static_cast<float>(rng0*(1.0/UINT_MAX) - rng1*(1.0/UINT_MAX)); + val += static_cast<float>(rng0*invRNGRange - rng1*invRNGRange); return fast_roundf(val) * invscale; }; for(FloatBufferLine &inout : Samples) |