resampler: Fix confusion between rear and side channels for 5.1 layouts

mpv and vlc play "normal" 5.1 AC3 and DTS files as if they had a
"5.1 (Side)" layout. Which is fine and consistent with ITU
recommendations if the user has a proper 7.1 system. But if the user
actually has a 5.1 system, PulseAudio will try to remap, poorly, between
the "5.1 (Side)" and "5.1" layouts, sending either an average between
front and rear channels, or an attenuated version of that average,
depending on the remixing-use-all-sink-channels setting.

This is not desired, the "Side" channels should be sent to "Rear", it is
only an unfortunate nomenclature confusion.

This patch does not fix 5.1 <-> 7.1 remixing.

Signed-off-by: Alexander E. Patrakov <patrakov@gmail.com>
This commit is contained in:
Alexander E. Patrakov 2018-10-13 22:11:20 +05:00 committed by Tanu Kaskinen
parent 3e80e0f777
commit 73156649e7

View file

@ -914,6 +914,8 @@ static void setup_remap(const pa_resampler *r, pa_remap_t *m, bool *lfe_remixed)
* The algorithm works basically like this:
*
* 1) Connect all channels with matching names.
* This also includes fixing confusion between "5.1" and
* "5.1 (Side)" layouts, done by mpv.
*
* 2) Mono Handling:
* S:Mono: See setup_oc_mono_map().
@ -1006,6 +1008,26 @@ static void setup_remap(const pa_resampler *r, pa_remap_t *m, bool *lfe_remixed)
}
}
if (!oc_connected) {
/* Maybe it is due to 5.1 rear/side confustion? */
for (ic = 0; ic < n_ic; ic++) {
pa_channel_position_t a = r->i_cm.map[ic];
if (ic_connected[ic])
continue;
if ((a == PA_CHANNEL_POSITION_REAR_LEFT && b == PA_CHANNEL_POSITION_SIDE_LEFT) ||
(a == PA_CHANNEL_POSITION_SIDE_LEFT && b == PA_CHANNEL_POSITION_REAR_LEFT) ||
(a == PA_CHANNEL_POSITION_REAR_RIGHT && b == PA_CHANNEL_POSITION_SIDE_RIGHT) ||
(a == PA_CHANNEL_POSITION_SIDE_RIGHT && b == PA_CHANNEL_POSITION_REAR_RIGHT)) {
m->map_table_f[oc][ic] = 1.0f;
oc_connected = true;
ic_connected[ic] = true;
}
}
}
if (!oc_connected) {
/* Try to find matching input ports for this output port */