decoder/mad: use Clamp()
This commit is contained in:
parent
10da9ee7ba
commit
9d44a6d2ae
@ -27,6 +27,7 @@
|
|||||||
#include "tag/ReplayGain.hxx"
|
#include "tag/ReplayGain.hxx"
|
||||||
#include "tag/MixRamp.hxx"
|
#include "tag/MixRamp.hxx"
|
||||||
#include "CheckAudioFormat.hxx"
|
#include "CheckAudioFormat.hxx"
|
||||||
|
#include "util/Clamp.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
@ -84,14 +85,9 @@ mad_fixed_to_24_sample(mad_fixed_t sample)
|
|||||||
/* round */
|
/* round */
|
||||||
sample = sample + (1L << (MAD_F_FRACBITS - bits));
|
sample = sample + (1L << (MAD_F_FRACBITS - bits));
|
||||||
|
|
||||||
/* clip */
|
|
||||||
if (gcc_unlikely(sample > MAX))
|
|
||||||
sample = MAX;
|
|
||||||
else if (gcc_unlikely(sample < MIN))
|
|
||||||
sample = MIN;
|
|
||||||
|
|
||||||
/* quantize */
|
/* quantize */
|
||||||
return sample >> (MAD_F_FRACBITS + 1 - bits);
|
return Clamp(sample, MIN, MAX)
|
||||||
|
>> (MAD_F_FRACBITS + 1 - bits);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
Reference in New Issue
Block a user