23 {
25 int n, l, max_ssqEn_n;
26 const float ssqEn_win[
NSUB_MAX-1]={(float)0.8,(
float)0.9,
27 (float)1.0,(float)0.9,(float)0.8};
28 const float sampEn_win[5]={(float)1.0/(float)6.0,
29 (float)2.0/(float)6.0, (float)3.0/(float)6.0,
30 (float)4.0/(float)6.0, (float)5.0/(float)6.0};
31
32
33
34 memset(fssqEn, 0,
NSUB_MAX*
sizeof(
float));
35 memset(bssqEn, 0,
NSUB_MAX*
sizeof(
float));
36
37
38
39 n=0;
40 pp=residual;
41 for (l=0; l<5; l++) {
42 fssqEn[n] += sampEn_win[l] * (*pp) * (*pp);
43 pp++;
44 }
45 for (l=5; l<
SUBL; l++) {
46
47
48
49
50
51 fssqEn[n] += (*pp) * (*pp);
52 pp++;
53 }
54
55
56
57 for (n=1; n<iLBCenc_inst->
nsub-1; n++) {
59 for (l=0; l<5; l++) {
60 fssqEn[n] += sampEn_win[l] * (*pp) * (*pp);
61 bssqEn[n] += (*pp) * (*pp);
62 pp++;
63 }
64 for (l=5; l<
SUBL-5; l++) {
65 fssqEn[n] += (*pp) * (*pp);
66 bssqEn[n] += (*pp) * (*pp);
67 pp++;
68 }
70 fssqEn[n] += (*pp) * (*pp);
71 bssqEn[n] += sampEn_win[
SUBL-l-1] * (*pp) * (*pp);
72 pp++;
73 }
74 }
75
76
77
78 n=iLBCenc_inst->
nsub-1;
80 for (l=0; l<
SUBL-5; l++) {
81 bssqEn[n] += (*pp) * (*pp);
82 pp++;
83 }
85 bssqEn[n] += sampEn_win[
SUBL-l-1] * (*pp) * (*pp);
86 pp++;
87 }
88
89
90
91
92 if (iLBCenc_inst->
mode==20) l=1;
93 else l=0;
94
95 max_ssqEn=(fssqEn[0]+bssqEn[1])*ssqEn_win[l];
96 max_ssqEn_n=1;
97 for (n=2; n<iLBCenc_inst->
nsub; n++) {
98
99
100
101
102
103
104 l++;
105 if ((fssqEn[n-1]+bssqEn[n])*ssqEn_win[l] > max_ssqEn) {
106 max_ssqEn=(fssqEn[n-1]+bssqEn[n]) *
107 ssqEn_win[l];
108 max_ssqEn_n=n;
109 }
110 }
111
112 return max_ssqEn_n;
113 }