Commit 8c50f67f authored by falkTX's avatar falkTX
Browse files

Use ARM neon intrinsics for AudioBufferMixdown

parent 51f92388
...@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ...@@ -28,6 +28,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <Accelerate/Accelerate.h> #include <Accelerate/Accelerate.h>
#elif defined (__SSE__) && !defined (__sun__) #elif defined (__SSE__) && !defined (__sun__)
#include <xmmintrin.h> #include <xmmintrin.h>
#elif defined (__ARM_NEON__)
#include <arm_neon.h>
#endif #endif
namespace Jack namespace Jack
...@@ -51,6 +53,13 @@ static inline void MixAudioBuffer(jack_default_audio_sample_t* mixbuffer, jack_d ...@@ -51,6 +53,13 @@ static inline void MixAudioBuffer(jack_default_audio_sample_t* mixbuffer, jack_d
__m128 vec = _mm_add_ps(_mm_load_ps(mixbuffer), _mm_load_ps(buffer)); __m128 vec = _mm_add_ps(_mm_load_ps(mixbuffer), _mm_load_ps(buffer));
_mm_store_ps(mixbuffer, vec); _mm_store_ps(mixbuffer, vec);
mixbuffer += 4;
buffer += 4;
frames_group--;
#elif defined (__ARM_NEON__)
float32x4_t vec = vaddq_f32(vld1q_f32(mixbuffer), vld1q_f32(buffer));
vst1q_f32(mixbuffer, vec);
mixbuffer += 4; mixbuffer += 4;
buffer += 4; buffer += 4;
frames_group--; frames_group--;
...@@ -116,7 +125,24 @@ static void AudioBufferMixdown(void* mixbuffer, void** src_buffers, int src_coun ...@@ -116,7 +125,24 @@ static void AudioBufferMixdown(void* mixbuffer, void** src_buffers, int src_coun
for (jack_nframes_t i = 0; i != remaining_frames; ++i) { for (jack_nframes_t i = 0; i != remaining_frames; ++i) {
target[i] = source[i]; target[i] = source[i];
} }
#elif defined (__ARM_NEON__)
jack_nframes_t frames_group = nframes / 4;
jack_nframes_t remaining_frames = nframes % 4;
jack_default_audio_sample_t* source = static_cast<jack_default_audio_sample_t*>(src_buffers[0]);
jack_default_audio_sample_t* target = static_cast<jack_default_audio_sample_t*>(mixbuffer);
while (frames_group > 0) {
float32x4_t vec = vld1q_f32(source);
vst1q_f32(target, vec);
source += 4;
target += 4;
--frames_group;
}
for (jack_nframes_t i = 0; i != remaining_frames; ++i) {
target[i] = source[i];
}
#else #else
memcpy(mixbuffer, src_buffers[0], nframes * sizeof(jack_default_audio_sample_t)); memcpy(mixbuffer, src_buffers[0], nframes * sizeof(jack_default_audio_sample_t));
#endif #endif
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment