aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-10-14 23:22:16 -0700
committerChris Robinson <[email protected]>2023-10-14 23:22:16 -0700
commit5a72f300dcfa63c9b32f23ad3cf256b245ee0cd3 (patch)
tree10794186be348093acea40a8a40f916559758427 /alc/effects
parent59b31970866cb226084e0fcb9dbf4a3cae1e409e (diff)
Avoid an extra copy to calculate the convolution FFT
Diffstat (limited to 'alc/effects')
-rw-r--r--alc/effects/convolution.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp
index ca356508..271a4348 100644
--- a/alc/effects/convolution.cpp
+++ b/alc/effects/convolution.cpp
@@ -224,7 +224,7 @@ struct ConvolutionState final : public EffectState {
uint mAmbiOrder{};
size_t mFifoPos{0};
- std::array<float,ConvolveUpdateSamples*2> mInput{};
+ alignas(16) std::array<float,ConvolveUpdateSamples*2> mInput{};
al::vector<std::array<float,ConvolveUpdateSamples>,16> mFilter;
al::vector<std::array<float,ConvolveUpdateSamples*2>,16> mOutput;
@@ -665,14 +665,13 @@ void ConvolutionState::process(const size_t samplesToDo,
/* Move the newest input to the front for the next iteration's history. */
std::copy(mInput.cbegin()+ConvolveUpdateSamples, mInput.cend(), mInput.begin());
+ std::fill(mInput.begin()+ConvolveUpdateSamples, mInput.end(), 0.0f);
- /* Calculate the frequency domain response and add the relevant
+ /* Calculate the frequency-domain response and add the relevant
* frequency bins to the FFT history.
*/
- auto fftiter = std::copy_n(mInput.cbegin(), ConvolveUpdateSamples, mFftBuffer.begin());
- std::fill(fftiter, mFftBuffer.end(), 0.0f);
- pffft_transform(mFft.get(), mFftBuffer.data(),
- mComplexData.get() + curseg*ConvolveUpdateSize, mFftWorkBuffer.data(), PFFFT_FORWARD);
+ pffft_transform(mFft.get(), mInput.data(), mComplexData.get() + curseg*ConvolveUpdateSize,
+ mFftWorkBuffer.data(), PFFFT_FORWARD);
const float *RESTRICT filter{mComplexData.get() + mNumConvolveSegs*ConvolveUpdateSize};
for(size_t c{0};c < chans.size();++c)