Revert "decoder/mad: use MAD_F_MIN and MAD_F_MAX"

This reverts commit f7ed7446ae.  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
This commit is contained in:
Max Kellermann 2019-08-05 13:06:33 +02:00
parent f44c67de09
commit 864d6f312d
2 changed files with 5 additions and 1 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.21.13 (not yet released)
* decoder
- mad: fix crackling sound (0.21.12 regression)
ver 0.21.12 (2019/08/03)
* decoder

View File

@ -79,12 +79,14 @@ static inline int32_t
mad_fixed_to_24_sample(mad_fixed_t sample) noexcept
{
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 */
sample = sample + (1L << (MAD_F_FRACBITS - bits));
/* quantize */
return Clamp(sample, MAD_F_MIN, MAD_F_MAX)
return Clamp(sample, MIN, MAX)
>> (MAD_F_FRACBITS + 1 - bits);
}