Using high-band noise less aggressively
[opus.git] / libcelt / quant_bands.c
index 756dab7..ba80fa9 100644 (file)
@@ -74,11 +74,11 @@ static int intra_decision(const celt_word16 *eBands, celt_word16 *oldEBands, int
    {
       for (i=start;i<end;i++)
       {
-         celt_word16 d = SUB16(eBands[i+c*len], oldEBands[i+c*len]);
+         celt_word16 d = SHR16(SUB16(eBands[i+c*len], oldEBands[i+c*len]),2);
          dist = MAC16_16(dist, d,d);
       }
    }
-   return SHR32(dist,2*DB_SHIFT) > 2*C*(end-start);
+   return SHR32(dist,2*DB_SHIFT-4) > 2*C*(end-start);
 }
 
 #ifndef STATIC_MODES
@@ -287,7 +287,7 @@ void quant_fine_energy(const CELTMode *m, int start, int end, celt_ener *eBands,
             q2 = 0;
          ec_enc_bits(enc, q2, fine_quant[i]);
 #ifdef FIXED_POINT
-         offset = SUB16(SHR16(SHL16(q2,DB_SHIFT)+QCONST16(.5,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT));
+         offset = SUB16(SHR32(SHL32(EXTEND32(q2),DB_SHIFT)+QCONST16(.5,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT));
 #else
          offset = (q2+.5f)*(1<<(14-fine_quant[i]))*(1.f/16384) - .5f;
 #endif
@@ -377,7 +377,7 @@ void unquant_fine_energy(const CELTMode *m, int start, int end, celt_ener *eBand
          celt_word16 offset;
          q2 = ec_dec_bits(dec, fine_quant[i]);
 #ifdef FIXED_POINT
-         offset = SUB16(SHR16(SHL16(q2,DB_SHIFT)+QCONST16(.5,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT));
+         offset = SUB16(SHR32(SHL32(EXTEND32(q2),DB_SHIFT)+QCONST16(.5,DB_SHIFT),fine_quant[i]),QCONST16(.5f,DB_SHIFT));
 #else
          offset = (q2+.5f)*(1<<(14-fine_quant[i]))*(1.f/16384) - .5f;
 #endif