[FFmpeg-devel] [PATCH] af_pan: comment a tricky piece of code.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Wed Feb 15 20:19:27 CET 2012


On Wed, Feb 15, 2012 at 07:43:42PM +0100, Nicolas George wrote:
> 
> Signed-off-by: Nicolas George <nicolas.george at normalesup.org>
> ---
>  libavfilter/af_pan.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> 
> I wrote it and I had trouble remembering what it did...
> 
> 
> diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c
> index 9f293a6..0280ab2 100644
> --- a/libavfilter/af_pan.c
> +++ b/libavfilter/af_pan.c
> @@ -66,6 +66,7 @@ static int parse_channel_name(char **arg, int *rchannel, int *rnamed)
>  
>      if (sscanf(*arg, " %7[A-Z] %n", buf, &len)) {
>          layout0 = layout = av_get_channel_layout(buf);
> +        /* channel_id <- first set bit in layout */
>          for (i = 32; i > 0; i >>= 1) {
>              if (layout >= (int64_t)1 << i) {
>                  channel_id += i;

Maybe you should just introduce a av_log2_64bit and use that?
(can even add an implementation using __builtin_clzll probably making
it a single instruction on x86_64 - even if it hardly matters here).


More information about the ffmpeg-devel mailing list