Skip to content
Snippets Groups Projects
Commit 66d429ab authored by Gregory Maxwell's avatar Gregory Maxwell
Browse files

log2_frac optimization from Simon Hosie back in Aug 2011.

parent b0c120b2
No related branches found
No related tags found
No related merge requests found
......@@ -48,8 +48,9 @@ int log2_frac(opus_uint32 val, int frac)
l=EC_ILOG(val);
if(val&(val-1)){
/*This is (val>>l-16), but guaranteed to round up, even if adding a bias
before the shift would cause overflow (e.g., for 0xFFFFxxxx).*/
if(l>16)val=(val>>(l-16))+(((val&((1<<(l-16))-1))+(1<<(l-16))-1)>>(l-16));
before the shift would cause overflow (e.g., for 0xFFFFxxxx).
Doesn't work for val=0, but that case fails the test above.*/
if(l>16)val=((val-1)>>(l-16))+1;
else val<<=16-l;
l=(l-1)<<frac;
/*Note that we always need one iteration, since the rounding up above means
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment