diff options
author | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2014-01-30 11:16:24 -0500 |
---|---|---|
committer | Jean-Marc Valin <jmvalin@jmvalin.ca> | 2014-01-30 11:16:24 -0500 |
commit | d9fb8a6651ea66f18f034fc70a51cfed17d3e12f (patch) | |
tree | 0ed9eda283defc1eac8d63cd2075c31e0424ba7f /celt/entcode.h | |
parent | 51231750178c8a4bf87157d82fb3cd2fb93b50b2 (diff) | |
download | libopus-d9fb8a6651ea66f18f034fc70a51cfed17d3e12f.tar.gz |
Optimizing divisions with a signed numerator
Diffstat (limited to 'celt/entcode.h')
-rw-r--r-- | celt/entcode.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/celt/entcode.h b/celt/entcode.h index 66f281de..13d6c84e 100644 --- a/celt/entcode.h +++ b/celt/entcode.h @@ -137,4 +137,16 @@ static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) { #endif } +static OPUS_INLINE opus_int32 celt_sudiv(opus_int32 n, opus_int32 d) { + celt_assert(d>0); +#ifdef USE_SMALL_DIV_TABLE + if (n<0) + return -(opus_int32)celt_udiv(-n, d); + else + return celt_udiv(n, d); +#else + return n/d; +#endif +} + #endif |