[xiph-cvs] cvs commit: speex/libspeex cb_search.c filters.c filters.h lsp.c ltp.c nb_celp.c sb_celp.c stack_alloc.h
Jean-Marc Valin
jm at xiph.org
Sat Oct 26 12:16:16 PDT 2002
jm 02/10/26 15:16:16
Modified: libspeex cb_search.c filters.c filters.h lsp.c ltp.c
nb_celp.c sb_celp.c stack_alloc.h
Log:
Stack allocation cleanup...
Revision Changes Path
1.76 +15 -19 speex/libspeex/cb_search.c
Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -r1.75 -r1.76
--- cb_search.c 25 Oct 2002 04:11:15 -0000 1.75
+++ cb_search.c 26 Oct 2002 19:16:16 -0000 1.76
@@ -98,15 +98,14 @@
shape_cb_size = 1<<params->shape_bits;
shape_cb = params->shape_cb;
have_sign = params->have_sign;
- resp = PUSH(stack, shape_cb_size*subvect_size);
- t = PUSH(stack, nsf);
- e = PUSH(stack, nsf);
- r2 = PUSH(stack, nsf);
- E = PUSH(stack, shape_cb_size);
- /*FIXME: This breaks if sizeof(int) != sizeof(float) */
- ind = (int*)PUSH(stack, nb_subvect);
+ resp = PUSH(stack, shape_cb_size*subvect_size, float);
+ t = PUSH(stack, nsf, float);
+ e = PUSH(stack, nsf, float);
+ r2 = PUSH(stack, nsf, float);
+ E = PUSH(stack, shape_cb_size, float);
+ ind = PUSH(stack, nb_subvect, int);
- tmp = PUSH(stack, 2*N*nsf);
+ tmp = PUSH(stack, 2*N*nsf, float);
for (i=0;i<N;i++)
{
ot[i]=tmp;
@@ -115,14 +114,12 @@
tmp += nsf;
}
- /*FIXME: This breaks if sizeof(int) != sizeof(float) */
- best_index = (int*)PUSH(stack, N);
- best_dist = PUSH(stack, N);
- ndist = PUSH(stack, N);
- odist = PUSH(stack, N);
+ best_index = PUSH(stack, N, int);
+ best_dist = PUSH(stack, N, float);
+ ndist = PUSH(stack, N, float);
+ odist = PUSH(stack, N, float);
- /*FIXME: This breaks if sizeof(int) != sizeof(float) */
- itmp = (int*)PUSH(stack, 2*N*nb_subvect);
+ itmp = PUSH(stack, 2*N*nb_subvect, int);
for (i=0;i<N;i++)
{
nind[i]=itmp;
@@ -343,9 +340,8 @@
shape_cb = params->shape_cb;
have_sign = params->have_sign;
- /*FIXME: This breaks if sizeof(int) != sizeof(float) */
- ind = (int*)PUSH(stack, nb_subvect);
- signs = (int*)PUSH(stack, nb_subvect);
+ ind = PUSH(stack, nb_subvect, int);
+ signs = PUSH(stack, nb_subvect, int);
/* Decode codewords and gains */
for (i=0;i<nb_subvect;i++)
@@ -383,7 +379,7 @@
)
{
int i;
- float *tmp=PUSH(stack, nsf);
+ float *tmp=PUSH(stack, nsf, float);
residue_percep_zero(target, ak, awk1, awk2, tmp, nsf, p, stack);
for (i=0;i<nsf;i++)
<p><p>1.28 +4 -3 speex/libspeex/filters.c
Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- filters.c 26 Oct 2002 04:37:15 -0000 1.27
+++ filters.c 26 Oct 2002 19:16:16 -0000 1.28
@@ -110,7 +110,7 @@
void syn_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, float *stack)
{
int i;
- float *mem = PUSH(stack,ord);
+ float *mem = PUSH(stack,ord, float);
for (i=0;i<ord;i++)
mem[i]=0;
filter_mem2(xx, awk1, ak, y, N, ord, mem);
@@ -122,7 +122,7 @@
void residue_percep_zero(float *xx, float *ak, float *awk1, float *awk2, float *y, int N, int ord, float *stack)
{
int i;
- float *mem = PUSH(stack,ord);
+ float *mem = PUSH(stack,ord, float);
for (i=0;i<ord;i++)
mem[i]=0;
filter_mem2(xx, ak, awk1, y, N, ord, mem);
@@ -172,7 +172,8 @@
N and M are multiples of 4 */
{
int i, j;
- float xx[N+M-1];
+ /*FIXME: Make that dynamic*/
+ float xx[384];
for (i = 0; i < N/2; i++)
xx[2*i] = x[N/2-1-i];
<p><p>1.19 +1 -0 speex/libspeex/filters.h
Index: filters.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- filters.h 23 Oct 2002 06:24:57 -0000 1.18
+++ filters.h 26 Oct 2002 19:16:16 -0000 1.19
@@ -34,6 +34,7 @@
#define FILTERS_H
void qmf_decomp(float *xx, float *aa, float *y1, float *y2, int N, int M, float *mem);
+void fir_mem_up(float *x, float *a, float *y, int N, int M, float *mem);
void print_vec(float *vec, int len, char *name);
<p><p>1.16 +4 -4 speex/libspeex/lsp.c
Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- lsp.c 24 Oct 2002 06:29:13 -0000 1.15
+++ lsp.c 26 Oct 2002 19:16:16 -0000 1.16
@@ -78,7 +78,7 @@
int m2=m>>1;
/* Allocate memory for chebyshev series formulation */
- T=PUSH(stack, m2+1);
+ T=PUSH(stack, m2+1, float);
/* Initialise values */
T[0]=1;
@@ -139,8 +139,8 @@
/* Allocate memory space for polynomials */
- Q = PUSH(stack, (m+1));
- P = PUSH(stack, (m+1));
+ Q = PUSH(stack, (m+1), float);
+ P = PUSH(stack, (m+1), float);
/* 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)) */
@@ -260,7 +260,7 @@
float *pw,*n1,*n2,*n3,*n4=NULL;
int m = lpcrdr/2;
- Wp = PUSH(stack, 4*m+2);
+ Wp = PUSH(stack, 4*m+2, float);
pw = Wp;
/* initialise contents of array */
<p><p>1.62 +10 -10 speex/libspeex/ltp.c
Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -u -r1.61 -r1.62
--- ltp.c 26 Oct 2002 04:37:15 -0000 1.61
+++ ltp.c 26 Oct 2002 19:16:16 -0000 1.62
@@ -77,10 +77,10 @@
float e0;
float *corr, *energy, *score;
- best_score = PUSH(stack,N);
- corr = PUSH(stack,end-start+1);
- energy = PUSH(stack,end-start+2);
- score = PUSH(stack,end-start+1);
+ best_score = PUSH(stack,N, float);
+ corr = PUSH(stack,end-start+1, float);
+ energy = PUSH(stack,end-start+2, float);
+ score = PUSH(stack,end-start+1, float);
for (i=0;i<N;i++)
{
best_score[i]=-1;
@@ -173,8 +173,8 @@
params = (ltp_params*) par;
gain_cdbk=params->gain_cdbk;
gain_cdbk_size=1<<params->gain_bits;
- tmp = PUSH(stack, 3*nsf);
- tmp2 = PUSH(stack, 3*nsf);
+ tmp = PUSH(stack, 3*nsf, float);
+ tmp2 = PUSH(stack, 3*nsf, float);
x[0]=tmp;
x[1]=tmp+nsf;
@@ -358,8 +358,8 @@
if (N>10)
N=10;
/*FIXME: This breaks if sizeof(int) != sizeof(float) */
- nbest=(int*)PUSH(stack, N);
- gains = PUSH(stack, N);
+ nbest=(int*)PUSH(stack, N, float);
+ gains = PUSH(stack, N, float);
params = (ltp_params*) par;
if (N==0 || end<start)
@@ -371,7 +371,7 @@
return start;
}
- best_exc=PUSH(stack,nsf);
+ best_exc=PUSH(stack,nsf, float);
if (N>end-start+1)
N=end-start+1;
@@ -460,7 +460,7 @@
{
float *e[3];
float *tmp2;
- tmp2=PUSH(stack, 3*nsf);
+ tmp2=PUSH(stack, 3*nsf, float);
e[0]=tmp2;
e[1]=tmp2+nsf;
e[2]=tmp2+2*nsf;
<p><p>1.71 +12 -12 speex/libspeex/nb_celp.c
Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- nb_celp.c 25 Oct 2002 04:11:15 -0000 1.70
+++ nb_celp.c 26 Oct 2002 19:16:16 -0000 1.71
@@ -451,11 +451,11 @@
}
/* Filter response */
- res = PUSH(stack, st->subframeSize);
+ res = PUSH(stack, st->subframeSize, float);
/* Target signal */
- target = PUSH(stack, st->subframeSize);
- syn_resp = PUSH(stack, st->subframeSize);
- mem = PUSH(stack, st->lpcSize);
+ target = PUSH(stack, st->subframeSize, float);
+ syn_resp = PUSH(stack, st->subframeSize, float);
+ mem = PUSH(stack, st->lpcSize, float);
/* Loop on sub-frames */
for (sub=0;sub<st->nbSubframes;sub++)
@@ -672,7 +672,7 @@
/* In some (rare) modes, we do a second search (more bits) to reduce noise even more */
if (SUBMODE(double_codebook)) {
float *tmp_stack=stack;
- float *innov2 = PUSH(tmp_stack, st->subframeSize);
+ float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
for (i=0;i<st->subframeSize;i++)
@@ -813,9 +813,9 @@
speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
speex_move(st->excBuf, st->excBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(float));
- awk1=PUSH(stack, (st->lpcSize+1));
- awk2=PUSH(stack, (st->lpcSize+1));
- awk3=PUSH(stack, (st->lpcSize+1));
+ awk1=PUSH(stack, (st->lpcSize+1), float);
+ awk2=PUSH(stack, (st->lpcSize+1), float);
+ awk3=PUSH(stack, (st->lpcSize+1), float);
for (sub=0;sub<st->nbSubframes;sub++)
{
@@ -1008,9 +1008,9 @@
/*printf ("decode_ol_gain: %f\n", ol_gain);*/
}
- awk1=PUSH(stack, st->lpcSize+1);
- awk2=PUSH(stack, st->lpcSize+1);
- awk3=PUSH(stack, st->lpcSize+1);
+ awk1=PUSH(stack, st->lpcSize+1, float);
+ awk2=PUSH(stack, st->lpcSize+1, float);
+ awk3=PUSH(stack, st->lpcSize+1, float);
/*Loop on subframes */
for (sub=0;sub<st->nbSubframes;sub++)
@@ -1157,7 +1157,7 @@
if (SUBMODE(double_codebook))
{
float *tmp_stack=stack;
- float *innov2 = PUSH(tmp_stack, st->subframeSize);
+ float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, tmp_stack);
<p><p>1.81 +6 -28 speex/libspeex/sb_celp.c
Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- sb_celp.c 26 Oct 2002 02:58:36 -0000 1.80
+++ sb_celp.c 26 Oct 2002 19:16:16 -0000 1.81
@@ -373,9 +373,9 @@
st->old_qlsp[i] = st->qlsp[i];
}
- mem=PUSH(stack, st->lpcSize);
- syn_resp=PUSH(stack, st->subframeSize);
- innov = PUSH(stack, st->subframeSize);
+ mem=PUSH(stack, st->lpcSize, float);
+ syn_resp=PUSH(stack, st->subframeSize, float);
+ innov = PUSH(stack, st->subframeSize, float);
for (sub=0;sub<st->nbSubframes;sub++)
{
@@ -519,23 +519,6 @@
mem[i]=st->mem_sw[i];
filter_mem2(sp, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, mem);
-#if 0
- /*for (i=0;i<st->lpcSize;i++)
- 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++)
- mem[i]=st->mem_sw[i];
- syn_filt_mem(res, st->bw_lpc2, res, st->subframeSize, st->lpcSize, mem);*/
-
- /* Compute weighted signal */
- for (i=0;i<st->lpcSize;i++)
- 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);
-#endif
-
/* Compute target signal */
for (i=0;i<st->subframeSize;i++)
target[i]=sw[i]-res[i];
@@ -562,7 +545,7 @@
if (SUBMODE(double_codebook)) {
float *tmp_stack=stack;
- float *innov2 = PUSH(tmp_stack, st->subframeSize);
+ float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
for (i=0;i<st->subframeSize;i++)
@@ -588,7 +571,7 @@
}
}
-#if 1
+
/*Keep the previous memory*/
for (i=0;i<st->lpcSize;i++)
mem[i]=st->mem_sp[i];
@@ -596,12 +579,7 @@
iir_mem2(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, mem);
- syn_filt_mem(sw, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
- */
filter_mem2(sp, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
-#endif
-
}
@@ -866,7 +844,7 @@
if (SUBMODE(double_codebook)) {
float *tmp_stack=stack;
- float *innov2 = PUSH(tmp_stack, st->subframeSize);
+ float *innov2 = PUSH(tmp_stack, st->subframeSize, float);
for (i=0;i<st->subframeSize;i++)
innov2[i]=0;
SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize,
<p><p>1.7 +2 -8 speex/libspeex/stack_alloc.h
Index: stack_alloc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/stack_alloc.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- stack_alloc.h 22 Oct 2002 03:22:54 -0000 1.6
+++ stack_alloc.h 26 Oct 2002 19:16:16 -0000 1.7
@@ -34,15 +34,9 @@
#ifndef STACK_ALLOC_H
#define STACK_ALLOC_H
+#define ALIGN(stack, size) (stack=(float*)((((int)stack)+((size)-1)) & (-(size))))
-/*#define PUSH(stack, size) (((int*)stack)[size]=(size),stack+=(size)+1,stack-(size)-1)
-#define POP(stack) (stack-=((int*)stack)[-1]+1)
-*/
-
-/*#define PUSH(stack, size) (stack+=(size),stack-(size))
- */
-
-#define PUSH(stack, size) (stack=(float*)(((int)stack)+((size)*sizeof(float))),(float*)(((int)stack)-((size)*sizeof(float))))
+#define PUSH(stack, size, type) (ALIGN(stack,sizeof(type)),stack=(float*)(((int)stack)+((size)*sizeof(type))),(type*)(((int)stack)-((size)*sizeof(type))))
#endif
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list