[FFmpeg-devel] [PATCH] Use channel count if channel layout is undefined

Marcin Gorzel gorzel at google.com
Mon Jul 9 20:50:09 EEST 2018


Hi Nicolas,


> Please remember to mention "lswr" or "libswresample" in the first line
> of the commit message.
>

Apologies, I will update the commit message.


> > Rematrixing supports up to 64 channels but there is only a limited
> > number of channel layouts defined. Currently, in/out channel count is
> > obtained from the channel layout so if the channel layout is undefined
> > (e.g. for 9, 10, 11 channels etc.) the in/out channel count will be 0
> > and the rematrixing will fail. This change adds a check if the channel
> > layout is non-zero, and if not, prefers to use the in|out_ch_count
> > instead. This seems to be related to ticket #6790.
>
> I do not understand how it can work: the actual layouts are necessary to
> build the matrix, otherwise it is not possible to know which channel
> needs to be mixed into which. Can you explain how this patch was tested?


I create a 9-channel wav file, with a different sine tone in each channel
(100Hz, 200Hz, 300Hz, ...).
I downmix it to 6 channels using the following command:

./ffmpeg -i input_9ch.wav -filter:a:0
pan="6c|c0=0.166*c0+0.166*c6|c1=c1|c2=c2|c3=c3|c4=c4|c5=c5" -y
output_6ch.wav

Without the patch, the output in the first channel (c0) is noise. After
applying the patch, I can verify that two sine tones are mixed together and
scaled properly.

Could you explain what you mean by "the actual layouts are necessary to build
the matrix"? In the case of input channel counts of 8 or more (16 is an
exception) the channel layout is 0, although the matrix is created
correctly? For example, based on the above example:

[Parsed_pan_0 @ 0x561d8777dbc0] [SWR @ 0x561d87787740] Using s16p
internally between filters
[Parsed_pan_0 @ 0x561d8777dbc0] o0 = 0.166 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 +
0 i5 + 0.166 i6 + 0 i7 + 0 i8
[Parsed_pan_0 @ 0x561d8777dbc0] o1 = 0 i0 + 1 i1 + 0 i2 + 0 i3 + 0 i4 + 0
i5 + 0 i6 + 0 i7 + 0 i8
[Parsed_pan_0 @ 0x561d8777dbc0] o2 = 0 i0 + 0 i1 + 1 i2 + 0 i3 + 0 i4 + 0
i5 + 0 i6 + 0 i7 + 0 i8
[Parsed_pan_0 @ 0x561d8777dbc0] o3 = 0 i0 + 0 i1 + 0 i2 + 1 i3 + 0 i4 + 0
i5 + 0 i6 + 0 i7 + 0 i8
[Parsed_pan_0 @ 0x561d8777dbc0] o4 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 1 i4 + 0
i5 + 0 i6 + 0 i7 + 0 i8
[Parsed_pan_0 @ 0x561d8777dbc0] o5 = 0 i0 + 0 i1 + 0 i2 + 0 i3 + 0 i4 + 1
i5 + 0 i6 + 0 i7 + 0 i8
Output #0, wav, to 'output_6ch.wav':
  Metadata:
    ISFT            : Lavf58.17.101
    Stream #0:0, 0, 1/48000: Audio: pcm_s16le ([1][0][0][0] / 0x0001),
48000 Hz, 5.1, s16, 4608 kb/s

Regards,

Marcin


-- 

Marcin Gorzel |  Software Engineer |  gorzel at google.com |


More information about the ffmpeg-devel mailing list