diff options
author | Gregory Maxwell <greg@xiph.org> | 2012-07-25 01:51:25 +0400 |
---|---|---|
committer | Gregory Maxwell <greg@xiph.org> | 2012-07-25 01:56:49 +0400 |
commit | 66d429ab5367b0111b936473e43a2bf9a3232d09 (patch) | |
tree | fcd8815058912ac47ed48c421b57dc50008e3293 | |
parent | b0c120b2141bd9ec6ec4bd39e8b1a2ba75ae2a9a (diff) |
log2_frac optimization from Simon Hosie back in Aug 2011.
-rw-r--r-- | celt/cwrs.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/celt/cwrs.c b/celt/cwrs.c index 2c31d6fe..ac81a7eb 100644 --- a/celt/cwrs.c +++ b/celt/cwrs.c @@ -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 |