audiomixer: support multiple channels when mixing with AVX, SSE and SSE2

This commit is contained in:
Julian Bouzas 2021-09-09 09:28:24 -04:00 committed by Wim Taymans
parent 3f8fb6e4dc
commit 767ac79328
4 changed files with 15 additions and 15 deletions

View file

@ -124,12 +124,12 @@ mix_f32_avx(struct mix_ops *ops, void * SPA_RESTRICT dst, const void * SPA_RESTR
uint32_t i;
if (n_src == 0)
memset(dst, 0, n_samples * sizeof(float));
memset(dst, 0, n_samples * ops->n_channels * sizeof(float));
else if (dst != src[0])
memcpy(dst, src[0], n_samples * sizeof(float));
memcpy(dst, src[0], n_samples * ops->n_channels * sizeof(float));
for (i = 1; i + 2 < n_src; i += 3)
mix_4(dst, src[i], src[i + 1], src[i + 2], n_samples);
for (; i < n_src; i++)
mix_2(dst, src[i], n_samples);
mix_2(dst, src[i], n_samples * ops->n_channels);
}

View file

@ -79,11 +79,11 @@ mix_f32_sse(struct mix_ops *ops, void * SPA_RESTRICT dst, const void * SPA_RESTR
uint32_t i;
if (n_src == 0)
memset(dst, 0, n_samples * sizeof(float));
memset(dst, 0, n_samples * ops->n_channels * sizeof(float));
else if (dst != src[0])
memcpy(dst, src[0], n_samples * sizeof(float));
memcpy(dst, src[0], n_samples * ops->n_channels * sizeof(float));
for (i = 1; i < n_src; i++) {
mix_2(dst, src[i], n_samples);
mix_2(dst, src[i], n_samples * ops->n_channels);
}
}

View file

@ -79,11 +79,11 @@ mix_f64_sse2(struct mix_ops *ops, void * SPA_RESTRICT dst, const void * SPA_REST
uint32_t i;
if (n_src == 0)
memset(dst, 0, n_samples * sizeof(double));
memset(dst, 0, n_samples * ops->n_channels * sizeof(double));
else if (dst != src[0])
memcpy(dst, src[0], n_samples * sizeof(double));
memcpy(dst, src[0], n_samples * ops->n_channels * sizeof(double));
for (i = 1; i < n_src; i++) {
mix_2(dst, src[i], n_samples);
mix_2(dst, src[i], n_samples * ops->n_channels);
}
}

View file

@ -47,20 +47,20 @@ static struct mix_info mix_table[] =
{
/* f32 */
#if defined(HAVE_AVX)
{ SPA_AUDIO_FORMAT_F32, 1, SPA_CPU_FLAG_AVX, 4, mix_f32_avx },
{ SPA_AUDIO_FORMAT_F32P, 1, SPA_CPU_FLAG_AVX, 4, mix_f32_avx },
{ SPA_AUDIO_FORMAT_F32, 0, SPA_CPU_FLAG_AVX, 4, mix_f32_avx },
{ SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_AVX, 4, mix_f32_avx },
#endif
#if defined (HAVE_SSE)
{ SPA_AUDIO_FORMAT_F32, 1, SPA_CPU_FLAG_SSE, 4, mix_f32_sse },
{ SPA_AUDIO_FORMAT_F32P, 1, SPA_CPU_FLAG_SSE, 4, mix_f32_sse },
{ SPA_AUDIO_FORMAT_F32, 0, SPA_CPU_FLAG_SSE, 4, mix_f32_sse },
{ SPA_AUDIO_FORMAT_F32P, 0, SPA_CPU_FLAG_SSE, 4, mix_f32_sse },
#endif
{ SPA_AUDIO_FORMAT_F32, 0, 0, 4, mix_f32_c },
{ SPA_AUDIO_FORMAT_F32P, 0, 0, 4, mix_f32_c },
/* f64 */
#if defined (HAVE_SSE2)
{ SPA_AUDIO_FORMAT_F64, 1, SPA_CPU_FLAG_SSE2, 8, mix_f64_sse2 },
{ SPA_AUDIO_FORMAT_F64P, 1, SPA_CPU_FLAG_SSE2, 8, mix_f64_sse2 },
{ SPA_AUDIO_FORMAT_F64, 0, SPA_CPU_FLAG_SSE2, 8, mix_f64_sse2 },
{ SPA_AUDIO_FORMAT_F64P, 0, SPA_CPU_FLAG_SSE2, 8, mix_f64_sse2 },
#endif
{ SPA_AUDIO_FORMAT_F64, 0, 0, 8, mix_f64_c },
{ SPA_AUDIO_FORMAT_F64P, 0, 0, 8, mix_f64_c },