[xiph-cvs] cvs commit: speex/libspeex lpc.c lpc.h nb_celp.c nb_celp.h sb_celp.c sb_celp.h

Jean-Marc Valin jm at xiph.org
Fri May 16 13:41:50 PDT 2003



jm          03/05/16 16:41:50

  Modified:    libspeex lpc.c lpc.h nb_celp.c nb_celp.h sb_celp.c sb_celp.h
  Log:
  Minor cleanup (who needs reflection coefficients anyway) in LPC code.

Revision  Changes    Path
1.8       +33 -25    speex/libspeex/lpc.c

Index: lpc.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lpc.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- lpc.c	6 Nov 2002 01:47:39 -0000	1.7
+++ lpc.c	16 May 2003 20:41:49 -0000	1.8
@@ -17,7 +17,7 @@
   Carsten Bormann
 
 
-   Code slightly modified by Jean-Marc Valin
+   Code modified by Jean-Marc Valin
 
    Speex License:
 
@@ -51,7 +51,7 @@
 
 
 
-/* LPC- and Reflection Coefficients
+/* LPC analysis
  *
  * The next two functions calculate linear prediction coefficients
  * and/or the related reflection coefficients from the first P_MAX+1
@@ -63,36 +63,39 @@
 
 #include "lpc.h"
 
-float                      /* returns minimum mean square error    */
-wld(
-    float       * lpc, /*      [0...p-1] LPC coefficients      */
-    const float * ac,  /*  in: [0...p] autocorrelation values  */
-    float       * ref, /* out: [0...p-1] reflection coef's     */
-    int p
-    )
+/* returns minimum mean square error    */
+float _spx_lpc(
+float       *lpc, /* out: [0...p-1] LPC coefficients      */
+const float *ac,  /* in:  [0...p] autocorrelation values  */
+int          p
+)
 {
    int i, j;  float r, error = ac[0];
 
-   if (ac[0] == 0) {
-      for (i = 0; i < p; i++) ref[i] = 0; return 0; }
+   if (ac[0] == 0)
+   {
+      for (i = 0; i < p; i++)
+         lpc[i] = 0;
+      return 0;
+   }
 
    for (i = 0; i < p; i++) {
 
-      /* Sum up this iteration's reflection coefficient.
-       */
+      /* Sum up this iteration's reflection coefficient */
       r = -ac[i + 1];
-      for (j = 0; j < i; j++) r -= lpc[j] * ac[i - j];
-      ref[i] = r /= error;
+      for (j = 0; j < i; j++) 
+         r -= lpc[j] * ac[i - j];
 
-      /*  Update LPC coefficients and total error.
-       */
+      /*  Update LPC coefficients and total error */
       lpc[i] = r;
-      for (j = 0; j < i/2; j++) {
+      for (j = 0; j < i/2; j++) 
+      {
          float tmp  = lpc[j];
          lpc[j]     += r * lpc[i-1-j];
          lpc[i-1-j] += r * tmp;
       }
-      if (i % 2) lpc[j] += lpc[j] * r;
+      if (i & 1) 
+         lpc[j] += lpc[j] * r;
 
       error *= 1.0 - r * r;
    }
@@ -107,13 +110,18 @@
  * for lags between 0 and lag-1, and x == 0 outside 0...n-1
  */
 void _spx_autocorr(
-              const float * x,   /*  in: [0...n-1] samples x   */
-              float *ac,   /* out: [0...lag-1] ac values */
-              int lag, int   n)
+const float *x,   /*  in: [0...n-1] samples x   */
+float       *ac,  /* out: [0...lag-1] ac values */
+int          lag, 
+int          n
+)
 {
-   float d; int i;
-   while (lag--) {
-      for (i = lag, d = 0; i < n; i++) d += x[i] * x[i-lag];
+   float d;
+   int i;
+   while (lag--) 
+   {
+      for (i = lag, d = 0; i < n; i++) 
+         d += x[i] * x[i-lag];
       ac[lag] = d;
    }
 }

<p><p>1.5       +1 -2      speex/libspeex/lpc.h

Index: lpc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lpc.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- lpc.h	6 Nov 2002 01:47:39 -0000	1.4
+++ lpc.h	16 May 2003 20:41:49 -0000	1.5
@@ -39,10 +39,9 @@
               int lag, int   n);
 
 float                      /* returns minimum mean square error    */
-wld(
+_spx_lpc(
     float       * lpc, /*      [0...p-1] LPC coefficients      */
     const float * ac,  /*  in: [0...p] autocorrelation values  */
-    float       * ref, /* out: [0...p-1] reflection coef's     */
     int p
     );
 

<p><p>1.117     +2 -2      speex/libspeex/nb_celp.c

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -r1.116 -r1.117
--- nb_celp.c	13 May 2003 20:57:31 -0000	1.116
+++ nb_celp.c	16 May 2003 20:41:49 -0000	1.117
@@ -150,7 +150,7 @@
    st->old_qlsp = PUSH(st->stack, st->lpcSize, float);
    st->interp_lsp = PUSH(st->stack, st->lpcSize, float);
    st->interp_qlsp = PUSH(st->stack, st->lpcSize, float);
-   st->rc = PUSH(st->stack, st->lpcSize, float);
+
    st->first = 1;
    for (i=0;i<st->lpcSize;i++)
    {
@@ -241,7 +241,7 @@
       st->autocorr[i] *= st->lagWindow[i];
 
    /* Levinson-Durbin */
-   wld(st->lpc+1, st->autocorr, st->rc, st->lpcSize);
+   _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
    st->lpc[0]=1;
 
    /* LPC to LSPs (x-domain) transform */

<p><p>1.50      +0 -1      speex/libspeex/nb_celp.h

Index: nb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- nb_celp.h	13 May 2003 20:57:31 -0000	1.49
+++ nb_celp.h	16 May 2003 20:41:49 -0000	1.50
@@ -97,7 +97,6 @@
    float *interp_qlpc;    /**< Interpolated quantized LPCs */
    float *bw_lpc1;        /**< LPCs after bandwidth expansion by gamma1 for perceptual weighting*/
    float *bw_lpc2;        /**< LPCs after bandwidth expansion by gamma2 for perceptual weighting*/
-   float *rc;             /**< Reflection coefficients */
    float *mem_sp;         /**< Filter memory for signal synthesis */
    float *mem_sw;         /**< Filter memory for perceptually-weighted signal */
    float *mem_sw_whole;   /**< Filter memory for perceptually-weighted signal (whole frame)*/

<p><p>1.121     +1 -2      speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -r1.120 -r1.121
--- sb_celp.c	8 May 2003 04:27:56 -0000	1.120
+++ sb_celp.c	16 May 2003 20:41:50 -0000	1.121
@@ -189,7 +189,6 @@
    for (i=0;i<st->lpcSize+1;i++)
       st->lagWindow[i]=exp(-.5*sqr(2*M_PI*st->lag_factor*i));
 
-   st->rc = PUSH(st->stack, st->lpcSize, float);
    st->autocorr = PUSH(st->stack, st->lpcSize+1, float);
    st->lpc = PUSH(st->stack, st->lpcSize+1, float);
    st->bw_lpc1 = PUSH(st->stack, st->lpcSize+1, float);
@@ -288,7 +287,7 @@
       st->autocorr[i] *= st->lagWindow[i];
 
    /* Levinson-Durbin */
-   wld(st->lpc+1, st->autocorr, st->rc, st->lpcSize);
+   _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
    st->lpc[0]=1;
 
    /* LPC to LSPs (x-domain) transform */

<p><p>1.39      +0 -1      speex/libspeex/sb_celp.h

Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -r1.38 -r1.39
--- sb_celp.h	8 Jan 2003 21:58:59 -0000	1.38
+++ sb_celp.h	16 May 2003 20:41:50 -0000	1.39
@@ -72,7 +72,6 @@
    float *window;              /**< LPC analysis window */
    float *lagWindow;           /**< Auto-correlation window */
    float *autocorr;            /**< Auto-correlation (for LPC analysis) */
-   float *rc;                  /**< Reflection coefficients (unused) */
    float *lpc;                 /**< LPC coefficients */
    float *lsp;                 /**< LSP coefficients */
    float *qlsp;                /**< Quantized LSPs */

<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