[xiph-commits] r11026 - trunk/speex/libspeex
jm at svn.xiph.org
jm at svn.xiph.org
Sun Mar 19 05:17:06 PST 2006
Author: jm
Date: 2006-03-19 05:17:02 -0800 (Sun, 19 Mar 2006)
New Revision: 11026
Modified:
trunk/speex/libspeex/ltp.c
Log:
Getting rid of 25600 divide operations/sec in the pitch search.
Modified: trunk/speex/libspeex/ltp.c
===================================================================
--- trunk/speex/libspeex/ltp.c 2006-03-19 09:35:24 UTC (rev 11025)
+++ trunk/speex/libspeex/ltp.c 2006-03-19 13:17:02 UTC (rev 11026)
@@ -172,6 +172,7 @@
{
int i,j,k;
VARDECL(spx_word32_t *best_score);
+ VARDECL(spx_word32_t *best_ener);
spx_word32_t e0;
VARDECL(spx_word32_t *corr);
VARDECL(spx_word32_t *energy);
@@ -180,6 +181,7 @@
spx_word16_t *swn;
ALLOC(best_score, N, spx_word32_t);
+ ALLOC(best_ener, N, spx_word32_t);
ALLOC(corr, end-start+1, spx_word32_t);
ALLOC(energy, end-start+2, spx_word32_t);
ALLOC(score, end-start+1, spx_word32_t);
@@ -195,6 +197,7 @@
for (i=0;i<N;i++)
{
best_score[i]=-1;
+ best_ener[i]=0;
pitch[i]=start;
}
@@ -244,15 +247,30 @@
#else
for (i=start;i<=end;i++)
{
- float g = corr[i-start]/(1+energy[i-start]);
- if (g>16)
- g = 16;
- else if (g<-16)
- g = -16;
- score[i-start] = g*corr[i-start];
+ float tmp = corr[i-start]*corr[i-start];
+ if (tmp*best_ener[N-1]>best_score[N-1]*(1+energy[i-start]))
+ {
+ for (j=0;j<N;j++)
+ {
+ if (tmp*best_ener[j]>best_score[j]*(1+energy[i-start]))
+ {
+ for (k=N-1;k>j;k--)
+ {
+ best_score[k]=best_score[k-1];
+ best_ener[k]=best_ener[k-1];
+ pitch[k]=pitch[k-1];
+ }
+ best_score[j]=tmp;
+ best_ener[j]=energy[i-start]+1;
+ pitch[j]=i;
+ break;
+ }
+ }
+ }
}
#endif
+#ifdef FIXED_POINT
/* Extract best scores */
for (i=start;i<=end;i++)
{
@@ -274,6 +292,7 @@
}
}
}
+#endif
/* Compute open-loop gain */
if (gain)
More information about the commits
mailing list