summaryrefslogtreecommitdiff
path: root/src/decoder/plugins/MadDecoderPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-08-03 00:26:57 +0200
committerMax Kellermann <max@musicpd.org>2019-08-03 00:26:57 +0200
commit9d44a6d2ae7df74085210c4fc8c7cf1f617a65e5 (patch)
tree2dd0f96c2d48a5492ba0e4f122247252e27bf397 /src/decoder/plugins/MadDecoderPlugin.cxx
parent10da9ee7bab531add7edac81fe5beced37456b4b (diff)
decoder/mad: use Clamp()
Diffstat (limited to 'src/decoder/plugins/MadDecoderPlugin.cxx')
-rw-r--r--src/decoder/plugins/MadDecoderPlugin.cxx10
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