Commit 864d6f31 authored by Max Kellermann's avatar Max Kellermann

Revert "decoder/mad: use MAD_F_MIN and MAD_F_MAX"

This reverts commit f7ed7446. It was a bad idea, because MAD_F_MIN and MAD_F_MAX do not represent the clamping limits, but the theoretical minimum and maximum values of the mad_fixed_t data type. Closes https://github.com/MusicPlayerDaemon/MPD/issues/617
parent f44c67de
ver 0.21.13 (not yet released) ver 0.21.13 (not yet released)
* decoder
- mad: fix crackling sound (0.21.12 regression)
ver 0.21.12 (2019/08/03) ver 0.21.12 (2019/08/03)
* decoder * decoder
......
...@@ -79,12 +79,14 @@ static inline int32_t ...@@ -79,12 +79,14 @@ static inline int32_t
mad_fixed_to_24_sample(mad_fixed_t sample) noexcept mad_fixed_to_24_sample(mad_fixed_t sample) noexcept
{ {
static constexpr unsigned bits = 24; static constexpr unsigned bits = 24;
static constexpr mad_fixed_t MIN = -MAD_F_ONE;
static constexpr mad_fixed_t MAX = MAD_F_ONE - 1;
/* round */ /* round */
sample = sample + (1L << (MAD_F_FRACBITS - bits)); sample = sample + (1L << (MAD_F_FRACBITS - bits));
/* quantize */ /* quantize */
return Clamp(sample, MAD_F_MIN, MAD_F_MAX) return Clamp(sample, MIN, MAX)
>> (MAD_F_FRACBITS + 1 - bits); >> (MAD_F_FRACBITS + 1 - bits);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment