diff --git a/app/audio/audiovisualwaveform.cpp b/app/audio/audiovisualwaveform.cpp
index 22e169a2f..1018c3e76 100644
--- a/app/audio/audiovisualwaveform.cpp
+++ b/app/audio/audiovisualwaveform.cpp
@@ -17,15 +17,15 @@
along with this program. If not, see .
***/
-#include
-
-#ifdef Q_PROCESSOR_X86_64
-#include
-#endif
#include "audiovisualwaveform.h"
#include
+#include
+
+#ifdef Q_PROCESSOR_X86
+#include
+#endif
#include "config/config.h"
#include "common/functiontimer.h"
@@ -291,15 +291,15 @@ AudioVisualWaveform::Sample AudioVisualWaveform::SumSamples(const float *samples
return summed_samples;
}
-#ifdef Q_PROCESSOR_X86_64
-void min_max_sse(float *a, int start, int end, float &min_val, float &max_val)
+#ifdef Q_PROCESSOR_X86
+void ExpandMinMaxSSE(float *a, int start, int end, float &min_val, float &max_val)
{
// load the first 4 elements of 'a' into min and max (they are 4 * 32 = 128 bits)
- __m128 max = _mm_loadu_ps(a + start);
+ __m128 max = _mm_loadu_ps(a + start);
__m128 min = _mm_loadu_ps(a + start);
- // loop over 'a' and compare current elements with min and max 4 by 4.
- // we need to make sure we don't read out of boundaries should 'a' lenght be not mod. 4
+ // loop over 'a' and compare current elements with min and max 4 by 4.
+ // we need to make sure we don't read out of boundaries should 'a' lenght be not mod. 4
for(int i = 4; i < end-4; i+=4) {
__m128 cur = _mm_loadu_ps(a + start + i);
max = _mm_max_ps(max, cur);
@@ -311,7 +311,7 @@ void min_max_sse(float *a, int start, int end, float &min_val, float &max_val)
min = _mm_min_ps(min, cur);
// this potentially overlaps up to the last 3 elements but it's not an issue.
- // min and max will contain 4 min and max. To get the absolute min and max
+ // min and max will contain 4 min and max. To get the absolute min and max
// we need to compare the 4 values over themselves by shuffling each time.
for (int i = 0; i < 3; i++) {
max = _mm_max_ps(max, _mm_shuffle_ps(max, max, 0x93));
@@ -331,11 +331,11 @@ AudioVisualWaveform::Sample AudioVisualWaveform::SumSamples(SampleBufferPtr samp
int channels = samples->audio_params().channel_count();
AudioVisualWaveform::Sample summed_samples(channels);
- #ifdef Q_PROCESSOR_X86_64
+ #ifdef Q_PROCESSOR_X86
for (int channel=0; channelaudio_params().channel_count(); channel++) {
- min_max_sse(samples->data(channel), start_index, length, summed_samples[channel].min, summed_samples[channel].max);
+ ExpandMinMaxSSE(samples->data(channel), start_index, length, summed_samples[channel].min, summed_samples[channel].max);
}
- #else
+ #else
int end_index = start_index + length;
for (int channel=0; channelaudio_params().channel_count(); channel++) {
for (int i=start_index; i
#include
+#ifdef Q_PROCESSOR_X86
+#include
+#endif
+
#include "common/tohex.h"
#include "node/distort/transform/transformdistortnode.h"
#include "render/color.h"
@@ -349,9 +353,32 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
if (IsInputStatic(number_param)) {
if (!NumberIsNoOp(operation, number)) {
for (int i=0;iaudio_params().channel_count();i++) {
+#ifdef Q_PROCESSOR_X86
+ // Use SSE instructions for optimization
+
+ float *a = job.samples()->data(i);
+ int end = job.samples()->sample_count();
+
+ int end_divisible_4 = (end / 4) * 4;
+
+ // loop over 'a' and compare current elements with min and max 4 by 4.
+ // we need to make sure we don't read out of boundaries should 'a' lenght be not mod. 4
+ __m128 mult = _mm_load1_ps(&number);
+ for(int j = 0; j < end_divisible_4; j+=4) {
+ __m128 cur = _mm_loadu_ps(a + j);
+ __m128 res = _mm_mul_ps(cur, mult);
+ _mm_storeu_ps(a + j, res);
+ }
+
+ // Do last three numbers, if non-divisible by 4
+ for (int j=end_divisible_4; jsample_count();j++) {
job.samples()->data(i)[j] = PerformAll(operation, job.samples()->data(i)[j], number);
}
+#endif
}
}