The levinson_durbin algorithm in lpc.c has a couple of arrays that are not
used. I changed the code to use just a variable instead. Not a lot of
memory saved, but this routine is called every encode frame (20 or 40 ms).
To check that the algorithm works the same, I used c2enc with hts1a.raw and
checked that the output values were the same. Here's a snippet:
Old algorithm: 1.000000 -1.930401 1.770051 -1.443837 0.961698 -0.523273
0.465262 -0.275403 0.496277 -0.624951
New algorithm: 1.000000 -1.930401 1.770051 -1.443837 0.961698 -0.523273
0.465262 -0.275403 0.496277 -0.624951
Old algorithm: 1.000000 -1.255710 0.800782 -1.023655 0.902301 -0.582309
0.414592 -0.220164 0.191661 -0.027249
New algorithm: 1.000000 -1.255710 0.800782 -1.023655 0.902301 -0.582309
0.414592 -0.220164 0.191661 -0.027249
diff -ruN freetel-code/codec2-dev/src/lpc.c
freetel-code-new/codec2-dev/src/lpc.c
--- freetel-code/codec2-dev/src/lpc.c 2014-06-26 08:08:06.042562836 -0500
+++ freetel-code-new/codec2-dev/src/lpc.c 2014-06-26 08:15:22.090549952
-0500
@@ -156,28 +156,26 @@
int order /* order of the LPC analysis */
)
{
- float E[order+1];
- float k[order+1];
float a[order+1][order+1];
- float sum;
+ float sum, e, k;
int i,j; /* loop variables */
- E[0] = R[0]; /* Equation 38a, Makhoul */
+ e = R[0]; /* Equation 38a, Makhoul */
for(i=1; i<=order; i++) {
sum = 0.0;
for(j=1; j<=i-1; j++)
sum += a[i-1][j]*R[i-j];
- k[i] = -1.0*(R[i] + sum)/E[i-1]; /* Equation 38b, Makhoul */
- if (fabsf(k[i]) > 1.0)
- k[i] = 0.0;
+ k = -1.0*(R[i] + sum)/e; /* Equation 38b, Makhoul */
+ if (fabsf(k) > 1.0)
+ k = 0.0;
- a[i][i] = k[i];
+ a[i][i] = k;
for(j=1; j<=i-1; j++)
- a[i][j] = a[i-1][j] + k[i]*a[i-1][i-j]; /* Equation 38c, Makhoul */
+ a[i][j] = a[i-1][j] + k*a[i-1][i-j]; /* Equation 38c, Makhoul */
- E[i] = (1-k[i]*k[i])*E[i-1]; /* Equation 38d, Makhoul */
+ e *= (1-k*k); /* Equation 38d, Makhoul */
}
for(i=1; i<=order; i++)
------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Freetel-codec2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freetel-codec2