Some general (minor) optimizations
authorjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Tue, 8 Feb 2005 06:23:41 +0000 (06:23 +0000)
committerjm <jm@0101bb08-14d6-0310-b084-bc0e0c8e3800>
Tue, 8 Feb 2005 06:23:41 +0000 (06:23 +0000)
git-svn-id: http://svn.xiph.org/trunk/speex@8870 0101bb08-14d6-0310-b084-bc0e0c8e3800

libspeex/cb_search.c
libspeex/lsp.c
libspeex/ltp.c

index 78b20e0..d22a1c5 100644 (file)
@@ -54,24 +54,24 @@ static void compute_weighted_codebook(const signed char *shape_cb, const spx_sig
 
       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]));
    }
 
 }
index e3a68e5..18acff3 100644 (file)
@@ -444,14 +444,16 @@ void lsp_to_lpc(spx_lsp_t *freq,spx_coef_t *ak,int lpcrdr, char *stack)
       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;
index 56f746f..a3abd07 100644 (file)
@@ -199,14 +199,20 @@ void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitc
          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