diff --git a/libcelt/bands.c b/libcelt/bands.c index 2eeff44b..c06efce4 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -146,7 +146,7 @@ void pitch_quant_bands(const CELTMode *m, float *X, float *P, float *gains) P[i] = 0; } -void quant_bands(const CELTMode *m, float *X, float *P) +void quant_bands(const CELTMode *m, float *X, float *P, ec_enc *enc) { int i, j, B; const int *eBands = m->eBands; @@ -156,11 +156,12 @@ void quant_bands(const CELTMode *m, float *X, float *P) for (i=0;inbEBands;i++) { - int q; + int q, id; q = m->nbPulses[i]; if (q>0) { float n = sqrt(B*(eBands[i+1]-eBands[i])); - alg_quant2(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i]); + id = alg_quant2(X+B*eBands[i], B*(eBands[i+1]-eBands[i]), q, P+B*eBands[i]); + ec_enc_uint(enc,id,ncwrs(B*(eBands[i+1]-eBands[i]), q)); for (j=B*eBands[i];jmode, X, P); + quant_bands(st->mode, X, P, &st->enc); /* Synthesis */ denormalise_bands(st->mode, X, bandE); @@ -267,7 +267,7 @@ int celt_encode(CELTState *st, short *pcm) pcm[i*N+j] = (short)floor(.5+tmp); } } - + printf ("%d\n", ec_byte_bytes(&st->buf)); return 0; } diff --git a/libcelt/vq.c b/libcelt/vq.c index c0c457a7..9b3d66d2 100644 --- a/libcelt/vq.c +++ b/libcelt/vq.c @@ -31,6 +31,7 @@ #include #include +#include "cwrs.h" /* Algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch a combination of pulses such that its norm is still equal to 1 */ @@ -94,7 +95,7 @@ void alg_quant(float *x, int N, int K, float *p) /* Improved algebraic pulse-base quantiser. The signal x is replaced by the sum of the pitch a combination of pulses such that its norm is still equal to 1. The only difference with the quantiser above is that the search is more complete. */ -void alg_quant2(float *x, int N, int K, float *p) +int alg_quant2(float *x, int N, int K, float *p) { int L = 5; //float tata[200]; @@ -236,6 +237,10 @@ void alg_quant2(float *x, int N, int K, float *p) for (i=0;i