channelmix: improve mute/volume handling

Don't try to merge the mute/volume into the matrix but pass the volume
as a separate parameter.
This commit is contained in:
Wim Taymans 2018-10-15 17:57:23 +02:00
parent 3018c17622
commit 6e6e87223f
3 changed files with 65 additions and 66 deletions

View file

@ -31,13 +31,11 @@
static void
channelmix_copy(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples = n_bytes / sizeof(float);
float **d = (float **)dst;
float **s = (float **)src;
float *m = matrix;
float v = m[0];
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -58,7 +56,7 @@ channelmix_copy(void *data, int n_dst, void *dst[n_dst],
static void
channelmix_f32_n_m(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, j, n, n_samples = n_bytes / sizeof(float);
float **d = (float **) dst;
@ -69,7 +67,7 @@ channelmix_f32_n_m(void *data, int n_dst, void *dst[n_dst],
for (i = 0; i < n_dst; i++) {
float sum = 0.0f;
for (j = 0; j < n_src; j++)
sum += s[j][n] * m[i * n_src + j];
sum += s[j][n] * m[i * n_src + j] * v;
d[i][n] = sum;
}
}
@ -80,13 +78,11 @@ channelmix_f32_n_m(void *data, int n_dst, void *dst[n_dst],
static void
channelmix_f32_1_2(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int n, n_samples = n_bytes / sizeof(float);
float **d = (float **)dst;
float **s = (float **)src;
float *m = matrix;
float v = m[0];
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_bytes);
@ -104,13 +100,11 @@ channelmix_f32_1_2(void *data, int n_dst, void *dst[n_dst],
static void
channelmix_f32_2_1(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int n, n_samples = n_bytes / sizeof(float);
float **d = (float **)dst;
float **s = (float **)src;
float *m = matrix;
float v = m[0];
if (v <= VOLUME_MIN) {
memset(d[0], 0, n_bytes);
@ -127,13 +121,11 @@ channelmix_f32_2_1(void *data, int n_dst, void *dst[n_dst],
static void
channelmix_f32_2_4(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples = n_bytes / sizeof(float);
float **d = (float **)dst;
float **s = (float **)src;
float *m = matrix;
float v = m[0];
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -156,13 +148,11 @@ channelmix_f32_2_4(void *data, int n_dst, void *dst[n_dst],
#define MASK_3_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)
static void
channelmix_f32_2_3p1(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples = n_bytes / sizeof(float);
float **d = (float **)dst;
float **s = (float **)src;
float *m = matrix;
float v = m[0];
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -190,13 +180,11 @@ channelmix_f32_2_3p1(void *data, int n_dst, void *dst[n_dst],
#define MASK_5_1 _M(FL)|_M(FR)|_M(FC)|_M(LFE)|_M(SL)|_M(SR)|_M(RL)|_M(RR)
static void
channelmix_f32_2_5p1(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples = n_bytes / sizeof(float);
float **d = (float **)dst;
float **s = (float **)src;
float *m = matrix;
float v = m[0];
if (v <= VOLUME_MIN) {
for (i = 0; i < n_dst; i++)
@ -224,13 +212,12 @@ channelmix_f32_2_5p1(void *data, int n_dst, void *dst[n_dst],
/* FL+FR+FC+LFE+SL+SR -> FL+FR */
static void
channelmix_f32_5p1_2(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int n, n_samples = n_bytes / sizeof(float);
float **d = (float **) dst;
float **s = (float **) src;
float *m = matrix;
float v = m[0];
const float clev = m[2];
const float llev = m[3];
const float slev = m[4];
@ -258,13 +245,11 @@ channelmix_f32_5p1_2(void *data, int n_dst, void *dst[n_dst],
/* FL+FR+FC+LFE+SL+SR -> FL+FR+FC+LFE*/
static void
channelmix_f32_5p1_3p1(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples;
float **d = (float **) dst;
float **s = (float **) src;
float *m = matrix;
float v = m[0];
n_samples = n_bytes / sizeof(float);
if (v <= VOLUME_MIN) {
@ -285,13 +270,12 @@ channelmix_f32_5p1_3p1(void *data, int n_dst, void *dst[n_dst],
/* FL+FR+FC+LFE+SL+SR -> FL+FR+RL+RR*/
static void
channelmix_f32_5p1_4(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples;
float **d = (float **) dst;
float **s = (float **) src;
float *m = matrix;
float v = m[0];
const float clev = m[2];
const float llev = m[3];
@ -325,13 +309,12 @@ channelmix_f32_5p1_4(void *data, int n_dst, void *dst[n_dst],
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR */
static void
channelmix_f32_7p1_2(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int n, n_samples = n_bytes / sizeof(float);
float **d = (float **) dst;
float **s = (float **) src;
float *m = matrix;
float v = m[0];
const float clev = m[2];
const float llev = m[3];
const float slev = m[4];
@ -359,13 +342,11 @@ channelmix_f32_7p1_2(void *data, int n_dst, void *dst[n_dst],
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+FC+LFE*/
static void
channelmix_f32_7p1_3p1(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples;
float **d = (float **) dst;
float **s = (float **) src;
float *m = matrix;
float v = m[0];
n_samples = n_bytes / sizeof(float);
if (v <= VOLUME_MIN) {
@ -386,13 +367,12 @@ channelmix_f32_7p1_3p1(void *data, int n_dst, void *dst[n_dst],
/* FL+FR+FC+LFE+SL+SR+RL+RR -> FL+FR+RL+RR*/
static void
channelmix_f32_7p1_4(void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src], void *matrix, int n_bytes)
int n_src, const void *src[n_src], void *matrix, float v, int n_bytes)
{
int i, n, n_samples;
float **d = (float **) dst;
float **s = (float **) src;
float *m = matrix;
float v = m[0];
const float clev = m[2];
const float llev = m[3];
const float slev = m[4];
@ -428,7 +408,7 @@ channelmix_f32_7p1_4(void *data, int n_dst, void *dst[n_dst],
typedef void (*channelmix_func_t) (void *data, int n_dst, void *dst[n_dst],
int n_src, const void *src[n_src],
void *matrix, int n_bytes);
void *matrix, float v, int n_bytes);
static const struct channelmix_info {