ref: 16901bfbbdeb87c09b7df932dcc8b139eabde72c
parent: 8a670b19e14ef727a2500d251fae63d4e1ac40da
author: Gregory Maxwell <[email protected]>
date: Fri Sep 2 15:29:06 EDT 2011
Avoid left-shift by 32 on int32 in ectest.
--- a/libcelt/entenc.c
+++ b/libcelt/entenc.c
@@ -195,6 +195,7 @@
int used;
window=_this->end_window;
used=_this->nend_bits;
+ celt_assert(_bits>0);
if(used+_bits>EC_WINDOW_SIZE){
do{
_this->error|=ec_write_byte_at_end(_this,(unsigned)window&EC_SYM_MAX);
--- a/libcelt/entenc.h
+++ b/libcelt/entenc.h
@@ -73,7 +73,7 @@
/*Encodes a sequence of raw bits in the stream.
_fl: The bits to encode.
_ftb: The number of bits to encode.
- This must be between 0 and 25, inclusive.*/
+ This must be between 1 and 25, inclusive.*/
void ec_enc_bits(ec_enc *_this,opus_uint32 _fl,unsigned _ftb);
/*Overwrites a few bits at the very start of an existing stream, after they
--- a/libcelt/tests/ectest.c
+++ b/libcelt/tests/ectest.c
@@ -55,7 +55,7 @@
}
}
/*Testing encoding of raw bit values.*/
- for(ftb=0;ftb<16;ftb++){
+ for(ftb=1;ftb<16;ftb++){
for(i=0;i<(1<<ftb);i++){
entropy+=ftb;
nbits=ec_tell(&enc);
@@ -84,7 +84,7 @@
}
}
}
- for(ftb=0;ftb<16;ftb++){
+ for(ftb=1;ftb<16;ftb++){
for(i=0;i<(1<<ftb);i++){
sym=ec_dec_bits(&dec,ftb);
if(sym!=(unsigned)i){