ref: 3c453121d2b2daaa2af47d99b9cbe5027611383f
parent: dff7d36a88df376a035b922dd6fb7648d5d24f4f
author: Jean-Marc Valin <[email protected]>
date: Fri Nov 30 12:41:09 EST 2007
Vector quantisation of the residual (copied from Ghost/ceft)
--- a/libcelt/Makefile.am
+++ b/libcelt/Makefile.am
@@ -9,7 +9,7 @@
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 =
@@ -16,7 +16,7 @@
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
--- 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
@@ -136,6 +137,23 @@
}
for (i=B*pbank[PBANDS];i<B*pbank[PBANDS+1];i++)
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;
}
--- a/libcelt/bands.h
+++ b/libcelt/bands.h
@@ -47,6 +47,8 @@
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 */
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -99,7 +99,7 @@
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 @@
//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);
--- a/libcelt/fftwrap.c
+++ b/libcelt/fftwrap.c
@@ -119,7 +119,6 @@
{
if (in==out)
{
- int i;
celt_warning("FFT should not be done in-place");
} else {
int i;