diff --git a/libcelt/Makefile.am b/libcelt/Makefile.am index a932ba57c0db500667819edecf35cd01269c667d..159755b2f0799d63306bbbb5ab1116f4f3127997 100644 --- a/libcelt/Makefile.am +++ b/libcelt/Makefile.am @@ -9,14 +9,14 @@ lib_LTLIBRARIES = libcelt.la # Sources for compilation in the library -libcelt_la_SOURCES = bands.c celt.c fftwrap.c mdct.c pitch.c smallft.c +libcelt_la_SOURCES = bands.c celt.c fftwrap.c mdct.c pitch.c smallft.c vq.c #noinst_HEADERS = libcelt_la_LDFLAGS = -version-info @CELT_LT_CURRENT@:@CELT_LT_REVISION@:@CELT_LT_AGE@ noinst_HEADERS = arch.h bands.h celt.h fftwrap.h mdct.h os_support.h pitch.h \ - smallft.h + smallft.h vq.h noinst_PROGRAMS = testcelt testcelt_SOURCES = testcelt.c diff --git a/libcelt/bands.c b/libcelt/bands.c index 6fbcf54e1464273f9bba9d1c0fadfacb814b4295..9c13444ba6efeb9688604f388bcf538f5124512b 100644 --- a/libcelt/bands.c +++ b/libcelt/bands.c @@ -31,6 +31,7 @@ #include <math.h> #include "bands.h" +#include "vq.h" const int qbank[NBANDS+2] = {0, 2, 4, 6, 8, 12, 16, 20, 24, 28, 36, 44, 52, 68, 84, 116, 128}; int qpulses[] = {4, 5, 4, 4, 3, 3, 3, 3, 3, 4, 4, 4, 0, 0, 0}; //c: 134 bits @@ -138,6 +139,23 @@ void pitch_quant_bands(float *X, int B, float *P, float *gains) P[i] = 0; } +void quant_bands(float *X, int B, float *P) +{ + int i; + for (i=0;i<NBANDS;i++) + { + int q; + q =qpulses[i]; + if (q) { + alg_quant2(X+B*qbank[i], B*(qbank[i+1]-qbank[i]), q, P+B*qbank[i]); + } else { + noise_quant(X+B*qbank[i], B*(qbank[i+1]-qbank[i]), q, P+B*qbank[i]); + } + } + for (i=B*qbank[NBANDS];i<B*qbank[NBANDS+1];i++) + X[i] = 0; +} + /* Scales the pulse-codebook entry in each band such that unit-energy is conserved when adding the pitch */ diff --git a/libcelt/bands.h b/libcelt/bands.h index 8b0929716cfdb735a5477d5bfd34a26dedc5f806..1181a6b8b926543a85bfd8fc519916e2845f6175 100644 --- a/libcelt/bands.h +++ b/libcelt/bands.h @@ -47,6 +47,8 @@ void compute_pitch_gain(float *X, int B, float *P, float *gains, float *bank); void pitch_quant_bands(float *X, int B, float *P, float *gains); +void quant_bands(float *X, int B, float *P); + void pitch_renormalise_bands(float *X, int B, float *P); #endif /* BANDS_H */ diff --git a/libcelt/celt.c b/libcelt/celt.c index 1542273a87a1e1046da16d7d0c4b55ce1a947e7e..445db2370a14ea19f1197fd39b67d18af4d15020 100644 --- a/libcelt/celt.c +++ b/libcelt/celt.c @@ -99,7 +99,7 @@ void celt_encoder_destroy(CELTState *st) celt_free(st); } -static compute_mdcts(mdct_lookup *mdct_lookup, float *window, float *in, float *out, int N, int B) +static void compute_mdcts(mdct_lookup *mdct_lookup, float *window, float *in, float *out, int N, int B) { int i; for (i=0;i<B;i++) @@ -174,19 +174,22 @@ int celt_encode(CELTState *st, short *pcm) //quantise_pitch(gains, PBANDS); pitch_quant_bands(X, B, P, gains); - for (i=0;i<B*N;i++) printf("%f ",P[i]);printf("\n"); + //for (i=0;i<B*N;i++) printf("%f ",P[i]);printf("\n"); /* Subtract the pitch prediction from the signal to encode */ for (i=0;i<B*N;i++) X[i] -= P[i]; /* Residual quantisation */ - if (1) { +#if 1 + quant_bands(X, B, P); +#else + { float tmpE[NBANDS]; compute_bands(X, B, tmpE); normalise_bands(X, B, tmpE); pitch_renormalise_bands(X, B, P); } - //quant_bands(X, P); +#endif /* Synthesis */ denormalise_bands(X, B, bandE); diff --git a/libcelt/fftwrap.c b/libcelt/fftwrap.c index 31215acc7a3b27e995c9a565fb67f70b189f53b9..ef3c1d4a7da17808ddbd5753bc11f07914ed19a0 100644 --- a/libcelt/fftwrap.c +++ b/libcelt/fftwrap.c @@ -119,7 +119,6 @@ void spx_ifft(void *table, float *in, float *out) { if (in==out) { - int i; celt_warning("FFT should not be done in-place"); } else { int i;