diff options
author | Max Kellermann <max@musicpd.org> | 2019-08-03 00:26:57 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-08-03 00:26:57 +0200 |
commit | 9d44a6d2ae7df74085210c4fc8c7cf1f617a65e5 (patch) | |
tree | 2dd0f96c2d48a5492ba0e4f122247252e27bf397 /src/decoder/plugins/MadDecoderPlugin.cxx | |
parent | 10da9ee7bab531add7edac81fe5beced37456b4b (diff) |
decoder/mad: use Clamp()
Diffstat (limited to 'src/decoder/plugins/MadDecoderPlugin.cxx')
-rw-r--r-- | src/decoder/plugins/MadDecoderPlugin.cxx | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 68380489d..bc7ed3e39 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -27,6 +27,7 @@ #include "tag/ReplayGain.hxx" #include "tag/MixRamp.hxx" #include "CheckAudioFormat.hxx" +#include "util/Clamp.hxx" #include "util/StringCompare.hxx" #include "util/Domain.hxx" #include "Log.hxx" @@ -84,14 +85,9 @@ mad_fixed_to_24_sample(mad_fixed_t sample) /* round */ sample = sample + (1L << (MAD_F_FRACBITS - bits)); - /* clip */ - if (gcc_unlikely(sample > MAX)) - sample = MAX; - else if (gcc_unlikely(sample < MIN)) - sample = MIN; - /* quantize */ - return sample >> (MAD_F_FRACBITS + 1 - bits); + return Clamp(sample, MIN, MAX) + >> (MAD_F_FRACBITS + 1 - bits); } static void |