# HG changeset patch # User michaelni # Date 1030045299 0 # Node ID 153a7ffd289bb761a6397018ab46e627586ae32f # Parent 98e39397636b6a2ff0450c88e128db7853923075 faster ff_sqrt() diff -r 98e39397636b -r 153a7ffd289b common.c --- a/common.c Thu Aug 22 19:41:06 2002 +0000 +++ b/common.c Thu Aug 22 19:41:39 2002 +0000 @@ -20,6 +20,13 @@ */ #include "avcodec.h" +const UINT8 ff_sqrt_tab[128]={ + 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, + 9, 9, 9, 9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11 +}; + void init_put_bits(PutBitContext *s, UINT8 *buffer, int buffer_size, void *opaque, diff -r 98e39397636b -r 153a7ffd289b common.h --- a/common.h Thu Aug 22 19:41:06 2002 +0000 +++ b/common.h Thu Aug 22 19:41:39 2002 +0000 @@ -901,6 +901,8 @@ } /* math */ +extern const UINT8 ff_sqrt_tab[128]; + int ff_gcd(int a, int b); static inline int ff_sqrt(int a) @@ -908,7 +910,9 @@ int ret=0; int s; int ret_sq=0; - + + if(a<128) return ff_sqrt_tab[a]; + for(s=15; s>=0; s--){ int b= ret_sq + (1<<(s*2)) + (ret<