Implemented "raw bits"

Making it so all the information encoded directly with ec_enc_bits() gets
stored at the end of the stream, without going through the range coder. This
should be both faster and reduce the effects of bit errors.

Conflicts:

	tests/ectest.c
This commit is contained in:
Jean-Marc Valin 2009-06-17 23:23:46 -04:00
parent 8d940a664e
commit c08be4485b
9 changed files with 101 additions and 19 deletions

View file

@ -38,10 +38,10 @@
#include "os_support.h"
#include "arch.h"
void ec_byte_readinit(ec_byte_buffer *_b,unsigned char *_buf,long _bytes){
_b->buf=_b->ptr=_buf;
_b->storage=_bytes;
_b->end_ptr=_b->buf+_bytes-1;
}
int ec_byte_look1(ec_byte_buffer *_b){
@ -51,6 +51,14 @@ int ec_byte_look1(ec_byte_buffer *_b){
else return _b->ptr[0];
}
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");
}
return *(_b->end_ptr--);
}
int ec_byte_look4(ec_byte_buffer *_b,ec_uint32 *_val){
ptrdiff_t endbyte;
endbyte=_b->ptr-_b->buf;
@ -121,13 +129,13 @@ ec_uint32 ec_dec_bits(ec_dec *_this,int _ftb){
t=0;
while(_ftb>EC_UNIT_BITS){
s=ec_decode_bin(_this,EC_UNIT_BITS);
ec_dec_update(_this,s,s+1,EC_UNIT_MASK+1);
/*ec_dec_update(_this,s,s+1,EC_UNIT_MASK+1);*/
t=t<<EC_UNIT_BITS|s;
_ftb-=EC_UNIT_BITS;
}
ft=1U<<_ftb;
s=ec_decode_bin(_this,_ftb);
ec_dec_update(_this,s,s+1,ft);
/*ec_dec_update(_this,s,s+1,ft);*/
t=t<<_ftb|s;
return t;
}