improved energy quantisation/prediction
authorJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Thu, 6 Dec 2007 02:50:14 +0000 (13:50 +1100)
committerJean-Marc Valin <Jean-Marc.Valin@csiro.au>
Thu, 6 Dec 2007 02:50:14 +0000 (13:50 +1100)
libcelt/bands.c
libcelt/quant_bands.c

index 52a2c69..2eeff44 100644 (file)
@@ -163,14 +163,13 @@ void quant_bands(const CELTMode *m, float *X, float *P)
          alg_quant2(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i]);
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
             norm[j] = X[j] * n;
-         //bits += log2(ncwrs(B*(qbank[i+1]-qbank[i]), q));
+         //bits += log2(ncwrs(B*(eBands[i+1]-eBands[i]), q));
       } else {
          float n = sqrt(B*(eBands[i+1]-eBands[i]));
          copy_quant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), -q, norm, B, eBands[i]);
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
             norm[j] = X[j] * n;
-         //bits += 1+log2(qbank[i])+log2(ncwrs(B*(qbank[i+1]-qbank[i]), -q));
-         //noise_quant(X+B*qbank[i], B*(qbank[i+1]-qbank[i]), q, P+B*qbank[i]);
+         //bits += 1+log2(eBands[i])+log2(ncwrs(B*(eBands[i+1]-eBands[i]), -q));
       }
    }
    //printf ("%f\n", bits);
index eaf4e2e..8011703 100644 (file)
@@ -43,21 +43,23 @@ void quant_energy(CELTMode *m, float *eBands, float *oldEBands)
       float q;
       float res;
       float x;
-      float pred = .9*oldEBands[i];
+      float pred = .7*oldEBands[i];
       
       x = 20*log10(.3+eBands[i]);
-      res = 1.0f;
+      res = .25f*(i+3.f);
+      //res = 1;
       qi = (int)floor(.5+(x-pred-prev)/res);
       q = qi*res;
       
       //printf("%f %f ", pred+prev+q, x);
       //printf("%d ", qi);
+      //printf("%f ", x-pred-prev);
       
       oldEBands[i] = pred+prev+q;
       eBands[i] = pow(10, .05*oldEBands[i])-.3;
       if (eBands[i] < 0)
          eBands[i] = 0;
-      prev = .65*q;
+      prev = (prev + .5*q);
    }
    //printf ("\n");
 }