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

jm at motherfish-iii.xiph.org jm at motherfish-iii.xiph.org
Mon Feb 7 22:23:43 PST 2005


Author: jm
Date: 2005-02-07 22:23:41 -0800 (Mon, 07 Feb 2005)
New Revision: 8870

Modified:
   trunk/speex/libspeex/cb_search.c
   trunk/speex/libspeex/lsp.c
   trunk/speex/libspeex/ltp.c
Log:
Some general (minor) optimizations


Modified: trunk/speex/libspeex/cb_search.c
===================================================================
--- trunk/speex/libspeex/cb_search.c	2005-02-08 05:02:13 UTC (rev 8869)
+++ trunk/speex/libspeex/cb_search.c	2005-02-08 06:23:41 UTC (rev 8870)
@@ -54,24 +54,24 @@
 
       res = resp+i*subvect_size;
       shape = shape_cb+i*subvect_size;
+      E[i]=0;
 
       /* Compute codeword response using convolution with impulse response */
       for(j=0;j<subvect_size;j++)
       {
          spx_word32_t resj=0;
          for (k=0;k<=j;k++)
-            resj = MAC16_16_Q11(resj,shape[k],r[j-k]);
-#ifndef FIXED_POINT
+            resj = MAC16_16(resj,shape[k],r[j-k]);
+#ifdef FIXED_POINT
+         resj = SHR(resj, 11);
+#else
          resj *= 0.03125;
 #endif
+         /* Compute codeword energy */
+         E[i]=ADD32(E[i],MULT16_16(resj,resj));
          res[j] = resj;
          /*printf ("%d\n", (int)res[j]);*/
       }
-      
-      /* Compute codeword energy */
-      E[i]=0;
-      for(j=0;j<subvect_size;j++)
-         E[i]=ADD32(E[i],MULT16_16(res[j],res[j]));
    }
 
 }

Modified: trunk/speex/libspeex/lsp.c
===================================================================
--- trunk/speex/libspeex/lsp.c	2005-02-08 05:02:13 UTC (rev 8869)
+++ trunk/speex/libspeex/lsp.c	2005-02-08 06:23:41 UTC (rev 8870)
@@ -444,14 +444,16 @@
       LSP coefficient */
 
     for(j=0;j<=lpcrdr;j++){
-       int i2=0;
-	for(i=0;i<m;i++,i2+=2){
-	    n1 = pw+(i*4);
+       spx_word16_t *fr=freqn;
+	for(i=0;i<m;i++){
+	    n1 = pw+(i<<2);
 	    n2 = n1 + 1;
 	    n3 = n2 + 1;
 	    n4 = n3 + 1;
-	    xout1 = ADD32(SUB32(xin1, MULT16_32_Q14(freqn[i2],*n1)), *n2);
-            xout2 = ADD32(SUB32(xin2, MULT16_32_Q14(freqn[i2+1],*n3)), *n4);
+	    xout1 = ADD32(SUB32(xin1, MULT16_32_Q14(*fr,*n1)), *n2);
+            fr++;
+            xout2 = ADD32(SUB32(xin2, MULT16_32_Q14(*fr,*n3)), *n4);
+            fr++;
 	    *n2 = *n1;
 	    *n4 = *n3;
 	    *n1 = xin1;

Modified: trunk/speex/libspeex/ltp.c
===================================================================
--- trunk/speex/libspeex/ltp.c	2005-02-08 05:02:13 UTC (rev 8869)
+++ trunk/speex/libspeex/ltp.c	2005-02-08 06:23:41 UTC (rev 8870)
@@ -199,14 +199,20 @@
          spx_word16_t g;
          spx_word32_t tmp;
          tmp = corr16[i-start];
-         if (SHR(corr16[i-start],4)>ener16[i-start])
-            tmp = SHL((spx_word32_t)ener16[i-start],14);
-         else if (-SHR(corr16[i-start],4)>ener16[i-start])
-            tmp = -SHL((spx_word32_t)ener16[i-start],14);
-         else
-            tmp = SHL(tmp,10);
-         g = DIV32_16(tmp, 8+ener16[i-start]);
-         score[i-start] = MULT16_16(corr16[i-start],g);
+         if (tmp>0)
+         {
+            if (SHR(corr16[i-start],4)>ener16[i-start])
+               tmp = SHL((spx_word32_t)ener16[i-start],14);
+            else if (-SHR(corr16[i-start],4)>ener16[i-start])
+               tmp = -SHL((spx_word32_t)ener16[i-start],14);
+            else
+               tmp = SHL(tmp,10);
+            g = DIV32_16(tmp, 8+ener16[i-start]);
+            score[i-start] = MULT16_16(corr16[i-start],g);
+         } else
+         {
+            score[i-start] = 1;
+         }
       }
    }
 #else



More information about the commits mailing list