shithub: opus

Download patch

ref: 0aa3903a4adf4aaa9b211cfac51d6ebb1d714493
parent: 6e9058adb94b0053c66fa1271928e13b817b0f03
author: Jean-Marc Valin <[email protected]>
date: Fri Dec 7 10:09:58 EST 2007

Cheating decoder now produces the same result as the encoder

--- a/libcelt/bands.c
+++ b/libcelt/bands.c
@@ -197,7 +197,7 @@
          float n = sqrt(B*(eBands[i+1]-eBands[i]));
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
             X[j] = 0;
-         //copy_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), -q, norm, B, eBands[i], dec);
+         copy_unquant(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), -q, norm, B, eBands[i], dec);
          for (j=B*eBands[i];j<B*eBands[i+1];j++)
             norm[j] = X[j] * n;
       }
--- a/libcelt/testcelt.c
+++ b/libcelt/testcelt.c
@@ -59,7 +59,7 @@
       fread(in, sizeof(short), FRAME_SIZE, fin);
       celt_encode(enc, in);
       data = celt_encoder_get_bytes(enc, &len);
-      //celt_decode(dec, data, len, in);
+      celt_decode(dec, data, len, in);
       fwrite(in, sizeof(short), FRAME_SIZE, fout);
    }
    celt_encoder_destroy(enc);
--- a/libcelt/vq.c
+++ b/libcelt/vq.c
@@ -199,6 +199,7 @@
    int best=0;
    float best_score=0;
    float s = 1;
+   int sign;
    float E;
    for (i=0;i<N0*B-N;i+=B)
    {
@@ -221,11 +222,12 @@
             s = -1;
       }
    }
-   //printf ("e%d e%d ", s, best);
-   if (s==-1)
-      ec_enc_uint(enc,1,1);
+   if (s<0)
+      sign = 1;
    else
-      ec_enc_uint(enc,0,1);
+      sign = 0;
+   //printf ("%d %d ", sign, best);
+   ec_enc_uint(enc,sign,2);
    ec_enc_uint(enc,best/B,N0-N/B);
    //printf ("%d %f\n", best, best_score);
    if (K==0)
@@ -302,16 +304,18 @@
 void copy_unquant(float *x, int N, int K, float *Y, int B, int N0, ec_dec *dec)
 {
    int i,j;
-   int s;
+   int sign;
+   float s;
    int best;
    float E;
-   if (ec_dec_uint(dec, 1) == 0)
+   sign = ec_dec_uint(dec, 2);
+   if (sign == 0)
       s = 1;
    else
       s = -1;
    
    best = B*ec_dec_uint(dec, N0-N/B);
-   printf ("d%d d%d ", s, best);
+   //printf ("%d %d ", sign, best);
 
    if (K==0)
    {