]> code.delx.au - pulseaudio/commit
resampler: Generate normalized rows in calc_map_table()
authorStefan Huber <shuber@sthu.org>
Thu, 7 Feb 2013 13:03:17 +0000 (14:03 +0100)
committerTanu Kaskinen <tanuk@iki.fi>
Thu, 7 Feb 2013 14:45:13 +0000 (16:45 +0200)
commit930654a3af266ab112d1d1f6b1083197ee4bb373
tree16fb3866dc094128735d5f548d5df99a216e7204
parent1a40af9c3baf23b963aab0d77234e530cc4cad22
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.
src/pulsecore/resampler.c