mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-04-14 08:21:47 -04:00
audioconvert: align some buffers
so that we can use aligned read and writes in SSE.
This commit is contained in:
parent
662bf68122
commit
2c132be626
3 changed files with 16 additions and 10 deletions
|
|
@ -266,7 +266,7 @@ static inline void convolver_run(const float *src, float *dst,
|
||||||
sum[0] = _mm_setzero_ps();
|
sum[0] = _mm_setzero_ps();
|
||||||
for(i = 0; i < n_taps; i+=4) {
|
for(i = 0; i < n_taps; i+=4) {
|
||||||
t[0] = _mm_loadu_ps(&src[i]);
|
t[0] = _mm_loadu_ps(&src[i]);
|
||||||
sum[0] = _mm_add_ps(sum[0], _mm_mul_ps(_mm_loadu_ps(&taps[i]), t[0]));
|
sum[0] = _mm_add_ps(sum[0], _mm_mul_ps(_mm_load_ps(&taps[i]), t[0]));
|
||||||
}
|
}
|
||||||
sum[0] = _mm_add_ps(sum[0], _mm_movehl_ps(sum[0], sum[0]));
|
sum[0] = _mm_add_ps(sum[0], _mm_movehl_ps(sum[0], sum[0]));
|
||||||
sum[0] = _mm_add_ss(sum[0], _mm_shuffle_ps(sum[0], sum[0], 0x55));
|
sum[0] = _mm_add_ss(sum[0], _mm_shuffle_ps(sum[0], sum[0], 0x55));
|
||||||
|
|
@ -303,8 +303,8 @@ static inline void delay_convolve_run_sse(float *buffer, uint32_t *pos,
|
||||||
w += 4;
|
w += 4;
|
||||||
if (w >= n_buffer) {
|
if (w >= n_buffer) {
|
||||||
w -= n_buffer;
|
w -= n_buffer;
|
||||||
t[0] = _mm_loadu_ps(&buffer[n_buffer]);
|
t[0] = _mm_load_ps(&buffer[n_buffer]);
|
||||||
_mm_storeu_ps(&buffer[0], t[0]);
|
_mm_store_ps(&buffer[0], t[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(; n < n_samples; n++) {
|
for(; n < n_samples; n++) {
|
||||||
|
|
@ -326,8 +326,8 @@ static inline void delay_convolve_run_sse(float *buffer, uint32_t *pos,
|
||||||
w += 4;
|
w += 4;
|
||||||
if (w >= n_buffer) {
|
if (w >= n_buffer) {
|
||||||
w -= n_buffer;
|
w -= n_buffer;
|
||||||
t[0] = _mm_loadu_ps(&buffer[n_buffer]);
|
t[0] = _mm_load_ps(&buffer[n_buffer]);
|
||||||
_mm_storeu_ps(&buffer[0], t[0]);
|
_mm_store_ps(&buffer[0], t[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(; n < n_samples; n++) {
|
for(; n < n_samples; n++) {
|
||||||
|
|
|
||||||
|
|
@ -775,7 +775,11 @@ int channelmix_init(struct channelmix *mix)
|
||||||
mix->delay = (uint32_t)(mix->rear_delay * mix->freq / 1000.0f);
|
mix->delay = (uint32_t)(mix->rear_delay * mix->freq / 1000.0f);
|
||||||
mix->func_name = info->name;
|
mix->func_name = info->name;
|
||||||
|
|
||||||
spa_zero(mix->taps);
|
spa_zero(mix->taps_mem);
|
||||||
|
mix->taps = SPA_PTR_ALIGN(mix->taps_mem, CHANNELMIX_OPS_MAX_ALIGN, float);
|
||||||
|
mix->buffer[0] = SPA_PTR_ALIGN(&mix->buffer_mem[0], CHANNELMIX_OPS_MAX_ALIGN, float);
|
||||||
|
mix->buffer[1] = SPA_PTR_ALIGN(&mix->buffer_mem[2*BUFFER_SIZE], CHANNELMIX_OPS_MAX_ALIGN, float);
|
||||||
|
|
||||||
if (mix->hilbert_taps > 0) {
|
if (mix->hilbert_taps > 0) {
|
||||||
mix->n_taps = SPA_CLAMP(mix->hilbert_taps, 15u, MAX_TAPS) | 1;
|
mix->n_taps = SPA_CLAMP(mix->hilbert_taps, 15u, MAX_TAPS) | 1;
|
||||||
blackman_window(mix->taps, mix->n_taps);
|
blackman_window(mix->taps, mix->n_taps);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
#define BUFFER_SIZE 4096
|
#define BUFFER_SIZE 4096
|
||||||
#define MAX_TAPS 255u
|
#define MAX_TAPS 255u
|
||||||
|
|
||||||
|
#define CHANNELMIX_OPS_MAX_ALIGN 16
|
||||||
|
|
||||||
struct channelmix {
|
struct channelmix {
|
||||||
uint32_t src_chan;
|
uint32_t src_chan;
|
||||||
uint32_t dst_chan;
|
uint32_t dst_chan;
|
||||||
|
|
@ -59,10 +61,12 @@ struct channelmix {
|
||||||
uint32_t hilbert_taps; /* to phase shift, 0 disabled */
|
uint32_t hilbert_taps; /* to phase shift, 0 disabled */
|
||||||
struct lr4 lr4[SPA_AUDIO_MAX_CHANNELS];
|
struct lr4 lr4[SPA_AUDIO_MAX_CHANNELS];
|
||||||
|
|
||||||
float buffer[2][BUFFER_SIZE*2 + 16];
|
float buffer_mem[2 * BUFFER_SIZE*2 + CHANNELMIX_OPS_MAX_ALIGN/4];
|
||||||
|
float *buffer[2];
|
||||||
uint32_t pos[2];
|
uint32_t pos[2];
|
||||||
uint32_t delay;
|
uint32_t delay;
|
||||||
float taps[MAX_TAPS];
|
float taps_mem[MAX_TAPS + CHANNELMIX_OPS_MAX_ALIGN/4];
|
||||||
|
float *taps;
|
||||||
uint32_t n_taps;
|
uint32_t n_taps;
|
||||||
|
|
||||||
void (*process) (struct channelmix *mix, void * SPA_RESTRICT dst[],
|
void (*process) (struct channelmix *mix, void * SPA_RESTRICT dst[],
|
||||||
|
|
@ -104,8 +108,6 @@ void channelmix_##name##_##arch(struct channelmix *mix, \
|
||||||
void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[], \
|
void * SPA_RESTRICT dst[], const void * SPA_RESTRICT src[], \
|
||||||
uint32_t n_samples);
|
uint32_t n_samples);
|
||||||
|
|
||||||
#define CHANNELMIX_OPS_MAX_ALIGN 16
|
|
||||||
|
|
||||||
DEFINE_FUNCTION(copy, c);
|
DEFINE_FUNCTION(copy, c);
|
||||||
DEFINE_FUNCTION(f32_n_m, c);
|
DEFINE_FUNCTION(f32_n_m, c);
|
||||||
DEFINE_FUNCTION(f32_1_2, c);
|
DEFINE_FUNCTION(f32_1_2, c);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue