[xiph-cvs] cvs commit: speex/libspeex cb_search.c smallft.c vq.c vq.h

Jean-Marc Valin jm at xiph.org
Tue Oct 7 21:47:57 PDT 2003



jm          03/10/08 00:47:57

  Modified:    libspeex cb_search.c smallft.c vq.c vq.h
  Log:
  fixed-point: most of the innovation search converted

Revision  Changes    Path
1.93      +25 -24    speex/libspeex/cb_search.c

Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- cb_search.c	8 Oct 2003 04:45:26 -0000	1.92
+++ cb_search.c	8 Oct 2003 04:47:56 -0000	1.93
@@ -53,13 +53,14 @@
 )
 {
    int i,j,k,m,n,q;
-   spx_sig_t *resp;
-   spx_sig_t *t, *e, *r2;
+   spx_word16_t *resp;
+   spx_word16_t *t;
+   spx_sig_t *e, *r2;
    spx_word32_t *E;
-   spx_sig_t *tmp;
-   float *ndist, *odist;
+   spx_word16_t *tmp;
+   spx_word32_t *ndist, *odist;
    int *itmp;
-   spx_sig_t **ot, **nt;
+   spx_word16_t **ot, **nt;
    int **nind, **oind;
    int *ind;
    signed char *shape_cb;
@@ -67,15 +68,15 @@
    split_cb_params *params;
    int N=2;
    int *best_index;
-   float *best_dist;
+   spx_word32_t *best_dist;
    int have_sign;
 
    N=complexity;
    if (N>10)
       N=10;
 
-   ot=PUSH(stack, N, spx_sig_t*);
-   nt=PUSH(stack, N, spx_sig_t*);
+   ot=PUSH(stack, N, spx_word16_t*);
+   nt=PUSH(stack, N, spx_word16_t*);
    oind=PUSH(stack, N, int*);
    nind=PUSH(stack, N, int*);
 
@@ -85,14 +86,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, spx_sig_t);
-   t = PUSH(stack, nsf, spx_sig_t);
+   resp = PUSH(stack, shape_cb_size*subvect_size, spx_word16_t);
+   t = PUSH(stack, nsf, spx_word16_t);
    e = PUSH(stack, nsf, spx_sig_t);
    r2 = PUSH(stack, nsf, spx_sig_t);
    E = PUSH(stack, shape_cb_size, spx_word32_t);
    ind = PUSH(stack, nb_subvect, int);
 
-   tmp = PUSH(stack, 2*N*nsf, spx_sig_t);
+   tmp = PUSH(stack, 2*N*nsf, spx_word16_t);
    for (i=0;i<N;i++)
    {
       ot[i]=tmp;
@@ -102,9 +103,9 @@
    }
 
    best_index = PUSH(stack, N, int);
-   best_dist = PUSH(stack, N, float);
-   ndist = PUSH(stack, N, float);
-   odist = PUSH(stack, N, float);
+   best_dist = PUSH(stack, N, spx_word32_t);
+   ndist = PUSH(stack, N, spx_word32_t);
+   odist = PUSH(stack, N, spx_word32_t);
    
    itmp = PUSH(stack, 2*N*nb_subvect, int);
    for (i=0;i<N;i++)
@@ -130,7 +131,7 @@
    /* Pre-compute codewords response and energy */
    for (i=0;i<shape_cb_size;i++)
    {
-      spx_sig_t *res;
+      spx_word16_t *res;
       signed char *shape;
 
       res = resp+i*subvect_size;
@@ -139,19 +140,19 @@
       /* Compute codeword response using convolution with impulse response */
       for(j=0;j<subvect_size;j++)
       {
-         res[j]=0;
+         spx_word32_t resj=0;
          for (k=0;k<=j;k++)
-            res[j] += shape[k]*r[j-k];
-         res[j] *= 0.03125;
+            resj += shape[k]*r[j-k];
+         resj *= 0.03125;
          
-         res[j] = SHR(res[j],6);
+         res[j] = SHR(resj,6);
          /*printf ("%d\n", (int)res[j]);*/
       }
       
       /* Compute codeword energy */
       E[i]=0;
       for(j=0;j<subvect_size;j++)
-         E[i]+=res[j]*res[j];
+         E[i]+=MULT16_16(res[j],res[j]);
    }
 
    for (j=0;j<N;j++)
@@ -166,7 +167,7 @@
       /*For all n-bests of previous subvector*/
       for (j=0;j<N;j++)
       {
-         spx_sig_t *x=ot[j]+subvect_size*i;
+         spx_word16_t *x=ot[j]+subvect_size*i;
          /*Find new n-best based on previous n-best j*/
          if (have_sign)
             vq_nbest_sign(x, resp, subvect_size, shape_cb_size, E, N, best_index, best_dist);
@@ -176,7 +177,7 @@
          /*For all new n-bests*/
          for (k=0;k<N;k++)
          {
-            spx_sig_t *ct;
+            spx_word16_t *ct;
             float err=0;
             ct = ot[j];
             /*update target*/
@@ -188,7 +189,7 @@
             /* New code: update only enough of the target to calculate error*/
             {
                int rind;
-               spx_sig_t *res;
+               spx_word16_t *res;
                float sign=1;
                rind = best_index[k];
                if (rind>=shape_cb_size)
@@ -266,7 +267,7 @@
       /*update old-new data*/
       /* just swap pointers instead of a long copy */
       {
-         spx_sig_t **tmp2;
+         spx_word16_t **tmp2;
          tmp2=ot;
          ot=nt;
          nt=tmp2;

<p><p>1.7       +0 -0      speex/libspeex/smallft.c

Index: smallft.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/smallft.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- smallft.c	8 Oct 2003 04:45:26 -0000	1.6
+++ smallft.c	8 Oct 2003 04:47:56 -0000	1.7
@@ -11,7 +11,7 @@
  ********************************************************************
 
  function: *unnormalized* fft transform
- last mod: $Id: smallft.c,v 1.6 2003/10/08 04:45:26 jm Exp $
+ last mod: $Id: smallft.c,v 1.7 2003/10/08 04:47:56 jm Exp $
 
  ********************************************************************/
 

<p><p>1.11      +6 -6      speex/libspeex/vq.c

Index: vq.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/vq.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- vq.c	8 Oct 2003 04:45:26 -0000	1.10
+++ vq.c	8 Oct 2003 04:47:56 -0000	1.11
@@ -57,15 +57,15 @@
 
 
 /*Finds the indices of the n-best entries in a codebook*/
-void vq_nbest(spx_sig_t *in, spx_sig_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, float *best_dist)
+void vq_nbest(spx_word16_t *in, spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist)
 {
    int i,j,k,used;
    used = 0;
    for (i=0;i<entries;i++)
    {
-      float dist=.5*E[i];
+      spx_word32_t dist=.5*E[i];
       for (j=0;j<len;j++)
-         dist -= in[j]**codebook++;
+         dist -= MULT16_16(in[j],*codebook++);
       if (i<N || dist<best_dist[N-1])
       {
          for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)
@@ -81,15 +81,15 @@
 }
 
 /*Finds the indices of the n-best entries in a codebook with sign*/
-void vq_nbest_sign(spx_sig_t *in, spx_sig_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, float *best_dist)
+void vq_nbest_sign(spx_word16_t *in, spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist)
 {
    int i,j,k, sign, used;
    used=0;
    for (i=0;i<entries;i++)
    {
-      float dist=0;
+      spx_word32_t dist=0;
       for (j=0;j<len;j++)
-         dist -= in[j]**codebook++;
+         dist -= MULT16_16(in[j],*codebook++);
       if (dist>0)
       {
          sign=1;

<p><p>1.10      +2 -2      speex/libspeex/vq.h

Index: vq.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/vq.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- vq.h	8 Oct 2003 04:45:26 -0000	1.9
+++ vq.h	8 Oct 2003 04:47:56 -0000	1.10
@@ -37,8 +37,8 @@
 
 int vq_index(float *in, float *codebook, int len, int entries);
 
-void vq_nbest(spx_sig_t *in, spx_sig_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, float *best_dist);
+void vq_nbest(spx_word16_t *in, spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist);
 
-void vq_nbest_sign(spx_sig_t *in, spx_sig_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, float *best_dist);
+void vq_nbest_sign(spx_word16_t *in, spx_word16_t *codebook, int len, int entries, spx_word32_t *E, int N, int *nbest, spx_word32_t *best_dist);
 
 #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