}
unsigned char ec_byte_look_at_end(ec_byte_buffer *_b){
- if (_b->end_ptr < _b->buf)
- {
- celt_fatal("Trying to read raw bits before the beginning of the stream");
- }
+ celt_assert2 (_b->end_ptr >= _b->buf, "Trying to read raw bits before the beginning of the stream");
return *(_b->end_ptr--);
}
else return *(_b->ptr++);
}
-
-ec_uint32 ec_dec_bits(ec_dec *_this,int _ftb){
- ec_uint32 t;
- unsigned s;
- t=0;
- while(_ftb>EC_UNIT_BITS){
- s=ec_decode_raw(_this,EC_UNIT_BITS);
- /*ec_dec_update(_this,s,s+1,EC_UNIT_MASK+1);*/
- t=t<<EC_UNIT_BITS|s;
- _ftb-=EC_UNIT_BITS;
- }
- s=ec_decode_raw(_this,_ftb);
- /*ec_dec_update(_this,s,s+1,ft);*/
- t=t<<_ftb|s;
- return t;
-}
-
ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){
- ec_uint32 t;
unsigned ft;
unsigned s;
int ftb;
- t=0;
/*In order to optimize EC_ILOG(), it is undefined for the value 0.*/
celt_assert(_ft>1);
_ft--;
ftb=EC_ILOG(_ft);
if(ftb>EC_UNIT_BITS){
+ ec_uint32 t;
ftb-=EC_UNIT_BITS;
ft=(unsigned)(_ft>>ftb)+1;
s=ec_decode(_this,ft);
ec_dec_update(_this,s,s+1,ft);
- t=t<<EC_UNIT_BITS|s;
- t = t<<ftb|ec_dec_bits(_this,ftb);
+ t=s;
+ t = t<<ftb|ec_dec_bits(_this,ftb&(1<<ftb)-1);
if (t>_ft)
{
- celt_notify("uint decode error");
_this->error |= 1;
t = _ft;
}
_ft++;
s=ec_decode(_this,(unsigned)_ft);
ec_dec_update(_this,s,s+1,(unsigned)_ft);
- t=t<<ftb|s;
- return t;
+ return s;
}
}