diff options
author | Chris Robinson <[email protected]> | 2018-12-24 20:44:55 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-12-24 20:44:55 -0800 |
commit | 3b7f668b28dbc5ef156bad9aa79f16b32efb2eb3 (patch) | |
tree | 2e2d609422219894bd74419fb4bc2c60bea38b1b /Alc | |
parent | fbae41020d8968d0e65af08584df4736b5ed7239 (diff) |
Avoid an intermediate mixing buffer
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/bformatdec.cpp | 19 | ||||
-rw-r--r-- | Alc/bformatdec.h | 6 |
2 files changed, 8 insertions, 17 deletions
diff --git a/Alc/bformatdec.cpp b/Alc/bformatdec.cpp index b22784c1..500cd276 100644 --- a/Alc/bformatdec.cpp +++ b/Alc/bformatdec.cpp @@ -198,10 +198,11 @@ void BFormatDec::reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, } } -void BFormatDec::process(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], const ALsizei SamplesToDo) +void BFormatDec::process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo) { ASSUME(OutChannels > 0); ASSUME(SamplesToDo > 0); + ASSUME(mNumChannels > 0); if(mDualBand) { @@ -214,18 +215,14 @@ void BFormatDec::process(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALsize if(UNLIKELY(!(mEnabled&(1<<chan)))) continue; - std::fill(std::begin(mChannelMix), std::begin(mChannelMix)+SamplesToDo, 0.0f); - MixRowSamples(mChannelMix, mMatrix.Dual[chan][HF_BAND], + MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][HF_BAND], &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(mSamplesHF[0]), mNumChannels, 0, SamplesToDo ); - MixRowSamples(mChannelMix, mMatrix.Dual[chan][LF_BAND], + MixRowSamples(OutBuffer[chan], mMatrix.Dual[chan][LF_BAND], &reinterpret_cast<ALfloat(&)[BUFFERSIZE]>(mSamplesLF[0]), mNumChannels, 0, SamplesToDo ); - - std::transform(std::begin(mChannelMix), std::begin(mChannelMix)+SamplesToDo, - OutBuffer[chan], OutBuffer[chan], std::plus<float>()); } } else @@ -235,17 +232,13 @@ void BFormatDec::process(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALsize if(UNLIKELY(!(mEnabled&(1<<chan)))) continue; - std::fill(std::begin(mChannelMix), std::begin(mChannelMix)+SamplesToDo, 0.0f); - MixRowSamples(mChannelMix, mMatrix.Single[chan], InSamples, + MixRowSamples(OutBuffer[chan], mMatrix.Single[chan], InSamples, mNumChannels, 0, SamplesToDo); - - std::transform(std::begin(mChannelMix), std::begin(mChannelMix)+SamplesToDo, - OutBuffer[chan], OutBuffer[chan], std::plus<float>()); } } } -void BFormatDec::upSample(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], const ALsizei InChannels, const ALsizei SamplesToDo) +void BFormatDec::upSample(ALfloat (*OutBuffer)[BUFFERSIZE], const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei InChannels, const ALsizei SamplesToDo) { ASSUME(InChannels > 0); ASSUME(SamplesToDo > 0); diff --git a/Alc/bformatdec.h b/Alc/bformatdec.h index ba6ceaa2..7b5d1cd2 100644 --- a/Alc/bformatdec.h +++ b/Alc/bformatdec.h @@ -29,8 +29,6 @@ private: std::array<ALfloat,BUFFERSIZE> *mSamplesHF; std::array<ALfloat,BUFFERSIZE> *mSamplesLF; - alignas(16) ALfloat mChannelMix[BUFFERSIZE]; - struct { BandSplitter XOver; ALfloat Gains[sNumBands]; @@ -43,10 +41,10 @@ public: void reset(const AmbDecConf *conf, ALsizei chancount, ALuint srate, const ALsizei (&chanmap)[MAX_OUTPUT_CHANNELS]); /* Decodes the ambisonic input to the given output channels. */ - void process(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], const ALsizei SamplesToDo); + void process(ALfloat (*OutBuffer)[BUFFERSIZE], const ALsizei OutChannels, const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei SamplesToDo); /* Up-samples a first-order input to the decoder's configuration. */ - void upSample(ALfloat (*RESTRICT OutBuffer)[BUFFERSIZE], const ALfloat (*RESTRICT InSamples)[BUFFERSIZE], const ALsizei InChannels, const ALsizei SamplesToDo); + void upSample(ALfloat (*OutBuffer)[BUFFERSIZE], const ALfloat (*InSamples)[BUFFERSIZE], const ALsizei InChannels, const ALsizei SamplesToDo); DEF_NEWDEL(BFormatDec) }; |