ref: 2b08d7a210f0d280fad9810f5b7f1fdbde1fe265
parent: b6a3b0c4646256a9ad158102214b0075d80af571
author: Jean-Marc Valin <[email protected]>
date: Sat Oct 4 17:10:26 EDT 2008
Removing the 64-bit part of the range coder.
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -355,7 +355,7 @@
int tell;
int q;
celt_word16_t n;
- celt_int16_t * const *BPbits;
+ const celt_int16_t * const *BPbits;
int curr_balance, curr_bits;
@@ -440,7 +440,7 @@
int tell;
int q;
celt_word16_t n;
- celt_int16_t * const *BPbits;
+ const celt_int16_t * const *BPbits;
int curr_balance, curr_bits;
--- a/libcelt/entcode.c
+++ b/libcelt/entcode.c
@@ -37,30 +37,3 @@
#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
-}
--- a/libcelt/entdec.c
+++ b/libcelt/entdec.c
@@ -100,16 +100,6 @@
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 t;
unsigned ft;
@@ -125,36 +115,6 @@
ec_dec_update(_this,s,s+1,ft);
t=t<<EC_UNIT_BITS|s;
t = t<<ftb|ec_dec_bits(_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;
- }
-}
-
-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");
--- a/libcelt/entenc.c
+++ b/libcelt/entenc.c
@@ -77,15 +77,6 @@
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){
unsigned ft;
unsigned fl;
@@ -103,19 +94,3 @@
}
}
-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);
- }
-}
--- a/tests/ectest.c
+++ b/tests/ectest.c
@@ -17,7 +17,6 @@
ec_byte_buffer buf;
ec_enc enc;
ec_dec dec;
- ec_uint64 sym64;
long nbits;
long nbits2;
double entropy;
@@ -36,8 +35,6 @@
for(i=0;i<ft;i++){
entropy+=log(ft)*M_LOG2E;
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.*/
@@ -52,15 +49,6 @@
nbits2-nbits,ftb);
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);
@@ -78,12 +66,6 @@
fprintf(stderr,"Decoded %i instead of %i with ft of %i.\n",sym,i,ft);
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++){
@@ -91,12 +73,6 @@
sym=ec_dec_bits(&dec,ftb);
if(sym!=i){
fprintf(stderr,"Decoded %i instead of %i with ftb of %i.\n",sym,i,ftb);
- 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;
}
}