[FFmpeg-devel] [PATCH 10/25] avfilter/af_headphone: Simplify parsing channel mapping string

Paul B Mahol onemda at gmail.com
Wed Sep 9 04:16:42 EEST 2020


On Tue, Sep 08, 2020 at 11:18:41PM +0200, Andreas Rheinhardt wrote:
> 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.)
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> ---
>  libavfilter/af_headphone.c | 31 +++++++++----------------------
>  1 file changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c
> index 8db712e9a0..32939af854 100644
> --- a/libavfilter/af_headphone.c
> +++ b/libavfilter/af_headphone.c
> @@ -87,26 +87,14 @@ typedef struct HeadphoneContext {
>      uint64_t mapping[64];
>  } HeadphoneContext;
>  

probably ok


More information about the ffmpeg-devel mailing list