[FFmpeg-devel] [PATCH 1/5] avutil/channel_layout: add 22.2 layout

Jan Ekström jeebjp at gmail.com
Sat Aug 1 16:51:57 EEST 2020


On Sat, Aug 1, 2020 at 4:42 PM James Almer <jamrial at gmail.com> wrote:
>
> On 8/1/2020 9:17 AM, Jan Ekström wrote:
> > On Sat, Aug 1, 2020 at 3:08 PM Carl Eugen Hoyos <ceffmpeg at gmail.com> wrote:
> >>
> >> Am Sa., 1. Aug. 2020 um 14:06 Uhr schrieb Jan Ekström <jeebjp at gmail.com>:
> >>
> >>> Additionally, the spec only mentions stereo/5.1 for direct mapping, so
> >>> I've kept to 5.1 since we have the capability for that one.
> >>
> >> And you still believe it would be a disadvantage if the decoder outputs
> >> this 5.1 mapping by default if nothing else was requested?
> >>
> >
> > Yes. API users so far have received the audio frames according to
> > encoded layout by default, so doing something else breaks that rule of
> > least surprises.
> >
> >> Is there an option to request the 5.1 mapping?
> >>
> >
> > As noted in the 0/0 cover letter, you can do it just fine with
> > `-channel_layout "5.1"` with ffmpeg.c. I have verified that it returns
> > the 5.1 channels as-is.
>
> I assume that does a "conversion" using swr from 22.2 to 5.1? (even if
> it just outputs the first six channels without extra resampling). What
> Carl wants is the decoder outputting only the first six channels,
> without the need for external resampling. This should be achievable with
> the -request_channel_layout input option (Try it with the DTS decoder on
> DTS-MA 7.1 samples to get 5.1, or in some DTS core samples to get
> stereo). No external conversion takes place in this scenario, since the
> decoder takes the hint to only output the requested channels, assuming
> it's doable (In the DTS case, the stream may not have a defined way
> within the bitstream to achieve this, and so the decoder just outputs
> the original channel layout silently).
>
> This would of course be separate work, but IMO very welcome and worth a
> look, and not a blocker. In any case, the decoder should by default
> output what the stream reports it contains, and not some arbitrary
> layout we think a CLI or player user will prefer. The user can and is
> expected to use a resampling library for that.
>

Aye. I know of that feature, and I actually did utilize
`-request_channel_layout 9223372036854775808` for testing my decoder
work (It is the only usage of that feature in the AAC decoder, it
skips the coding unit reordering. That feature still works even with
my changes).

I do agree that it could be implemented, but I'm not sure if it should
be part of this patch set which makes:
1. The streams demux and decode'able (unblocks remux)
2. Seems to output the correct 22.2 channel layout. (so that you can
dump the 22.2 into WAV or otherwise utilize it through the API by
default)
3. Can be utilized as output for 5.1 or stereo by utilizing swresample
(if input is 22.2 and output is not 22.2 then it gets handled as 5.1 -
at least until someone decides to make a proper mixing matrix
configuration for it).

I would actually prefer comments on how the swresample changes were
done. They led to correct results for me, but this is the first time
I'm poking swresample, so I might have missed something obvious.

Best regards,
Jan


More information about the ffmpeg-devel mailing list