]> git.sesse.net Git - ffmpeg/commit
avfilter/af_headphone: Simplify parsing channel mapping string
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Thu, 27 Aug 2020 01:14:02 +0000 (03:14 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Wed, 9 Sep 2020 11:46:51 +0000 (13:46 +0200)
commit71daaafa3a7f0e3494b73055bdbb3fd8aa114173
treedba822a4032dd881f315f331b402b9f6dbd622cb
parentbc533ba2ae46978a826c0ace242b3e2e4cabd9fb
avfilter/af_headphone: Simplify parsing channel mapping string

When parsing the channel mapping string (a string containing '|'
delimited tokens each of which is supposed to contain a channel name
like "FR"), the old code would at each step read up to seven uppercase
characters from the input string and give this to
av_get_channel_layout() to parse. The returned layout is then checked
for being a layout with a single channel set by computing its logarithm.

Besides being overtly complicated this also has the drawback of relying
on the assumption that every channel name consists of at most seven
uppercase letters only; but said assumption is wrong: The abbreviation
of the second low frequency channel is LFE2. Furthermore it treats
garbage like "FRfoo" as valid channel.

This commit changes this by using av_get_channel_layout() directly;
furthermore, av_get_channel_layout_nb_channels() (which uses popcount)
is used to find out the number of channels instead of the custom code
to calculate the logarithm.

(As a consequence, certain other formats to specify the channel layouts
are now accepted (like the hex versions of av_get_channel_layout()); but
this is actually not bad at all.)

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavfilter/af_headphone.c