Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/speexdsp.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libspeex/cb_search.c18
-rw-r--r--libspeex/lsp.c42
-rw-r--r--libspeex/lsp.h4
-rw-r--r--libspeex/modes.c2
-rw-r--r--libspeex/quant_lsp.c6
-rw-r--r--libspeex/quant_lsp.h4
-rw-r--r--libspeex/speex.c120
-rw-r--r--libspeex/speex.h13
-rw-r--r--libspeex/stack_alloc.h28
-rw-r--r--libspeex/stoc.c15
10 files changed, 134 insertions, 118 deletions
diff --git a/libspeex/cb_search.c b/libspeex/cb_search.c
index 8ffc64d..b213a83 100644
--- a/libspeex/cb_search.c
+++ b/libspeex/cb_search.c
@@ -10,7 +10,23 @@
\*-----------------------------------------------------------------------*/
-/* Modified by Jean-Marc Valin 2002 */
+/* Modified by Jean-Marc Valin 2002
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
#include <stdlib.h>
diff --git a/libspeex/lsp.c b/libspeex/lsp.c
index a112483..7376cb1 100644
--- a/libspeex/lsp.c
+++ b/libspeex/lsp.c
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "lsp.h"
+#include "stack_alloc.h"
/*---------------------------------------------------------------------------*\
@@ -31,7 +32,7 @@
-float cheb_poly_eva(float *coef,float x,int m)
+float cheb_poly_eva(float *coef,float x,int m,float *stack)
/* 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 */
@@ -43,10 +44,11 @@ float cheb_poly_eva(float *coef,float x,int m)
/* Allocate memory for chebyshev series formulation */
- if((T = (float *)malloc((m/2+1)*sizeof(float))) == NULL){
+ /*if((T = (float *)malloc((m/2+1)*sizeof(float))) == NULL){
printf("not enough memory to allocate buffer\n");
exit(1);
- }
+ }*/
+ T=PUSH(stack, m/2+1);
/* Initialise pointers */
@@ -69,7 +71,8 @@ float cheb_poly_eva(float *coef,float x,int m)
for(i=0;i<=m/2;i++)
sum+=coef[(m/2)-i]**t++;
- free(T);
+ /*free(T);*/
+ POP(stack);
return sum;
}
@@ -87,7 +90,7 @@ float cheb_poly_eva(float *coef,float x,int m)
\*---------------------------------------------------------------------------*/
-int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta)
+int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta, float *stack)
/* float *a lpc coefficients */
/* int lpcrdr order of LPC coefficients (10) */
/* float *freq LSP frequencies in the x domain */
@@ -116,7 +119,7 @@ int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta)
/* Allocate memory space for polynomials */
- if((Q = (float *) malloc((m+1)*sizeof(float))) == NULL){
+ /*if((Q = (float *) malloc((m+1)*sizeof(float))) == NULL){
printf("not enough memory to allocate buffer\n");
exit(1);
}
@@ -124,7 +127,9 @@ int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta)
if((P = (float *) malloc((m+1)*sizeof(float))) == NULL){
printf("not enough memory to allocate buffer\n");
exit(1);
- }
+ }*/
+ Q = PUSH(stack, (m+1));
+ P = PUSH(stack, (m+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)) */
@@ -163,11 +168,11 @@ int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta)
else
pt = px;
- psuml = cheb_poly_eva(pt,xl,lpcrdr); /* evals poly. at xl */
+ psuml = cheb_poly_eva(pt,xl,lpcrdr,stack); /* evals poly. at xl */
flag = 1;
while(flag && (xr >= -1.0)){
xr = xl - delta ; /* interval spacing */
- psumr = cheb_poly_eva(pt,xr,lpcrdr);/* poly(xl-delta_x) */
+ psumr = cheb_poly_eva(pt,xr,lpcrdr,stack);/* poly(xl-delta_x) */
temp_psumr = psumr;
temp_xr = xr;
@@ -186,7 +191,7 @@ int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta)
psumm=psuml;
for(k=0;k<=nb;k++){
xm = (xl+xr)/2; /* bisect the interval */
- psumm=cheb_poly_eva(pt,xm,lpcrdr);
+ psumm=cheb_poly_eva(pt,xm,lpcrdr,stack);
if(psumm*psuml>0.){
psuml=psumm;
xl=xm;
@@ -208,9 +213,10 @@ int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta)
}
}
}
- free(P); /* free memory space */
- free(Q);
-
+ /*free(P);*/ /* free memory space */
+ /*free(Q);*/
+ POP(stack);
+ POP(stack);
return(roots);
}
@@ -228,7 +234,7 @@ int lpc_to_lsp (float *a,int lpcrdr,float *freq,int nb,float delta)
\*---------------------------------------------------------------------------*/
-void lsp_to_lpc(float *freq,float *ak,int lpcrdr)
+void lsp_to_lpc(float *freq,float *ak,int lpcrdr, float *stack)
/* float *freq array of LSP frequencies in the x domain */
/* float *ak array of LPC coefficients */
/* int lpcrdr order of LPC coefficients */
@@ -241,10 +247,11 @@ void lsp_to_lpc(float *freq,float *ak,int lpcrdr)
float *pw,*n1,*n2,*n3,*n4=NULL;
int m = lpcrdr/2;
- if((Wp = (float *) malloc((4*m+2)*sizeof(float))) == NULL){
+ /*if((Wp = (float *) malloc((4*m+2)*sizeof(float))) == NULL){
printf("not enough memory to allocate buffer\n");
exit(1);
- }
+ }*/
+ Wp = PUSH(stack, 4*m+2);
pw = Wp;
/* initialise contents of array */
@@ -287,5 +294,6 @@ void lsp_to_lpc(float *freq,float *ak,int lpcrdr)
xin1 = 0.0;
xin2 = 0.0;
}
- free(Wp);
+ /*free(Wp);*/
+ POP(stack);
}
diff --git a/libspeex/lsp.h b/libspeex/lsp.h
index a800446..b0e6993 100644
--- a/libspeex/lsp.h
+++ b/libspeex/lsp.h
@@ -11,7 +11,7 @@
#ifndef __AK2LSPD__
#define __AK2LSPD__
-int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta);
-void lsp_to_lpc(float *freq, float *ak, int lpcrdr);
+int lpc_to_lsp (float *a, int lpcrdr, float *freq, int nb, float delta, float *stack);
+void lsp_to_lpc(float *freq, float *ak, int lpcrdr, float *stack);
#endif /* __AK2LSPD__ */
diff --git a/libspeex/modes.c b/libspeex/modes.c
index e8e5f46..73c4dcf 100644
--- a/libspeex/modes.c
+++ b/libspeex/modes.c
@@ -30,5 +30,5 @@ SpeexMode nb_mode = {
20, /*pitchStart*/
140, /*pitchEnd*/
0.9, /*gamma1*/
- 0.5 /*gamma2*/
+ 0.6 /*gamma2*/
};
diff --git a/libspeex/quant_lsp.c b/libspeex/quant_lsp.c
index 4550a20..6eb1ebd 100644
--- a/libspeex/quant_lsp.c
+++ b/libspeex/quant_lsp.c
@@ -79,11 +79,11 @@ int lsp_weight_quant(float *x, float *weight, float *cdbk, int nbVec, int nbDim)
}
-unsigned int lsp_quant_nb(float *lsp, int order)
+unsigned long long lsp_quant_nb(float *lsp, int order)
{
int i;
float tmp1, tmp2;
- unsigned int id;
+ unsigned long long id;
quant_weight[0] = 1/(lsp[1]-lsp[0]);
quant_weight[order-1] = 1/(lsp[order-1]-lsp[order-2]);
for (i=1;i<order-1;i++)
@@ -109,7 +109,7 @@ unsigned int lsp_quant_nb(float *lsp, int order)
return id;
}
-void lsp_unquant_nb(float *lsp, int order, unsigned int id)
+void lsp_unquant_nb(float *lsp, int order, unsigned long long id)
{
int i, tmp;
for (i=0;i<order;i++)
diff --git a/libspeex/quant_lsp.h b/libspeex/quant_lsp.h
index 441ad78..9699e21 100644
--- a/libspeex/quant_lsp.h
+++ b/libspeex/quant_lsp.h
@@ -36,9 +36,9 @@ extern float cdbk_nb_high1[];
extern float cdbk_nb_high2[];
/* Quantizes narrowband LSPs with 30 bits */
-unsigned int lsp_quant_nb(float *lsp, int order);
+unsigned long long lsp_quant_nb(float *lsp, int order);
/* Decodes quantized narrowband LSPs */
-void lsp_unquant_nb(float *lsp, int order, unsigned int id);
+void lsp_unquant_nb(float *lsp, int order, unsigned long long id);
#endif
diff --git a/libspeex/speex.c b/libspeex/speex.c
index 34da341..80dc369 100644
--- a/libspeex/speex.c
+++ b/libspeex/speex.c
@@ -27,6 +27,7 @@
#include "quant_lsp.h"
#include "cb_search.h"
#include "filters.h"
+#include "stack_alloc.h"
extern float stoc[];
@@ -53,24 +54,12 @@ void encoder_init(EncState *st, SpeexMode *mode)
st->inBuf = malloc(st->bufSize*sizeof(float));
st->frame = st->inBuf + st->bufSize - st->windowSize;
- st->wBuf = malloc(st->bufSize*sizeof(float));
- st->wframe = st->wBuf + st->bufSize - st->windowSize;
st->excBuf = malloc(st->bufSize*sizeof(float));
st->exc = st->excBuf + st->bufSize - st->windowSize;
- st->resBuf = malloc(st->bufSize*sizeof(float));
- st->res = st->resBuf + st->bufSize - st->windowSize;
- st->tBuf = malloc(st->bufSize*sizeof(float));
- st->tframe = st->tBuf + st->bufSize - st->windowSize;
for (i=0;i<st->bufSize;i++)
st->inBuf[i]=0;
for (i=0;i<st->bufSize;i++)
- st->wBuf[i]=0;
- for (i=0;i<st->bufSize;i++)
- st->resBuf[i]=0;
- for (i=0;i<st->bufSize;i++)
st->excBuf[i]=0;
- for (i=0;i<st->bufSize;i++)
- st->tBuf[i]=0;
/* Hanning window */
st->window = malloc(st->windowSize*sizeof(float));
@@ -84,6 +73,8 @@ void encoder_init(EncState *st, SpeexMode *mode)
st->autocorr = malloc((st->lpcSize+1)*sizeof(float));
+ st->stack = calloc(2000, sizeof(float));
+
st->buf2 = malloc(st->windowSize*sizeof(float));
st->lpc = malloc((st->lpcSize+1)*sizeof(float));
@@ -102,23 +93,17 @@ void encoder_init(EncState *st, SpeexMode *mode)
st->rc = malloc(st->lpcSize*sizeof(float));
st->first = 1;
- st->mem1 = calloc(st->lpcSize, sizeof(float));
- st->mem2 = calloc(st->lpcSize, sizeof(float));
- st->mem3 = calloc(st->lpcSize, sizeof(float));
- st->mem4 = calloc(st->lpcSize, sizeof(float));
- st->mem5 = calloc(st->lpcSize, sizeof(float));
- st->mem6 = calloc(st->lpcSize, sizeof(float));
- st->mem7 = calloc(st->lpcSize, sizeof(float));
+ st->mem_sp = calloc(st->lpcSize, sizeof(float));
+ st->mem_sw = calloc(st->lpcSize, sizeof(float));
}
void encoder_destroy(EncState *st)
{
/* Free all allocated memory */
free(st->inBuf);
- free(st->wBuf);
- free(st->resBuf);
free(st->excBuf);
- free(st->tBuf);
+
+ free(st->stack);
free(st->window);
free(st->buf2);
@@ -139,13 +124,8 @@ void encoder_destroy(EncState *st)
free(st->interp_qlsp);
free(st->rc);
- free(st->mem1);
- free(st->mem2);
- free(st->mem3);
- free(st->mem4);
- free(st->mem5);
- free(st->mem6);
- free(st->mem7);
+ free(st->mem_sp);
+ free(st->mem_sw);
}
void encode(EncState *st, float *in, FrameBits *bits)
@@ -157,10 +137,7 @@ void encode(EncState *st, float *in, FrameBits *bits)
memmove(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
for (i=0;i<st->frameSize;i++)
st->inBuf[st->bufSize-st->frameSize+i] = in[i];
- memmove(st->wBuf, st->wBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
- memmove(st->resBuf, st->resBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
memmove(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
- memmove(st->tBuf, st->tBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
/* Window for analysis */
for (i=0;i<st->windowSize;i++)
@@ -180,7 +157,7 @@ void encode(EncState *st, float *in, FrameBits *bits)
st->lpc[0]=1;
/* LPC to LSPs (x-domain) transform */
- roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 6, 0.02);
+ roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 6, 0.02, st->stack);
if (roots!=st->lpcSize)
{
fprintf (stderr, "roots!=st->lpcSize\n");
@@ -195,8 +172,8 @@ void encode(EncState *st, float *in, FrameBits *bits)
{
unsigned int id;
for (i=0;i<st->lpcSize;i++)
- st->buf2[i]=st->lsp[i];
- id=lsp_quant_nb(st->buf2,10 );
+ st->qlsp[i]=st->lsp[i];
+ id=lsp_quant_nb(st->qlsp,10 );
lsp_unquant_nb(st->qlsp,10,id);
}
@@ -206,15 +183,19 @@ void encode(EncState *st, float *in, FrameBits *bits)
float tmp, tmp1,tmp2,gain[3];
float esig=0, enoise=0, snr;
int pitch, offset, pitch_gain_index;
- float *sp, *sw, *res, *exc, *target;
+ float *sp, *sw, *res, *exc, *target, *mem;
/* Offset relative to start of frame */
offset = st->subframeSize*sub;
sp=st->frame+offset;
- sw=st->wframe+offset;
- res=st->res+offset;
exc=st->exc+offset;
- target=st->tframe+offset;
+ /* Weighted signal */
+ sw = PUSH(st->stack, st->subframeSize);
+ /* Filter response */
+ res = PUSH(st->stack, st->subframeSize);
+ /* Target signal */
+ target = PUSH(st->stack, st->subframeSize);
+ mem = PUSH(st->stack, st->lpcSize);
/* LSP interpolation (quantized and unquantized) */
tmp = (.5 + sub)/st->nbSubframes;
@@ -226,11 +207,11 @@ void encode(EncState *st, float *in, FrameBits *bits)
/* Compute interpolated LPCs (quantized and unquantized) */
for (i=0;i<st->lpcSize;i++)
st->interp_lsp[i] = cos(st->interp_lsp[i]);
- lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize);
+ lsp_to_lpc(st->interp_lsp, st->interp_lpc, st->lpcSize,st->stack);
for (i=0;i<st->lpcSize;i++)
st->interp_qlsp[i] = cos(st->interp_qlsp[i]);
- lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize);
+ lsp_to_lpc(st->interp_qlsp, st->interp_qlpc, st->lpcSize, st->stack);
/* Compute bandwidth-expanded (unquantized) LPCs for perceptual weighting */
tmp=1;
@@ -252,20 +233,22 @@ void encode(EncState *st, float *in, FrameBits *bits)
/* Compute zero response of A(z/g1) / ( A(z/g2) * Aq(z) ) */
for (i=0;i<st->lpcSize;i++)
- st->mem4[i]=st->mem5[i];
- syn_filt_mem(exc, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, st->mem4);
+ mem[i]=st->mem_sp[i];
+ syn_filt_mem(exc, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, mem);
for (i=0;i<st->lpcSize;i++)
- st->mem4[i]=st->mem5[i];
- residue_mem(exc, st->bw_lpc1, res, st->subframeSize, st->lpcSize, st->mem4);
+ mem[i]=st->mem_sp[i];
+ residue_mem(exc, st->bw_lpc1, res, st->subframeSize, st->lpcSize, mem);
for (i=0;i<st->lpcSize;i++)
- st->mem4[i]=st->mem2[i];
- syn_filt_mem(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize, st->mem4);
+ mem[i]=st->mem_sw[i];
+ syn_filt_mem(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize, mem);
/* Compute weighted signal */
- residue(sp, st->bw_lpc1, sw, st->subframeSize, st->lpcSize);
for (i=0;i<st->lpcSize;i++)
- st->mem4[i]=st->mem2[i];
- syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem4);
+ mem[i]=st->mem_sp[i];
+ residue_mem(sp, st->bw_lpc1, sw, st->subframeSize, st->lpcSize, mem);
+ for (i=0;i<st->lpcSize;i++)
+ mem[i]=st->mem_sw[i];
+ syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, mem);
for (i=0;i<st->subframeSize;i++)
esig+=sw[i]*sw[i];
@@ -292,23 +275,33 @@ void encode(EncState *st, float *in, FrameBits *bits)
syn_filt_zero(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize);
for (i=0;i<st->subframeSize;i++)
target[i]-=res[i];
-
+ {
+ /*float stoc2[1080];*/
+ float *stoc2 = PUSH(st->stack,1080);
+ for (i=0;i<1080;i++)
+ {
+ stoc2[i]=stoc[i];
+ if (i-(pitch-1)>=0)
+ stoc2[i] += .8*stoc[i-(pitch-1)];
+ }
+ POP(st->stack);
/* Perform stochastic codebook search */
overlap_cb_search(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
- stoc, 1024, &gain[0], &pitch, st->lpcSize,
+ stoc2, 1024, &gain[0], &pitch, st->lpcSize,
st->subframeSize);
- printf ("gain = %f, index = %d\n",gain[0], pitch);
+ printf ("gain = %f index = %d energy = %f\n",gain[0], pitch, esig);
for (i=0;i<st->subframeSize;i++)
- exc[i]+=gain[0]*stoc[i+pitch];
+ exc[i]+=gain[0]*stoc2[i+pitch];
/* Update target for adaptive codebook contribution (Useless for now)*/
- residue_zero(stoc+pitch, st->bw_lpc1, res, st->subframeSize, st->lpcSize);
+ residue_zero(stoc2+pitch, st->bw_lpc1, res, st->subframeSize, st->lpcSize);
syn_filt_zero(res, st->interp_qlpc, res, st->subframeSize, st->lpcSize);
syn_filt_zero(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize);
for (i=0;i<st->subframeSize;i++)
target[i]-=gain[0]*res[i];
+ }
-
+ /* Compute weighted noise energy, SNR */
for (i=0;i<st->subframeSize;i++)
enoise += target[i]*target[i];
snr = 10*log10((esig+1)/(enoise+1));
@@ -319,6 +312,7 @@ void encode(EncState *st, float *in, FrameBits *bits)
#if 0 /* Code to calculate the exact excitation after pitch prediction */
for (i=0;i<st->subframeSize;i++)
st->buf2[i]=target[i];
+
pitch_search_3tap(target, st->interp_qlpc, st->bw_lpc1, st->bw_lpc2,
exc, 20, 147, &gain[0], &pitch, &pitch_gain_index, st->lpcSize,
st->subframeSize);
@@ -332,6 +326,7 @@ void encode(EncState *st, float *in, FrameBits *bits)
syn_filt_zero(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize);
for (i=0;i<st->subframeSize;i++)
target[i]-=res[i];
+
syn_filt_zero(target, st->bw_lpc1, res, st->subframeSize, st->lpcSize);
residue_zero(res, st->interp_qlpc, exc, st->subframeSize, st->lpcSize);
residue_zero(exc, st->bw_lpc2, exc, st->subframeSize, st->lpcSize);
@@ -349,13 +344,20 @@ void encode(EncState *st, float *in, FrameBits *bits)
residue_zero(exc, st->bw_lpc2, exc, st->subframeSize, st->lpcSize);
#endif
+ /*Keep the previous memory*/
+ for (i=0;i<st->lpcSize;i++)
+ mem[i]=st->mem_sp[i];
/* Final signal synthesis from excitation */
- syn_filt_mem(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem5);
+ syn_filt_mem(exc, st->interp_qlpc, sp, st->subframeSize, st->lpcSize, st->mem_sp);
/* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
- residue_mem(sp, st->bw_lpc1, sw, st->subframeSize, st->lpcSize, st->mem1);
- syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem2);
+ residue_mem(sp, st->bw_lpc1, sw, st->subframeSize, st->lpcSize, mem);
+ syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
+ POP(st->stack);
+ POP(st->stack);
+ POP(st->stack);
+ POP(st->stack);
}
/* Store the LSPs for interpolation in the next frame */
diff --git a/libspeex/speex.h b/libspeex/speex.h
index a77daf5..053f433 100644
--- a/libspeex/speex.h
+++ b/libspeex/speex.h
@@ -34,16 +34,15 @@ typedef struct EncState {
int bufSize; /* Buffer size */
float gamma1; /* Perceptual filter: A(z/gamma1) */
float gamma2; /* Perceptual filter: A(z/gamma2) */
+ float *stack; /* Pseudo-stack allocation */
+ int os_fact; /* Over-sampling factor for fractional pitch */
+ int os_filt_ord; /* Over-sampling filter size for fractional pitch */
+ float *os_exc; /* Over-sampled excitation for fractional pitch */
+ float *os_filt; /* Over-sampling filter for fractional pitch */
float *inBuf; /* Input buffer (original signal) */
float *frame; /* Start of original frame */
- float *wBuf; /* "Weighted" buffer */
- float *wframe; /* Start of "weighted" frame */
float *excBuf; /* Excitation buffer */
float *exc; /* Start of excitation frame */
- float *resBuf; /* Excitation buffer */
- float *res; /* Start of excitation frame */
- float *tBuf; /* "weighted target" buffer */
- float *tframe; /* Start of "weighted target" frame */
float *window; /* Temporary (Hanning) window */
float *buf2; /* 2nd temporary buffer */
float *autocorr; /* auto-correlation */
@@ -61,7 +60,7 @@ typedef struct EncState {
float *bw_lpc2; /* LPCs after bandwidth expansion by gamma2 for perceptual weighting*/
float *bw_az; /* Convolution of bw_lpc2 and interp_qlpc */
float *rc; /* Reflection coefficients */
- float *mem1, *mem2, *mem3, *mem4, *mem5, *mem6, *mem7;
+ float *mem_sp, *mem_sw;
float *dmem1, *dmem2;
} EncState;
diff --git a/libspeex/stack_alloc.h b/libspeex/stack_alloc.h
index d58015c..a4a82e3 100644
--- a/libspeex/stack_alloc.h
+++ b/libspeex/stack_alloc.h
@@ -22,32 +22,8 @@
#define STACK_ALLOC_H
-#ifdef __GNUC__
-#define VAR_ARRAY
-#endif
-
-
-#if defined (VAR_ARRAY) /* Prefered method is variable-size arrays is supported */
-
-#define DYN_VEC(type, num, var) type var[num];
-
-#elif defined (HAVE_ALLOCA_H) /* Second best: alloca */
-
-#include <alloca.h>
-
-#define DYN_VEC(type, num, var) type *var=(type*)alloca((num)*sizeof(type));
-
-#elif defined WIN32 /* On Win32, it's _alloca */
-
-#include <malloc.h>
-#define DYN_VEC(type, num, var) type *var=(type*)_alloca((num)*sizeof(type));
-
-#else /* When all else fails, allocate on the heap (but it's going to be slow) */
-
-#error Cannot allocate memory on stack
-
-#endif
-
+#define PUSH(stack, size) (((int*)stack)[size]=(size),stack+=(size)+1,stack-(size)-1)
+#define POP(stack) (stack-=((int*)stack)[-1]+1)
#endif
diff --git a/libspeex/stoc.c b/libspeex/stoc.c
index 37de1a2..49434d9 100644
--- a/libspeex/stoc.c
+++ b/libspeex/stoc.c
@@ -9,6 +9,21 @@
| DoD CELP 3.2 stochastic codebook. |
| |
\*---------------------------------------------------------------------------*/
+/*
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
float stoc[] = {