Mercurial > libavutil.hg
changeset 334:d4ccc9609aa9 libavutil
reduce number of shifts
author | michael |
---|---|
date | Fri, 04 May 2007 22:35:56 +0000 |
parents | 893380ba2425 |
children | 62dad9741857 |
files | internal.h |
diffstat | 1 files changed, 5 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/internal.h Fri May 04 21:22:43 2007 +0000 +++ b/internal.h Fri May 04 22:35:56 2007 +0000 @@ -189,15 +189,16 @@ static inline int ff_sqrt(int a) { int ret=0; - int s; + int s, b; if(a<128) return ff_sqrt_tab[a]; - for(s=15; s>=0; s--){ - int b= (1<<(s*2)) + (ret<<s)*2; + for(s=30; s>=0; s-=2){ + ret+=ret; + b= (1+2*ret)<<s; if(b<=a){ a-=b; - ret+= 1<<s; + ret++; } } return ret;