[FFmpeg-devel] [PATCH 0/5 v2] 22.2 channel layout support for AAC decoding

Jan Ekström jeebjp at gmail.com
Fri Jul 31 00:25:10 EEST 2020


On Wed, Jul 29, 2020 at 2:39 PM Jan Ekström <jeebjp at gmail.com> wrote:
>
> swresample seems to give out the correct channels for 5.1 and stereo
> downmix (checked with ffmpeg.c by utilizing `-channel_layout` 5.1 and stereo),
> although the default downmix logic seems to lower the volume somewhat.
>

I attempted to take this into mention, and apparently seem to have
succeeded. Not pretty but since we don't yet have a full matrix for it
and as the rest of the channel layout doesn't follow the bit mask's
rising order I guess for now this is the least bad way of handling it.
Added a warning since anyone interested in actually implementing this
in a more complete manner might get interested.

Note: I have no idea if this is the correct location or way to put
this override, but since the stereo overrides seemed to be here as
well, I followed similar logic.

format-patch follows:

>From 16e9eda23862daaaf2a43824b75ddf7e8054f23e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Ekstr=C3=B6m?= <jeebjp at gmail.com>
Date: Thu, 30 Jul 2020 23:52:57 +0300
Subject: [PATCH] swresample/rematrix: treat 22.2 as 5.1 (back) when mixing

Only this sub-set of channels actually follows the bit mask order
in the official 22.2 channel mapping.
---
 libswresample/rematrix.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/libswresample/rematrix.c b/libswresample/rematrix.c
index 6b5feaa07b..43845a429f 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_param == AV_CH_LAYOUT_22POINT2 &&
+        out_ch_layout_param != 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);
-- 
2.26.2


More information about the ffmpeg-devel mailing list