Mercurial > libavutil.hg
comparison internal.h @ 334:d4ccc9609aa9 libavutil
reduce number of shifts
author | michael |
---|---|
date | Fri, 04 May 2007 22:35:56 +0000 |
parents | 893380ba2425 |
children | 8829032777d5 |
comparison
equal
deleted
inserted
replaced
333:893380ba2425 | 334:d4ccc9609aa9 |
---|---|
187 extern const uint8_t ff_sqrt_tab[128]; | 187 extern const uint8_t ff_sqrt_tab[128]; |
188 | 188 |
189 static inline int ff_sqrt(int a) | 189 static inline int ff_sqrt(int a) |
190 { | 190 { |
191 int ret=0; | 191 int ret=0; |
192 int s; | 192 int s, b; |
193 | 193 |
194 if(a<128) return ff_sqrt_tab[a]; | 194 if(a<128) return ff_sqrt_tab[a]; |
195 | 195 |
196 for(s=15; s>=0; s--){ | 196 for(s=30; s>=0; s-=2){ |
197 int b= (1<<(s*2)) + (ret<<s)*2; | 197 ret+=ret; |
198 b= (1+2*ret)<<s; | |
198 if(b<=a){ | 199 if(b<=a){ |
199 a-=b; | 200 a-=b; |
200 ret+= 1<<s; | 201 ret++; |
201 } | 202 } |
202 } | 203 } |
203 return ret; | 204 return ret; |
204 } | 205 } |
205 | 206 |