From 17fd38c3a5e4a665cbe24ecf6b3aef795d4ea4df Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Sun, 14 Mar 2021 15:42:53 +0100 Subject: [PATCH] channelmix: use front-center matrix values Use the front-center matrix values to mix left and right. --- spa/plugins/audioconvert/channelmix-ops-c.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/spa/plugins/audioconvert/channelmix-ops-c.c b/spa/plugins/audioconvert/channelmix-ops-c.c index 4502fee82..e70f70d68 100644 --- a/spa/plugins/audioconvert/channelmix-ops-c.c +++ b/spa/plugins/audioconvert/channelmix-ops-c.c @@ -237,6 +237,7 @@ channelmix_f32_2_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI 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; if (SPA_FLAG_IS_SET(mix->flags, CHANNELMIX_FLAG_ZERO)) { for (i = 0; i < n_dst; i++) @@ -246,7 +247,7 @@ channelmix_f32_2_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI for (n = 0; n < n_samples; n++) { d[0][n] = s[0][n]; d[1][n] = s[1][n]; - d[2][n] = (s[0][n] + s[1][n]) * 0.5f; + d[2][n] = (s[0][n] + s[1][n]) * v2; d[3][n] = 0.0f; } } @@ -254,7 +255,7 @@ channelmix_f32_2_3p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI for (n = 0; n < n_samples; n++) { d[0][n] = s[0][n] * v0; d[1][n] = s[1][n] * v1; - d[2][n] = (d[0][n] + d[1][n]) * 0.5f; + d[2][n] = (d[0][n] + d[1][n]) * v2; d[3][n] = 0.0f; } } @@ -270,6 +271,7 @@ channelmix_f32_2_5p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI 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 v4 = mix->matrix[4][0]; const float v5 = mix->matrix[5][1]; @@ -281,7 +283,7 @@ channelmix_f32_2_5p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI for (n = 0; n < n_samples; n++) { d[0][n] = d[4][n] = s[0][n]; d[1][n] = d[5][n] = s[1][n]; - d[2][n] = (s[0][n] + s[1][n]) * 0.5f; + d[2][n] = (s[0][n] + s[1][n]) * v2; d[3][n] = 0.0f; } } @@ -289,7 +291,7 @@ channelmix_f32_2_5p1_c(struct channelmix *mix, uint32_t n_dst, void * SPA_RESTRI for (n = 0; n < n_samples; n++) { d[0][n] = s[0][n] * v0; d[1][n] = s[1][n] * v1; - d[2][n] = (d[0][n] + d[1][n]) * 0.5f; + d[2][n] = (d[0][n] + d[1][n]) * v2; d[3][n] = 0.0f; d[4][n] = s[0][n] * v4; d[5][n] = s[1][n] * v5;