From 552bc307bdd88993435e5779c7df1869f4eb6efc Mon Sep 17 00:00:00 2001 From: drowe67 Date: Fri, 1 Oct 2010 00:46:46 +0000 Subject: [PATCH] Patch from Bruce: Generate const C tables for LSP codebook at compile time. Replace mallocs with stack arrays. ANSI C90 compatibility. Conditional compile DUMP, give embedded systems a space break. Conditional-define out unused VQ functions. Initialize variables that are first passed by address with no initialization, to keep the compiler from complaining. Set GCC pedantic flag, we need to be that portable. Get rid of any BSS or DATA segment data, there were a few unused static variables. All compile-time initialized data is read-only and in the text segment now. git-svn-id: https://svn.code.sf.net/p/freetel/code@196 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2/src/Makefile | 32 +- codec2/src/c2dec.c | 7 +- codec2/src/c2enc.c | 7 +- codec2/src/c2sim.c | 18 +- codec2/src/defines.h | 10 + codec2/src/dump.c | 2 + codec2/src/lsp.c | 629 +++++++++++++++++++-------------------- codec2/src/nlp.c | 6 +- codec2/src/pack.c | 5 +- codec2/src/postfilter.c | 2 + codec2/src/quantise.c | 157 ++-------- codec2/src/quantise.h | 1 - codec2/unittest/Makefile | 9 +- codec2/unittest/tnlp.c | 12 +- 14 files changed, 418 insertions(+), 479 deletions(-) diff --git a/codec2/src/Makefile b/codec2/src/Makefile index 66af79f4..4254db82 100644 --- a/codec2/src/Makefile +++ b/codec2/src/Makefile @@ -1,14 +1,27 @@ CC=gcc -CFLAGS=-g -Wall -I. -I../src -Wall -g -DFLOATING_POINT -DVAR_ARRAYS -O2 +CFLAGS=--pedantic -Wall -I. -I../src -Wall -g -DFLOATING_POINT -DVAR_ARRAYS -O2 C2SIM_OBJ = sine.o nlp.o four1.o dump.o quantise.o lpc.o lsp.o phase.o \ - pack.o postfilter.o interp.o codec2.o c2sim.o + pack.o postfilter.o interp.o codec2.o c2sim.o codebook.o C2ENC_OBJ = sine.o nlp.o four1.o dump.o quantise.o lpc.o lsp.o phase.o \ - pack.o postfilter.o interp.o codec2.o c2enc.o + pack.o postfilter.o interp.o codec2.o c2enc.o codebook.o C2DEC_OBJ = sine.o nlp.o four1.o dump.o quantise.o lpc.o lsp.o phase.o \ - pack.o postfilter.o interp.o codec2.o c2dec.o + pack.o postfilter.o interp.o codec2.o c2dec.o codebook.o + +D=codebook +CODEBOOKS= \ + $D/lsp1.txt \ + $D/lsp2.txt \ + $D/lsp3.txt \ + $D/lsp4.txt \ + $D/lsp5.txt \ + $D/lsp6.txt \ + $D/lsp7.txt \ + $D/lsp8.txt \ + $D/lsp9.txt \ + $D/lsp10.txt all: c2sim c2enc c2dec @@ -21,8 +34,17 @@ c2enc: $(C2ENC_OBJ) c2dec: $(C2DEC_OBJ) $(CC) $(CFLAGS) $(C2DEC_OBJ) -o c2dec -lm +codebook.c: generate_codebook $(CODEBOOKS) + ./generate_codebook $(CODEBOOKS) > codebook.c + +codebook.o: codebook.c + $(CC) -c $(CFLAGS) $< -o $@ + +generate_codebook: generate_codebook.o + $(CC) $(CFLAGS) generate_codebook.o -o generate_codebook -lm + %.o : %.c $(CC) -c $(CFLAGS) $< -o $@ clean : - rm -f *.o *~ src/*~ c2enc c2dec c2sim + rm -f *.o *~ src/*~ c2enc c2dec c2sim generate_codebook src/codebook.c diff --git a/codec2/src/c2dec.c b/codec2/src/c2dec.c index 3b876bca..f64b3807 100644 --- a/codec2/src/c2dec.c +++ b/codec2/src/c2dec.c @@ -38,14 +38,15 @@ #include #include +#define BITS_SIZE ((CODEC2_BITS_PER_FRAME + 7) / 8) + int main(int argc, char *argv[]) { - static const int bitsSize = ((CODEC2_BITS_PER_FRAME + 7) / 8); void *codec2; FILE *fin; FILE *fout; short buf[CODEC2_SAMPLES_PER_FRAME]; - unsigned char bits[bitsSize]; + unsigned char bits[BITS_SIZE]; if (argc != 3) { printf("usage: %s InputBitFile OutputRawSpeechFile\n", argv[0]); @@ -66,7 +67,7 @@ int main(int argc, char *argv[]) codec2 = codec2_create(); - while(fread(bits, sizeof(char), bitsSize, fin) == bitsSize) { + while(fread(bits, sizeof(char), BITS_SIZE, fin) == BITS_SIZE) { codec2_decode(codec2, buf, bits); fwrite(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fout); } diff --git a/codec2/src/c2enc.c b/codec2/src/c2enc.c index 8fd7c777..a2d02db6 100644 --- a/codec2/src/c2enc.c +++ b/codec2/src/c2enc.c @@ -39,14 +39,15 @@ #include #include +#define BITS_SIZE ((CODEC2_BITS_PER_FRAME + 7) / 8) + int main(int argc, char *argv[]) { - static const int bitsSize = ((CODEC2_BITS_PER_FRAME + 7) / 8); void *codec2; FILE *fin; FILE *fout; short buf[CODEC2_SAMPLES_PER_FRAME]; - unsigned char bits[bitsSize]; + unsigned char bits[BITS_SIZE]; if (argc != 3) { printf("usage: %s InputRawspeechFile OutputBitFile\n", argv[0]); @@ -70,7 +71,7 @@ int main(int argc, char *argv[]) while(fread(buf, sizeof(short), CODEC2_SAMPLES_PER_FRAME, fin) == CODEC2_SAMPLES_PER_FRAME) { codec2_encode(codec2, bits, buf); - fwrite(bits, sizeof(char), bitsSize, fout); + fwrite(bits, sizeof(char), BITS_SIZE, fout); } codec2_destroy(codec2); diff --git a/codec2/src/c2sim.c b/codec2/src/c2sim.c index 72c5632f..1230425d 100644 --- a/codec2/src/c2sim.c +++ b/codec2/src/c2sim.c @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) float snr; float sum_snr; - int lpc_model, order; + int lpc_model, order = 0; int lsp, lsp_quantiser; float ak[LPC_MAX]; COMP Sw_[FFT_ENC]; @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) float bg_est; int hand_voicing; - FILE *fvoicing; + FILE *fvoicing = 0; MODEL prev_model, interp_model; int decimate; @@ -188,8 +188,10 @@ int main(int argc, char *argv[]) } dump = switch_present("--dump",argc,argv); +#ifdef DUMP if (dump) dump_on(argv[dump+1]); +#endif lsp = switch_present("--lsp",argc,argv); lsp_quantiser = 0; @@ -241,7 +243,9 @@ int main(int argc, char *argv[]) dft_speech(Sw, Sn, w); two_stage_pitch_refinement(&model, Sw); estimate_amplitudes(&model, Sw, W); +#ifdef DUMP dump_Sn(Sn); dump_Sw(Sw); dump_model(&model); +#endif /* optional zero-phase modelling */ @@ -249,7 +253,9 @@ int main(int argc, char *argv[]) float Wn[M]; /* windowed speech samples */ float Rk[LPC_ORD+1]; /* autocorrelation coeffs */ +#ifdef DUMP dump_phase(&model.phi[0], model.L); +#endif /* find aks here, these are overwritten if LPC modelling is enabled */ @@ -261,13 +267,17 @@ int main(int argc, char *argv[]) if (lpc_model) assert(order == LPC_ORD); +#ifdef DUMP dump_ak(ak, LPC_ORD); +#endif /* determine voicing */ snr = est_voicing_mbe(&model, Sw, W, (FS/TWO_PI)*model.Wo, Sw_); +#ifdef DUMP dump_Sw_(Sw_); dump_snr(snr); +#endif /* just to make sure we are not cheating - kill all phases */ @@ -309,7 +319,9 @@ int main(int argc, char *argv[]) aks_to_M2(ak, order, &model, e, &snr, 1); apply_lpc_correction(&model, lpc_correction); sum_snr += snr; +#ifdef DUMP dump_quantised_model(&model); +#endif } /* option decimation to 20ms rate, which enables interpolation @@ -380,8 +392,10 @@ int main(int argc, char *argv[]) if (lpc_model) printf("SNR av = %5.2f dB\n", sum_snr/frames); +#ifdef DUMP if (dump) dump_off(); +#endif if (hand_voicing) fclose(fvoicing); diff --git a/codec2/src/defines.h b/codec2/src/defines.h index ef4899f7..76955e65 100644 --- a/codec2/src/defines.h +++ b/codec2/src/defines.h @@ -81,4 +81,14 @@ typedef struct { int voiced; /* non-zero if this frame is voiced */ } MODEL; +/* describes each codebook */ + +struct lsp_codebook { + int k; /* dimension of vector */ + int log2m; /* number of bits in m */ + int m; /* elements in codebook */ + const float * cb; /* The elements */ +}; +extern const struct lsp_codebook lsp_cb[]; + #endif diff --git a/codec2/src/dump.c b/codec2/src/dump.c index 2d187444..1c5d74ac 100644 --- a/codec2/src/dump.c +++ b/codec2/src/dump.c @@ -32,6 +32,7 @@ #include #include +#ifdef DUMP static int dumpon = 0; static FILE *fsn = NULL; @@ -400,3 +401,4 @@ void dump_E(float E) { fprintf(fE,"%f\n", 10.0*log10(E)); } +#endif diff --git a/codec2/src/lsp.c b/codec2/src/lsp.c index feab4219..158e9a19 100644 --- a/codec2/src/lsp.c +++ b/codec2/src/lsp.c @@ -1,323 +1,306 @@ -/*---------------------------------------------------------------------------*\ - - FILE........: lsp.c - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - - This file contains functions for LPC to LSP conversion and LSP to - LPC conversion. Note that the LSP coefficients are not in radians - format but in the x domain of the unit circle. - -\*---------------------------------------------------------------------------*/ - -#include "defines.h" -#include "lsp.h" -#include -#include -#include - -/*---------------------------------------------------------------------------*\ - - Introduction to Line Spectrum Pairs (LSPs) - ------------------------------------------ - - LSPs are used to encode the LPC filter coefficients {ak} for - transmission over the channel. LSPs have several properties (like - less sensitivity to quantisation noise) that make them superior to - direct quantisation of {ak}. - - A(z) is a polynomial of order lpcrdr with {ak} as the coefficients. - - A(z) is transformed to P(z) and Q(z) (using a substitution and some - algebra), to obtain something like: - - A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1) - - As you can imagine A(z) has complex zeros all over the z-plane. P(z) - and Q(z) have the very neat property of only having zeros _on_ the - unit circle. So to find them we take a test point z=exp(jw) and - evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0 - and pi. - - The zeros (roots) of P(z) also happen to alternate, which is why we - swap coefficients as we find roots. So the process of finding the - LSP frequencies is basically finding the roots of 5th order - polynomials. - - The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence - the name Line Spectrum Pairs (LSPs). - - To convert back to ak we just evaluate (1), "clocking" an impulse - thru it lpcrdr times gives us the impulse response of A(z) which is - {ak}. - -\*---------------------------------------------------------------------------*/ - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: cheb_poly_eva() - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - This function evalutes a series of chebyshev polynomials - - FIXME: performing memory allocation at run time is very inefficient, - replace with stack variables of MAX_P size. - -\*---------------------------------------------------------------------------*/ - - -float cheb_poly_eva(float *coef,float x,int m) -/* float coef[] coefficients of the polynomial to be evaluated */ -/* float x the point where polynomial is to be evaluated */ -/* int m order of the polynomial */ -{ - int i; - float *T,*t,*u,*v,sum; - - /* Allocate memory for chebyshev series formulation */ - - if((T = (float *)malloc((m/2+1)*sizeof(float))) == NULL){ - fprintf(stderr, "not enough memory to allocate buffer\n"); - exit(1); - } - - /* Initialise pointers */ - - t = T; /* T[i-2] */ - *t++ = 1.0; - u = t--; /* T[i-1] */ - *u++ = x; - v = u--; /* T[i] */ - - /* Evaluate chebyshev series formulation using iterative approach */ - - for(i=2;i<=m/2;i++) - *v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */ - - sum=0.0; /* initialise sum to zero */ - t = T; /* reset pointer */ - - /* Evaluate polynomial and return value also free memory space */ - - for(i=0;i<=m/2;i++) - sum+=coef[(m/2)-i]**t++; - - free(T); - return sum; -} - - -/*---------------------------------------------------------------------------*\ - - FUNCTION....: lpc_to_lsp() - AUTHOR......: David Rowe - DATE CREATED: 24/2/93 - - This function converts LPC coefficients to LSP coefficients. - -\*---------------------------------------------------------------------------*/ - -int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta) -/* float *a lpc coefficients */ -/* int lpcrdr order of LPC coefficients (10) */ -/* float *freq LSP frequencies in radians */ -/* int nb number of sub-intervals (4) */ -/* float delta grid spacing interval (0.02) */ -{ - float psuml,psumr,psumm,temp_xr,xl,xr,xm; - float temp_psumr; - int i,j,m,flag,k; - float *Q; /* ptrs for memory allocation */ - float *P; - float *px; /* ptrs of respective P'(z) & Q'(z) */ - float *qx; - float *p; - float *q; - float *pt; /* ptr used for cheb_poly_eval() - whether P' or Q' */ - int roots=0; /* number of roots found */ - flag = 1; - m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */ - - /* Allocate memory space for polynomials */ - - Q = (float *) malloc((m+1)*sizeof(float)); - P = (float *) malloc((m+1)*sizeof(float)); - if( (P == NULL) || (Q == NULL) ) { - fprintf(stderr,"not enough memory to allocate buffer\n"); - exit(1); - } - - /* determine P'(z)'s and Q'(z)'s coefficients where - P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */ - - px = P; /* initilaise ptrs */ - qx = Q; - p = px; - q = qx; - *px++ = 1.0; - *qx++ = 1.0; - for(i=1;i<=m;i++){ - *px++ = a[i]+a[lpcrdr+1-i]-*p++; - *qx++ = a[i]-a[lpcrdr+1-i]+*q++; - } - px = P; - qx = Q; - for(i=0;i= -1.0)){ - xr = xl - delta ; /* interval spacing */ - psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */ - temp_psumr = psumr; - temp_xr = xr; - - /* if no sign change increment xr and re-evaluate - poly(xr). Repeat til sign change. if a sign change has - occurred the interval is bisected and then checked again - for a sign change which determines in which interval the - zero lies in. If there is no sign change between poly(xm) - and poly(xl) set interval between xm and xr else set - interval between xl and xr and repeat till root is located - within the specified limits */ - - if((psumr*psuml)<0.0){ - roots++; - - psumm=psuml; - for(k=0;k<=nb;k++){ - xm = (xl+xr)/2; /* bisect the interval */ - psumm=cheb_poly_eva(pt,xm,lpcrdr); - if(psumm*psuml>0.){ - psuml=psumm; - xl=xm; - } - else{ - psumr=psumm; - xr=xm; - } - } - - /* once zero is found, reset initial interval to xr */ - freq[j] = (xm); - xl = xm; - flag = 0; /* reset flag for next search */ - } - else{ - psuml=temp_psumr; - xl=temp_xr; - } - } - } - free(P); /* free memory space */ - free(Q); - - /* convert from x domain to radians */ - - for(i=0; i +#include +#include + +/* Only 10 gets used, so far. */ +#define LSP_MAX_ORDER 20 +/*---------------------------------------------------------------------------*\ + + Introduction to Line Spectrum Pairs (LSPs) + ------------------------------------------ + + LSPs are used to encode the LPC filter coefficients {ak} for + transmission over the channel. LSPs have several properties (like + less sensitivity to quantisation noise) that make them superior to + direct quantisation of {ak}. + + A(z) is a polynomial of order lpcrdr with {ak} as the coefficients. + + A(z) is transformed to P(z) and Q(z) (using a substitution and some + algebra), to obtain something like: + + A(z) = 0.5[P(z)(z+z^-1) + Q(z)(z-z^-1)] (1) + + As you can imagine A(z) has complex zeros all over the z-plane. P(z) + and Q(z) have the very neat property of only having zeros _on_ the + unit circle. So to find them we take a test point z=exp(jw) and + evaluate P (exp(jw)) and Q(exp(jw)) using a grid of points between 0 + and pi. + + The zeros (roots) of P(z) also happen to alternate, which is why we + swap coefficients as we find roots. So the process of finding the + LSP frequencies is basically finding the roots of 5th order + polynomials. + + The root so P(z) and Q(z) occur in symmetrical pairs at +/-w, hence + the name Line Spectrum Pairs (LSPs). + + To convert back to ak we just evaluate (1), "clocking" an impulse + thru it lpcrdr times gives us the impulse response of A(z) which is + {ak}. + +\*---------------------------------------------------------------------------*/ + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: cheb_poly_eva() + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + This function evalutes a series of chebyshev polynomials + + FIXME: performing memory allocation at run time is very inefficient, + replace with stack variables of MAX_P size. + +\*---------------------------------------------------------------------------*/ + + +static float +cheb_poly_eva(float *coef,float x,int m) +/* float coef[] coefficients of the polynomial to be evaluated */ +/* float x the point where polynomial is to be evaluated */ +/* int m order of the polynomial */ +{ + int i; + float *t,*u,*v,sum; + float T[(LSP_MAX_ORDER / 2) + 1]; + + /* Initialise pointers */ + + t = T; /* T[i-2] */ + *t++ = 1.0; + u = t--; /* T[i-1] */ + *u++ = x; + v = u--; /* T[i] */ + + /* Evaluate chebyshev series formulation using iterative approach */ + + for(i=2;i<=m/2;i++) + *v++ = (2*x)*(*u++) - *t++; /* T[i] = 2*x*T[i-1] - T[i-2] */ + + sum=0.0; /* initialise sum to zero */ + t = T; /* reset pointer */ + + /* Evaluate polynomial and return value also free memory space */ + + for(i=0;i<=m/2;i++) + sum+=coef[(m/2)-i]**t++; + + return sum; +} + + +/*---------------------------------------------------------------------------*\ + + FUNCTION....: lpc_to_lsp() + AUTHOR......: David Rowe + DATE CREATED: 24/2/93 + + This function converts LPC coefficients to LSP coefficients. + +\*---------------------------------------------------------------------------*/ + +int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta) +/* float *a lpc coefficients */ +/* int lpcrdr order of LPC coefficients (10) */ +/* float *freq LSP frequencies in radians */ +/* int nb number of sub-intervals (4) */ +/* float delta grid spacing interval (0.02) */ +{ + float psuml,psumr,psumm,temp_xr,xl,xr,xm = 0; + float temp_psumr; + int i,j,m,flag,k; + float *px; /* ptrs of respective P'(z) & Q'(z) */ + float *qx; + float *p; + float *q; + float *pt; /* ptr used for cheb_poly_eval() + whether P' or Q' */ + int roots=0; /* number of roots found */ + float Q[LSP_MAX_ORDER + 1]; + float P[LSP_MAX_ORDER + 1]; + + flag = 1; + m = lpcrdr/2; /* order of P'(z) & Q'(z) polynimials */ + + /* Allocate memory space for polynomials */ + + /* determine P'(z)'s and Q'(z)'s coefficients where + P'(z) = P(z)/(1 + z^(-1)) and Q'(z) = Q(z)/(1-z^(-1)) */ + + px = P; /* initilaise ptrs */ + qx = Q; + p = px; + q = qx; + *px++ = 1.0; + *qx++ = 1.0; + for(i=1;i<=m;i++){ + *px++ = a[i]+a[lpcrdr+1-i]-*p++; + *qx++ = a[i]-a[lpcrdr+1-i]+*q++; + } + px = P; + qx = Q; + for(i=0;i= -1.0)){ + xr = xl - delta ; /* interval spacing */ + psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */ + temp_psumr = psumr; + temp_xr = xr; + + /* if no sign change increment xr and re-evaluate + poly(xr). Repeat til sign change. if a sign change has + occurred the interval is bisected and then checked again + for a sign change which determines in which interval the + zero lies in. If there is no sign change between poly(xm) + and poly(xl) set interval between xm and xr else set + interval between xl and xr and repeat till root is located + within the specified limits */ + + if((psumr*psuml)<0.0){ + roots++; + + psumm=psuml; + for(k=0;k<=nb;k++){ + xm = (xl+xr)/2; /* bisect the interval */ + psumm=cheb_poly_eva(pt,xm,lpcrdr); + if(psumm*psuml>0.){ + psuml=psumm; + xl=xm; + } + else{ + psumr=psumm; + xr=xm; + } + } + + /* once zero is found, reset initial interval to xr */ + freq[j] = (xm); + xl = xm; + flag = 0; /* reset flag for next search */ + } + else{ + psuml=temp_psumr; + xl=temp_xr; + } + } + } + + /* convert from x domain to radians */ + + for(i=0; isq[i*DEC]*(0.5 - 0.5*cos(2*PI*i/(m/DEC-1))); } +#ifdef DUMP dump_dec(Fw); +#endif four1(&Fw[-1].imag,PE_FFT_SIZE,1); for(i=0; isq); dump_Fw(Fw); +#endif /* find global peak */ diff --git a/codec2/src/pack.c b/codec2/src/pack.c index 2cbff443..31551dfc 100644 --- a/codec2/src/pack.c +++ b/codec2/src/pack.c @@ -81,7 +81,8 @@ unpack( unsigned int fieldWidth/* Width of the field in BITS, not bytes. */ ) { - unsigned int field = 0; + unsigned int field = 0; + unsigned int t; do { unsigned int bI = *bitIndex; @@ -96,7 +97,7 @@ unpack( } while ( fieldWidth != 0 ); /* Convert from Gray code to binary. Works for maximum 8-bit fields. */ - unsigned int t = field ^ (field >> 8); + t = field ^ (field >> 8); t ^= (t >> 4); t ^= (t >> 2); t ^= (t >> 1); diff --git a/codec2/src/postfilter.c b/codec2/src/postfilter.c index 6dad76b1..cd6c28b0 100644 --- a/codec2/src/postfilter.c +++ b/codec2/src/postfilter.c @@ -126,6 +126,8 @@ void postfilter( uv++; } +#ifdef DUMP dump_bg(e, *bg_est, 100.0*uv/model->L); +#endif } diff --git a/codec2/src/quantise.c b/codec2/src/quantise.c index 90a25131..e386bf89 100644 --- a/codec2/src/quantise.c +++ b/codec2/src/quantise.c @@ -39,48 +39,6 @@ #include "four1.h" #define LSP_DELTA1 0.01 /* grid spacing for LSP root searches */ -#define MAX_CB 20 /* max number of codebooks */ - -/* describes each codebook */ - -typedef struct { - int k; /* dimension of vector */ - int log2m; /* number of bits in m */ - int m; /* elements in codebook */ - char *fn; /* file name of text file storing the VQ */ -} LSP_CB; - -/* lsp_q describes entire quantiser made up of several codebooks */ - -#ifdef OLDER -/* 10+10+6+6 = 32 bit LSP difference split VQ */ - -LSP_CB lsp_q[] = { - {3, 1024, "../unittest/lspd123.txt"}, - {3, 1024, "../unittest/lspd456.txt"}, - {2, 64, "../unittest/lspd78.txt"}, - {2, 64, "../unittest/lspd910.txt"}, - {0, 0, ""} -}; -#endif - -LSP_CB lsp_q[] = { - {1,4,16, "../unittest/lsp1.txt"}, - {1,4,16, "../unittest/lsp2.txt"}, - {1,4,16, "../unittest/lsp3.txt"}, - {1,4,16, "../unittest/lsp4.txt"}, - {1,4,16, "../unittest/lsp5.txt"}, - {1,4,16, "../unittest/lsp6.txt"}, - {1,4,16, "../unittest/lsp7.txt"}, - {1,3,8, "../unittest/lsp8.txt"}, - {1,3,8, "../unittest/lsp9.txt"}, - {1,2,4, "../unittest/lsp10.txt"}, - {0,0,0, ""} -}; - -/* ptr to each codebook */ - -static float *plsp_cb[MAX_CB]; /*---------------------------------------------------------------------------*\ @@ -98,9 +56,10 @@ float speech_to_uq_lsps(float lsp[], float ak[], float Sn[], float w[], \*---------------------------------------------------------------------------*/ int lsp_bits(int i) { - return lsp_q[i].log2m; + return lsp_cb[i].log2m; } +#if VECTOR_QUANTISATION /*---------------------------------------------------------------------------*\ quantise_uniform @@ -161,61 +120,7 @@ void lsp_quantise( for(i=1; i