Commit 0aa3903a authored by Jean-Marc Valin's avatar Jean-Marc Valin
Browse files

Cheating decoder now produces the same result as the encoder

parent 6e9058ad
......@@ -197,7 +197,7 @@ void unquant_bands(const CELTMode *m, float *X, float *P, ec_dec *dec)
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;
}
......
......@@ -59,7 +59,7 @@ int main(int argc, char *argv[])
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);
......
......@@ -199,6 +199,7 @@ void copy_quant(float *x, int N, int K, float *Y, int B, int N0, ec_enc *enc)
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 @@ void copy_quant(float *x, int N, int K, float *Y, int B, int N0, ec_enc *enc)
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 alg_unquant(float *x, int N, int K, float *p, ec_dec *dec)
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)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment