pcm/Clamp: convert to constexpr
This commit is contained in:
@@ -34,8 +34,7 @@ template<SampleFormat F> struct SampleTraits;
|
|||||||
* and caps it if necessary.
|
* and caps it if necessary.
|
||||||
*/
|
*/
|
||||||
template<SampleFormat F, class Traits=SampleTraits<F>>
|
template<SampleFormat F, class Traits=SampleTraits<F>>
|
||||||
gcc_const
|
constexpr typename Traits::value_type
|
||||||
static inline typename Traits::value_type
|
|
||||||
PcmClamp(typename Traits::long_type x) noexcept
|
PcmClamp(typename Traits::long_type x) noexcept
|
||||||
{
|
{
|
||||||
typedef typename Traits::value_type T;
|
typedef typename Traits::value_type T;
|
||||||
|
@@ -37,8 +37,7 @@ struct FloatToIntegerSampleConvert {
|
|||||||
static constexpr SV factor = uintmax_t(1) << (DstTraits::BITS - 1);
|
static constexpr SV factor = uintmax_t(1) << (DstTraits::BITS - 1);
|
||||||
static_assert(factor > 0, "Wrong factor");
|
static_assert(factor > 0, "Wrong factor");
|
||||||
|
|
||||||
gcc_const
|
static constexpr DV Convert(SV src) noexcept {
|
||||||
static DV Convert(SV src) noexcept {
|
|
||||||
return PcmClamp<F, Traits>(SL(src * factor));
|
return PcmClamp<F, Traits>(SL(src * factor));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -134,7 +134,7 @@ pcm_add_vol(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<SampleFormat F, class Traits=SampleTraits<F>>
|
template<SampleFormat F, class Traits=SampleTraits<F>>
|
||||||
static typename Traits::value_type
|
static constexpr typename Traits::value_type
|
||||||
PcmAdd(typename Traits::value_type _a, typename Traits::value_type _b) noexcept
|
PcmAdd(typename Traits::value_type _a, typename Traits::value_type _b) noexcept
|
||||||
{
|
{
|
||||||
typename Traits::sum_type a(_a), b(_b);
|
typename Traits::sum_type a(_a), b(_b);
|
||||||
|
Reference in New Issue
Block a user