[FFmpeg-devel] [PATCH 2/4] audioconvert: add av_get_channel_description().

Stefano Sabatini stefasab at gmail.com
Mon Jul 30 11:09:59 CEST 2012


On date Monday 2012-07-30 10:41:07 +0200, Nicolas George encoded:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavutil/audioconvert.c |   11 +++++++++++
>  libavutil/audioconvert.h |    7 +++++++
>  2 files changed, 18 insertions(+)
> 
> 
> Version bump and APIchanges are in the next patch.
> 
> 
> diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c
> index 8e65d59..224db86 100644
> --- a/libavutil/audioconvert.c
> +++ b/libavutil/audioconvert.c
> @@ -219,6 +219,17 @@ const char *av_get_channel_name(uint64_t channel)
>      return NULL;
>  }
>  
> +const char *av_get_channel_description(uint64_t channel)
> +{
> +    int i;
> +    if (av_get_channel_layout_nb_channels(channel) != 1)
> +        return NULL;
> +    for (i = 0; i < FF_ARRAY_ELEMS(channel_names); i++)
> +        if ((1ULL<<i) & channel)
> +            return channel_names[i].description;
> +    return NULL;
> +}
> +
>  uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index)
>  {
>      int i;
> diff --git a/libavutil/audioconvert.h b/libavutil/audioconvert.h
> index 25e9cf0..063cb12 100644
> --- a/libavutil/audioconvert.h
> +++ b/libavutil/audioconvert.h
> @@ -181,6 +181,13 @@ uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index);
>  const char *av_get_channel_name(uint64_t channel);
>  
>  /**
> + * Get the description of a given channel.

Maybe add a short description of what a channel is meant in this
context, "a channel is represented by the corresponding channel layout
containing only that channel".

> + *
> + * @return channel description on success, NULL on error.

Nit: drop the final dot

> + */
> +const char *av_get_channel_description(uint64_t channel);

Looks good otherwise, thanks.
-- 
FFmpeg = Fancy and Fantastic Marvellous Proud Erratic Gadget


More information about the ffmpeg-devel mailing list