mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
channelmix: fix normalization
Don't count the sum for unused matrix coefficients. When doing pairing, we set the mask to ~0 and so we would otherwise count too much. Apply normalization to the active matrix coefficients, not whatever the loop variables end up being at the end of the loops.
This commit is contained in:
parent
3b507e062c
commit
b7928799e5
1 changed files with 4 additions and 3 deletions
|
|
@ -483,6 +483,8 @@ done:
|
|||
for (jc = 0, j = 0; j < SPA_AUDIO_MAX_CHANNELS; j++) {
|
||||
if ((src_mask & (1UL << j)) == 0)
|
||||
continue;
|
||||
if (ic >= dst_chan || jc >= src_chan)
|
||||
continue;
|
||||
mix->matrix_orig[ic][jc++] = matrix[i][j];
|
||||
sum += fabs(matrix[i][j]);
|
||||
}
|
||||
|
|
@ -501,11 +503,10 @@ done:
|
|||
if (SPA_FLAG_IS_SET(mix->options, CHANNELMIX_OPTION_NORMALIZE) &&
|
||||
maxsum > 1.0f) {
|
||||
spa_log_debug(mix->log, "normalize %f", maxsum);
|
||||
for (i = 0; i < ic; i++)
|
||||
for (j = 0; j < jc; j++)
|
||||
for (i = 0; i < dst_chan; i++)
|
||||
for (j = 0; j < src_chan; j++)
|
||||
mix->matrix_orig[i][j] /= maxsum;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue