Re: Weak bass in stereo mode – possibility of virtual 2.1 sound profiles

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/7/18 6:27 PM, Alexander E. Patrakov wrote:
вс, 7 окт. 2018 г. в 16:42, Karl Ove Hufthammer <karl@xxxxxxxxxx <mailto:karl@xxxxxxxxxx>>:

    Alexander E. Patrakov skreiv 07.10.2018 09:44:
     >
     >     I don’t understand why this is happening. Shouldn’t
     >     ‘remixing-use-all-sink-channels = no’ just affect *upmixing* of
     >     sound,
     >     and leave 5.1 material alone?
     >
     >
     > This is a known bug that appears because there are two 5.1
    standards:
     > proper 5.1 and 5.1 Side. The video player (I guess you use mpv)
    says:
     > the extra two channels have to come from the side.

    Looks like you’re right. If I run ‘ffprobe’ on my 5.1 test file, it
    returns:

        Stream #0:1[0x1100]: Audio: dts (DTS-HD MA) ([134][0][0][0] /
    0x0086), 48000 Hz, 5.1(side), s32p (24 bit)

    So the video file (and mpv) seems to  use the ‘5.1(side)’ standard.
    (Which is a bit strange, since this is supposed to be a video file to
    test a normal 5.1 setup, AFAICS.)


(speaking with my "DTS encoder author" hat on)

The issue is that it is a DTS file. DTS uses completely different channel names than what's found in PulseAudio source. The proper normative reference is:

https://www.etsi.org/deliver/etsi_ts/102100_102199/102114/01.03.01_60/ts_102114v010301p.pdf
page 19, table 5.4 (note that the presence of the LFE channel is transmitted separately).

Your file uses AMODE=0b001001=9, so the list of channels is: "Center", "Left", "Right", "Surround Left", "Surround Right". And there is also a 64x downsampled LFE channel. FFMmpeg-based decoders map "Surround" to "Side" because "Rear" also exists in other channel layouts and means something different. There is no way in DTS to express a layout with "Rear" but no "Surround" channels.



     > But your system does not have speakers there, it has them on the
    rear.
     > So PulseAudio attempts to remix. In fact, sound both with and
    without
     > remixing-use-all-sink-channels is wrong.

    What’s wrong about the remixing when one uses
    ‘remixing-use-all-sink-channels = yes’?


The rear channels will get not a copy of the side, but an average of front and side.

As promised, here is a patch.

Note that I am unhappy with it, because it fixes only a particular common problem case, while other related issues stay unfixed. E.g. if one tries to play 5.1 audio on 7.1 system, with or without this patch:

- Front, Center and LFE channels are mapped 1:1, which is correct
- Rear (or what mpv calls "Side") source channels are mapped to Side, which is also correct, because it's the Side speakers in the ITU-T 7.1 layout, not Rear, which have the nearest position to what Dolby specifies for Surround AC3 speakers. - The true rear channels get a mix between Front and Side, which is clearly incorrect. ITU R-REC-BS.775-3-201208 says that both sets of surround channels should be fed the same signal.

But the needed refactoring (e.g. choosing what to mix where based on speaker azimuths) is way too big, so I decided to postpone it.

--
Alexander E. Patrakov

>From dc03008eb79f899c50b9d29a87245962399728ec Mon Sep 17 00:00:00 2001
From: "Alexander E. Patrakov" <patrakov@xxxxxxxxx>
Date: Sat, 13 Oct 2018 22:11:20 +0500
Subject: [PATCH] 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@xxxxxxxxx>
---
 src/pulsecore/resampler.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index d42cbc298..6a4ded690 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -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 */
 
-- 
2.19.0


_______________________________________________
pulseaudio-discuss mailing list
pulseaudio-discuss@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux