ref: d6335abedc33283bbebf04db166b312771f64da5
parent: 17a29c256749fa7f44930ce3648339ace9fd2506
author: Gregory Maxwell <[email protected]>
date: Tue Aug 30 15:50:41 EDT 2011
Adds many syntactically unnecessary parentheses to silence GCC -Wparentheses. The object code is unchanged (except ectest). Also reenables -Wparentheses, -Wsign-compare, and the MSVC warnings.
--- a/configure.ac
+++ b/configure.ac
@@ -161,7 +161,7 @@
fi
if test $ac_cv_c_compiler_gnu = yes ; then
- CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-parentheses -Wno-unused-parameter -Wno-sign-compare"
+ CFLAGS="$CFLAGS -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wno-unused-parameter"
fi
AC_CHECK_FUNCS([lrintf])
--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -758,7 +758,7 @@
split = 1;
LM -= 1;
if (B==1)
- fill = fill&1|fill<<1;
+ fill = (fill&1)|(fill<<1);
B = (B+1)>>1;
}
}
@@ -1020,13 +1020,13 @@
folding will be done to the side. */
cm |= quant_band(encode, m, i, Y, NULL, N, sbits, spread, B, intensity, tf_change,
next_lowband2, ec, remaining_bits, LM, NULL,
- NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1);
+ NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<((B0>>1)&(stereo-1));
} else {
/* For a stereo split, the high bits of fill are always zero, so no
folding will be done to the side. */
cm = quant_band(encode, m, i, Y, NULL, N, sbits, spread, B, intensity, tf_change,
next_lowband2, ec, remaining_bits, LM, NULL,
- NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<(B0>>1&stereo-1);
+ NULL, next_level, seed, MULT16_16_P15(gain,side), NULL, fill>>B)<<((B0>>1)&(stereo-1));
rebalance = sbits - (rebalance-*remaining_bits);
if (rebalance > 3<<BITRES && itheta!=16384)
mbits += rebalance - (3<<BITRES);
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -46,12 +46,12 @@
{
int l;
l=EC_ILOG(val);
- if(val&val-1){
+ if(val&(val-1)){
/*This is (val>>l-16), but guaranteed to round up, even if adding a bias
before the shift would cause overflow (e.g., for 0xFFFFxxxx).*/
- if(l>16)val=(val>>l-16)+((val&(1<<l-16)-1)+(1<<l-16)-1>>l-16);
+ if(l>16)val=(val>>(l-16))+(((val&((1<<(l-16))-1))+(1<<(l-16))-1)>>(l-16));
else val<<=16-l;
- l=l-1<<frac;
+ l=(l-1)<<frac;
/*Note that we always need one iteration, since the rounding up above means
that we might need to adjust the integer part of the logarithm.*/
do{
@@ -58,8 +58,8 @@
int b;
b=(int)(val>>16);
l+=b<<frac;
- val=val+b>>b;
- val=val*val+0x7FFF>>15;
+ val=(val+b)>>b;
+ val=(val*val+0x7FFF)>>15;
}
while(frac-->0);
/*If val is not exactly 0x8000, then we have to round up the remainder.*/
@@ -66,7 +66,7 @@
return l+(val>0x8000);
}
/*Exact powers of two require no rounding.*/
- else return l-1<<frac;
+ else return (l-1)<<frac;
}
#endif
@@ -117,7 +117,7 @@
int one;
celt_assert(_d>0);
celt_assert(_d<=54);
- shift=EC_ILOG(_d^_d-1);
+ shift=EC_ILOG(_d^(_d-1));
inv=INV_TABLE[(_d-1)>>shift];
shift--;
one=1<<shift;
@@ -371,7 +371,7 @@
static inline void cwrsi1(int _k,opus_uint32 _i,int *_y){
int s;
s=-(int)_i;
- _y[0]=_k+s^s;
+ _y[0]=(_k+s)^s;
}
/*Returns the _i'th combination of _k elements (at most 32767) chosen from a
@@ -389,7 +389,7 @@
p=_k?ucwrs2(_k):0;
_i-=p;
yj-=_k;
- _y[0]=yj+s^s;
+ _y[0]=(yj+s)^s;
cwrsi1(_k,_i,_y+1);
}
@@ -410,7 +410,7 @@
p=_k?ucwrs3(_k):0;
_i-=p;
yj-=_k;
- _y[0]=yj+s^s;
+ _y[0]=(yj+s)^s;
cwrsi2(_k,_i,_y+1);
}
@@ -444,7 +444,7 @@
}
_i-=p;
yj-=_k;
- _y[0]=yj+s^s;
+ _y[0]=(yj+s)^s;
cwrsi3(_k,_i,_y+1);
}
@@ -471,7 +471,7 @@
while(p>_i)p=_u[--_k];
_i-=p;
yj-=_k;
- _y[j]=yj+s^s;
+ _y[j]=(yj+s)^s;
uprev(_u,_k+2,0);
}
while(++j<_n);
--- a/libcelt/ecintrin.h
+++ b/libcelt/ecintrin.h
@@ -57,7 +57,7 @@
are just as fast, and do not require any special target architecture.
Earlier gcc versions (3.x) compiled both code to the same assembly
instructions, because of the way they represented ((_b)>(_a)) internally.*/
-# define EC_MINI(_a,_b) ((_a)+((_b)-(_a)&-((_b)<(_a))))
+# define EC_MINI(_a,_b) ((_a)+(((_b)-(_a))&-((_b)<(_a))))
/*Count leading zeros.
This macro should only be used for implementing ec_ilog(), if it is defined.
--- a/libcelt/entdec.c
+++ b/libcelt/entdec.c
@@ -116,7 +116,7 @@
/*Take the rest of the bits we need from this new symbol.*/
sym=(sym<<EC_SYM_BITS|_this->rem)>>(EC_SYM_BITS-EC_CODE_EXTRA);
/*And subtract them from val, capped to be less than EC_CODE_TOP.*/
- _this->val=(_this->val<<EC_SYM_BITS)+(EC_SYM_MAX&~sym)&EC_CODE_TOP-1;
+ _this->val=((_this->val<<EC_SYM_BITS)+(EC_SYM_MAX&~sym))&(EC_CODE_TOP-1);
}
}
@@ -238,7 +238,7 @@
}
while(available<=EC_WINDOW_SIZE-EC_SYM_BITS);
}
- ret=(opus_uint32)window&((opus_uint32)1<<_bits)-1U;
+ ret=(opus_uint32)window&(((opus_uint32)1<<_bits)-1U);
window>>=_bits;
available-=_bits;
_this->end_window=window;
--- a/libcelt/entenc.c
+++ b/libcelt/entenc.c
@@ -89,7 +89,7 @@
if(_this->rem>=0)_this->error|=ec_write_byte(_this,_this->rem+carry);
if(_this->ext>0){
unsigned sym;
- sym=EC_SYM_MAX+carry&EC_SYM_MAX;
+ sym=(EC_SYM_MAX+carry)&EC_SYM_MAX;
do _this->error|=ec_write_byte(_this,sym);
while(--(_this->ext)>0);
}
@@ -103,7 +103,7 @@
while(_this->rng<=EC_CODE_BOT){
ec_enc_carry_out(_this,(int)(_this->val>>EC_CODE_SHIFT));
/*Move the next-to-high-order symbol into the high-order position.*/
- _this->val=(_this->val<<EC_SYM_BITS)&EC_CODE_TOP-1;
+ _this->val=(_this->val<<EC_SYM_BITS)&(EC_CODE_TOP-1);
_this->rng<<=EC_SYM_BITS;
_this->nbits_total+=EC_SYM_BITS;
}
@@ -185,7 +185,7 @@
ft=(_ft>>ftb)+1;
fl=(unsigned)(_fl>>ftb);
ec_encode(_this,fl,fl+1,ft);
- ec_enc_bits(_this,_fl&((opus_uint32)1<<ftb)-1,ftb);
+ ec_enc_bits(_this,_fl&(((opus_uint32)1<<ftb)-1U),ftb);
}
else ec_encode(_this,_fl,_fl+1,_ft+1);
}
@@ -218,15 +218,15 @@
mask=((1<<_nbits)-1)<<shift;
if(_this->offs>0){
/*The first byte has been finalized.*/
- _this->buf[0]=(unsigned char)(_this->buf[0]&~mask|_val<<shift);
+ _this->buf[0]=(unsigned char)((_this->buf[0]&~mask)|_val<<shift);
}
else if(_this->rem>=0){
/*The first byte is still awaiting carry propagation.*/
- _this->rem=_this->rem&~mask|_val<<shift;
+ _this->rem=(_this->rem&~mask)|_val<<shift;
}
else if(_this->rng<=(EC_CODE_TOP>>shift)){
/*The renormalization loop has never been run.*/
- _this->val=_this->val&~((opus_uint32)mask<<EC_CODE_SHIFT)|
+ _this->val=(_this->val&~((opus_uint32)mask<<EC_CODE_SHIFT))|
(opus_uint32)_val<<(EC_CODE_SHIFT+shift);
}
/*The encoder hasn't even encoded _nbits of data yet.*/
@@ -250,15 +250,15 @@
thus far will be decoded correctly regardless of the bits that follow.*/
l=EC_CODE_BITS-EC_ILOG(_this->rng);
msk=(EC_CODE_TOP-1)>>l;
- end=_this->val+msk&~msk;
+ end=(_this->val+msk)&~msk;
if((end|msk)>=_this->val+_this->rng){
l++;
msk>>=1;
- end=_this->val+msk&~msk;
+ end=(_this->val+msk)&~msk;
}
while(l>0){
ec_enc_carry_out(_this,(int)(end>>EC_CODE_SHIFT));
- end=(end<<EC_SYM_BITS)&EC_CODE_TOP-1;
+ end=(end<<EC_SYM_BITS)&(EC_CODE_TOP-1);
l-=EC_SYM_BITS;
}
/*If we have a buffered byte flush it into the output buffer.*/
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -189,7 +189,7 @@
/* Offset the number of qtheta bits by log2(N)/2
+ QTHETA_OFFSET compared to their "fair share" of
total/N */
- offset = (m->logN[j]+(LM0+k<<BITRES)>>1)-QTHETA_OFFSET;
+ offset = ((m->logN[j]+((LM0+k)<<BITRES))>>1)-QTHETA_OFFSET;
/* The number of qtheta bits we'll allocate if the remainder
is to be max_bits.
The average measured cost for theta is 0.89701 times qb,
@@ -205,7 +205,7 @@
if (C==2)
{
max_bits <<= 1;
- offset = (m->logN[j]+(i<<BITRES)>>1)-(N==2?QTHETA_OFFSET_TWOPHASE:QTHETA_OFFSET);
+ offset = ((m->logN[j]+(i<<BITRES))>>1)-(N==2?QTHETA_OFFSET_TWOPHASE:QTHETA_OFFSET);
ndof = 2*N-1-(N==2);
/* The average measured cost for theta with the step PDF is
0.95164 times qb, approximated here as 487/512. */
@@ -220,7 +220,7 @@
ndof = C*N + ((C==2 && N>2) ? 1 : 0);
/* Offset the number of fine bits by log2(N)/2 + FINE_OFFSET
compared to their "fair share" of total/N */
- offset = (m->logN[j] + (i<<BITRES)>>1)-FINE_OFFSET;
+ offset = ((m->logN[j] + (i<<BITRES))>>1)-FINE_OFFSET;
/* N=2 is the only point that doesn't match the curve */
if (N==2)
offset += 1<<BITRES>>2;
@@ -227,12 +227,12 @@
/* The number of fine bits we'll allocate if the remainder is
to be max_bits. */
num = max_bits+ndof*offset;
- den = ndof-1<<BITRES;
+ den = (ndof-1)<<BITRES;
qb = IMIN((num+(den>>1))/den, MAX_FINE_BITS);
celt_assert(qb >= 0);
max_bits += C*qb<<BITRES;
}
- max_bits = (4*max_bits/(C*(m->eBands[j+1]-m->eBands[j]<<i)))-64;
+ max_bits = (4*max_bits/(C*((m->eBands[j+1]-m->eBands[j])<<i)))-64;
celt_assert(max_bits >= 0);
celt_assert(max_bits < 256);
*cap++ = (unsigned char)max_bits;
--- a/libcelt/tests/ectest.c
+++ b/libcelt/tests/ectest.c
@@ -29,10 +29,10 @@
double entropy;
int ft;
int ftb;
- int sym;
int sz;
int i;
int ret;
+ unsigned int sym;
unsigned int seed;
unsigned char *ptr;
ret=0;
@@ -78,7 +78,7 @@
for(ft=2;ft<1024;ft++){
for(i=0;i<ft;i++){
sym=ec_dec_uint(&dec,ft);
- if(sym!=i){
+ if(sym!=(unsigned)i){
fprintf(stderr,"Decoded %i instead of %i with ft of %i.\n",sym,i,ft);
ret=-1;
}
@@ -87,7 +87,7 @@
for(ftb=0;ftb<16;ftb++){
for(i=0;i<(1<<ftb);i++){
sym=ec_dec_bits(&dec,ftb);
- if(sym!=i){
+ if(sym!=(unsigned)i){
fprintf(stderr,"Decoded %i instead of %i with ftb of %i.\n",sym,i,ftb);
ret=-1;
}
@@ -105,8 +105,8 @@
for(i=0;i<409600;i++){
unsigned *data;
unsigned *tell;
+ unsigned tell_bits;
int j;
- int tell_bits;
int zeros;
ft=rand()/((RAND_MAX>>(rand()%11))+1)+10;
sz=rand()/((RAND_MAX>>(rand()%9))+1);
@@ -128,7 +128,7 @@
ec_enc_uint(&enc, rand()%2, 2);
tell_bits = ec_tell(&enc);
ec_enc_done(&enc);
- if(tell_bits!=ec_tell(&enc)){
+ if(tell_bits!=(unsigned)ec_tell(&enc)){
fprintf(stderr,"ec_tell() changed after ec_enc_done(): %i instead of %i (Random seed: %u)\n",
ec_tell(&enc),tell_bits,seed);
ret=-1;
@@ -203,7 +203,7 @@
tell[j+1]=ec_tell_frac(&enc);
}
ec_enc_done(&enc);
- if((ec_tell(&enc)+7)/8<ec_range_bytes(&enc)){
+ if((ec_tell(&enc)+7U)/8U<ec_range_bytes(&enc)){
fprintf(stderr,"tell() lied, there's %i bytes instead of %d (Random seed: %u)\n",
ec_range_bytes(&enc),(ec_tell(&enc)+7)/8,seed);
ret=-1;
--- a/src/repacketizer.c
+++ b/src/repacketizer.c
@@ -73,7 +73,7 @@
{
rp->toc = data[0];
rp->framesize = opus_packet_get_samples_per_frame(data, 48000);
- } else if (rp->toc&0xFC != data[0]&0xFC)
+ } else if ((rp->toc&0xFC) != (data[0]&0xFC))
{
/*fprintf(stderr, "toc mismatch: 0x%x vs 0x%x\n", rp->toc, data[0]);*/
return OPUS_CORRUPTED_DATA;
--- a/win32/config.h
+++ b/win32/config.h
@@ -15,12 +15,6 @@
/* Get rid of the CELT VS compile warnings */
#if 1
-#pragma warning(disable : 4018)/* signed/unsigned mismatch */
-#pragma warning(disable : 4244)/* conversion from 'double' to 'opus_val16', possible loss of data */
-#pragma warning(disable : 4267)/* conversion from 'size_t' to 'int', possible loss of data */
-#pragma warning(disable : 4305)/* truncation from 'double' to 'const float' */
-#pragma warning(disable : 4311)/* pointer truncation from 'char *' to 'long' */
-#pragma warning(disable : 4554)/* check operator precedence for possible error; use parentheses to clarify precedence */
#pragma warning(disable : 4996)/* This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. */
#endif