28 #include "opus_types.h"
29 #include "opus_defines.h"
31 #if !defined(_entcode_H)
32 # define _entcode_H (1)
35 # include "ecintrin.h"
37 extern const opus_uint32 SMALL_DIV_TABLE[129];
40 #define USE_SMALL_DIV_TABLE
45 typedef opus_uint32 ec_window;
46 typedef struct ec_ctx ec_ctx;
47 typedef struct ec_ctx ec_enc;
48 typedef struct ec_ctx ec_dec;
50 # define EC_WINDOW_SIZE ((int)sizeof(ec_window)*CHAR_BIT)
53 # define EC_UINT_BITS (8)
93 static OPUS_INLINE opus_uint32 ec_range_bytes(ec_ctx *_this){
97 static OPUS_INLINE
unsigned char *ec_get_buffer(ec_ctx *_this){
101 static OPUS_INLINE
int ec_get_error(ec_ctx *_this){
111 static OPUS_INLINE
int ec_tell(ec_ctx *_this){
112 return _this->nbits_total-EC_ILOG(_this->rng);
121 opus_uint32 ec_tell_frac(ec_ctx *_this);
124 static OPUS_INLINE opus_uint32 celt_udiv(opus_uint32 n, opus_uint32 d) {
126 #ifdef USE_SMALL_DIV_TABLE
132 q = (opus_uint64)SMALL_DIV_TABLE[d>>t]*(n>>(t-1))>>32;
133 return q+(n-q*d >= d);
140 static OPUS_INLINE opus_int32 celt_sudiv(opus_int32 n, opus_int32 d) {
142 #ifdef USE_SMALL_DIV_TABLE
144 return -(opus_int32)celt_udiv(-n, d);
146 return celt_udiv(n, d);