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

Jean-Marc Valin jm at xiph.org
Sat Nov 1 21:55:23 PST 2003



jm          03/11/02 00:55:23

  Modified:    libspeex cb_search.c filters.c lsp.c misc.h
  Log:
  ...

Revision  Changes    Path
1.99      +5 -4      speex/libspeex/cb_search.c

Index: cb_search.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/cb_search.c,v
retrieving revision 1.98
retrieving revision 1.99
diff -u -r1.98 -r1.99
--- cb_search.c	2 Nov 2003 05:08:56 -0000	1.98
+++ cb_search.c	2 Nov 2003 05:55:22 -0000	1.99
@@ -143,17 +143,18 @@
       {
          spx_word32_t resj=0;
          for (k=0;k<=j;k++)
-            resj += shape[k]*r[j-k];
+            resj = ADD32(resj,MULT16_32_Q11(shape[k],r[j-k]));
+#ifndef FIXED_POINT
          resj *= 0.03125;
-         
-         res[j] = SHR(resj,6);
+#endif
+         res[j] = resj;
          /*printf ("%d\n", (int)res[j]);*/
       }
       
       /* Compute codeword energy */
       E[i]=0;
       for(j=0;j<subvect_size;j++)
-         E[i]+=MULT16_16(res[j],res[j]);
+         E[i]=ADD32(E[i],MULT16_16(res[j],res[j]));
    }
 
    for (j=0;j<N;j++)

<p><p>1.50      +1 -1      speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- filters.c	8 Oct 2003 22:31:41 -0000	1.49
+++ filters.c	2 Nov 2003 05:55:22 -0000	1.50
@@ -338,7 +338,7 @@
       spx_sig_t y0, y1, y2, y3;
       spx_word16_t x0;
 
-      y0 = y1 = y2 = y3 = 0.f;
+      y0 = y1 = y2 = y3 = 0;
       x0 = xx[N-4-i];
 
       for (j = 0; j < M; j += 4) {

<p><p>1.36      +14 -7     speex/libspeex/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- lsp.c	2 Nov 2003 05:08:56 -0000	1.35
+++ lsp.c	2 Nov 2003 05:55:22 -0000	1.36
@@ -107,7 +107,7 @@
 
 #ifdef FIXED_POINT
 
-static float cheb_poly_eva(spx_word32_t *coef,float x,int m,char *stack)
+static spx_word32_t cheb_poly_eva(spx_word32_t *coef,float x,int m,char *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 			*/
@@ -193,6 +193,11 @@
 
 \*---------------------------------------------------------------------------*/
 
+#ifdef FIXED_POINT
+#define SIGN_CHANGE(a,b) (((a)&0x70000000)^((b)&0x70000000)||(b==0))
+#else
+#define SIGN_CHANGE(a,b) (((a)*(b))<0.0)
+#endif
 
 int lpc_to_lsp (spx_coef_t *a,int lpcrdr,spx_lsp_t *freq,int nb,float delta, char *stack)
 /*  float *a 		     	lpc coefficients			*/
@@ -204,8 +209,8 @@
 
 {
 
-    float psuml,psumr,psumm,temp_xr,xl,xr,xm=0;
-    float temp_psumr/*,temp_qsumr*/;
+    float 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;
@@ -311,18 +316,20 @@
     between xm and xr else set interval between xl and xr and repeat till
     root is located within the specified limits 			*/
 
-	    if((psumr*psuml)<0.0){
+	    if(SIGN_CHANGE(psumr,psuml))
+            {
                 roots++;
 
                 psumm=psuml;
                 for(k=0;k<=nb;k++){
                     xm = (xl+xr)/2;        	/* bisect the interval 	*/
                     psumm=cheb_poly_eva(pt,xm,lpcrdr,stack);
-		    if(psumm*psuml>0.){
+		    /*if(psumm*psuml>0.)*/
+		    if(!SIGN_CHANGE(psumm,psuml))
+                    {
                         psuml=psumm;
                         xl=xm;
-		    }
-		    else{
+		    } else {
                         psumr=psumm;
                         xr=xm;
                     }

<p><p>1.39      +8 -1      speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- misc.h	2 Nov 2003 05:08:56 -0000	1.38
+++ misc.h	2 Nov 2003 05:55:22 -0000	1.39
@@ -60,7 +60,9 @@
 #define SHL(a,shift) ((a) << (shift))
 
 #define ADD16(a,b) ((a)+(b))
+#define SUB16(a,b) ((a)-(b))
 #define ADD32(a,b) ((a)+(b))
+#define SUB32(a,b) ((a)-(b))
 
 /* result fits in 16 bits */
 #define MULT16_16_16(a,b)     (((short)(a))*((short)(b)))
@@ -80,7 +82,7 @@
 #define MULT16_16_P14(a,b) (SHR(ADD16(8192,MULT16_16((a),(b))),14))
 
 
-#define DIV32_16(a,b) (((signed int)(a))/(b))
+#define DIV32_16(a,b) (((signed int)(a))/((short)(b)))
 
 #else
 
@@ -101,9 +103,14 @@
 #define PSHR(a,shift)       (a)
 #define SHR(a,shift)       (a)
 #define SHL(a,shift)       (a)
+#define ADD16(a,b) ((a)+(b))
+#define SUB16(a,b) ((a)-(b))
+#define ADD32(a,b) ((a)+(b))
+#define SUB32(a,b) ((a)-(b))
 #define MULT16_16_16(a,b)     ((a)*(b))
 #define MULT16_16(a,b)     ((a)*(b))
 
+#define MULT16_32_Q11(a,b)     ((a)*(b))
 #define MULT16_32_Q13(a,b)     ((a)*(b))
 #define MULT16_32_Q14(a,b)     ((a)*(b))
 #define MULT16_32_Q15(a,b)     ((a)*(b))

<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