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

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



jm          03/10/08 00:32:25

  Modified:    libspeex lsp.c misc.h nb_celp.c sb_celp.c testenc_wb.c
  Log:
  fixed-point: LPC/LSP cleanup

Revision  Changes    Path
1.28      +2 -2      speex/libspeex/lsp.c

Index: lsp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/lsp.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- lsp.c	8 Oct 2003 04:31:40 -0000	1.27
+++ lsp.c	8 Oct 2003 04:32:24 -0000	1.28
@@ -197,8 +197,8 @@
     *px++ = 1.0;
     *qx++ = 1.0;
     for(i=1;i<=m;i++){
-	*px++ = (a[i]+a[lpcrdr+1-i])/8192.-*p++;
-	*qx++ = (a[i]-a[lpcrdr+1-i])/8192.+*q++;
+	*px++ = (a[i]+a[lpcrdr+1-i])/LPC_SCALING - *p++;
+	*qx++ = (a[i]-a[lpcrdr+1-i])/LPC_SCALING + *q++;
     }
     px = P;
     qx = Q;

<p><p>1.25      +4 -0      speex/libspeex/misc.h

Index: misc.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/misc.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- misc.h	8 Oct 2003 04:31:40 -0000	1.24
+++ misc.h	8 Oct 2003 04:32:24 -0000	1.25
@@ -54,6 +54,8 @@
 typedef spx_word16_t spx_coef_t;
 typedef float   spx_sig_t;
 
+#define LPC_SCALING  8192.
+
 #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))
 
@@ -74,6 +76,8 @@
 typedef float spx_word16_t;
 typedef float spx_word32_t;
 
+#define LPC_SCALING  1.
+
 #endif
 
 #ifndef RELEASE

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

Index: nb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/nb_celp.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -r1.125 -r1.126
--- nb_celp.c	8 Oct 2003 04:31:40 -0000	1.125
+++ nb_celp.c	8 Oct 2003 04:32:24 -0000	1.126
@@ -243,7 +243,7 @@
 
    /* Levinson-Durbin */
    _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
-   st->lpc[0]=8192.;
+   st->lpc[0]=LPC_SCALING;
 
    /* LPC to LSPs (x-domain) transform */
    roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
@@ -668,6 +668,8 @@
          st->pi_gain[sub] += tmp*st->interp_qlpc[i];
          tmp = -tmp;
       }
+      st->pi_gain[sub] /= LPC_SCALING;
+
 
       /* Compute bandwidth-expanded (unquantized) LPCs for perceptual weighting */
       bw_lpc(st->gamma1, st->interp_lpc, st->bw_lpc1, st->lpcSize);
@@ -1423,6 +1425,7 @@
          st->pi_gain[sub] += tmp*st->interp_qlpc[i];
          tmp = -tmp;
       }
+      st->pi_gain[sub] /= LPC_SCALING;
 
       /* Reset excitation */
       for (i=0;i<st->subframeSize;i++)

<p><p>1.128     +7 -1      speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -u -r1.127 -r1.128
--- sb_celp.c	8 Oct 2003 04:30:25 -0000	1.127
+++ sb_celp.c	8 Oct 2003 04:32:24 -0000	1.128
@@ -290,7 +290,7 @@
 
    /* Levinson-Durbin */
    _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);
-   st->lpc[0]=1;
+   st->lpc[0]=LPC_SCALING;
 
    /* LPC to LSPs (x-domain) transform */
    roots=lpc_to_lsp (st->lpc, st->lpcSize, st->lsp, 15, 0.2, stack);
@@ -494,6 +494,9 @@
          tmp = -tmp;
          st->pi_gain[sub]+=st->interp_qlpc[i];
       }
+      rh /= LPC_SCALING;
+      st->pi_gain[sub] /= LPC_SCALING;
+
       rl = low_pi_gain[sub];
       rl=1/(fabs(rl)+.01);
       rh=1/(fabs(rh)+.01);
@@ -972,6 +975,9 @@
             tmp = -tmp;
             st->pi_gain[sub]+=st->interp_qlpc[i];
          }
+         rh /= LPC_SCALING;
+         st->pi_gain[sub] /= LPC_SCALING;
+
          rl = low_pi_gain[sub];
          rl=1/(fabs(rl)+.01);
          rh=1/(fabs(rh)+.01);

<p><p>1.32      +3 -3      speex/libspeex/testenc_wb.c

Index: testenc_wb.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/testenc_wb.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- testenc_wb.c	27 Oct 2002 06:01:30 -0000	1.31
+++ testenc_wb.c	8 Oct 2003 04:32:24 -0000	1.32
@@ -30,7 +30,7 @@
    speex_encoder_ctl(st, SPEEX_SET_VBR, &tmp);
    tmp=10;
    speex_encoder_ctl(st, SPEEX_SET_QUALITY, &tmp);
-   tmp=3;
+   tmp=5;
    speex_encoder_ctl(st, SPEEX_SET_COMPLEXITY, &tmp);
    tmp=3;
    speex_encoder_ctl(st, SPEEX_SET_HIGH_MODE, &tmp);
@@ -63,7 +63,7 @@
       speex_encode(st, input, &bits);
       nbBits = speex_bits_write(&bits, cbits, 200);
       bitCount+=bits.nbBits;
-      printf ("Encoding frame in %d bits\n", nbBits*8);
+      /*printf ("Encoding frame in %d bits\n", nbBits*8);*/
       if (argc==4)
          fwrite(cbits, 1, nbBits, fbits);
       {
@@ -74,7 +74,7 @@
             esig += bak2[i]*bak2[i];
          }
          snr = 10*log10((esig+1)/(enoise+1));
-         printf ("real SNR = %f\n", snr);
+         /*printf ("real SNR = %f\n", snr);*/
       }
       speex_bits_rewind(&bits);
       

<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