diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2014-01-29 19:16:53 +0400 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2014-01-29 19:18:06 +0400 |
commit | 51231750178c8a4bf87157d82fb3cd2fb93b50b2 (patch) | |
tree | c49894eb40684d2a1d086969b69d1edc3529fc15 /celt | |
parent | 58107d896811f0e975bc1f8f75a5c1c2f6e746b0 (diff) |
Speeding up ec_tell_frac()
Diffstat (limited to 'celt')
-rw-r--r-- | celt/entcode.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/celt/entcode.c b/celt/entcode.c index edb7ef90..70f32016 100644 --- a/celt/entcode.c +++ b/celt/entcode.c @@ -62,6 +62,27 @@ int ec_ilog(opus_uint32 _v){ } #endif +#if 1 +/* This is a faster version of ec_tell_frac() that takes advantage + of the low (1/8 bit) resolution to use just a linear function + followed by a lookup to determine the exact transition thresholds. */ +opus_uint32 ec_tell_frac(ec_ctx *_this){ + static const unsigned correction[8] = + {35733, 38967, 42495, 46340, + 50535, 55109, 60097, 65535}; + opus_uint32 nbits; + opus_uint32 r; + int l; + unsigned b; + nbits=_this->nbits_total<<BITRES; + l=EC_ILOG(_this->rng); + r=_this->rng>>(l-16); + b = (r>>12)-8; + b += r>correction[b]; + l = (l<<3)+b; + return nbits-l; +} +#else opus_uint32 ec_tell_frac(ec_ctx *_this){ opus_uint32 nbits; opus_uint32 r; @@ -91,6 +112,7 @@ opus_uint32 ec_tell_frac(ec_ctx *_this){ } return nbits-l; } +#endif #ifdef USE_SMALL_DIV_TABLE /* Result of 2^32/(2*i+1), except for i=0. */ |