resampler: Generate normalized rows in calc_map_table()
Remixing one channel map to another is (except for special cases) done
via a linear mapping between channels, whose corresponding matrix is
computed by calc_map_table(). The k-th row in this matrix corresponds to
the coefficients of the linear combination of the input channels that
result in the k-th output channel. In order to avoid clipping of samples
we require that the sum of these coefficients is (at most) 1. This
commit ensures this.
Prior to this commit tests/remix-test.c gives 52 of 132 matrices that
violate this property. For example:
'front-left,front-right,front-center,lfe' -> 'front-left,front-right'
prior this commit after this commit
I00 I01 I02 I03 I00 I01 I02 I03
+------------------------ +------------------------
O00 | 0.750 0.000 0.375 0.375 O00 | 0.533 0.000 0.267 0.200
O01 | 0.000 0.750 0.375 0.375 O01 | 0.000 0.533 0.267 0.200
Building the matrix is done in several steps. However, only insufficient
measures are taken in order to preserve a row-sum of 1.0 (or leaves it
at 0.0) after each step. The current patch adds a post-processing step
in order check for each row whether the sum exceeds 1.0 and, if
necessary, normalizes this row. This allows for further simplifactions:
- The insufficient normalizations after some steps are removed. Gains
are adapted to (partially) resemble the old matrices.
- Handling unconnected input channls becomes a lot simpler.