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

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



jm          03/10/08 00:31:40

  Modified:    libspeex filters.c lpc.c lsp.c misc.h nb_celp.c
  Log:
  fixed-point: LPC and LSP types changed to word16

Revision  Changes    Path
1.35      +6 -6      speex/libspeex/filters.c

Index: filters.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/filters.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- filters.c	8 Oct 2003 04:29:45 -0000	1.34
+++ filters.c	8 Oct 2003 04:31:40 -0000	1.35
@@ -61,8 +61,8 @@
    
    for (i=0;i<ord+1;i++)
    {
-      nums[i] = (int)floor(.5+8192*num[i]);
-      dens[i] = (int)floor(.5+8192*den[i]);
+      nums[i] = (int)floor(.5+num[i]);
+      dens[i] = (int)floor(.5+den[i]);
    }
 
    for (i=0;i<N;i++)
@@ -88,12 +88,12 @@
    
    for (i=0;i<11;i++)
    {
-      if (fabs(den[i])>3.999)
+      if (fabs(den[i])>3.999*8192)
       {
          speex_warning_int("tata", den[i]*100);
-         den[i]=3.999;
+         den[i]=3.999*8192;
       }
-      dens[i] = (int)floor(.5+8192*den[i]);
+      dens[i] = (int)floor(.5+den[i]);
    }
 
    for (i=0;i<N;i++)
@@ -120,7 +120,7 @@
    
    for (i=0;i<11;i++)
    {
-      nums[i] = (int)floor(.5+8192*num[i]);
+      nums[i] = (int)floor(.5+num[i]);
    }
 
    for (i=0;i<N;i++)

<p><p>1.14      +1 -1      speex/libspeex/lpc.c

Index: lpc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lpc.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- lpc.c	8 Oct 2003 04:30:25 -0000	1.13
+++ lpc.c	8 Oct 2003 04:31:40 -0000	1.14
@@ -107,7 +107,7 @@
       error -= MULT16_16_Q13(r,MULT16_16_Q13(error,r));
    }
    for (i = 0; i < p; i++)
-      lpc[i] = lpcq[i]/8192.;
+      lpc[i] = lpcq[i];
    return error;
 }
 

<p><p>1.27      +7 -10     speex/libspeex/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- lsp.c	8 Oct 2003 04:29:45 -0000	1.26
+++ lsp.c	8 Oct 2003 04:31:40 -0000	1.27
@@ -67,8 +67,6 @@
 
 \*---------------------------------------------------------------------------*/
 
-#undef FIXED_POINT
-
 #ifdef FIXED_POINT
 
 static float cheb_poly_eva(float *coef,float x,int m,char *stack)
@@ -199,8 +197,8 @@
     *px++ = 1.0;
     *qx++ = 1.0;
     for(i=1;i<=m;i++){
-	*px++ = a[i]+a[lpcrdr+1-i]-*p++;
-	*qx++ = a[i]-a[lpcrdr+1-i]+*q++;
+	*px++ = (a[i]+a[lpcrdr+1-i])/8192.-*p++;
+	*qx++ = (a[i]-a[lpcrdr+1-i])/8192.+*q++;
     }
     px = P;
     qx = Q;
@@ -342,23 +340,22 @@
             n4 = n3 + 1;
             xout1 = xin1 - MULT16_32_Q14(freqn[i2],*n1) + *n2;
             xout2 = xin2 - MULT16_32_Q14(freqn[i2+1],*n3) + *n4;
-	    *n2 = floor(.5+*n1);
-	    *n4 = floor(.5+*n3);
-	    *n1 = floor(.5+xin1);
-	    *n3 = floor(.5+xin2);
+	    *n2 = *n1;
+	    *n4 = *n3;
+	    *n1 = xin1;
+	    *n3 = xin2;
             xin1 = xout1;
             xin2 = xout2;
         }
         xout1 = xin1 + *(n4+1);
         xout2 = xin2 - *(n4+2);
-	ak[j] = ((128+xout1 + xout2)>>8)/8192.;
+	ak[j] = ((128+xout1 + xout2)>>8);
         *(n4+1) = xin1;
         *(n4+2) = xin2;
 
         xin1 = 0.0;
         xin2 = 0.0;
     }
-
 }
 #else
 

<p><p>1.24      +5 -5      speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- misc.h	8 Oct 2003 04:29:45 -0000	1.23
+++ misc.h	8 Oct 2003 04:31:40 -0000	1.24
@@ -48,11 +48,11 @@
 
 #ifdef FIXED_POINT
 
-typedef int spx_mem_t;
-typedef float spx_coef_t;
-typedef float spx_sig_t;
-typedef short spx_word16_t;
-typedef int spx_word32_t;
+typedef short        spx_word16_t;
+typedef int          spx_word32_t;
+typedef spx_word32_t spx_mem_t;
+typedef spx_word16_t spx_coef_t;
+typedef float   spx_sig_t;
 
 #define MULT16_32_Q14(a,b) (((a)*((b)>>14)) + ((a)*((signed int)((b)&0x00003fff))>>14))
 #define MULT16_32_Q15(a,b) (((a)*((b)>>15)) + ((a)*((signed int)((b)&0x00007fff))>>15))

<p><p>1.125     +1 -1      speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- nb_celp.c	8 Oct 2003 04:30:25 -0000	1.124
+++ nb_celp.c	8 Oct 2003 04:31:40 -0000	1.125
@@ -243,7 +243,7 @@
 
    /* Levinson-Durbin */
    _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
-   st->lpc[0]=1;
+   st->lpc[0]=8192.;
 
    /* LPC to LSPs (x-domain) transform */
    roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);

<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