diff mbox series

[FFmpeg-devel] swresample/rematrix: handle 22.2 as a 9 channel layout

Message ID 20200812222658.29282-1-jeebjp@gmail.com
State Accepted
Commit 1c7e55dd504245d71444fac1a73e5370cc76fede
Headers show
Series [FFmpeg-devel] swresample/rematrix: handle 22.2 as a 9 channel layout
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Jan Ekström Aug. 12, 2020, 10:26 p.m. UTC
This is as far as 22.2 follows the same channel order as
WaveFormatExtensible's channel mask (and the AV_CH_* defines).

After LFE2 the side channels would follow, but that offset of
one stops us from utilizing them without further tweaks.

This change was verified by using swresample to downmix to 5.1,
and then feeding that to WASAPI.
---
 libswresample/rematrix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Michael Niedermayer Aug. 14, 2020, 5:36 p.m. UTC | #1
On Thu, Aug 13, 2020 at 01:26:58AM +0300, Jan Ekström wrote:
> This is as far as 22.2 follows the same channel order as
> WaveFormatExtensible's channel mask (and the AV_CH_* defines).
> 
> After LFE2 the side channels would follow, but that offset of
> one stops us from utilizing them without further tweaks.
> 
> This change was verified by using swresample to downmix to 5.1,
> and then feeding that to WASAPI.
> ---
>  libswresample/rematrix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

probably ok

[...]
Jan Ekström Aug. 15, 2020, 9:29 a.m. UTC | #2
On Fri, Aug 14, 2020 at 8:36 PM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> On Thu, Aug 13, 2020 at 01:26:58AM +0300, Jan Ekström wrote:
> > This is as far as 22.2 follows the same channel order as
> > WaveFormatExtensible's channel mask (and the AV_CH_* defines).
> >
> > After LFE2 the side channels would follow, but that offset of
> > one stops us from utilizing them without further tweaks.
> >
> > This change was verified by using swresample to downmix to 5.1,
> > and then feeding that to WASAPI.
> > ---
> >  libswresample/rematrix.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
>
> probably ok
>

Thanks for taking a look. I originally planned on sending a link to a
test sample I created somewhere during the time attempting to validate
the AAC decoder, which I then also utilized to check the result of
this:
https://megumin.fushizen.eu/samples/22.2_input_test_sample.wav

...but alas then I never got to it afterwards.

Jan
Jan Ekström Aug. 15, 2020, 9:40 a.m. UTC | #3
On Sat, Aug 15, 2020 at 12:29 PM Jan Ekström <jeebjp@gmail.com> wrote:
>
> On Fri, Aug 14, 2020 at 8:36 PM Michael Niedermayer
> <michael@niedermayer.cc> wrote:
> >
> > On Thu, Aug 13, 2020 at 01:26:58AM +0300, Jan Ekström wrote:
> > > This is as far as 22.2 follows the same channel order as
> > > WaveFormatExtensible's channel mask (and the AV_CH_* defines).
> > >
> > > After LFE2 the side channels would follow, but that offset of
> > > one stops us from utilizing them without further tweaks.
> > >
> > > This change was verified by using swresample to downmix to 5.1,
> > > and then feeding that to WASAPI.
> > > ---
> > >  libswresample/rematrix.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > probably ok
> >
>
> Thanks for taking a look. I originally planned on sending a link to a
> test sample I created somewhere during the time attempting to validate
> the AAC decoder, which I then also utilized to check the result of
> this:
> https://megumin.fushizen.eu/samples/22.2_input_test_sample.wav
>
> ...but alas then I never got to it afterwards.
>

Aand once again hit the send button a bit too soon.

For context, the reason why I started poking at this a bit more is
because a friendly person elsewhere who implemented 22.2 to X downmix
on his side pointed out that
https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BS.2159-8-2019-PDF-E.pdf
contained the downmix matrix to 5.1 (TABLE11, System H is 22.2).

So I planned on taking the same shortcut of doing 22.2->5.1->X, since
5.1 was already implemented or could be pushed to most audio output
systems, but after looking at rematrix for a bit I got that no such
shortcuts would be possible.

So now the plan is to attempt to see if:
1) I can work around the +1 offset for side left/right, thus creating
the base level 10.1 that seems to be implemented in rematrix.
2) Mix top/bottom channels into their matching base level, adding
support for them being mixed in.
3) Mix LFE2 into LFE1.

If this would work, we could get a downmix going by means of 22.2->10.1->X .

Jan
Jan Ekström Aug. 18, 2020, 8:01 p.m. UTC | #4
On Fri, Aug 14, 2020 at 8:36 PM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> On Thu, Aug 13, 2020 at 01:26:58AM +0300, Jan Ekström wrote:
> > This is as far as 22.2 follows the same channel order as
> > WaveFormatExtensible's channel mask (and the AV_CH_* defines).
> >
> > After LFE2 the side channels would follow, but that offset of
> > one stops us from utilizing them without further tweaks.
> >
> > This change was verified by using swresample to downmix to 5.1,
> > and then feeding that to WASAPI.
> > ---
> >  libswresample/rematrix.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
>
> probably ok
>

Applied as 1c7e55dd504245d71444fac1a73e5370cc76fede .

Jan
diff mbox series

Patch

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index d0c4a212b3..94b3de88f6 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -143,7 +143,7 @@  av_cold int swr_build_matrix(uint64_t in_ch_layout_param, uint64_t out_ch_layout
 
     if (in_ch_layout == AV_CH_LAYOUT_22POINT2 &&
         out_ch_layout != AV_CH_LAYOUT_22POINT2) {
-        in_ch_layout = AV_CH_LAYOUT_5POINT1_BACK;
+        in_ch_layout = (AV_CH_LAYOUT_7POINT1_WIDE_BACK|AV_CH_BACK_CENTER);
         av_get_channel_layout_string(buf, sizeof(buf), -1, in_ch_layout);
         av_log(log_context, AV_LOG_WARNING,
                "Full-on remixing from 22.2 has not yet been implemented! "