shithub: opus

Download patch

ref: 75d27803d52f44f4618c4796111c179e24ba558e
parent: be89c395872c57087a6fd0b004ee175677bb3d79
author: Gregory Maxwell <[email protected]>
date: Tue Aug 30 10:02:41 EDT 2011

Adds many syntactically unnecessary parentheses to silence MSVC C4554.
The object code is unchanged.

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -68,7 +68,7 @@
    ls=EC_ILOG(isin);
    icos<<=15-lc;
    isin<<=15-ls;
-   return (ls-lc<<11)
+   return ((ls-lc)<<11)
          +FRAC_MUL16(isin, FRAC_MUL16(isin, -2597) + 7932)
          -FRAC_MUL16(icos, FRAC_MUL16(icos, -2597) + 7932);
 }
@@ -222,7 +222,7 @@
 
       N0 = m->eBands[i+1]-m->eBands[i];
       /* depth in 1/8 bits */
-      depth = (1+pulses[i])/(m->eBands[i+1]-m->eBands[i]<<LM);
+      depth = (1+pulses[i])/((m->eBands[i+1]-m->eBands[i])<<LM);
 
 #ifdef FIXED_POINT
       thresh = MULT16_32_Q15(QCONST16(0.5f, 15), MIN32(32767,SHR32(celt_exp2(-SHL16(depth, 10-BITRES)),1) ));
@@ -903,7 +903,7 @@
       {
          imid = 0;
          iside = 32767;
-         fill &= (1<<B)-1<<B;
+         fill &= ((1<<B)-1)<<B;
          delta = 16384;
       } else {
          imid = bitexact_cos(itheta);
@@ -910,7 +910,7 @@
          iside = bitexact_cos(16384-itheta);
          /* This is the mid vs side allocation that minimizes squared error
             in that band. */
-         delta = FRAC_MUL16(N-1<<7,bitexact_log2tan(iside,imid));
+         delta = FRAC_MUL16((N-1)<<7,bitexact_log2tan(iside,imid));
       }
 
 #ifdef FIXED_POINT
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -1025,7 +1025,7 @@
              was entirely empty, but to allow 0 in hybrid mode. */
          vbr_bound = vbr_rate;
          max_allowed = IMIN(IMAX(tell==1?2:0,
-               vbr_rate+vbr_bound-st->vbr_reservoir>>(BITRES+3)),
+               (vbr_rate+vbr_bound-st->vbr_reservoir)>>(BITRES+3)),
                nbAvailableBytes);
          if(max_allowed < nbAvailableBytes)
          {
@@ -1404,9 +1404,9 @@
          result in the encoder running out of bits.
         The margin of 2 bytes ensures that none of the bust-prevention logic
          in the decoder will have triggered so far. */
-     min_allowed = (tell+total_boost+(1<<BITRES+3)-1>>(BITRES+3)) + 2 - nbFilledBytes;
+     min_allowed = ((tell+total_boost+(1<<(BITRES+3))-1)>>(BITRES+3)) + 2 - nbFilledBytes;
 
-     nbAvailableBytes = target+(1<<(BITRES+2))>>(BITRES+3);
+     nbAvailableBytes = (target+(1<<(BITRES+2)))>>(BITRES+3);
      nbAvailableBytes = IMAX(min_allowed,nbAvailableBytes);
      nbAvailableBytes = IMIN(nbCompressedBytes,nbAvailableBytes+nbFilledBytes) - nbFilledBytes;
 
@@ -1492,8 +1492,8 @@
    ALLOC(fine_priority, st->mode->nbEBands, int);
 
    /* bits =           packet size                    - where we are - safety*/
-   bits = ((opus_int32)nbCompressedBytes*8<<BITRES) - ec_tell_frac(enc) - 1;
-   anti_collapse_rsv = isTransient&&LM>=2&&bits>=(LM+2<<BITRES) ? (1<<BITRES) : 0;
+   bits = (((opus_int32)nbCompressedBytes*8)<<BITRES) - ec_tell_frac(enc) - 1;
+   anti_collapse_rsv = isTransient&&LM>=2&&bits>=((LM+2)<<BITRES) ? (1<<BITRES) : 0;
    bits -= anti_collapse_rsv;
    codedBands = compute_allocation(st->mode, st->start, st->end, offsets, cap,
          alloc_trim, &intensity, &dual_stereo, bits, &balance, pulses,
@@ -2480,8 +2480,8 @@
    alloc_trim = tell+(6<<BITRES) <= total_bits ?
          ec_dec_icdf(dec, trim_icdf, 7) : 5;
 
-   bits = ((opus_int32)len*8<<BITRES) - ec_tell_frac(dec) - 1;
-   anti_collapse_rsv = isTransient&&LM>=2&&bits>=(LM+2<<BITRES) ? (1<<BITRES) : 0;
+   bits = (((opus_int32)len*8)<<BITRES) - ec_tell_frac(dec) - 1;
+   anti_collapse_rsv = isTransient&&LM>=2&&bits>=((LM+2)<<BITRES) ? (1<<BITRES) : 0;
    bits -= anti_collapse_rsv;
    codedBands = compute_allocation(st->mode, st->start, st->end, offsets, cap,
          alloc_trim, &intensity, &dual_stereo, bits, &balance, pulses,
--- a/libcelt/cwrs.c
+++ b/libcelt/cwrs.c
@@ -118,12 +118,12 @@
   celt_assert(_d>0);
   celt_assert(_d<=54);
   shift=EC_ILOG(_d^_d-1);
-  inv=INV_TABLE[_d-1>>shift];
+  inv=INV_TABLE[(_d-1)>>shift];
   shift--;
   one=1<<shift;
   mask=one-1;
   return (_a*(_b>>shift)-(_c>>shift)+
-   (_a*(_b&mask)+one-(_c&mask)>>shift)-1)*inv&MASK32;
+   ((_a*(_b&mask)+one-(_c&mask))>>shift)-1)*inv&MASK32;
 }
 
 #endif /* SMALL_FOOTPRINT */
@@ -356,7 +356,7 @@
       /*U(N,K) = ((2*N-1)*U(N,K-1)-U(N,K-2))/(K-1) + U(N,K-2)*/
       _u[k]=um2=imusdiv32even(n2m1,um1,um2,k-1)+um2;
       if(++k>=len)break;
-      _u[k]=um1=imusdiv32odd(n2m1,um2,um1,k-1>>1)+um1;
+      _u[k]=um1=imusdiv32odd(n2m1,um2,um1,(k-1)>>1)+um1;
     }
   }
 #endif /* SMALL_FOOTPRINT */
@@ -385,7 +385,7 @@
   s=-(_i>=p);
   _i-=p&s;
   yj=_k;
-  _k=_i+1>>1;
+  _k=(_i+1)>>1;
   p=_k?ucwrs2(_k):0;
   _i-=p;
   yj-=_k;
@@ -406,7 +406,7 @@
   yj=_k;
   /*Finds the maximum _k such that ucwrs3(_k)<=_i (tested for all
      _i<2147418113=U(3,32768)).*/
-  _k=_i>0?isqrt32(2*_i-1)+1>>1:0;
+  _k=_i>0?(isqrt32(2*_i-1)+1)>>1:0;
   p=_k?ucwrs3(_k):0;
   _i-=p;
   yj-=_k;
@@ -433,7 +433,7 @@
   kl=0;
   kr=_k;
   for(;;){
-    _k=kl+kr>>1;
+    _k=(kl+kr)>>1;
     p=_k?ucwrs4(_k):0;
     if(p<_i){
       if(_k>=kr)break;
--- a/libcelt/entcode.c
+++ b/libcelt/entcode.c
@@ -76,7 +76,7 @@
      encoder or decoder claims to have used 1 bit.*/
   nbits=_this->nbits_total<<BITRES;
   l=EC_ILOG(_this->rng);
-  r=_this->rng>>l-16;
+  r=_this->rng>>(l-16);
   for(i=BITRES;i-->0;){
     int b;
     r=r*r>>15;
--- a/libcelt/entdec.c
+++ b/libcelt/entdec.c
@@ -114,7 +114,7 @@
     /*Read the next value from the input.*/
     _this->rem=ec_read_byte(_this);
     /*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;
+    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;
   }
@@ -129,7 +129,7 @@
   _this->offs=0;
   _this->rng=1U<<EC_CODE_EXTRA;
   _this->rem=ec_read_byte(_this);
-  _this->val=_this->rng-1-(_this->rem>>EC_SYM_BITS-EC_CODE_EXTRA);
+  _this->val=_this->rng-1-(_this->rem>>(EC_SYM_BITS-EC_CODE_EXTRA));
   _this->error=0;
   /*Normalize the interval.*/
   ec_dec_normalize(_this);
--- a/libcelt/entenc.c
+++ b/libcelt/entenc.c
@@ -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;
   }
@@ -215,7 +215,7 @@
   unsigned mask;
   celt_assert(_nbits<=EC_SYM_BITS);
   shift=EC_SYM_BITS-_nbits;
-  mask=(1<<_nbits)-1<<shift;
+  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);
@@ -224,10 +224,10 @@
     /*The first byte is still awaiting carry propagation.*/
     _this->rem=_this->rem&~mask|_val<<shift;
   }
-  else if(_this->rng<=EC_CODE_TOP>>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)|
-     (opus_uint32)_val<<EC_CODE_SHIFT+shift;
+     (opus_uint32)_val<<(EC_CODE_SHIFT+shift);
   }
   /*The encoder hasn't even encoded _nbits of data yet.*/
   else _this->error=-1;
@@ -249,7 +249,7 @@
   /*We output the minimum number of bits that ensures that the symbols encoded
      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;
+  msk=(EC_CODE_TOP-1)>>l;
   end=_this->val+msk&~msk;
   if((end|msk)>=_this->val+_this->rng){
     l++;
@@ -258,7 +258,7 @@
   }
   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/mathops.c
+++ b/libcelt/mathops.c
@@ -48,11 +48,11 @@
     The main idea is to search for the largest binary digit b such that
      (g+b)*(g+b) <= _val, and add it to the solution g.*/
   g=0;
-  bshift=EC_ILOG(_val)-1>>1;
+  bshift=(EC_ILOG(_val)-1)>>1;
   b=1U<<bshift;
   do{
     opus_uint32 t;
-    t=((opus_uint32)g<<1)+b<<bshift;
+    t=(((opus_uint32)g<<1)+b)<<bshift;
     if(t<=_val){
       g+=b;
       _val-=t;
--- a/libcelt/mfrngcod.h
+++ b/libcelt/mfrngcod.h
@@ -40,7 +40,7 @@
 /*Bits to shift by to move a symbol into the high-order position.*/
 # define EC_CODE_SHIFT (EC_CODE_BITS-EC_SYM_BITS-1)
 /*Carry bit of the high-order range symbol.*/
-# define EC_CODE_TOP   (((opus_uint32)1U)<<EC_CODE_BITS-1)
+# define EC_CODE_TOP   (((opus_uint32)1U)<<(EC_CODE_BITS-1))
 /*Low-order bit of the high-order range symbol.*/
 # define EC_CODE_BOT   (EC_CODE_TOP>>EC_SYM_BITS)
 /*The number of bits available for the last, partial symbol in the code field.*/
--- a/libcelt/rate.c
+++ b/libcelt/rate.c
@@ -497,7 +497,7 @@
       {
          int extra_fine;
          int extra_bits;
-         extra_fine = IMIN(excess >> stereo+BITRES, MAX_FINE_BITS-ebits[j]);
+         extra_fine = IMIN(excess>>(stereo+BITRES),MAX_FINE_BITS-ebits[j]);
          ebits[j] += extra_fine;
          extra_bits = extra_fine*C<<BITRES;
          fine_priority[j] = extra_bits >= excess-balance;