minor formatting
This commit is contained in:
@@ -17,15 +17,15 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
***/
|
***/
|
||||||
#include <QtGlobal>
|
|
||||||
|
|
||||||
#ifdef Q_PROCESSOR_X86_64
|
|
||||||
#include <xmmintrin.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "audiovisualwaveform.h"
|
#include "audiovisualwaveform.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
#include <QtGlobal>
|
||||||
|
|
||||||
|
#ifdef Q_PROCESSOR_X86
|
||||||
|
#include <xmmintrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "config/config.h"
|
#include "config/config.h"
|
||||||
#include "common/functiontimer.h"
|
#include "common/functiontimer.h"
|
||||||
@@ -291,8 +291,8 @@ AudioVisualWaveform::Sample AudioVisualWaveform::SumSamples(const float *samples
|
|||||||
return summed_samples;
|
return summed_samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_PROCESSOR_X86_64
|
#ifdef Q_PROCESSOR_X86
|
||||||
void min_max_sse(float *a, int start, int end, float &min_val, float &max_val)
|
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)
|
// 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);
|
||||||
@@ -331,9 +331,9 @@ AudioVisualWaveform::Sample AudioVisualWaveform::SumSamples(SampleBufferPtr samp
|
|||||||
int channels = samples->audio_params().channel_count();
|
int channels = samples->audio_params().channel_count();
|
||||||
AudioVisualWaveform::Sample summed_samples(channels);
|
AudioVisualWaveform::Sample summed_samples(channels);
|
||||||
|
|
||||||
#ifdef Q_PROCESSOR_X86_64
|
#ifdef Q_PROCESSOR_X86
|
||||||
for (int channel=0; channel<samples->audio_params().channel_count(); channel++) {
|
for (int channel=0; channel<samples->audio_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;
|
int end_index = start_index + length;
|
||||||
|
|||||||
@@ -23,6 +23,10 @@
|
|||||||
#include <QMatrix4x4>
|
#include <QMatrix4x4>
|
||||||
#include <QVector2D>
|
#include <QVector2D>
|
||||||
|
|
||||||
|
#ifdef Q_PROCESSOR_X86
|
||||||
|
#include <xmmintrin.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "common/tohex.h"
|
#include "common/tohex.h"
|
||||||
#include "node/distort/transform/transformdistortnode.h"
|
#include "node/distort/transform/transformdistortnode.h"
|
||||||
#include "render/color.h"
|
#include "render/color.h"
|
||||||
@@ -349,9 +353,32 @@ void MathNodeBase::ValueInternal(Operation operation, Pairing pairing, const QSt
|
|||||||
if (IsInputStatic(number_param)) {
|
if (IsInputStatic(number_param)) {
|
||||||
if (!NumberIsNoOp(operation, number)) {
|
if (!NumberIsNoOp(operation, number)) {
|
||||||
for (int i=0;i<job.samples()->audio_params().channel_count();i++) {
|
for (int i=0;i<job.samples()->audio_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; j<end; j++) {
|
||||||
|
a[j] *= number;
|
||||||
|
}
|
||||||
|
#else
|
||||||
for (int j=0;j<job.samples()->sample_count();j++) {
|
for (int j=0;j<job.samples()->sample_count();j++) {
|
||||||
job.samples()->data(i)[j] = PerformAll(operation, job.samples()->data(i)[j], number);
|
job.samples()->data(i)[j] = PerformAll(operation, job.samples()->data(i)[j], number);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user