mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-20 21:37:47 -04:00
channelmix: Convert matrices to float arrays
Convert matrix_orig and matrix to float arrays and use variable size 2d arrays to access the elements of the matrices. This removes the need for storing pointers to matrix rows.
This commit is contained in:
parent
7cfcb46fbf
commit
a7994882b9
6 changed files with 161 additions and 134 deletions
|
|
@ -27,11 +27,12 @@ SPA_LOG_IMPL(logger);
|
|||
|
||||
static void dump_matrix(struct channelmix *mix, double *coeff)
|
||||
{
|
||||
CHANNELMIX_DEF_MATRIX(matrix, mix, matrix);
|
||||
uint32_t i, j;
|
||||
|
||||
for (i = 0; i < mix->dst_chan; i++) {
|
||||
for (j = 0; j < mix->src_chan; j++) {
|
||||
float v = mix->matrix[i][j];
|
||||
float v = matrix[i][j];
|
||||
spa_log_debug(mix->log, "%d %d: %f <-> %f", i, j, v, *coeff);
|
||||
spa_assert_se(CLOSE_ENOUGH(v, (float)*coeff));
|
||||
coeff++;
|
||||
|
|
@ -352,16 +353,18 @@ static void test_n_m_impl(void)
|
|||
/* identity matrix */
|
||||
run_n_m_impl(&mix, (const void**)src, N_SAMPLES);
|
||||
|
||||
CHANNELMIX_DEF_MATRIX(matrix_orig, &mix, matrix_orig);
|
||||
|
||||
/* some zero destination */
|
||||
mix.matrix_orig[2][2] = 0.0f;
|
||||
mix.matrix_orig[7][7] = 0.0f;
|
||||
matrix_orig[2][2] = 0.0f;
|
||||
matrix_orig[7][7] = 0.0f;
|
||||
channelmix_set_volume(&mix, 1.0f, false, 0, NULL);
|
||||
run_n_m_impl(&mix, (const void**)src, N_SAMPLES);
|
||||
|
||||
/* random matrix */
|
||||
for (i = 0; i < mix.dst_chan; i++) {
|
||||
for (j = 0; j < mix.src_chan; j++) {
|
||||
mix.matrix_orig[i][j] = (float)(drand48() - 0.5f);
|
||||
matrix_orig[i][j] = (float)(drand48() - 0.5f);
|
||||
}
|
||||
}
|
||||
channelmix_set_volume(&mix, 1.0f, false, 0, NULL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue