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:
parent
f44c67de09
commit
864d6f312d
2
NEWS
2
NEWS
|
@ -1,4 +1,6 @@
|
||||||
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
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue