Lines Matching refs:_this
60 static int ec_write_byte(ec_enc *_this,unsigned _value){ in ec_write_byte() argument
61 if(_this->offs+_this->end_offs>=_this->storage)return -1; in ec_write_byte()
62 _this->buf[_this->offs++]=(unsigned char)_value; in ec_write_byte()
66 static int ec_write_byte_at_end(ec_enc *_this,unsigned _value){ in ec_write_byte_at_end() argument
67 if(_this->offs+_this->end_offs>=_this->storage)return -1; in ec_write_byte_at_end()
68 _this->buf[_this->storage-++(_this->end_offs)]=(unsigned char)_value; in ec_write_byte_at_end()
82 static void ec_enc_carry_out(ec_enc *_this,int _c){ in ec_enc_carry_out() argument
89 if(_this->rem>=0)_this->error|=ec_write_byte(_this,_this->rem+carry); in ec_enc_carry_out()
90 if(_this->ext>0){ in ec_enc_carry_out()
93 do _this->error|=ec_write_byte(_this,sym); in ec_enc_carry_out()
94 while(--(_this->ext)>0); in ec_enc_carry_out()
96 _this->rem=_c&EC_SYM_MAX; in ec_enc_carry_out()
98 else _this->ext++; in ec_enc_carry_out()
101 static void ec_enc_normalize(ec_enc *_this){ in ec_enc_normalize() argument
103 while(_this->rng<=EC_CODE_BOT){ in ec_enc_normalize()
104 ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT)); in ec_enc_normalize()
106 _this->val=(_this->val<<EC_SYM_BITS)&(EC_CODE_TOP-1); in ec_enc_normalize()
107 _this->rng<<=EC_SYM_BITS; in ec_enc_normalize()
108 _this->nbits_total+=EC_SYM_BITS; in ec_enc_normalize()
112 void ec_enc_init(ec_enc *_this,unsigned char *_buf,opus_uint32 _size){ in ec_enc_init() argument
113 _this->buf=_buf; in ec_enc_init()
114 _this->end_offs=0; in ec_enc_init()
115 _this->end_window=0; in ec_enc_init()
116 _this->nend_bits=0; in ec_enc_init()
118 _this->nbits_total=EC_CODE_BITS+1; in ec_enc_init()
119 _this->offs=0; in ec_enc_init()
120 _this->rng=EC_CODE_TOP; in ec_enc_init()
121 _this->rem=-1; in ec_enc_init()
122 _this->val=0; in ec_enc_init()
123 _this->ext=0; in ec_enc_init()
124 _this->storage=_size; in ec_enc_init()
125 _this->error=0; in ec_enc_init()
128 void ec_encode(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _ft){ in ec_encode() argument
130 r=_this->rng/_ft; in ec_encode()
132 _this->val+=_this->rng-IMUL32(r,(_ft-_fl)); in ec_encode()
133 _this->rng=IMUL32(r,(_fh-_fl)); in ec_encode()
135 else _this->rng-=IMUL32(r,(_ft-_fh)); in ec_encode()
136 ec_enc_normalize(_this); in ec_encode()
139 void ec_encode_bin(ec_enc *_this,unsigned _fl,unsigned _fh,unsigned _bits){ in ec_encode_bin() argument
141 r=_this->rng>>_bits; in ec_encode_bin()
143 _this->val+=_this->rng-IMUL32(r,((1U<<_bits)-_fl)); in ec_encode_bin()
144 _this->rng=IMUL32(r,(_fh-_fl)); in ec_encode_bin()
146 else _this->rng-=IMUL32(r,((1U<<_bits)-_fh)); in ec_encode_bin()
147 ec_enc_normalize(_this); in ec_encode_bin()
151 void ec_enc_bit_logp(ec_enc *_this,int _val,unsigned _logp){ in ec_enc_bit_logp() argument
155 r=_this->rng; in ec_enc_bit_logp()
156 l=_this->val; in ec_enc_bit_logp()
159 if(_val)_this->val=l+r; in ec_enc_bit_logp()
160 _this->rng=_val?s:r; in ec_enc_bit_logp()
161 ec_enc_normalize(_this); in ec_enc_bit_logp()
164 void ec_enc_icdf(ec_enc *_this,int _s,const unsigned char *_icdf,unsigned _ftb){ in ec_enc_icdf() argument
166 r=_this->rng>>_ftb; in ec_enc_icdf()
168 _this->val+=_this->rng-IMUL32(r,_icdf[_s-1]); in ec_enc_icdf()
169 _this->rng=IMUL32(r,_icdf[_s-1]-_icdf[_s]); in ec_enc_icdf()
171 else _this->rng-=IMUL32(r,_icdf[_s]); in ec_enc_icdf()
172 ec_enc_normalize(_this); in ec_enc_icdf()
175 void ec_enc_uint(ec_enc *_this,opus_uint32 _fl,opus_uint32 _ft){ in ec_enc_uint() argument
187 ec_encode(_this,fl,fl+1,ft); in ec_enc_uint()
188 ec_enc_bits(_this,_fl&(((opus_uint32)1<<ftb)-1U),ftb); in ec_enc_uint()
190 else ec_encode(_this,_fl,_fl+1,_ft+1); in ec_enc_uint()
193 void ec_enc_bits(ec_enc *_this,opus_uint32 _fl,unsigned _bits){ in ec_enc_bits() argument
196 window=_this->end_window; in ec_enc_bits()
197 used=_this->nend_bits; in ec_enc_bits()
201 _this->error|=ec_write_byte_at_end(_this,(unsigned)window&EC_SYM_MAX); in ec_enc_bits()
209 _this->end_window=window; in ec_enc_bits()
210 _this->nend_bits=used; in ec_enc_bits()
211 _this->nbits_total+=_bits; in ec_enc_bits()
214 void ec_enc_patch_initial_bits(ec_enc *_this,unsigned _val,unsigned _nbits){ in ec_enc_patch_initial_bits() argument
220 if(_this->offs>0){ in ec_enc_patch_initial_bits()
222 _this->buf[0]=(unsigned char)((_this->buf[0]&~mask)|_val<<shift); in ec_enc_patch_initial_bits()
224 else if(_this->rem>=0){ in ec_enc_patch_initial_bits()
226 _this->rem=(_this->rem&~mask)|_val<<shift; in ec_enc_patch_initial_bits()
228 else if(_this->rng<=(EC_CODE_TOP>>_nbits)){ in ec_enc_patch_initial_bits()
230 _this->val=(_this->val&~((opus_uint32)mask<<EC_CODE_SHIFT))| in ec_enc_patch_initial_bits()
234 else _this->error=-1; in ec_enc_patch_initial_bits()
237 void ec_enc_shrink(ec_enc *_this,opus_uint32 _size){ in ec_enc_shrink() argument
238 celt_assert(_this->offs+_this->end_offs<=_size); in ec_enc_shrink()
239 OPUS_MOVE(_this->buf+_size-_this->end_offs, in ec_enc_shrink()
240 _this->buf+_this->storage-_this->end_offs,_this->end_offs); in ec_enc_shrink()
241 _this->storage=_size; in ec_enc_shrink()
244 void ec_enc_done(ec_enc *_this){ in ec_enc_done() argument
252 l=EC_CODE_BITS-EC_ILOG(_this->rng); in ec_enc_done()
254 end=(_this->val+msk)&~msk; in ec_enc_done()
255 if((end|msk)>=_this->val+_this->rng){ in ec_enc_done()
258 end=(_this->val+msk)&~msk; in ec_enc_done()
261 ec_enc_carry_out(_this,(int)(end>>EC_CODE_SHIFT)); in ec_enc_done()
266 if(_this->rem>=0||_this->ext>0)ec_enc_carry_out(_this,0); in ec_enc_done()
268 window=_this->end_window; in ec_enc_done()
269 used=_this->nend_bits; in ec_enc_done()
271 _this->error|=ec_write_byte_at_end(_this,(unsigned)window&EC_SYM_MAX); in ec_enc_done()
276 if(!_this->error){ in ec_enc_done()
277 OPUS_CLEAR(_this->buf+_this->offs, in ec_enc_done()
278 _this->storage-_this->offs-_this->end_offs); in ec_enc_done()
281 if(_this->end_offs>=_this->storage)_this->error=-1; in ec_enc_done()
286 if(_this->offs+_this->end_offs>=_this->storage&&l<used){ in ec_enc_done()
288 _this->error=-1; in ec_enc_done()
290 _this->buf[_this->storage-_this->end_offs-1]|=(unsigned char)window; in ec_enc_done()