[xiph-commits] r11114 - trunk/speex/libspeex

jm at svn.xiph.org jm at svn.xiph.org
Sun Apr 9 17:35:41 PDT 2006


Author: jm
Date: 2006-04-09 17:35:38 -0700 (Sun, 09 Apr 2006)
New Revision: 11114

Modified:
   trunk/speex/libspeex/filters.c
   trunk/speex/libspeex/nb_celp.c
Log:
ringing computation now done with 16-bit accuracy.


Modified: trunk/speex/libspeex/filters.c
===================================================================
--- trunk/speex/libspeex/filters.c	2006-04-09 09:54:51 UTC (rev 11113)
+++ trunk/speex/libspeex/filters.c	2006-04-10 00:35:38 UTC (rev 11114)
@@ -236,6 +236,8 @@
    int i,j;
    spx_sig_t xi,yi,nyi;
 
+   for (i=0;i<ord;i++)
+      mem[i] = SHR32(mem[i],1);   
    for (i=0;i<N;i++)
    {
       xi=SATURATE(x[i],805306368);
@@ -248,6 +250,8 @@
       mem[ord-1] = SUB32(MULT16_32_Q15(num[ord-1],xi), MULT16_32_Q15(den[ord-1],yi));
       y[i] = yi;
    }
+   for (i=0;i<ord;i++)
+      mem[i] = SHL32(mem[i],1);   
 }
 #endif
 #endif
@@ -256,10 +260,6 @@
 {
    int i,j;
    spx_word16_t xi,yi,nyi;
-#ifndef PRECISION16
-   for (i=0;i<ord;i++)
-      mem[i] = SHL32(mem[i],1);   
-#endif
    for (i=0;i<N;i++)
    {
       xi= x[i];
@@ -272,10 +272,6 @@
       mem[ord-1] = ADD32(MULT16_16(num[ord-1],xi), MULT16_16(den[ord-1],nyi));
       y[i] = yi;
    }
-#ifndef PRECISION16
-   for (i=0;i<ord;i++)
-      mem[i] = SHR32(mem[i],1);   
-#endif
 }
 
 
@@ -304,6 +300,8 @@
    int i,j;
    spx_word32_t xi,yi,nyi;
 
+   for (i=0;i<ord;i++)
+      mem[i] = SHR32(mem[i],1);   
    for (i=0;i<N;i++)
    {
       xi=SATURATE(x[i],805306368);
@@ -316,6 +314,8 @@
       mem[ord-1] = MULT16_32_Q15(den[ord-1],nyi);
       y[i] = yi;
    }
+   for (i=0;i<ord;i++)
+      mem[i] = SHL32(mem[i],1);   
 }
 #endif
 #endif
@@ -365,6 +365,8 @@
    int i,j;
    spx_word32_t xi,yi;
 
+   for (i=0;i<ord;i++)
+      mem[i] = SHR32(mem[i],1);   
    for (i=0;i<N;i++)
    {
       xi=SATURATE(x[i],805306368);
@@ -376,6 +378,8 @@
       mem[ord-1] = MULT16_32_Q15(num[ord-1],xi);
       y[i] = SATURATE(yi,805306368);
    }
+   for (i=0;i<ord;i++)
+      mem[i] = SHL32(mem[i],1);   
 }
 #endif
 #endif

Modified: trunk/speex/libspeex/nb_celp.c
===================================================================
--- trunk/speex/libspeex/nb_celp.c	2006-04-09 09:54:51 UTC (rev 11113)
+++ trunk/speex/libspeex/nb_celp.c	2006-04-10 00:35:38 UTC (rev 11114)
@@ -276,7 +276,7 @@
    int ol_pitch;
    spx_word16_t ol_pitch_coef;
    spx_word32_t ol_gain;
-   VARDECL(spx_sig_t *res);
+   VARDECL(spx_word16_t *ringing);
    VARDECL(spx_sig_t *target);
    VARDECL(spx_mem_t *mem);
    char *stack;
@@ -683,10 +683,9 @@
          st->old_qlsp[i] = st->qlsp[i];
    }
 
-   /* Filter response */
-   ALLOC(res, st->subframeSize, spx_sig_t);
    /* Target signal */
    ALLOC(target, st->subframeSize, spx_sig_t);
+   ALLOC(ringing, st->subframeSize, spx_word16_t);
    ALLOC(syn_resp, st->subframeSize, spx_word16_t);
    ALLOC(real_exc, st->subframeSize, spx_sig_t);
    ALLOC(mem, st->lpcSize, spx_mem_t);
@@ -787,25 +786,23 @@
       for (i=response_bound;i<st->subframeSize;i++)
          syn_resp[i]=VERY_SMALL;
       
-      /* Reset excitation */
-      for (i=0;i<st->subframeSize;i++)
-         exc[i]=VERY_SMALL;
-
       /* Compute zero response of A(z/g1) / ( A(z/g2) * A(z) ) */
       for (i=0;i<st->lpcSize;i++)
-         mem[i]=st->mem_sp[i];
+         mem[i]=SHL32(st->mem_sp[i],1);
+      for (i=0;i<st->subframeSize;i++)
+         ringing[i] = VERY_SMALL;
 #ifdef SHORTCUTS2
-      iir_mem2(exc, st->interp_qlpc, exc, response_bound, st->lpcSize, mem);
+      iir_mem16(ringing, st->interp_qlpc, ringing, response_bound, st->lpcSize, mem);
       for (i=0;i<st->lpcSize;i++)
-         mem[i]=st->mem_sw[i];
-      filter_mem2(exc, st->bw_lpc1, st->bw_lpc2, res, response_bound, st->lpcSize, mem);
+         mem[i]=SHL32(st->mem_sw[i],1);
+      filter_mem16(ringing, st->bw_lpc1, st->bw_lpc2, ringing, response_bound, st->lpcSize, mem);
       for (i=response_bound;i<st->subframeSize;i++)
-         res[i]=0;
+         ringing[i]=0;
 #else
-      iir_mem2(exc, st->interp_qlpc, exc, st->subframeSize, st->lpcSize, mem);
+      iir_mem16(ringing, st->interp_qlpc, ringing, st->subframeSize, st->lpcSize, mem);
       for (i=0;i<st->lpcSize;i++)
-         mem[i]=st->mem_sw[i];
-      filter_mem2(exc, st->bw_lpc1, st->bw_lpc2, res, st->subframeSize, st->lpcSize, mem);
+         mem[i]=SHL32(st->mem_sw[i],1);
+      filter_mem16(ringing, st->bw_lpc1, st->bw_lpc2, ringing, st->subframeSize, st->lpcSize, mem);
 #endif
       
       /* Compute weighted signal */
@@ -819,8 +816,9 @@
       
       /* Compute target signal */
       for (i=0;i<st->subframeSize;i++)
-         target[i]=SHL32(sw[i],SIG_SHIFT)-res[i];
+         target[i]=SHL32(sw[i]-PSHR32(ringing[i],1),SIG_SHIFT);
 
+      /* Reset excitation */
       for (i=0;i<st->subframeSize;i++)
          exc[i]=0;
 
@@ -965,12 +963,11 @@
 
       }
 
-      /* Note that we re-use "res" as output (to be discarder anyway) */
+      for (i=0;i<st->subframeSize;i++)
+         sw[i] = PSHR32(exc[i], SIG_SHIFT);
       /* Final signal synthesis from excitation */
-      iir_mem2(exc, st->interp_qlpc, res, st->subframeSize, st->lpcSize, st->mem_sp);
+      iir_mem16(sw, st->interp_qlpc, sw, st->subframeSize, st->lpcSize, st->mem_sp);
 
-      for (i=0;i<st->subframeSize;i++)
-         sw[i] = PSHR32(res[i], SIG_SHIFT);
       /* Compute weighted signal again, from synthesized speech (not sure it's the right thing) */
       if (st->complexity!=0)
          filter_mem16(sw, st->bw_lpc1, st->bw_lpc2, sw, st->subframeSize, st->lpcSize, st->mem_sw);
@@ -1263,6 +1260,7 @@
    int ol_pitch_id=0;
 #endif
    spx_word16_t *out = vout;
+   VARDECL(spx_lsp_t *interp_qlsp);
 
    st=(DecState*)state;
    stack=st->stack;
@@ -1711,6 +1709,8 @@
 
    }
    
+   ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t);
+
 #ifdef NEW_ENHANCER
    multicomb(st->exc-40, st->frame, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, pitch, pitch_gain, SUBMODE(comb_gain), stack);
    multicomb(st->exc+40, st->frame+80, st->interp_qlpc, st->lpcSize, 2*st->subframeSize, pitch, pitch_gain, SUBMODE(comb_gain), stack);
@@ -1721,8 +1721,6 @@
       int offset;
       spx_word16_t *sp;
       spx_sig_t *exc;
-      VARDECL(spx_lsp_t *interp_qlsp);
-      ALLOC(interp_qlsp, st->lpcSize, spx_lsp_t);
       /* Offset relative to start of frame */
       offset = st->subframeSize*sub;
       /* Original signal */



More information about the commits mailing list