From 9d44a6d2ae7df74085210c4fc8c7cf1f617a65e5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 3 Aug 2019 00:26:57 +0200 Subject: decoder/mad: use Clamp() --- src/decoder/plugins/MadDecoderPlugin.cxx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/decoder') 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 -- cgit v1.2.3