summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libopus/celt/entcode.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libopus/celt/entcode.h')
-rw-r--r--lib/rbcodec/codecs/libopus/celt/entcode.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libopus/celt/entcode.h b/lib/rbcodec/codecs/libopus/celt/entcode.h
index dd13e49e50..13d6c84ef0 100644
--- a/lib/rbcodec/codecs/libopus/celt/entcode.h
+++ b/lib/rbcodec/codecs/libopus/celt/entcode.h
@@ -34,6 +34,12 @@
34# include <stddef.h> 34# include <stddef.h>
35# include "ecintrin.h" 35# include "ecintrin.h"
36 36
37extern const opus_uint32 SMALL_DIV_TABLE[129];
38
39#ifdef OPUS_ARM_ASM
40#define USE_SMALL_DIV_TABLE
41#endif
42
37/*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a 43/*OPT: ec_window must be at least 32 bits, but if you have fast arithmetic on a
38 larger type, you can speed up the decoder by using it here.*/ 44 larger type, you can speed up the decoder by using it here.*/
39typedef opus_uint32 ec_window; 45typedef opus_uint32 ec_window;
@@ -114,4 +120,33 @@ static OPUS_INLINE int ec_tell(ec_ctx *_this){
114 rounding error is in the positive direction).*/ 120 rounding error is in the positive direction).*/
115opus_uint32 ec_tell_frac(ec_ctx *_this); 121opus_uint32 ec_tell_frac(ec_ctx *_this);
116 122
123/* Tested exhaustively for all n and for 1<=d<=256 */
124static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) {
125 celt_assert(d>0);
126#ifdef USE_SMALL_DIV_TABLE
127 if (d>256)
128 return n/d;
129 else {
130 opus_uint32 t, q;
131 t = EC_ILOG(d&-d);
132 q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32;
133 return q+(n-q*d >= d);
134 }
135#else
136 return n/d;
137#endif
138}
139
140static OPUS_INLINE opus_int32 celt_sudiv(opus_int32 n, opus_int32 d) {
141 celt_assert(d>0);
142#ifdef USE_SMALL_DIV_TABLE
143 if (n<0)
144 return -(opus_int32)celt_udiv(-n, d);
145 else
146 return celt_udiv(n, d);
147#else
148 return n/d;
149#endif
150}
151
117#endif 152#endif