Mercurial > libavcodec.hg
comparison lpc.c @ 7748:5044f9b6aadf libavcodec
Merge declaration and initialization of a few vars in compute_lpc_coefs()
author | vitor |
---|---|
date | Sun, 31 Aug 2008 02:31:05 +0000 |
parents | d8849273139c |
children | 816293be2e54 |
comparison
equal
deleted
inserted
replaced
7747:54bcd7270fd9 | 7748:5044f9b6aadf |
---|---|
30 */ | 30 */ |
31 static void compute_lpc_coefs(const double *autoc, int max_order, | 31 static void compute_lpc_coefs(const double *autoc, int max_order, |
32 double lpc[][MAX_LPC_ORDER], double *ref) | 32 double lpc[][MAX_LPC_ORDER], double *ref) |
33 { | 33 { |
34 int i, j, i2; | 34 int i, j, i2; |
35 double r, err, tmp; | 35 double err = autoc[0]; |
36 double lpc_tmp[MAX_LPC_ORDER]; | 36 double lpc_tmp[MAX_LPC_ORDER]; |
37 | 37 |
38 err = autoc[0]; | |
39 | |
40 for(i=0; i<max_order; i++) { | 38 for(i=0; i<max_order; i++) { |
41 r = -autoc[i+1]; | 39 double r = -autoc[i+1]; |
42 for(j=0; j<i; j++) { | 40 for(j=0; j<i; j++) { |
43 r -= lpc_tmp[j] * autoc[i-j]; | 41 r -= lpc_tmp[j] * autoc[i-j]; |
44 } | 42 } |
45 r /= err; | 43 r /= err; |
46 ref[i] = fabs(r); | 44 ref[i] = fabs(r); |
48 err *= 1.0 - (r * r); | 46 err *= 1.0 - (r * r); |
49 | 47 |
50 i2 = (i >> 1); | 48 i2 = (i >> 1); |
51 lpc_tmp[i] = r; | 49 lpc_tmp[i] = r; |
52 for(j=0; j<i2; j++) { | 50 for(j=0; j<i2; j++) { |
53 tmp = lpc_tmp[j]; | 51 double tmp = lpc_tmp[j]; |
54 lpc_tmp[j] += r * lpc_tmp[i-1-j]; | 52 lpc_tmp[j] += r * lpc_tmp[i-1-j]; |
55 lpc_tmp[i-1-j] += r * tmp; | 53 lpc_tmp[i-1-j] += r * tmp; |
56 } | 54 } |
57 if(i & 1) { | 55 if(i & 1) { |
58 lpc_tmp[j] += lpc_tmp[j] * r; | 56 lpc_tmp[j] += lpc_tmp[j] * r; |