summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--src/decoder/plugins/MadDecoderPlugin.cxx4
2 files changed, 5 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index fb4034a1f..34b6c0a00 100644
--- a/NEWS
+++ b/NEWS
@@ -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);
}