shithub: opus

Download patch

ref: 020ef4f810ce441a79abdbe9cd0840a462d888ac
parent: 1213ba5e6837be1ddb33aa22fb0ca32e38fff0c7
author: Jean-Marc Valin <[email protected]>
date: Tue Aug 31 13:08:45 EDT 2010

Ignoring lower bands in folding_decision()

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -248,7 +248,7 @@
 int folding_decision(const CELTMode *m, celt_norm *X, int *average, int *last_decision, int end, int _C, int M)
 {
    int i, c, N0;
-   int sum = 0;
+   int sum = 0, nbBands=0;
    const int C = CHANNELS(_C);
    const celt_int16 * restrict eBands = m->eBands;
    int decision;
@@ -262,7 +262,9 @@
          int j, N, tmp=0;
          int tcount[3] = {0};
          celt_norm * restrict x = X+M*eBands[i]+c*N0;
-         N = M*eBands[i+1]-M*eBands[i];
+         N = M*(eBands[i+1]-eBands[i]);
+         if (N<=8)
+            continue;
          /* Compute rough CDF of |x[j]| */
          for (j=0;j<N;j++)
          {
@@ -279,9 +281,10 @@
 
          tmp = (2*tcount[2] >= N) + (2*tcount[1] >= N) + (2*tcount[0] >= N);
          sum += tmp*256;
+         nbBands++;
       }
    }
-   sum /= C*end;
+   sum /= nbBands;
    /* Recursive averaging */
    sum = (sum+*average)>>1;
    *average = sum;