[xiph-cvs] cvs commit: speex/libspeex cb_search.c filters.c ltp.c misc.h vq.c

Jean-Marc Valin jm at xiph.org
Sat Nov 1 22:59:49 PST 2003



jm          03/11/02 01:59:49

  Modified:    libspeex cb_search.c filters.c ltp.c misc.h vq.c
  Log:
  fixed-point: cleanup

Revision  Changes    Path
1.100     +2 -2      speex/libspeex/cb_search.c

Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -r1.99 -r1.100
--- cb_search.c	2 Nov 2003 05:55:22 -0000	1.99
+++ cb_search.c	2 Nov 2003 06:59:48 -0000	1.100
@@ -236,11 +236,11 @@
 #ifdef FIXED_POINT
                   g=sign*shape_cb[rind*subvect_size+m];
                   for (n=subvect_size*(i+1);n<nsf;n++,q++)
-                     t[n] -= MULT16_32_Q11(g,r[q]);
+                     t[n] = SUB32(t[n],MULT16_32_Q11(g,r[q]));
 #else
                   g=sign*0.03125*shape_cb[rind*subvect_size+m];
                   for (n=subvect_size*(i+1);n<nsf;n++,q++)
-                     t[n] -= g*r[q];
+                     t[n] = SUB32(t[n],g*r[q]);
 #endif
                }
 

<p><p>1.51      +4 -6      speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- filters.c	2 Nov 2003 05:55:22 -0000	1.50
+++ filters.c	2 Nov 2003 06:59:48 -0000	1.51
@@ -119,8 +119,6 @@
    return (1<<(sig_shift+3))*sqrt(1+sum/len)/(float)SIG_SCALING;
 }
 
-#define MUL_16_32_R15(a,bh,bl) ((a)*(bh) + ((a)*(bl)>>15))
-
 
 void filter_mem2(spx_sig_t *x, spx_coef_t *num, spx_coef_t *den, spx_sig_t *y, int N, int ord, spx_mem_t *mem)
 {
@@ -135,9 +133,9 @@
       xh = xi>>15; xl=xi&0x00007fff; yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = mem[j+1] +  MUL_16_32_R15(num[j+1],xh,xl) - MUL_16_32_R15(den[j+1],yh,yl);
+         mem[j] = SUB32(ADD32(mem[j+1],  MUL_16_32_R15(num[j+1],xh,xl)), MUL_16_32_R15(den[j+1],yh,yl));
       }
-      mem[ord-1] = MUL_16_32_R15(num[ord],xh,xl) - MUL_16_32_R15(den[ord],yh,yl);
+      mem[ord-1] = SUB32(MUL_16_32_R15(num[ord],xh,xl), MUL_16_32_R15(den[ord],yh,yl));
       y[i] = yi;
    }
 }
@@ -155,7 +153,7 @@
       yh = yi>>15; yl=yi&0x00007fff; 
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = mem[j+1] - MUL_16_32_R15(den[j+1],yh,yl);
+         mem[j] = SUB32(mem[j+1], MUL_16_32_R15(den[j+1],yh,yl));
       }
       mem[ord-1] = - MUL_16_32_R15(den[ord],yh,yl);
       y[i] = yi;
@@ -176,7 +174,7 @@
       xh = xi>>15; xl=xi&0x00007fff;
       for (j=0;j<ord-1;j++)
       {
-         mem[j] = mem[j+1] +  MUL_16_32_R15(num[j+1],xh,xl);
+         mem[j] = ADD32(mem[j+1], MUL_16_32_R15(num[j+1],xh,xl));
       }
       mem[ord-1] = MUL_16_32_R15(num[ord],xh,xl);
       y[i] = yi;

<p><p>1.93      +5 -5      speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- ltp.c	2 Nov 2003 05:08:56 -0000	1.92
+++ ltp.c	2 Nov 2003 06:59:48 -0000	1.93
@@ -48,11 +48,11 @@
    for (i=0;i<len;i+=4)
    {
       spx_word32_t part=0;
-      part += MULT16_16(x[i],y[i]);
-      part += MULT16_16(x[i+1],y[i+1]);
-      part += MULT16_16(x[i+2],y[i+2]);
-      part += MULT16_16(x[i+3],y[i+3]);
-      sum += SHR(part,6);
+      part = ADD32(part,MULT16_16(x[i],y[i]));
+      part = ADD32(part,MULT16_16(x[i+1],y[i+1]));
+      part = ADD32(part,MULT16_16(x[i+2],y[i+2]));
+      part = ADD32(part,MULT16_16(x[i+3],y[i+3]));
+      sum = ADD32(sum,SHR(part,6));
    }
    return sum;
 }

<p><p>1.40      +3 -0      speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- misc.h	2 Nov 2003 05:55:22 -0000	1.39
+++ misc.h	2 Nov 2003 06:59:48 -0000	1.40
@@ -81,6 +81,9 @@
 
 #define MULT16_16_P14(a,b) (SHR(ADD16(8192,MULT16_16((a),(b))),14))
 
+#define MUL_16_32_R15(a,bh,bl) ADD32(MULT16_16((a),(bh)), SHR(MULT16_16((a),(bl)),15))
+
+
 
 #define DIV32_16(a,b) (((signed int)(a))/((short)(b)))
 

<p><p>1.12      +11 -3     speex/libspeex/vq.c

Index: vq.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/vq.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- vq.c	8 Oct 2003 04:47:56 -0000	1.11
+++ vq.c	2 Nov 2003 06:59:48 -0000	1.12
@@ -63,9 +63,13 @@
    used = 0;
    for (i=0;i<entries;i++)
    {
+#ifdef FIXED_POINT
+      spx_word32_t dist=SHR(E[i],1);
+#else
       spx_word32_t dist=.5*E[i];
+#endif
       for (j=0;j<len;j++)
-         dist -= MULT16_16(in[j],*codebook++);
+         dist = SUB32(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--)
@@ -89,7 +93,7 @@
    {
       spx_word32_t dist=0;
       for (j=0;j<len;j++)
-         dist -= MULT16_16(in[j],*codebook++);
+         dist = SUB32(dist,MULT16_16(in[j],*codebook++));
       if (dist>0)
       {
          sign=1;
@@ -98,7 +102,11 @@
       {
          sign=0;
       }
-      dist += .5*E[i];
+#ifdef FIXED_POINT
+      dist = ADD32(dist,SHR(E[i],1));
+#else
+      dist = ADD32(dist,.5*E[i]);
+#endif
       if (i<N || dist<best_dist[N-1])
       {
          for (k=N-1; (k >= 1) && (k > used || dist < best_dist[k-1]); k--)

<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