diff options
author | Max Kellermann <max@musicpd.org> | 2019-08-05 13:06:33 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-08-05 13:07:41 +0200 |
commit | 864d6f312d30ea3ae145d901d245f90c8bd11185 (patch) | |
tree | 7b53650e7f9b1b3133b8eb6935d54816bb3dc7d0 | |
parent | f44c67de0991d47765403e966dd43a0b0fe0aeef (diff) |
Revert "decoder/mad: use MAD_F_MIN and MAD_F_MAX"
This reverts commit f7ed7446ae4be9226de554d6d75a14a9fb71dd7c. 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
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | src/decoder/plugins/MadDecoderPlugin.cxx | 4 |
2 files changed, 5 insertions, 1 deletions
@@ -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 diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 1e357fd81..66cf8fb96 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -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); } |