channelmix: add stereo to 7.1 upmix

This commit is contained in:
Wim Taymans 2022-02-24 16:09:14 +01:00
parent b1ca470d99
commit 2e8e8938bc
3 changed files with 51 additions and 0 deletions

View file

@ -317,6 +317,55 @@ channelmix_f32_2_5p1_c(struct channelmix *mix, void * SPA_RESTRICT dst[],
}
}
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;
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];
const float v7 = mix->matrix[7][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 == 1.0f && v1 == 1.0f && v4 == 1.0f && v5 == 1.0f &&
v6 == 1.0f && v7 == 1.0f) {
for (n = 0; n < n_samples; n++) {
float c = s[0][n] + s[1][n];
d[0][n] = d[4][n] = d[6][n] = s[0][n];
d[1][n] = d[5][n] = d[7][n] = s[1][n];
d[2][n] = c * v2;
d[3][n] = c * v3;
}
if (v3 > 0.0f)
lr4_process(&mix->lr4[3], d[3], n_samples);
}
else {
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 * v3;
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;
}
if (v3 > 0.0f)
lr4_process(&mix->lr4[3], d[3], n_samples);
}
}
/* FL+FR+FC+LFE+SL+SR -> FL+FR */
void
channelmix_f32_5p1_2_c(struct channelmix *mix, void * SPA_RESTRICT dst[],

View file

@ -84,6 +84,7 @@ static const struct channelmix_info {
{ 2, MASK_STEREO, 4, MASK_QUAD, channelmix_f32_2_4_c, 0, "f32_2_4_c" },
{ 2, MASK_STEREO, 4, MASK_3_1, channelmix_f32_2_3p1_c, 0, "f32_2_3p1_c" },
{ 2, MASK_STEREO, 6, MASK_5_1, channelmix_f32_2_5p1_c, 0, "f32_2_5p1_c" },
{ 2, MASK_STEREO, 8, MASK_7_1, channelmix_f32_2_7p1_c, 0, "f32_2_7p1_c" },
#if defined (HAVE_SSE)
{ 6, MASK_5_1, 2, MASK_STEREO, channelmix_f32_5p1_2_sse, SPA_CPU_FLAG_SSE, "f32_5p1_2_sse" },
#endif

View file

@ -103,6 +103,7 @@ DEFINE_FUNCTION(f32_3p1_1, c);
DEFINE_FUNCTION(f32_2_4, c);
DEFINE_FUNCTION(f32_2_3p1, c);
DEFINE_FUNCTION(f32_2_5p1, c);
DEFINE_FUNCTION(f32_2_7p1, c);
DEFINE_FUNCTION(f32_5p1_2, c);
DEFINE_FUNCTION(f32_5p1_3p1, c);
DEFINE_FUNCTION(f32_5p1_4, c);