[xiph-commits] r9030 - trunk/speex/libspeex

jm at motherfish-iii.xiph.org jm at motherfish-iii.xiph.org
Thu Mar 3 10:30:55 PST 2005


Author: jm
Date: 2005-03-03 10:30:50 -0800 (Thu, 03 Mar 2005)
New Revision: 9030

Modified:
   trunk/speex/libspeex/cb_search.c
   trunk/speex/libspeex/cb_search_sse.h
   trunk/speex/libspeex/filters.c
   trunk/speex/libspeex/lsp.c
   trunk/speex/libspeex/ltp.c
   trunk/speex/libspeex/ltp_sse.h
   trunk/speex/libspeex/nb_celp.c
   trunk/speex/libspeex/sb_celp.c
   trunk/speex/libspeex/stack_alloc.h
   trunk/speex/libspeex/vq.c
Log:
Now possible to put temporary arrays directly on the (real) stack


Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/cb_search.c	2005-03-03 18:30:50 UTC (rev 9030)
@@ -98,16 +98,16 @@
 )
 {
    int i,j,m,n,q;
-   spx_word16_t *resp;
+   VARDECL(spx_word16_t *resp);
 #ifdef _USE_SSE
-   __m128 *resp2;
-   __m128 *E;
+   VARDECL(__m128 *resp2);
+   VARDECL(__m128 *E);
 #else
    spx_word16_t *resp2;
-   spx_word32_t *E;
+   VARDECL(spx_word32_t *E);
 #endif
-   spx_word16_t *t;
-   spx_sig_t *e;
+   VARDECL(spx_word16_t *t);
+   VARDECL(spx_sig_t *e);
    const signed char *shape_cb;
    int shape_cb_size, subvect_size, nb_subvect;
    split_cb_params *params;
@@ -127,16 +127,16 @@
    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, spx_word16_t);
+   ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
 #ifdef _USE_SSE
-   resp2 = PUSH(stack, (shape_cb_size*subvect_size)>>2, __m128);
-   E = PUSH(stack, shape_cb_size>>2, __m128);
+   ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
+   ALLOC(E, shape_cb_size>>2, __m128);
 #else
    resp2 = resp;
-   E = PUSH(stack, shape_cb_size, spx_word32_t);
+   ALLOC(E, shape_cb_size, spx_word32_t);
 #endif
-   t = PUSH(stack, nsf, spx_word16_t);
-   e = PUSH(stack, nsf, spx_sig_t);
+   ALLOC(t, nsf, spx_word16_t);
+   ALLOC(e, nsf, spx_sig_t);
    
    /* FIXME: make that adaptive? */
    for (i=0;i<nsf;i++)
@@ -222,8 +222,8 @@
    /* Update target: only update target if necessary */
    if (update_target)
    {
-      spx_sig_t *r2;
-      r2 = PUSH(stack, nsf, spx_sig_t);
+      VARDECL(spx_sig_t *r2);
+      ALLOC(r2, nsf, spx_sig_t);
       syn_percep_zero(e, ak, awk1, awk2, r2, nsf,p, stack);
       for (j=0;j<nsf;j++)
          target[j]-=r2[j];
@@ -249,28 +249,33 @@
 )
 {
    int i,j,k,m,n,q;
-   spx_word16_t *resp;
+   VARDECL(spx_word16_t *resp);
 #ifdef _USE_SSE
-   __m128 *resp2;
-   __m128 *E;
+   VARDECL(__m128 *resp2);
+   VARDECL(__m128 *E);
 #else
    spx_word16_t *resp2;
-   spx_word32_t *E;
+   VARDECL(spx_word32_t *E);
 #endif
-   spx_word16_t *t;
-   spx_sig_t *e, *r2;
-   spx_word16_t *tmp;
-   spx_word32_t *ndist, *odist;
-   int *itmp;
+   VARDECL(spx_word16_t *t);
+   VARDECL(spx_sig_t *e);
+   VARDECL(spx_sig_t *r2);
+   VARDECL(spx_word16_t *tmp);
+   VARDECL(spx_word32_t *ndist);
+   VARDECL(spx_word32_t *odist);
+   VARDECL(int *itmp);
+   VARDECL(spx_word16_t **ot2);
+   VARDECL(spx_word16_t **nt2);
    spx_word16_t **ot, **nt;
-   int **nind, **oind;
-   int *ind;
+   VARDECL(int **nind);
+   VARDECL(int **oind);
+   VARDECL(int *ind);
    const signed char *shape_cb;
    int shape_cb_size, subvect_size, nb_subvect;
    split_cb_params *params;
    int N=2;
-   int *best_index;
-   spx_word32_t *best_dist;
+   VARDECL(int *best_index);
+   VARDECL(spx_word32_t *best_dist);
    int have_sign;
    N=complexity;
    if (N>10)
@@ -283,10 +288,10 @@
       split_cb_search_shape_sign_N1(target,ak,awk1,awk2,par,p,nsf,exc,r,bits,stack,complexity,update_target);
       return;
    }
-   ot=PUSH(stack, N, spx_word16_t*);
-   nt=PUSH(stack, N, spx_word16_t*);
-   oind=PUSH(stack, N, int*);
-   nind=PUSH(stack, N, int*);
+   ALLOC(ot2, N, spx_word16_t*);
+   ALLOC(nt2, N, spx_word16_t*);
+   ALLOC(oind, N, int*);
+   ALLOC(nind, N, int*);
 
    params = (split_cb_params *) par;
    subvect_size = params->subvect_size;
@@ -294,39 +299,37 @@
    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, spx_word16_t);
+   ALLOC(resp, shape_cb_size*subvect_size, spx_word16_t);
 #ifdef _USE_SSE
-   resp2 = PUSH(stack, (shape_cb_size*subvect_size)>>2, __m128);
-   E = PUSH(stack, shape_cb_size>>2, __m128);
+   ALLOC(resp2, (shape_cb_size*subvect_size)>>2, __m128);
+   ALLOC(E, shape_cb_size>>2, __m128);
 #else
    resp2 = resp;
-   E = PUSH(stack, shape_cb_size, spx_word32_t);
+   ALLOC(E, shape_cb_size, spx_word32_t);
 #endif
-   t = PUSH(stack, nsf, spx_word16_t);
-   e = PUSH(stack, nsf, spx_sig_t);
-   r2 = PUSH(stack, nsf, spx_sig_t);
-   ind = PUSH(stack, nb_subvect, int);
+   ALLOC(t, nsf, spx_word16_t);
+   ALLOC(e, nsf, spx_sig_t);
+   ALLOC(r2, nsf, spx_sig_t);
+   ALLOC(ind, nb_subvect, int);
 
-   tmp = PUSH(stack, 2*N*nsf, spx_word16_t);
+   ALLOC(tmp, 2*N*nsf, spx_word16_t);
    for (i=0;i<N;i++)
    {
-      ot[i]=tmp;
-      tmp += nsf;
-      nt[i]=tmp;
-      tmp += nsf;
+      ot2[i]=tmp+2*i*nsf;
+      nt2[i]=tmp+(2*i+1)*nsf;
    }
-   best_index = PUSH(stack, N, int);
-   best_dist = PUSH(stack, N, spx_word32_t);
-   ndist = PUSH(stack, N, spx_word32_t);
-   odist = PUSH(stack, N, spx_word32_t);
+   ot=ot2;
+   nt=nt2;
+   ALLOC(best_index, N, int);
+   ALLOC(best_dist, N, spx_word32_t);
+   ALLOC(ndist, N, spx_word32_t);
+   ALLOC(odist, N, spx_word32_t);
    
-   itmp = PUSH(stack, 2*N*nb_subvect, int);
+   ALLOC(itmp, 2*N*nb_subvect, int);
    for (i=0;i<N;i++)
    {
-      nind[i]=itmp;
-      itmp+=nb_subvect;
-      oind[i]=itmp;
-      itmp+=nb_subvect;
+      nind[i]=itmp+2*i*nb_subvect;
+      oind[i]=itmp+(2*i+1)*nb_subvect;
       for (j=0;j<nb_subvect;j++)
          nind[i][j]=oind[i][j]=-1;
    }
@@ -530,7 +533,8 @@
 )
 {
    int i,j;
-   int *ind, *signs;
+   VARDECL(int *ind);
+   VARDECL(int *signs);
    const signed char *shape_cb;
    int shape_cb_size, subvect_size, nb_subvect;
    split_cb_params *params;
@@ -543,8 +547,8 @@
    shape_cb = params->shape_cb;
    have_sign = params->have_sign;
 
-   ind = PUSH(stack, nb_subvect, int);
-   signs = PUSH(stack, nb_subvect, int);
+   ALLOC(ind, nb_subvect, int);
+   ALLOC(signs, nb_subvect, int);
 
    /* Decode codewords and gains */
    for (i=0;i<nb_subvect;i++)
@@ -594,8 +598,8 @@
 )
 {
    int i;
-   spx_sig_t *tmp;
-   tmp = PUSH(stack, nsf, spx_sig_t);
+   VARDECL(spx_sig_t *tmp);
+   ALLOC(tmp, nsf, spx_sig_t);
    residue_percep_zero(target, ak, awk1, awk2, tmp, nsf, p, stack);
 
    for (i=0;i<nsf;i++)

Modified: trunk/speex/libspeex/cb_search_sse.h
===================================================================
--- trunk/speex/libspeex/cb_search_sse.h	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/cb_search_sse.h	2005-03-03 18:30:50 UTC (rev 9030)
@@ -52,9 +52,10 @@
 {
    int i, j, k;
    __m128 resj, EE;
-   __m128 *r, *shape;
-   r = PUSH(stack, subvect_size, __m128);
-   shape = PUSH(stack, subvect_size, __m128);
+   VARDECL(__m128 *r);
+   VARDECL(__m128 *shape);
+   ALLOC(r, subvect_size, __m128);
+   ALLOC(shape, subvect_size, __m128);
    for(j=0;j<subvect_size;j++)
       r[j] = _mm_load_ps1(_r+j);
    for (i=0;i<shape_cb_size;i+=4)

Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/filters.c	2005-03-03 18:30:50 UTC (rev 9030)
@@ -337,8 +337,8 @@
 void syn_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack)
 {
    int i;
-   spx_mem_t *mem;
-   mem = PUSH(stack,ord, spx_mem_t);
+   VARDECL(spx_mem_t *mem);
+   ALLOC(mem, ord, spx_mem_t);
    for (i=0;i<ord;i++)
      mem[i]=0;
    iir_mem2(xx, ak, y, N, ord, mem);
@@ -350,8 +350,8 @@
 void residue_percep_zero(const spx_sig_t *xx, const spx_coef_t *ak, const spx_coef_t *awk1, const spx_coef_t *awk2, spx_sig_t *y, int N, int ord, char *stack)
 {
    int i;
-   spx_mem_t *mem;
-   mem = PUSH(stack,ord, spx_mem_t);
+   VARDECL(spx_mem_t *mem);
+   ALLOC(mem, ord, spx_mem_t);
    for (i=0;i<ord;i++)
       mem[i]=0;
    filter_mem2(xx, ak, awk1, y, N, ord, mem);
@@ -363,12 +363,12 @@
 void qmf_decomp(const spx_word16_t *xx, const spx_word16_t *aa, spx_sig_t *y1, spx_sig_t *y2, int N, int M, spx_word16_t *mem, char *stack)
 {
    int i,j,k,M2;
-   spx_word16_t *a;
-   spx_word16_t *x;
+   VARDECL(spx_word16_t *a);
+   VARDECL(spx_word16_t *x);
    spx_word16_t *x2;
    
-   a = PUSH(stack, M, spx_word16_t);
-   x = PUSH(stack, N+M-1, spx_word16_t);
+   ALLOC(a, M, spx_word16_t);
+   ALLOC(x, N+M-1, spx_word16_t);
    x2=x+M-1;
    M2=M>>1;
    for (i=0;i<M;i++)
@@ -403,9 +403,9 @@
       N and M are multiples of 4 */
 {
    int i, j;
-   spx_word16_t *xx;
+   VARDECL(spx_word16_t *xx);
    
-   xx= PUSH(stack, M+N-1, spx_word16_t);
+   ALLOC(xx, M+N-1, spx_word16_t);
 
    for (i = 0; i < N/2; i++)
       xx[2*i] = SHR(x[N/2-1-i],SIG_SHIFT+1);

Modified: trunk/speex/libspeex/lsp.c
===================================================================
--- trunk/speex/libspeex/lsp.c	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/lsp.c	2005-03-03 18:30:50 UTC (rev 9030)
@@ -143,10 +143,10 @@
 /*  int m 		order of the polynomial 			*/
 {
     int i;
-    spx_word16_t *T;
+    VARDECL(spx_word16_t *T);
     spx_word32_t sum;
     int m2=m>>1;
-    spx_word16_t *coefn;
+    VARDECL(spx_word16_t *coefn);
 
     /*Prevents overflows*/
     if (x>16383)
@@ -155,8 +155,8 @@
        x = -16383;
 
     /* Allocate memory for Chebyshev series formulation */
-    T=PUSH(stack, m2+1, spx_word16_t);
-    coefn=PUSH(stack, m2+1, spx_word16_t);
+    ALLOC(T, m2+1, spx_word16_t);
+    ALLOC(coefn, m2+1, spx_word16_t);
 
     for (i=0;i<m2+1;i++)
     {
@@ -190,11 +190,12 @@
 /*  int m 		order of the polynomial 			*/
 {
     int i;
-    float *T,sum;
+    VARDECL(float *T);
+    float sum;
     int m2=m>>1;
 
     /* Allocate memory for Chebyshev series formulation */
-    T=PUSH(stack, m2+1, float);
+    ALLOC(T, m2+1, float);
 
     /* Initialise values */
     T[0]=1;
@@ -245,8 +246,8 @@
     spx_word16_t temp_xr,xl,xr,xm=0;
     spx_word32_t psuml,psumr,psumm,temp_psumr/*,temp_qsumr*/;
     int i,j,m,flag,k;
-    spx_word32_t *Q;                 	/* ptrs for memory allocation 		*/
-    spx_word32_t *P;
+    VARDECL(spx_word32_t *Q);                 	/* ptrs for memory allocation 		*/
+    VARDECL(spx_word32_t *P);
     spx_word32_t *px;                	/* ptrs of respective P'(z) & Q'(z)	*/
     spx_word32_t *qx;
     spx_word32_t *p;
@@ -259,8 +260,8 @@
     m = lpcrdr/2;            	/* order of P'(z) & Q'(z) polynomials 	*/
 
     /* Allocate memory space for polynomials */
-    Q = PUSH(stack, (m+1), spx_word32_t);
-    P = PUSH(stack, (m+1), spx_word32_t);
+    ALLOC(Q, (m+1), spx_word32_t);
+    ALLOC(P, (m+1), spx_word32_t);
 
     /* 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)) */
@@ -414,16 +415,16 @@
 {
     int i,j;
     spx_word32_t xout1,xout2,xin1,xin2;
-    spx_word32_t *Wp;
+    VARDECL(spx_word32_t *Wp);
     spx_word32_t *pw,*n1,*n2,*n3,*n4=NULL;
-    spx_word16_t *freqn;
+    VARDECL(spx_word16_t *freqn);
     int m = lpcrdr>>1;
     
-    freqn = PUSH(stack, lpcrdr, spx_word16_t);
+    ALLOC(freqn, lpcrdr, spx_word16_t);
     for (i=0;i<lpcrdr;i++)
        freqn[i] = ANGLE2X(freq[i]);
 
-    Wp = PUSH(stack, 4*m+2, spx_word32_t);
+    ALLOC(Wp, 4*m+2, spx_word32_t);
     pw = Wp;
 
 
@@ -488,12 +489,12 @@
 {
     int i,j;
     float xout1,xout2,xin1,xin2;
-    float *Wp;
+    VARDECL(float *Wp);
     float *pw,*n1,*n2,*n3,*n4=NULL;
-    float *x_freq;
+    VARDECL(float *x_freq);
     int m = lpcrdr>>1;
 
-    Wp = PUSH(stack, 4*m+2, float);
+    ALLOC(Wp, 4*m+2, float);
     pw = Wp;
 
     /* initialise contents of array */
@@ -508,7 +509,7 @@
     xin1 = 1.0;
     xin2 = 1.0;
 
-    x_freq=PUSH(stack, lpcrdr, float);
+    ALLOC(x_freq, lpcrdr, float);
     for (i=0;i<lpcrdr;i++)
        x_freq[i] = ANGLE2X(freq[i]);
 

Modified: trunk/speex/libspeex/ltp.c
===================================================================
--- trunk/speex/libspeex/ltp.c	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/ltp.c	2005-03-03 18:30:50 UTC (rev 9030)
@@ -151,21 +151,23 @@
 void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack)
 {
    int i,j,k;
-   spx_word32_t *best_score;
+   VARDECL(spx_word32_t *best_score);
    spx_word32_t e0;
-   spx_word32_t *corr, *energy;
-   spx_word32_t *score;
+   VARDECL(spx_word32_t *corr);
+   VARDECL(spx_word32_t *energy);
+   VARDECL(spx_word32_t *score);
+   VARDECL(spx_word16_t *swn2);
    spx_word16_t *swn;
 
-   best_score = PUSH(stack,N, spx_word32_t);
-   corr = PUSH(stack,end-start+1, spx_word32_t);
-   energy = PUSH(stack,end-start+2, spx_word32_t);
-   score = PUSH(stack,end-start+1, spx_word32_t);
+   ALLOC(best_score, N, spx_word32_t);
+   ALLOC(corr, end-start+1, spx_word32_t);
+   ALLOC(energy, end-start+2, spx_word32_t);
+   ALLOC(score, end-start+1, spx_word32_t);
 
 #ifdef FIXED_POINT
-   swn = PUSH(stack, end+len, spx_word16_t);
-   normalize16(sw-end, swn, 16384, end+len);
-   swn += end;
+   ALLOC(swn2, end+len, spx_word16_t);
+   normalize16(sw-end, swn2, 16384, end+len);
+   swn = swn2 + end;
 #else
    swn = sw;
 #endif
@@ -189,10 +191,10 @@
 
 #ifdef FIXED_POINT
    {
-      spx_word16_t *corr16;
-      spx_word16_t *ener16;
-      corr16 = PUSH(stack, end-start+1, spx_word16_t);
-      ener16 = PUSH(stack, end-start+1, spx_word16_t);
+      VARDECL(spx_word16_t *corr16);
+      VARDECL(spx_word16_t *ener16);
+      ALLOC(corr16, end-start+1, spx_word16_t);
+      ALLOC(ener16, end-start+1, spx_word16_t);
       normalize16(corr, corr16, 16384, end-start+1);
       normalize16(energy, ener16, 16384, end-start+1);
 
@@ -289,7 +291,8 @@
 )
 {
    int i,j;
-   spx_sig_t *tmp, *tmp2;
+   VARDECL(spx_sig_t *tmp);
+   VARDECL(spx_sig_t *tmp2);
    spx_sig_t *x[3];
    spx_sig_t *e[3];
    spx_word32_t corr[3];
@@ -303,8 +306,8 @@
    params = (ltp_params*) par;
    gain_cdbk_size = 1<<params->gain_bits;
    gain_cdbk = params->gain_cdbk + 3*gain_cdbk_size*cdbk_offset;
-   tmp = PUSH(stack, 3*nsf, spx_sig_t);
-   tmp2 = PUSH(stack, 3*nsf, spx_sig_t);
+   ALLOC(tmp, 3*nsf, spx_sig_t);
+   ALLOC(tmp2, 3*nsf, spx_sig_t);
 
    x[0]=tmp;
    x[1]=tmp+nsf;
@@ -343,15 +346,23 @@
    {
       /* If using fixed-point, we need to normalize the signals first */
       spx_word16_t *y[3];
-      spx_word16_t *t;
+      VARDECL(spx_word16_t *ytmp);
+      VARDECL(spx_word16_t *t);
 
       spx_sig_t max_val=1;
       int sig_shift;
       
-      y[0] = PUSH(stack, nsf, spx_word16_t);
-      y[1] = PUSH(stack, nsf, spx_word16_t);
-      y[2] = PUSH(stack, nsf, spx_word16_t);
-      t = PUSH(stack, nsf, spx_word16_t);
+      ALLOC(ytmp, 3*nsf, spx_word16_t);
+#if 0
+      ALLOC(y[0], nsf, spx_word16_t);
+      ALLOC(y[1], nsf, spx_word16_t);
+      ALLOC(y[2], nsf, spx_word16_t);
+#else
+      y[0] = ytmp;
+      y[1] = ytmp+nsf;
+      y[2] = ytmp+2*nsf;
+#endif
+      ALLOC(t, nsf, spx_word16_t);
       for (j=0;j<3;j++)
       {
          for (i=0;i<nsf;i++)
@@ -523,12 +534,14 @@
 {
    int i,j;
    int cdbk_index, pitch=0, best_gain_index=0;
-   spx_sig_t *best_exc, *new_target, *best_target;
+   VARDECL(spx_sig_t *best_exc);
+   VARDECL(spx_sig_t *new_target);
+   VARDECL(spx_sig_t *best_target);
    int best_pitch=0;
    spx_word64_t err, best_err=-1;
    int N;
    ltp_params *params;
-   int *nbest;
+   VARDECL(int *nbest);
 
    N=complexity;
    if (N>10)
@@ -536,7 +549,7 @@
    if (N<1)
       N=1;
 
-   nbest=PUSH(stack, N, int);
+   ALLOC(nbest, N, int);
    params = (ltp_params*) par;
 
    if (end<start)
@@ -548,9 +561,9 @@
       return start;
    }
    
-   best_exc=PUSH(stack,nsf, spx_sig_t);
-   new_target=PUSH(stack,nsf, spx_sig_t);
-   best_target=PUSH(stack,nsf, spx_sig_t);
+   ALLOC(best_exc, nsf, spx_sig_t);
+   ALLOC(new_target, nsf, spx_sig_t);
+   ALLOC(best_target, nsf, spx_sig_t);
    
    if (N>end-start+1)
       N=end-start+1;
@@ -656,8 +669,8 @@
 
    {
       spx_sig_t *e[3];
-      spx_sig_t *tmp2;
-      tmp2=PUSH(stack, 3*nsf, spx_sig_t);
+      VARDECL(spx_sig_t *tmp2);
+      ALLOC(tmp2, 3*nsf, spx_sig_t);
       e[0]=tmp2;
       e[1]=tmp2+nsf;
       e[2]=tmp2+2*nsf;

Modified: trunk/speex/libspeex/ltp_sse.h
===================================================================
--- trunk/speex/libspeex/ltp_sse.h	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/ltp_sse.h	2005-03-03 18:30:50 UTC (rev 9030)
@@ -53,12 +53,13 @@
 static void pitch_xcorr(const float *_x, const float *_y, float *corr, int len, int nb_pitch, char *stack)
 {
    int i, offset;
-   __m128 *x, *y;
+   VARDECL(__m128 *x);
+   VARDECL(__m128 *y);
    int N, L;
    N = len>>2;
    L = nb_pitch>>2;
-   x = PUSH(stack, N, __m128);
-   y = PUSH(stack, N+L, __m128);
+   ALLOC(x, N, __m128);
+   ALLOC(y, N+L, __m128);
    for (i=0;i<N;i++)
       x[i] = _mm_loadu_ps(_x+(i<<2));
    for (offset=0;offset<4;offset++)

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/nb_celp.c	2005-03-03 18:30:50 UTC (rev 9030)
@@ -218,11 +218,12 @@
    int ol_pitch;
    spx_word16_t ol_pitch_coef;
    spx_word32_t ol_gain;
-   spx_sig_t *res, *target;
-   spx_mem_t *mem;
+   VARDECL(spx_sig_t *res);
+   VARDECL(spx_sig_t *target);
+   VARDECL(spx_mem_t *mem);
    char *stack;
-   spx_sig_t *syn_resp;
-   spx_sig_t *real_exc;
+   VARDECL(spx_sig_t *syn_resp);
+   VARDECL(spx_sig_t *real_exc);
 #ifdef EPIC_48K
    int pitch_half[2];
    int ol_pitch_id=0;
@@ -242,8 +243,8 @@
    speex_move(st->swBuf, st->swBuf+st->frameSize, (st->max_pitch+1)*sizeof(spx_sig_t));
 
    {
-      spx_word16_t *w_sig;
-      w_sig = PUSH(stack, st->windowSize, spx_word16_t);
+      VARDECL(spx_word16_t *w_sig);
+      ALLOC(w_sig, st->windowSize, spx_word16_t);
       /* Window for analysis */
       for (i=0;i<st->windowSize;i++)
          w_sig[i] = SHR(MULT16_16(SHR((spx_word32_t)(st->frame[i]),SIG_SHIFT),st->window[i]),SIG_SHIFT);
@@ -615,12 +616,12 @@
    }
 
    /* Filter response */
-   res = PUSH(stack, st->subframeSize, spx_sig_t);
+   ALLOC(res, st->subframeSize, spx_sig_t);
    /* Target signal */
-   target = PUSH(stack, st->subframeSize, spx_sig_t);
-   syn_resp = PUSH(stack, st->subframeSize, spx_sig_t);
-   real_exc = PUSH(stack, st->subframeSize, spx_sig_t);
-   mem = PUSH(stack, st->lpcSize, spx_mem_t);
+   ALLOC(target, st->subframeSize, spx_sig_t);
+   ALLOC(syn_resp, st->subframeSize, spx_sig_t);
+   ALLOC(real_exc, st->subframeSize, spx_sig_t);
+   ALLOC(mem, st->lpcSize, spx_mem_t);
 
    /* Loop on sub-frames */
    for (sub=0;sub<st->nbSubframes;sub++)
@@ -858,8 +859,8 @@
          /* In some (rare) modes, we do a second search (more bits) to reduce noise even more */
          if (SUBMODE(double_codebook)) {
             char *tmp_stack=stack;
-            spx_sig_t *innov2;
-            innov2 = PUSH(stack, st->subframeSize, spx_sig_t);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             for (i=0;i<st->subframeSize;i++)
@@ -1010,7 +1011,9 @@
 static void nb_decode_lost(DecState *st, spx_word16_t *out, char *stack)
 {
    int i, sub;
-   spx_coef_t *awk1, *awk2, *awk3;
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
    float pitch_gain, fact;
    spx_word16_t gain_med;
 
@@ -1029,9 +1032,9 @@
    /*speex_move(st->inBuf, st->inBuf+st->frameSize, (st->bufSize-st->frameSize)*sizeof(spx_sig_t));*/
    speex_move(st->excBuf, st->excBuf+st->frameSize, (st->max_pitch + 1)*sizeof(spx_sig_t));
 
-   awk1=PUSH(stack, (st->lpcSize+1), spx_coef_t);
-   awk2=PUSH(stack, (st->lpcSize+1), spx_coef_t);
-   awk3=PUSH(stack, (st->lpcSize+1), spx_coef_t);
+   ALLOC(awk1, (st->lpcSize+1), spx_coef_t);
+   ALLOC(awk2, (st->lpcSize+1), spx_coef_t);
+   ALLOC(awk3, (st->lpcSize+1), spx_coef_t);
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
@@ -1132,7 +1135,9 @@
    int wideband;
    int m;
    char *stack;
-   spx_coef_t *awk1, *awk2, *awk3;
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
    spx_word16_t pitch_average=0;
 #ifdef EPIC_48K
    int pitch_half[2];
@@ -1244,8 +1249,8 @@
    /* If null mode (no transmission), just set a couple things to zero*/
    if (st->submodes[st->submodeID] == NULL)
    {
-      spx_coef_t *lpc;
-      lpc = PUSH(stack,11, spx_coef_t);
+      VARDECL(spx_coef_t *lpc);
+      ALLOC(lpc, 11, spx_coef_t);
       bw_lpc(GAMMA_SCALING*.93, st->interp_qlpc, lpc, 10);
       {
          float innov_gain=0;
@@ -1345,9 +1350,9 @@
    }
 #endif
 
-   awk1=PUSH(stack, st->lpcSize+1, spx_coef_t);
-   awk2=PUSH(stack, st->lpcSize+1, spx_coef_t);
-   awk3=PUSH(stack, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk1, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk2, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk3, st->lpcSize+1, spx_coef_t);
 
    if (st->submodeID==1)
    {
@@ -1567,8 +1572,8 @@
          if (SUBMODE(double_codebook))
          {
             char *tmp_stack=stack;
-            spx_sig_t *innov2;
-            innov2 = PUSH(stack, st->subframeSize, spx_sig_t);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, bits, stack);

Modified: trunk/speex/libspeex/sb_celp.c
===================================================================
--- trunk/speex/libspeex/sb_celp.c	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/sb_celp.c	2005-03-03 18:30:50 UTC (rev 9030)
@@ -285,10 +285,12 @@
    SBEncState *st;
    int i, roots, sub;
    char *stack;
-   spx_mem_t *mem;
-   spx_sig_t *innov, *syn_resp;
-   spx_word32_t *low_pi_gain;
-   spx_sig_t *low_exc, *low_innov;
+   VARDECL(spx_mem_t *mem);
+   VARDECL(spx_sig_t *innov);
+   VARDECL(spx_sig_t *syn_resp);
+   VARDECL(spx_word32_t *low_pi_gain);
+   VARDECL(spx_sig_t *low_exc);
+   VARDECL(spx_sig_t *low_innov);
    SpeexSBMode *mode;
    int dtx;
    spx_word16_t *in = vin;
@@ -298,8 +300,8 @@
    mode = (SpeexSBMode*)(st->mode->mode);
 
    {
-      spx_word16_t *low;
-      low = PUSH(stack, st->frame_size, spx_word16_t);
+      VARDECL(spx_word16_t *low);
+      ALLOC(low, st->frame_size, spx_word16_t);
 
       /* Compute the two sub-bands by filtering with h0 and h1*/
       qmf_decomp(in, h0, st->x0d, st->x1d, st->full_frame_size, QMF_ORDER, st->h0_mem, stack);
@@ -322,9 +324,9 @@
    speex_move(st->excBuf, st->excBuf+st->frame_size, (st->bufSize-st->frame_size)*sizeof(spx_sig_t));
 
 
-   low_pi_gain = PUSH(stack, st->nbSubframes, spx_word32_t);
-   low_exc = PUSH(stack, st->frame_size, spx_sig_t);
-   low_innov = PUSH(stack, st->frame_size, spx_sig_t);
+   ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t);
+   ALLOC(low_exc, st->frame_size, spx_sig_t);
+   ALLOC(low_innov, st->frame_size, spx_sig_t);
    speex_encoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain);
    speex_encoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc);
    speex_encoder_ctl(st->st_low, SPEEX_GET_INNOV, low_innov);
@@ -337,8 +339,8 @@
       dtx=0;
 
    {
-      spx_word16_t *w_sig;
-      w_sig = PUSH(stack, st->windowSize, spx_word16_t);
+      VARDECL(spx_word16_t *w_sig);
+      ALLOC(w_sig, st->windowSize, spx_word16_t);
       /* Window for analysis */
       for (i=0;i<st->windowSize;i++)
          w_sig[i] = SHR(MULT16_16(SHR((spx_word32_t)(st->high[i]),SIG_SHIFT),st->window[i]),SIG_SHIFT);
@@ -502,9 +504,9 @@
          st->old_qlsp[i] = st->qlsp[i];
    }
    
-   mem=PUSH(stack, st->lpcSize, spx_mem_t);
-   syn_resp=PUSH(stack, st->subframeSize, spx_sig_t);
-   innov = PUSH(stack, st->subframeSize, spx_sig_t);
+   ALLOC(mem, st->lpcSize, spx_mem_t);
+   ALLOC(syn_resp, st->subframeSize, spx_sig_t);
+   ALLOC(innov, st->subframeSize, spx_sig_t);
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
@@ -570,7 +572,7 @@
             char *tmp_stack=stack;
             float *tmp_sig;
             float g2;
-            tmp_sig = PUSH(stack, st->subframeSize, spx_sig_t);
+            ALLOC(tmp_sig, st->subframeSize, spx_sig_t);
             for (i=0;i<st->lpcSize;i++)
                mem[i]=st->mem_sp[i];
             iir_mem2(low_innov+offset, st->interp_qlpc, tmp_sig, st->subframeSize, st->lpcSize, mem);
@@ -681,8 +683,8 @@
 
          if (SUBMODE(double_codebook)) {
             char *tmp_stack=stack;
-            spx_sig_t *innov2;
-            innov2 = PUSH(stack, st->subframeSize, spx_sig_t);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             for (i=0;i<st->subframeSize;i++)
@@ -801,7 +803,9 @@
 static void sb_decode_lost(SBDecState *st, spx_word16_t *out, int dtx, char *stack)
 {
    int i;
-   spx_coef_t *awk1, *awk2, *awk3;
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
    int saved_modeid=0;
 
    if (dtx)
@@ -814,9 +818,9 @@
 
    st->first=1;
    
-   awk1=PUSH(stack, st->lpcSize+1, spx_coef_t);
-   awk2=PUSH(stack, st->lpcSize+1, spx_coef_t);
-   awk3=PUSH(stack, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk1, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk2, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk3, st->lpcSize+1, spx_coef_t);
    
    if (st->lpc_enh_enabled)
    {
@@ -885,9 +889,12 @@
    int wideband;
    int ret;
    char *stack;
-   spx_word32_t *low_pi_gain;
-   spx_sig_t *low_exc, *low_innov;
-   spx_coef_t *awk1, *awk2, *awk3;
+   VARDECL(spx_word32_t *low_pi_gain);
+   VARDECL(spx_sig_t *low_exc);
+   VARDECL(spx_sig_t *low_innov);
+   VARDECL(spx_coef_t *awk1);
+   VARDECL(spx_coef_t *awk2);
+   VARDECL(spx_coef_t *awk3);
    int dtx;
    SpeexSBMode *mode;
    spx_word16_t *out = vout;
@@ -897,8 +904,8 @@
    mode = (SpeexSBMode*)(st->mode->mode);
 
    {
-      spx_word16_t *low;
-      low = PUSH(stack, st->frame_size, spx_word16_t);
+      VARDECL(spx_word16_t *low);
+      ALLOC(low, st->frame_size, spx_word16_t);
       
       /* Decode the low-band */
       ret = speex_decode_native(st->st_low, bits, low);
@@ -975,9 +982,9 @@
    for (i=0;i<st->frame_size;i++)
       st->exc[i]=0;
 
-   low_pi_gain = PUSH(stack, st->nbSubframes, spx_word32_t);
-   low_exc = PUSH(stack, st->frame_size, spx_sig_t);
-   low_innov = PUSH(stack, st->frame_size, spx_sig_t);
+   ALLOC(low_pi_gain, st->nbSubframes, spx_word32_t);
+   ALLOC(low_exc, st->frame_size, spx_sig_t);
+   ALLOC(low_innov, st->frame_size, spx_sig_t);
    speex_decoder_ctl(st->st_low, SPEEX_GET_PI_GAIN, low_pi_gain);
    speex_decoder_ctl(st->st_low, SPEEX_GET_EXC, low_exc);
    speex_decoder_ctl(st->st_low, SPEEX_GET_INNOV, low_innov);
@@ -990,9 +997,9 @@
          st->old_qlsp[i] = st->qlsp[i];
    }
    
-   awk1=PUSH(stack, st->lpcSize+1, spx_coef_t);
-   awk2=PUSH(stack, st->lpcSize+1, spx_coef_t);
-   awk3=PUSH(stack, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk1, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk2, st->lpcSize+1, spx_coef_t);
+   ALLOC(awk3, st->lpcSize+1, spx_coef_t);
 
    for (sub=0;sub<st->nbSubframes;sub++)
    {
@@ -1090,8 +1097,8 @@
 
          if (SUBMODE(double_codebook)) {
             char *tmp_stack=stack;
-            spx_sig_t *innov2;
-            innov2 = PUSH(stack, st->subframeSize, spx_sig_t);
+            VARDECL(spx_sig_t *innov2);
+            ALLOC(innov2, st->subframeSize, spx_sig_t);
             for (i=0;i<st->subframeSize;i++)
                innov2[i]=0;
             SUBMODE(innovation_unquant)(innov2, SUBMODE(innovation_params), st->subframeSize, 

Modified: trunk/speex/libspeex/stack_alloc.h
===================================================================
--- trunk/speex/libspeex/stack_alloc.h	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/stack_alloc.h	2005-03-03 18:30:50 UTC (rev 9030)
@@ -60,6 +60,13 @@
 
 #endif
 
+#ifdef VAR_ARRAYS
+#define VARDECL(var) 
+#define ALLOC(var, size, type) type var[size]
+#else
+#define VARDECL(var) var
+#define ALLOC(var, size, type) var = PUSH(stack, size, type)
+#endif
 
 
 #endif

Modified: trunk/speex/libspeex/vq.c
===================================================================
--- trunk/speex/libspeex/vq.c	2005-03-03 16:58:45 UTC (rev 9029)
+++ trunk/speex/libspeex/vq.c	2005-03-03 18:30:50 UTC (rev 9030)
@@ -88,13 +88,13 @@
 void vq_nbest(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
 {
    int i,j,k,used;
-   float *dist;
-   __m128 *in;
+   VARDECL(float *dist);
+   VARDECL(__m128 *in);
    __m128 half;
    used = 0;
-   dist = PUSH(stack, entries, float);
+   ALLOC(dist, entries, float);
    half = _mm_set_ps1(.5f);
-   in = PUSH(stack, len, __m128);
+   ALLOC(in, len, __m128);
    for (i=0;i<len;i++)
       in[i] = _mm_set_ps1(_in[i]);
    for (i=0;i<entries>>2;i++)
@@ -166,13 +166,13 @@
 void vq_nbest_sign(spx_word16_t *_in, const __m128 *codebook, int len, int entries, __m128 *E, int N, int *nbest, spx_word32_t *best_dist, char *stack)
 {
    int i,j,k,used;
-   float *dist;
-   __m128 *in;
+   VARDECL(float *dist);
+   VARDECL(__m128 *in);
    __m128 half;
    used = 0;
-   dist = PUSH(stack, entries, float);
+   ALLOC(dist, entries, float);
    half = _mm_set_ps1(.5f);
-   in = PUSH(stack, len, __m128);
+   ALLOC(in, len, __m128);
    for (i=0;i<len;i++)
       in[i] = _mm_set_ps1(_in[i]);
    for (i=0;i<entries>>2;i++)



More information about the commits mailing list