mirror of
https://github.com/xiph/opus.git
synced 2025-06-06 23:40:50 +00:00
Removing the 64-bit part of the range coder.
This commit is contained in:
parent
b6a3b0c464
commit
2b08d7a210
5 changed files with 2 additions and 118 deletions
|
@ -355,7 +355,7 @@ void quant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P, ce
|
||||||
int tell;
|
int tell;
|
||||||
int q;
|
int q;
|
||||||
celt_word16_t n;
|
celt_word16_t n;
|
||||||
celt_int16_t * const *BPbits;
|
const celt_int16_t * const *BPbits;
|
||||||
|
|
||||||
int curr_balance, curr_bits;
|
int curr_balance, curr_bits;
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ void unquant_bands(const CELTMode *m, celt_norm_t * restrict X, celt_norm_t *P,
|
||||||
int tell;
|
int tell;
|
||||||
int q;
|
int q;
|
||||||
celt_word16_t n;
|
celt_word16_t n;
|
||||||
celt_int16_t * const *BPbits;
|
const celt_int16_t * const *BPbits;
|
||||||
|
|
||||||
int curr_balance, curr_bits;
|
int curr_balance, curr_bits;
|
||||||
|
|
||||||
|
|
|
@ -37,30 +37,3 @@ int ec_ilog(ec_uint32 _v){
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int ec_ilog64(ec_uint64 _v){
|
|
||||||
#if defined(EC_CLZ64)
|
|
||||||
return EC_CLZ64_0-EC_CLZ64(_v);
|
|
||||||
#else
|
|
||||||
ec_uint32 v;
|
|
||||||
int ret;
|
|
||||||
int m;
|
|
||||||
ret=!!_v;
|
|
||||||
m=!!(_v&((ec_uint64)0xFFFFFFFF)<<32)<<5;
|
|
||||||
v=(ec_uint32)(_v>>m);
|
|
||||||
ret|=m;
|
|
||||||
m=!!(v&0xFFFF0000)<<4;
|
|
||||||
v>>=m;
|
|
||||||
ret|=m;
|
|
||||||
m=!!(v&0xFF00)<<3;
|
|
||||||
v>>=m;
|
|
||||||
ret|=m;
|
|
||||||
m=!!(v&0xF0)<<2;
|
|
||||||
v>>=m;
|
|
||||||
ret|=m;
|
|
||||||
m=!!(v&0xC)<<1;
|
|
||||||
v>>=m;
|
|
||||||
ret|=m;
|
|
||||||
ret+=!!(v&0x2);
|
|
||||||
return ret;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
|
@ -100,16 +100,6 @@ ec_uint32 ec_dec_bits(ec_dec *_this,int _ftb){
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
ec_uint64 ec_dec_bits64(ec_dec *_this,int _ftb){
|
|
||||||
ec_uint32 t;
|
|
||||||
if(_ftb>32){
|
|
||||||
t=ec_dec_bits(_this,_ftb-32);
|
|
||||||
_ftb=32;
|
|
||||||
}
|
|
||||||
else t=0;
|
|
||||||
return (ec_uint64)t<<32|ec_dec_bits(_this,_ftb);
|
|
||||||
}
|
|
||||||
|
|
||||||
ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){
|
ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){
|
||||||
ec_uint32 t;
|
ec_uint32 t;
|
||||||
unsigned ft;
|
unsigned ft;
|
||||||
|
@ -139,33 +129,3 @@ ec_uint32 ec_dec_uint(ec_dec *_this,ec_uint32 _ft){
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ec_uint64 ec_dec_uint64(ec_dec *_this,ec_uint64 _ft){
|
|
||||||
ec_uint64 t;
|
|
||||||
unsigned ft;
|
|
||||||
unsigned s;
|
|
||||||
int ftb;
|
|
||||||
t=0;
|
|
||||||
_ft--;
|
|
||||||
ftb=EC_ILOG64(_ft);
|
|
||||||
if(ftb>EC_UNIT_BITS){
|
|
||||||
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_bits64(_this,ftb);
|
|
||||||
if (t>_ft)
|
|
||||||
{
|
|
||||||
celt_notify("uint decode error");
|
|
||||||
t = _ft;
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
} else {
|
|
||||||
_ft++;
|
|
||||||
s=ec_decode(_this,(unsigned)_ft);
|
|
||||||
ec_dec_update(_this,s,s+1,(unsigned)_ft);
|
|
||||||
t=t<<ftb|s;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -77,15 +77,6 @@ void ec_enc_bits(ec_enc *_this,ec_uint32 _fl,int _ftb){
|
||||||
ec_encode_bin(_this,fl,fl+1,_ftb);
|
ec_encode_bin(_this,fl,fl+1,_ftb);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ec_enc_bits64(ec_enc *_this,ec_uint64 _fl,int _ftb){
|
|
||||||
if(_ftb>32){
|
|
||||||
ec_enc_bits(_this,(ec_uint32)(_fl>>32),_ftb-32);
|
|
||||||
_ftb=32;
|
|
||||||
_fl&=0xFFFFFFFF;
|
|
||||||
}
|
|
||||||
ec_enc_bits(_this,(ec_uint32)_fl,_ftb);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft){
|
void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft){
|
||||||
unsigned ft;
|
unsigned ft;
|
||||||
unsigned fl;
|
unsigned fl;
|
||||||
|
@ -103,19 +94,3 @@ void ec_enc_uint(ec_enc *_this,ec_uint32 _fl,ec_uint32 _ft){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ec_enc_uint64(ec_enc *_this,ec_uint64 _fl,ec_uint64 _ft){
|
|
||||||
unsigned ft;
|
|
||||||
unsigned fl;
|
|
||||||
int ftb;
|
|
||||||
_ft--;
|
|
||||||
ftb=EC_ILOG64(_ft)&-!!_ft;
|
|
||||||
if(ftb>EC_UNIT_BITS){
|
|
||||||
ftb-=EC_UNIT_BITS;
|
|
||||||
ft=(unsigned)(_ft>>ftb)+1;
|
|
||||||
fl=(unsigned)(_fl>>ftb);
|
|
||||||
ec_encode(_this,fl,fl+1,ft);
|
|
||||||
ec_enc_bits64(_this,_fl,ftb);
|
|
||||||
} else {
|
|
||||||
ec_encode(_this,_fl,_fl+1,_ft+1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ int main(int _argc,char **_argv){
|
||||||
ec_byte_buffer buf;
|
ec_byte_buffer buf;
|
||||||
ec_enc enc;
|
ec_enc enc;
|
||||||
ec_dec dec;
|
ec_dec dec;
|
||||||
ec_uint64 sym64;
|
|
||||||
long nbits;
|
long nbits;
|
||||||
long nbits2;
|
long nbits2;
|
||||||
double entropy;
|
double entropy;
|
||||||
|
@ -36,8 +35,6 @@ int main(int _argc,char **_argv){
|
||||||
for(i=0;i<ft;i++){
|
for(i=0;i<ft;i++){
|
||||||
entropy+=log(ft)*M_LOG2E;
|
entropy+=log(ft)*M_LOG2E;
|
||||||
ec_enc_uint(&enc,i,ft);
|
ec_enc_uint(&enc,i,ft);
|
||||||
entropy+=log(ft)*M_LOG2E+30;
|
|
||||||
ec_enc_uint64(&enc,(ec_uint64)i<<30|i,(ec_uint64)ft<<30);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*Testing encoding of raw bit values.*/
|
/*Testing encoding of raw bit values.*/
|
||||||
|
@ -52,15 +49,6 @@ int main(int _argc,char **_argv){
|
||||||
nbits2-nbits,ftb);
|
nbits2-nbits,ftb);
|
||||||
ret=-1;
|
ret=-1;
|
||||||
}
|
}
|
||||||
entropy+=ftb+30;
|
|
||||||
nbits=nbits2;
|
|
||||||
ec_enc_bits64(&enc,(ec_uint64)i<<30|i,ftb+30);
|
|
||||||
nbits2=ec_enc_tell(&enc,0);
|
|
||||||
if(nbits2-nbits!=ftb+30){
|
|
||||||
fprintf(stderr,"Used %li bits to encode %i bits directly.\n",
|
|
||||||
nbits2-nbits,ftb+30);
|
|
||||||
ret=-1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nbits=ec_enc_tell(&enc,4);
|
nbits=ec_enc_tell(&enc,4);
|
||||||
|
@ -78,12 +66,6 @@ int main(int _argc,char **_argv){
|
||||||
fprintf(stderr,"Decoded %i instead of %i with ft of %i.\n",sym,i,ft);
|
fprintf(stderr,"Decoded %i instead of %i with ft of %i.\n",sym,i,ft);
|
||||||
ret=-1;
|
ret=-1;
|
||||||
}
|
}
|
||||||
sym64=ec_dec_uint64(&dec,(ec_uint64)ft<<30);
|
|
||||||
if(sym64!=((ec_uint64)i<<30|i)){
|
|
||||||
fprintf(stderr,"Decoded %lu instead of %lu with ft of %lu.\n",sym64,
|
|
||||||
(ec_uint64)i<<30|i,(ec_uint64)ft<<30);
|
|
||||||
ret=-1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ftb=0;ftb<16;ftb++){
|
for(ftb=0;ftb<16;ftb++){
|
||||||
|
@ -93,12 +75,6 @@ int main(int _argc,char **_argv){
|
||||||
fprintf(stderr,"Decoded %i instead of %i with ftb of %i.\n",sym,i,ftb);
|
fprintf(stderr,"Decoded %i instead of %i with ftb of %i.\n",sym,i,ftb);
|
||||||
ret=-1;
|
ret=-1;
|
||||||
}
|
}
|
||||||
sym64=ec_dec_bits64(&dec,ftb+30);
|
|
||||||
if(sym64!=((ec_uint64)i<<30|i)){
|
|
||||||
fprintf(stderr,"Decoded %lu instead of %lu with ftb of %i.\n",
|
|
||||||
sym64,(ec_uint64)i<<30|i,ftb+30);
|
|
||||||
ret=-1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nbits2=ec_dec_tell(&dec,4);
|
nbits2=ec_dec_tell(&dec,4);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue