diff options
author | Chris Robinson <[email protected]> | 2020-12-03 23:26:07 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-12-04 11:15:50 -0800 |
commit | aa05feec4a1d77eb37043aa93fc3237f70dc12ef (patch) | |
tree | ecee1464289c3c5b8eccd4424453f19706fa2029 /alc/converter.cpp | |
parent | b1c2671e9dfa68c03bec124f2ead59246caf7672 (diff) |
Avoid a global MAX_PITCH macro
Diffstat (limited to 'alc/converter.cpp')
-rw-r--r-- | alc/converter.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/alc/converter.cpp b/alc/converter.cpp index 57b902b8..de6f4587 100644 --- a/alc/converter.cpp +++ b/alc/converter.cpp @@ -4,11 +4,13 @@ #include "converter.h" #include <algorithm> +#include <cmath> #include <cstdint> #include <iterator> +#include <limits.h> #include "albyte.h" -#include "alu.h" +#include "alnumeric.h" #include "fpu_ctrl.h" #include "mixer/defs.h" @@ -18,6 +20,12 @@ struct CopyTag; namespace { +constexpr uint MaxPitch{10}; + +static_assert((BufferLineSize-1)/MaxPitch > 0, "MaxPitch is too large for BufferLineSize!"); +static_assert((INT_MAX>>MixerFracBits)/MaxPitch > BufferLineSize, + "MaxPitch and/or BufferLineSize are too large for MixerFracBits!"); + /* Base template left undefined. Should be marked =delete, but Clang 3.8.1 * chokes on that given the inline specializations. */ @@ -173,7 +181,7 @@ SampleConverterPtr CreateSampleConverter(DevFmtType srcType, DevFmtType dstType, /* Have to set the mixer FPU mode since that's what the resampler code expects. */ FPUCtl mixer_mode{}; auto step = static_cast<uint>( - mind(srcRate*double{MixerFracOne}/dstRate + 0.5, MAX_PITCH*MixerFracOne)); + mind(srcRate*double{MixerFracOne}/dstRate + 0.5, MaxPitch*MixerFracOne)); converter->mIncrement = maxu(step, 1); if(converter->mIncrement == MixerFracOne) converter->mResample = Resample_<CopyTag,CTag>; |