From 7ad1bb3e365876fd37a77f54a5451dbc909bfef1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 1 Oct 2021 00:23:05 +0200 Subject: Vectorize two loops in the LV2 process function --- src/effects/lv2/lv2effectprocessor.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/effects/lv2/lv2effectprocessor.cpp b/src/effects/lv2/lv2effectprocessor.cpp index d455c4a4f6..5ac3632a2c 100644 --- a/src/effects/lv2/lv2effectprocessor.cpp +++ b/src/effects/lv2/lv2effectprocessor.cpp @@ -120,20 +120,19 @@ void LV2EffectProcessor::process(const ChannelHandle& inputHandle, m_params[i] = static_cast(m_parameters[i]->value()); } - int j = 0; - for (SINT i = 0; i < bufferParameters.samplesPerBuffer(); i += 2) { - m_inputL[j] = pInput[i]; - m_inputR[j] = pInput[i + 1]; - j++; + SINT framesPerBuffer = bufferParameters.framesPerBuffer(); + // note: LOOP VECTORIZED. + for (SINT i = 0; i < framesPerBuffer; ++i) { + m_inputL[i] = pInput[i * 2]; + m_inputR[i] = pInput[i * 2 + 1]; } - lilv_instance_run(pState->lilvIinstance(), bufferParameters.framesPerBuffer()); + lilv_instance_run(pState->lilvIinstance(), framesPerBuffer); - j = 0; - for (SINT i = 0; i < bufferParameters.samplesPerBuffer(); i += 2) { - pOutput[i] = m_outputL[j]; - pOutput[i + 1] = m_outputR[j]; - j++; + // note: LOOP VECTORIZED. + for (SINT i = 0; i < framesPerBuffer; ++i) { + pOutput[i * 2] = m_outputL[i]; + pOutput[i * 2 + 1] = m_outputR[i]; } } -- cgit v1.2.3