[FFmpeg-devel] [PATCH] Demuxer for Leitch/Harris' VR native stream format (LXF)

Måns Rullgård mans
Tue Sep 14 09:06:52 CEST 2010


Tomas H?rdin <tomas.hardin at codemill.se> writes:

> Updated the patch per M?ns suggestions (unrolled, static table). I kept
> it as simple as possible for now, assuming the compiler will ignore
> shifts by zero. I didn't perform any detailed speedup analysis, but it's
> around 50% faster.
>
> /Tomas
>
> diff --git a/libavutil/avutil.h b/libavutil/avutil.h
> index c51a682..0b0b4ce 100644
> --- a/libavutil/avutil.h
> +++ b/libavutil/avutil.h
> @@ -40,7 +40,7 @@
>  #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
>  
>  #define LIBAVUTIL_VERSION_MAJOR 50
> -#define LIBAVUTIL_VERSION_MINOR 26
> +#define LIBAVUTIL_VERSION_MINOR 27
>  #define LIBAVUTIL_VERSION_MICRO  0
>  
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> diff --git a/libavutil/common.h b/libavutil/common.h
> index d054f87..00c70ed 100644
> --- a/libavutil/common.h
> +++ b/libavutil/common.h
> @@ -192,6 +192,26 @@ static inline av_const int av_ceil_log2_c(int x)
>      return av_log2((x - 1) << 1);
>  }
>  
> +/**
> + * Count number of bits set to one in x
> + * @param x value to count bits of
> + * @return the number of bits set to one in x
> + */
> +static inline av_const int av_popcount_c(uint32_t x)
> +{
> +    static const uint8_t tab[16] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4};
> +#define AV_POPCOUNT_ITER(s) tab[(x >> s) & 0xF]
> +
> +    return AV_POPCOUNT_ITER(0 ) +
> +           AV_POPCOUNT_ITER(4 ) +
> +           AV_POPCOUNT_ITER(8 ) +
> +           AV_POPCOUNT_ITER(12) +
> +           AV_POPCOUNT_ITER(16) +
> +           AV_POPCOUNT_ITER(20) +
> +           AV_POPCOUNT_ITER(24) +
> +           AV_POPCOUNT_ITER(28);
> +}

Sorry to be annoying, but the loop looked better, and gcc seems to do
the right thing after all.  Anyway, the bit twisting hack is probably
better still.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list