mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
channelmix: reuse more functions
Make some copy/vol functions and reuse them. Reuse the 2->3p1 upmix code, tweak it a little to that the widen param is always used.
This commit is contained in:
parent
e12e4295cf
commit
66e4334c92
3 changed files with 110 additions and 242 deletions
|
|
@ -24,28 +24,52 @@
|
|||
|
||||
#include "channelmix-ops.h"
|
||||
|
||||
static inline void clear_c(float *d, uint32_t n_samples)
|
||||
{
|
||||
memset(d, 0, n_samples * sizeof(float));
|
||||
}
|
||||
|
||||
static inline void copy_c(float *d, const float *s, uint32_t n_samples)
|
||||
{
|
||||
spa_memcpy(d, s, n_samples * sizeof(float));
|
||||
}
|
||||
|
||||
static inline void vol_c(float *d, const float *s, float vol, uint32_t n_samples)
|
||||
{
|
||||
uint32_t n;
|
||||
if (vol == 0.0f) {
|
||||
clear_c(d, n_samples);
|
||||
} else if (vol == 1.0f) {
|
||||
copy_c(d, s, n_samples);
|
||||
} else {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[n] = s[n] * vol;
|
||||
}
|
||||
}
|
||||
|
||||
static inline void add_c(float *d, const float *s0, const float *s1, uint32_t n_samples)
|
||||
{
|
||||
uint32_t n;
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[n] = s0[n] + s1[n];
|
||||
}
|
||||
|
||||
static inline void sub_c(float *d, const float *s0, const float *s1, uint32_t n_samples)
|
||||
{
|
||||
uint32_t n;
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[n] = s0[n] - s1[n];
|
||||
}
|
||||
|
||||
void
|
||||
channelmix_copy_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
||||
const void * SPA_RESTRICT src[], uint32_t n_samples)
|
||||
{
|
||||
uint32_t i, n, n_dst = mix->dst_chan;
|
||||
uint32_t i, n_dst = mix->dst_chan;
|
||||
float **d = (float **)dst;
|
||||
const float **s = (const float **)src;
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
}
|
||||
else if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_IDENTITY)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
spa_memcpy(d[i], s[i], n_samples * sizeof(float));
|
||||
}
|
||||
else {
|
||||
for (i = 0; i < n_dst; i++) {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[i][n] = s[i][n] * mix->matrix[i][i];
|
||||
}
|
||||
}
|
||||
for (i = 0; i < n_dst; i++)
|
||||
vol_c(d[i], s[i], mix->matrix[i][i], n_samples);
|
||||
}
|
||||
|
||||
#define _M(ch) (1UL << SPA_AUDIO_CHANNEL_ ## ch)
|
||||
|
|
@ -60,14 +84,14 @@ channelmix_f32_n_m_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_COPY)) {
|
||||
uint32_t copy = SPA_MIN(n_dst, n_src);
|
||||
for (i = 0; i < copy; i++)
|
||||
spa_memcpy(d[i], s[i], n_samples * sizeof(float));
|
||||
copy_c(d[i], s[i], n_samples);
|
||||
for (; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
|
|
@ -90,29 +114,13 @@ void
|
|||
channelmix_f32_1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
||||
const void * SPA_RESTRICT src[], uint32_t n_samples)
|
||||
{
|
||||
uint32_t n;
|
||||
float **d = (float **)dst;
|
||||
const float **s = (const float **)src;
|
||||
const float v0 = mix->matrix[0][0];
|
||||
const float v1 = mix->matrix[1][0];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
memset(d[0], 0, n_samples * sizeof(float));
|
||||
memset(d[1], 0, n_samples * sizeof(float));
|
||||
} else if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_EQUAL)) {
|
||||
if (v0 == 1.0f) {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[0][n] = d[1][n] = s[0][n];
|
||||
} else {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[0][n] = d[1][n] = s[0][n] * v0;
|
||||
}
|
||||
} else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
d[0][n] = s[0][n] * v0;
|
||||
d[1][n] = s[0][n] * v1;
|
||||
}
|
||||
}
|
||||
vol_c(d[0], s[0], v0, n_samples);
|
||||
vol_c(d[1], s[0], v1, n_samples);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -126,7 +134,7 @@ channelmix_f32_2_1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
const float v1 = mix->matrix[0][1];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
memset(d[0], 0, n_samples * sizeof(float));
|
||||
clear_c(d[0], n_samples);
|
||||
} else if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_EQUAL)) {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[0][n] = (s[0][n] + s[1][n]) * v0;
|
||||
|
|
@ -150,7 +158,7 @@ channelmix_f32_4_1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
const float v3 = mix->matrix[0][3];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
memset(d[0], 0, n_samples * sizeof(float));
|
||||
clear_c(d[0], n_samples);
|
||||
}
|
||||
else if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_EQUAL)) {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
|
|
@ -163,38 +171,12 @@ channelmix_f32_4_1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
channelmix_f32_3p1_1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
||||
const void * SPA_RESTRICT src[], uint32_t n_samples)
|
||||
{
|
||||
uint32_t n;
|
||||
float **d = (float **)dst;
|
||||
const float **s = (const float **)src;
|
||||
const float v0 = mix->matrix[0][0];
|
||||
const float v1 = mix->matrix[0][1];
|
||||
const float v2 = mix->matrix[0][2];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
memset(d[0], 0, n_samples * sizeof(float));
|
||||
}
|
||||
else if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_EQUAL)) {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[0][n] = (s[0][n] + s[1][n] + s[2][n] + s[3][n]) * v0;
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++)
|
||||
d[0][n] = s[0][n] * v0 + s[1][n] * v1 + s[2][n] * v2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define MASK_QUAD _M(FL)|_M(FR)|_M(RL)|_M(RR)|_M(UNKNOWN)
|
||||
|
||||
void
|
||||
channelmix_f32_2_4_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
||||
const void * SPA_RESTRICT src[], uint32_t n_samples)
|
||||
{
|
||||
uint32_t i, n, n_dst = mix->dst_chan;
|
||||
float **d = (float **)dst;
|
||||
const float **s = (const float **)src;
|
||||
const float v0 = mix->matrix[0][0];
|
||||
|
|
@ -202,31 +184,10 @@ channelmix_f32_2_4_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
const float v2 = mix->matrix[2][0];
|
||||
const float v3 = mix->matrix[3][1];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
}
|
||||
else if (v0 == v2 && v1 == v3) {
|
||||
if (v0 == 1.0f && v1 == 1.0f) {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
d[0][n] = d[2][n] = s[0][n];
|
||||
d[1][n] = d[3][n] = s[1][n];
|
||||
}
|
||||
} else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
d[0][n] = d[2][n] = s[0][n] * v0;
|
||||
d[1][n] = d[3][n] = s[1][n] * v1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
d[0][n] = s[0][n] * v0;
|
||||
d[1][n] = s[1][n] * v1;
|
||||
d[2][n] = s[0][n] * v2;
|
||||
d[3][n] = s[1][n] * v3;
|
||||
}
|
||||
}
|
||||
vol_c(d[0], s[0], v0, n_samples);
|
||||
vol_c(d[1], s[1], v1, n_samples);
|
||||
vol_c(d[2], s[0], v2, n_samples);
|
||||
vol_c(d[3], s[1], v3, n_samples);
|
||||
}
|
||||
|
||||
#define MASK_3_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)
|
||||
|
|
@ -244,36 +205,21 @@ channelmix_f32_2_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
}
|
||||
else if (mix->upmix == CHANNELMIX_UPMIX_SIMPLE) {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
d[0][n] = s[0][n] * v0;
|
||||
d[1][n] = s[1][n] * v1;
|
||||
d[2][n] = c * v2;
|
||||
d[3][n] = c;
|
||||
}
|
||||
lr4_process(&mix->lr4[3], d[3], d[3], v3, n_samples);
|
||||
}
|
||||
else if (v0 == 1.0f && v1 == 1.0f) {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
float w = c * mix->widen;
|
||||
d[0][n] = s[0][n] - w;
|
||||
d[1][n] = s[1][n] - w;
|
||||
d[2][n] = c;
|
||||
}
|
||||
lr4_process(&mix->lr4[3], d[3], d[2], v3, n_samples);
|
||||
lr4_process(&mix->lr4[2], d[2], d[2], v2, n_samples);
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
float w = c * mix->widen;
|
||||
d[0][n] = (s[0][n] - w) * v0;
|
||||
d[1][n] = (s[1][n] - w) * v1;
|
||||
d[2][n] = c;
|
||||
if (mix->widen == 0.0f) {
|
||||
vol_c(d[0], s[0], v0, n_samples);
|
||||
vol_c(d[1], s[1], v1, n_samples);
|
||||
add_c(d[2], s[0], s[1], n_samples);
|
||||
} else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
float w = c * mix->widen;
|
||||
d[0][n] = (s[0][n] - w) * v0;
|
||||
d[1][n] = (s[1][n] - w) * v1;
|
||||
d[2][n] = c;
|
||||
}
|
||||
}
|
||||
lr4_process(&mix->lr4[3], d[3], d[2], v3, n_samples);
|
||||
lr4_process(&mix->lr4[2], d[2], d[2], v2, n_samples);
|
||||
|
|
@ -285,67 +231,30 @@ void
|
|||
channelmix_f32_2_5p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
||||
const void * SPA_RESTRICT src[], uint32_t n_samples)
|
||||
{
|
||||
uint32_t i, n, n_dst = mix->dst_chan;
|
||||
uint32_t i, n_dst = mix->dst_chan;
|
||||
float **d = (float **)dst;
|
||||
const float **s = (const float **)src;
|
||||
const float v0 = mix->matrix[0][0];
|
||||
const float v1 = mix->matrix[1][1];
|
||||
const float v2 = (mix->matrix[2][0] + mix->matrix[2][1]) * 0.5f;
|
||||
const float v3 = (mix->matrix[3][0] + mix->matrix[3][1]) * 0.5f;
|
||||
const float v4 = mix->matrix[4][0];
|
||||
const float v5 = mix->matrix[5][1];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
}
|
||||
else if (mix->upmix == CHANNELMIX_UPMIX_SIMPLE) {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
d[0][n] = s[0][n] * v0;
|
||||
d[1][n] = s[1][n] * v1;
|
||||
d[2][n] = c * v2;
|
||||
d[3][n] = c;
|
||||
d[4][n] = s[0][n] * v4;
|
||||
d[5][n] = s[1][n] * v5;
|
||||
}
|
||||
lr4_process(&mix->lr4[3], d[3], d[3], v3, n_samples);
|
||||
}
|
||||
else if (v0 == 1.0f && v1 == 1.0f) {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
float w = c * mix->widen;
|
||||
float m = s[0][n] - s[1][n];
|
||||
d[0][n] = s[0][n] - w;
|
||||
d[1][n] = s[1][n] - w;
|
||||
d[3][n] = c;
|
||||
d[5][n] = m;
|
||||
}
|
||||
lr4_process(&mix->lr4[2], d[2], d[3], v2, n_samples);
|
||||
lr4_process(&mix->lr4[3], d[3], d[3], v3, n_samples);
|
||||
|
||||
delay_convolve_run(mix->buffer[0], &mix->pos[0], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[4], d[5], v4, n_samples);
|
||||
delay_convolve_run(mix->buffer[1], &mix->pos[1], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[5], d[5], -v5, n_samples);
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
float w = c * mix->widen;
|
||||
float m = s[0][n] - s[1][n];
|
||||
d[0][n] = (s[0][n] - w) * v0;
|
||||
d[1][n] = (s[1][n] - w) * v1;
|
||||
d[3][n] = c;
|
||||
d[5][n] = m;
|
||||
}
|
||||
lr4_process(&mix->lr4[2], d[2], d[3], v2, n_samples);
|
||||
lr4_process(&mix->lr4[3], d[3], d[3], v3, n_samples);
|
||||
channelmix_f32_2_3p1_c(mix, dst, src, n_samples);
|
||||
|
||||
delay_convolve_run(mix->buffer[0], &mix->pos[0], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[4], d[5], v4, n_samples);
|
||||
delay_convolve_run(mix->buffer[1], &mix->pos[1], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[5], d[5], -v5, n_samples);
|
||||
if (mix->upmix != CHANNELMIX_UPMIX_PSD) {
|
||||
vol_c(d[4], s[0], v4, n_samples);
|
||||
vol_c(d[5], s[1], v5, n_samples);
|
||||
} else {
|
||||
sub_c(d[4], s[0], s[1], n_samples);
|
||||
|
||||
delay_convolve_run(mix->buffer[1], &mix->pos[1], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[5], d[4], -v5, n_samples);
|
||||
delay_convolve_run(mix->buffer[0], &mix->pos[0], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[4], d[4], v4, n_samples);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -353,13 +262,9 @@ void
|
|||
channelmix_f32_2_7p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
||||
const void * SPA_RESTRICT src[], uint32_t n_samples)
|
||||
{
|
||||
uint32_t i, n, n_dst = mix->dst_chan;
|
||||
uint32_t i, n_dst = mix->dst_chan;
|
||||
float **d = (float **)dst;
|
||||
const float **s = (const float **)src;
|
||||
const float v0 = mix->matrix[0][0];
|
||||
const float v1 = mix->matrix[1][1];
|
||||
const float v2 = (mix->matrix[2][0] + mix->matrix[2][1]) * 0.5f;
|
||||
const float v3 = (mix->matrix[3][0] + mix->matrix[3][1]) * 0.5f;
|
||||
const float v4 = mix->matrix[4][0];
|
||||
const float v5 = mix->matrix[5][1];
|
||||
const float v6 = mix->matrix[6][0];
|
||||
|
|
@ -367,61 +272,25 @@ channelmix_f32_2_7p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
}
|
||||
else if (mix->upmix == CHANNELMIX_UPMIX_SIMPLE) {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
d[0][n] = s[0][n] * v0;
|
||||
d[1][n] = s[1][n] * v1;
|
||||
d[2][n] = c * v2;
|
||||
d[3][n] = c;
|
||||
d[4][n] = s[0][n] * v4;
|
||||
d[5][n] = s[1][n] * v5;
|
||||
d[6][n] = s[0][n] * v6;
|
||||
d[7][n] = s[1][n] * v7;
|
||||
}
|
||||
lr4_process(&mix->lr4[3], d[3], d[3], v3, n_samples);
|
||||
}
|
||||
else if (v0 == 1.0f && v1 == 1.0f && v4 == 1.0f && v5 == 1.0f) {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
float w = c * mix->widen;
|
||||
float m = s[0][n] - s[1][n];
|
||||
d[0][n] = s[0][n] - w;
|
||||
d[1][n] = s[1][n] - w;
|
||||
d[3][n] = c;
|
||||
d[4][n] = s[0][n];
|
||||
d[5][n] = s[1][n];
|
||||
d[7][n] = m;
|
||||
}
|
||||
lr4_process(&mix->lr4[2], d[2], d[3], v2, n_samples);
|
||||
lr4_process(&mix->lr4[3], d[3], d[3], v3, n_samples);
|
||||
|
||||
delay_convolve_run(mix->buffer[0], &mix->pos[0], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[6], d[7], v6, n_samples);
|
||||
delay_convolve_run(mix->buffer[1], &mix->pos[1], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[7], d[7], -v7, n_samples);
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
float c = s[0][n] + s[1][n];
|
||||
float w = c * mix->widen;
|
||||
float m = s[0][n] - s[1][n];
|
||||
d[0][n] = (s[0][n] - w) * v0;
|
||||
d[1][n] = (s[1][n] - w) * v1;
|
||||
d[3][n] = c;
|
||||
d[4][n] = s[0][n] * v4;
|
||||
d[5][n] = s[1][n] * v5;
|
||||
d[7][n] = m;
|
||||
}
|
||||
lr4_process(&mix->lr4[2], d[2], d[3], v2, n_samples);
|
||||
lr4_process(&mix->lr4[3], d[3], d[3], v3, n_samples);
|
||||
channelmix_f32_2_3p1_c(mix, dst, src, n_samples);
|
||||
|
||||
delay_convolve_run(mix->buffer[0], &mix->pos[0], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[6], d[7], v6, n_samples);
|
||||
delay_convolve_run(mix->buffer[1], &mix->pos[1], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[7], d[7], -v7, n_samples);
|
||||
vol_c(d[4], s[0], v4, n_samples);
|
||||
vol_c(d[5], s[1], v5, n_samples);
|
||||
|
||||
if (mix->upmix != CHANNELMIX_UPMIX_PSD) {
|
||||
vol_c(d[6], s[0], v6, n_samples);
|
||||
vol_c(d[7], s[1], v7, n_samples);
|
||||
} else {
|
||||
sub_c(d[6], s[0], s[1], n_samples);
|
||||
|
||||
delay_convolve_run(mix->buffer[1], &mix->pos[1], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[7], d[6], -v7, n_samples);
|
||||
delay_convolve_run(mix->buffer[0], &mix->pos[0], BUFFER_SIZE, mix->delay,
|
||||
mix->taps, mix->n_taps, d[6], d[6], v6, n_samples);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -441,8 +310,8 @@ channelmix_f32_5p1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
const float slev1 = mix->matrix[1][5];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
memset(d[0], 0, n_samples * sizeof(float));
|
||||
memset(d[1], 0, n_samples * sizeof(float));
|
||||
clear_c(d[0], n_samples);
|
||||
clear_c(d[1], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
|
|
@ -470,15 +339,15 @@ channelmix_f32_5p1_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
d[0][n] = s[0][n] * v0 + s[4][n] * v4;
|
||||
d[1][n] = s[1][n] * v1 + s[5][n] * v5;
|
||||
d[2][n] = s[2][n] * v2;
|
||||
d[3][n] = s[3][n] * v3;
|
||||
}
|
||||
vol_c(d[2], s[2], v2, n_samples);
|
||||
vol_c(d[3], s[3], v3, n_samples);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -499,16 +368,16 @@ channelmix_f32_5p1_4_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
const float ctr = s[2][n] * clev + s[3][n] * llev;
|
||||
d[0][n] = s[0][n] * v0 + ctr;
|
||||
d[1][n] = s[1][n] * v1 + ctr;
|
||||
d[2][n] = s[4][n] * v4;
|
||||
d[3][n] = s[5][n] * v5;
|
||||
}
|
||||
vol_c(d[2], s[4], v4, n_samples);
|
||||
vol_c(d[3], s[5], v5, n_samples);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -532,8 +401,8 @@ channelmix_f32_7p1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
const float rlev1 = mix->matrix[1][7];
|
||||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
memset(d[0], 0, n_samples * sizeof(float));
|
||||
memset(d[1], 0, n_samples * sizeof(float));
|
||||
clear_c(d[0], n_samples);
|
||||
clear_c(d[1], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
|
|
@ -561,15 +430,15 @@ channelmix_f32_7p1_3p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
d[0][n] = s[0][n] * v0 + (s[4][n] + s[6][n]) * v4;
|
||||
d[1][n] = s[1][n] * v1 + (s[5][n] + s[7][n]) * v5;
|
||||
d[2][n] = s[2][n] * v2;
|
||||
d[3][n] = s[3][n] * v3;
|
||||
}
|
||||
vol_c(d[2], s[2], v2, n_samples);
|
||||
vol_c(d[3], s[3], v3, n_samples);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -592,7 +461,7 @@ channelmix_f32_7p1_4_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
|
|||
|
||||
if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) {
|
||||
for (i = 0; i < n_dst; i++)
|
||||
memset(d[i], 0, n_samples * sizeof(float));
|
||||
clear_c(d[i], n_samples);
|
||||
}
|
||||
else {
|
||||
for (n = 0; n < n_samples; n++) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ static const struct channelmix_info {
|
|||
{ 1, MASK_MONO, 2, MASK_STEREO, channelmix_f32_1_2_c, 0, "f32_1_2_c" },
|
||||
{ 2, MASK_STEREO, 1, MASK_MONO, channelmix_f32_2_1_c, 0, "f32_2_1_c" },
|
||||
{ 4, MASK_QUAD, 1, MASK_MONO, channelmix_f32_4_1_c, 0, "f32_4_1_c" },
|
||||
{ 4, MASK_3_1, 1, MASK_MONO, channelmix_f32_3p1_1_c, 0, "f32_3p1_1_c" },
|
||||
{ 4, MASK_3_1, 1, MASK_MONO, channelmix_f32_4_1_c, 0, "f32_4_1_c" },
|
||||
#if defined (HAVE_SSE)
|
||||
{ 2, MASK_STEREO, 4, MASK_QUAD, channelmix_f32_2_4_sse, SPA_CPU_FLAG_SSE, "f32_2_4_sse" },
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -138,7 +138,6 @@ DEFINE_FUNCTION(f32_n_m, c);
|
|||
DEFINE_FUNCTION(f32_1_2, c);
|
||||
DEFINE_FUNCTION(f32_2_1, c);
|
||||
DEFINE_FUNCTION(f32_4_1, c);
|
||||
DEFINE_FUNCTION(f32_3p1_1, c);
|
||||
DEFINE_FUNCTION(f32_2_4, c);
|
||||
DEFINE_FUNCTION(f32_2_3p1, c);
|
||||
DEFINE_FUNCTION(f32_2_5p1, c);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue