diff options
author | Chris Robinson <[email protected]> | 2019-02-23 00:01:38 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-02-23 00:01:38 -0800 |
commit | 3683e31662f187ef539ab65134176b96f9c40b3e (patch) | |
tree | 0f7800726f356c32129f04ac4bf523a2dc0efde2 | |
parent | 317206e8f3312fb84a61b3681303fb5f8f92af7d (diff) |
Constify some parameters and remove an explicit loop
-rw-r--r-- | Alc/bformatdec.cpp | 20 | ||||
-rw-r--r-- | Alc/bformatdec.h | 13 |
2 files changed, 23 insertions, 10 deletions
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp index bb88c1b1..a54e8c42 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -49,7 +49,8 @@ inline auto GetAmbiScales(AmbDecScale scaletype) noexcept -> const std::array<fl } // namespace -void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]) +void BFormatDec::reset(const AmbDecConf *conf, const bool allow_2band, const ALsizei inchans, + const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]) { mSamples.clear(); mSamplesHF = nullptr; @@ -61,6 +62,7 @@ void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans mSamples.resize(2); else { + ASSUME(inchans > 0); mSamples.resize(inchans * 2); mSamplesHF = mSamples.data(); mSamplesLF = mSamplesHF + inchans; @@ -122,7 +124,9 @@ void BFormatDec::reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans } } -void BFormatDec::reset(const ALsizei inchans, const ALsizei chancount, const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS], const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]) +void BFormatDec::reset(const ALsizei inchans, const ALsizei chancount, + const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS], + const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]) { mSamples.clear(); mSamplesHF = nullptr; @@ -133,18 +137,22 @@ void BFormatDec::reset(const ALsizei inchans, const ALsizei chancount, const Cha mSamples.resize(2); mNumChannels = inchans; + ASSUME(chancount > 0); mEnabled = std::accumulate(std::begin(chanmap), std::begin(chanmap)+chancount, 0u, [](ALuint mask, const ALsizei &chan) noexcept -> ALuint { return mask | (1 << chan); } ); - for(ALsizei i{0};i < chancount;i++) + auto set_coeffs = [this,inchans,&chancoeffs](const ALsizei chanidx) noexcept -> void { - const ALfloat (&coeffs)[MAX_AMBI_CHANNELS] = chancoeffs[chanmap[i]]; - ALfloat (&mtx)[MAX_AMBI_CHANNELS] = mMatrix.Single[chanmap[i]]; + ASSUME(chanidx >= 0); + const ALfloat (&coeffs)[MAX_AMBI_CHANNELS] = chancoeffs[chanidx]; + ALfloat (&mtx)[MAX_AMBI_CHANNELS] = mMatrix.Single[chanidx]; + ASSUME(inchans > 0); std::copy_n(std::begin(coeffs), inchans, std::begin(mtx)); - } + }; + std::for_each(chanmap, chanmap+chancount, set_coeffs); } diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h index 29699abf..7dc283f7 100644 --- a/Alc/bformatdec.h +++ b/Alc/bformatdec.h @@ -36,15 +36,20 @@ class BFormatDec { ALboolean mDualBand; public: - void reset(const AmbDecConf *conf, bool allow_2band, ALsizei inchans, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]); + void reset(const AmbDecConf *conf, const bool allow_2band, const ALsizei inchans, + const ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]); - void reset(const ALsizei inchans, const ALsizei chancount, const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS], const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]); + void reset(const ALsizei inchans, const ALsizei chancount, + const ChannelDec (&chancoeffs)[MAX_OUTPUT_CHANNELS], + const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]); /* Decodes the ambisonic input to the given output channels. */ - void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo); + void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, + const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo); /* Retrieves per-order HF scaling factors for "upsampling" ambisonic data. */ - static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order, const ALsizei out_order) noexcept; + static std::array<ALfloat,MAX_AMBI_ORDER+1> GetHFOrderScales(const ALsizei in_order, + const ALsizei out_order) noexcept; DEF_NEWDEL(BFormatDec) }; |