diff mbox series

[FFmpeg-devel,3/7] swresample/rematrix: treat 22.2 as 5.1 (back) when mixing

Message ID 20200801110730.30642-4-jeebjp@gmail.com
State Accepted
Commit f5390a9f86d68ced52a39e00eca70d15d25accc7
Headers show
Series 22.2 channel layout support for AAC decoding
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. 1, 2020, 11:07 a.m. UTC
Only this sub-set of channels actually follows the bit mask order
in the official 22.2 channel mapping. Additionally, the 5.1 channels
are there for backwards compatibility with the previous system.

This enables the utilization of 22.2 content until a proper down/up
matrix is added into swresample.
---
 libswresample/rematrix.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Michael Niedermayer Aug. 1, 2020, 6:52 p.m. UTC | #1
On Sat, Aug 01, 2020 at 02:07:26PM +0300, Jan Ekström wrote:
> Only this sub-set of channels actually follows the bit mask order
> in the official 22.2 channel mapping. Additionally, the 5.1 channels
> are there for backwards compatibility with the previous system.
> 
> This enables the utilization of 22.2 content until a proper down/up
> matrix is added into swresample.
> ---
>  libswresample/rematrix.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

assuming this is true and theres no issue with order 
it should be ok

thx

[...]
Jan Ekström Aug. 1, 2020, 7:46 p.m. UTC | #2
On Sat, Aug 1, 2020 at 9:52 PM Michael Niedermayer
<michael@niedermayer.cc> wrote:
>
> On Sat, Aug 01, 2020 at 02:07:26PM +0300, Jan Ekström wrote:
> > Only this sub-set of channels actually follows the bit mask order
> > in the official 22.2 channel mapping. Additionally, the 5.1 channels
> > are there for backwards compatibility with the previous system.
> >
> > This enables the utilization of 22.2 content until a proper down/up
> > matrix is added into swresample.
> > ---
> >  libswresample/rematrix.c | 10 ++++++++++
> >  1 file changed, 10 insertions(+)
>
> assuming this is true and theres no issue with order
> it should be ok
>

Thanks for taking a look.

Yes, the first 6 channels in 22.2 are mapped the same as 5.1 (back),
and the AAC decoder code reorders the coding units accordingly to
match specification. This change was then verified using
`-channel_layout "5.1"` with ffmpeg.c to just take the first six
channels.

Jan
diff mbox series

Patch

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 983355ba36..d0c4a212b3 100644
--- a/libswresample/rematrix.c
+++ b/libswresample/rematrix.c
@@ -141,6 +141,16 @@  av_cold int swr_build_matrix(uint64_t in_ch_layout_param, uint64_t out_ch_layout
     )
         in_ch_layout = AV_CH_LAYOUT_STEREO;
 
+    if (in_ch_layout == AV_CH_LAYOUT_22POINT2 &&
+        out_ch_layout != AV_CH_LAYOUT_22POINT2) {
+        in_ch_layout = AV_CH_LAYOUT_5POINT1_BACK;
+        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! "
+               "Processing the input as '%s'\n",
+               buf);
+    }
+
     if(!sane_layout(in_ch_layout)){
         av_get_channel_layout_string(buf, sizeof(buf), -1, in_ch_layout_param);
         av_log(log_context, AV_LOG_ERROR, "Input channel layout '%s' is not supported\n", buf);