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

Jean-Marc Valin jm at xiph.org
Fri Nov 14 09:49:00 PST 2003



jm          03/11/14 12:49:00

  Modified:    libspeex ltp.c sb_celp.c sb_celp.h
  Log:
  cleanup

Revision  Changes    Path
1.97      +10 -19    speex/libspeex/ltp.c

Index: ltp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/ltp.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -r1.96 -r1.97
--- ltp.c	11 Nov 2003 00:19:46 -0000	1.96
+++ ltp.c	14 Nov 2003 17:48:58 -0000	1.97
@@ -207,10 +207,9 @@
    spx_sig_t *e[3];
    spx_word32_t corr[3];
    spx_word32_t A[3][3];
-   float gain[3];
    int   gain_cdbk_size;
    signed char *gain_cdbk;
-   spx_word16_t sgain[3];
+   spx_word16_t gain[3];
    spx_word64_t err;
 
    ltp_params *params;
@@ -366,16 +365,7 @@
          sum -= MULT16_32_Q15(MULT16_16_16(g1,g1),C[7]);
          sum -= MULT16_32_Q15(MULT16_16_16(g2,g2),C[8]);
 
-         /* If 1, force "safe" pitch values to handle packet loss better */
-         if (0) {
-            float tot = fabs(ptr[1]);
-            if (ptr[0]>0)
-               tot+=ptr[0];
-            if (ptr[2]>0)
-               tot+=ptr[2];
-            if (tot>1)
-               continue;
-         }
+         /* We could force "safe" pitch values to handle packet loss better */
 
          if (sum>best_sum || i==0)
          {
@@ -383,25 +373,26 @@
             best_cdbk=i;
          }
       }
+#ifdef FIXED_POINT
+      gain[0] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3];
+      gain[1] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+1];
+      gain[2] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+2];
+#else
       gain[0] = 0.015625*gain_cdbk[best_cdbk*3]  + .5;
       gain[1] = 0.015625*gain_cdbk[best_cdbk*3+1]+ .5;
       gain[2] = 0.015625*gain_cdbk[best_cdbk*3+2]+ .5;
-
-      sgain[0] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3];
-      sgain[1] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+1];
-      sgain[2] = 32+(spx_word16_t)gain_cdbk[best_cdbk*3+2];
-
+#endif
       *cdbk_index=best_cdbk;
    }
    
 #ifdef FIXED_POINT
    for (i=0;i<nsf;i++)
-     exc[i]=MULT16_32_Q13(SHL(sgain[0],7),e[2][i])+MULT16_32_Q13(SHL(sgain[1],7),e[1][i])+MULT16_32_Q13(SHL(sgain[2],7),e[0][i]);
+     exc[i]=MULT16_32_Q13(SHL(gain[0],7),e[2][i])+MULT16_32_Q13(SHL(gain[1],7),e[1][i])+MULT16_32_Q13(SHL(gain[2],7),e[0][i]);
    
    err=0;
    for (i=0;i<nsf;i++)
    {
-      spx_sig_t perr=target[i]-(MULT16_32_Q13(SHL(sgain[0],7),x[2][i])+MULT16_32_Q13(SHL(sgain[1],7),x[1][i])+MULT16_32_Q13(SHL(sgain[2],7),x[0][i]));
+      spx_sig_t perr=target[i]-(MULT16_32_Q13(SHL(gain[0],7),x[2][i])+MULT16_32_Q13(SHL(gain[1],7),x[1][i])+MULT16_32_Q13(SHL(gain[2],7),x[0][i]));
       spx_word16_t perr2 = SHR(perr,15);
       err = ADD64(err,MULT16_16(perr2,perr2));
       

<p><p>1.151     +3 -3      speex/libspeex/sb_celp.c

Index: sb_celp.c
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.c,v
retrieving revision 1.150
retrieving revision 1.151
diff -u -r1.150 -r1.151
--- sb_celp.c	13 Nov 2003 20:39:06 -0000	1.150
+++ sb_celp.c	14 Nov 2003 17:48:58 -0000	1.151
@@ -217,9 +217,9 @@
          st->window[part1+i]=(spx_word16_t)(SIG_SCALING*(.54+.46*cos(M_PI*i/part2)));
    }
 
-   st->lagWindow = PUSH(st->stack, st->lpcSize+1, float);
+   st->lagWindow = PUSH(st->stack, st->lpcSize+1, spx_word16_t);
    for (i=0;i<st->lpcSize+1;i++)
-      st->lagWindow[i]=exp(-.5*sqr(2*M_PI*st->lag_factor*i));
+      st->lagWindow[i]=16384*exp(-.5*sqr(2*M_PI*st->lag_factor*i));
 
    st->autocorr = PUSH(st->stack, st->lpcSize+1, spx_word16_t);
    st->lpc = PUSH(st->stack, st->lpcSize+1, spx_coef_t);
@@ -331,7 +331,7 @@
    st->autocorr[0] = (spx_word16_t)(st->autocorr[0]*st->lpc_floor); /* Noise floor in auto-correlation domain */
    /* Lag windowing: equivalent to filtering in the power-spectrum domain */
    for (i=0;i<st->lpcSize+1;i++)
-      st->autocorr[i] = (spx_word16_t)(st->autocorr[i]*st->lagWindow[i]);
+      st->autocorr[i] = MULT16_16_Q14(st->autocorr[i],st->lagWindow[i]);
 
    /* Levinson-Durbin */
    _spx_lpc(st->lpc+1, st->autocorr, st->lpcSize);

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

Index: sb_celp.h
===================================================================
RCS file: /usr/local/cvsroot/speex/libspeex/sb_celp.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- sb_celp.h	9 Oct 2003 03:54:37 -0000	1.47
+++ sb_celp.h	14 Nov 2003 17:48:58 -0000	1.48
@@ -71,7 +71,7 @@
    spx_sig_t *sw;                  /**< Perceptually weighted signal */
    spx_sig_t *target;              /**< Weighted target signal (analysis by synthesis) */
    spx_word16_t *window;              /**< LPC analysis window */
-   float *lagWindow;           /**< Auto-correlation window */
+   spx_word16_t *lagWindow;           /**< Auto-correlation window */
    spx_word16_t *autocorr;            /**< Auto-correlation (for LPC analysis) */
    spx_coef_t *lpc;                 /**< LPC coefficients */
    spx_lsp_t *lsp;                 /**< LSP coefficients */

<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