[FFmpeg-devel] [PATCH] Optimisations for av_log2 and integer clip functions

Jason Garrett-Glaser darkshikari
Wed Jan 13 22:32:15 CET 2010


> +#define av_log2 av_log2
> +static inline av_const int av_log2(unsigned int v)
> +{
> + ? ?return v? 31 - __builtin_clz(v) : 0;
> +}
> +
> +#ifndef av_log2_16bit
> +#define av_log2_16bit av_log2
> +#endif

Won't ^31 be faster?  "31 - X" requires an extra mov on x86.

Also, __builtin_clz/ctz maps to bsr/bsf, which are extraordinarily
slow on Athlons.

Dark Shikari



More information about the ffmpeg-devel mailing list