1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | |
27 | |
28 | |
29 | #if defined(HAVE_CONFIG_H1) |
30 | #include "config.h" |
31 | #endif |
32 | |
33 | #include "typedef.h" |
34 | #include "bv32cnst.h" |
35 | #include "bvcommon.h" |
36 | #include "bv32externs.h" |
37 | |
38 | int bv32_pitchtapquan(Float *x, |
39 | int pp, |
40 | Float *b) |
41 | { |
42 | Float p[9]; |
43 | Float t; |
44 | Float s0; |
45 | Float s1; |
46 | Float s2; |
47 | Float cormax; |
48 | Float cor; |
49 | Float t0; |
50 | Float t1; |
51 | Float t2; |
52 | Float *xt; |
53 | const Float *fp0; |
54 | Float *fp1; |
55 | const Float *fp2; |
56 | int ppm2; |
57 | int qidx = 0; |
58 | int i; |
59 | int j; |
60 | |
61 | ppm2 = pp - 2; |
62 | xt = x + XOFF(265 +1); |
63 | |
64 | for (i = 0; i < 3; i++) |
65 | { |
66 | fp0 = xt; |
67 | fp1 = x + XOFF(265 +1) - ppm2 - i - 1; |
68 | t = 0; |
69 | for (j = 0; j < FRSZ80; j++) |
70 | t += (*fp0++) * (*fp1++); |
71 | p[i] = t; |
72 | } |
73 | |
74 | fp0 = x + XOFF(265 +1) - ppm2 - 3; |
75 | s0 = *fp0++; |
76 | s1 = *fp0++; |
77 | s2 = *fp0--; |
78 | t0 = p[8] = s0*s0; |
79 | t1 = p[4] = s0*s1; |
80 | p[5] = s0*s2; |
81 | s0 = *fp0++; |
82 | s1 = *fp0++; |
83 | s2 = *fp0--; |
84 | t2 = s0*s0; |
85 | p[8] += t2; |
86 | p[4] += s0*s1; |
87 | p[5] += s0*s2; |
88 | for (i = 0; i < (FRSZ80 - 2); i++) |
89 | { |
90 | s0 = *fp0++; |
91 | s1 = *fp0++; |
92 | s2 = *fp0--; |
93 | p[8] += s0*s0; |
94 | p[4] += s0*s1; |
95 | p[5] += s0*s2; |
96 | } |
97 | s0 = *fp0++; |
98 | s1 = *fp0++; |
99 | s2 = *fp0--; |
| Value stored to 's2' is never read |
100 | p[7] = p[8] + (s0*s0) - t0; |
101 | p[3] = p[4] + (s0*s1) - t1; |
102 | p[6] = p[7] + (s1*s1) - t2; |
103 | |
104 | cormax = -1.0e30; |
105 | fp0 = bv32_pp9cb; |
106 | for (i = 0; i < PPCBSZ32; i++) |
107 | { |
108 | cor = 0.0; |
109 | fp1 = p; |
110 | for (j = 0; j < 9; j++) |
111 | cor += (*fp0++)*(*fp1++); |
112 | if (cor > cormax) |
113 | { |
114 | cormax = cor; |
115 | qidx = i; |
116 | } |
117 | } |
118 | |
119 | fp2 = bv32_pp9cb + qidx*9; |
120 | for (i = 0; i < 3; i++) |
121 | b[i] = fp2[i]*0.5; |
122 | |
123 | return qidx; |
124 | } |