[FFmpeg-devel] [PATCH] simplify GET_UTF8 to use ff_log2_tab

Ivan Kalvachev ikalvachev
Mon Dec 10 21:13:42 CET 2007


On Dec 10, 2007 12:14 AM, Rich Felker <dalias at aerifal.cx> wrote:
> On Sun, Dec 09, 2007 at 11:09:25AM +0100, Reimar D?ffinger wrote:
>
> > Hello,
> > currently GET_UTF8 calls av_log2 which is simply overkill,
> > since we only care about the lowest 8 bits.
> > This may be intentional since my suggestion would be problematic
> > if GET_UTF8 should become part of the public API, since ff_log2_tab
> > is not public.
> > A possibility would be to at least use av_log2_16bit or better add a
> > public av_log2_8bit.
> > Comments?
>
> Counting the number of ones is useless. Instead, just left shift at
> each iteration and check the high bit as your "loop counter".
> Thankfully gcc even optimizes this correctly as (shl ; js) on i386,
> even in my ancient gcc 2.95.

Ever heard of "bsr" and "bsf" instructions?
I think BitScanReverse have huge latency (i386=10+3*n, P1=72, Athlon=14),
but it still should be faster than loop or cache miss.

Once there was [RFC] about assembler optimizations of avutil,
unfortunately it degradated in altivect bashing.




More information about the ffmpeg-devel mailing list