18 #include "iLBC_define.h"
19 #include "constants.h"
38 float tempbuff2[CB_MEML+CB_FILTERLEN];
41 memset(tempbuff2, 0, (CB_HALFFILTERLEN-1)*
sizeof(
float));
42 memcpy(&tempbuff2[CB_HALFFILTERLEN-1], mem, lMem*
sizeof(
float));
43 memset(&tempbuff2[lMem+CB_HALFFILTERLEN-1], 0,
44 (CB_HALFFILTERLEN+1)*
sizeof(
float));
50 memset(pos, 0, lMem*
sizeof(
float));
51 for (k=0; k<lMem; k++) {
53 pp1=&cbfiltersTbl[CB_FILTERLEN-1];
54 for (j=0;j<CB_FILTERLEN;j++) {
55 (*pos)+=(*pp++)*(*pp1--);
71 void searchAugmentedCB(
88 int icount, ilow, j, tmpIndex;
89 float *pp, *ppo, *ppi, *ppe, crossDot, alfa;
90 float weighted, measure, nrjRecursive;
95 nrjRecursive = (float) 0.0;
96 pp = buffer - low + 1;
97 for (j=0; j<(low-5); j++) {
98 nrjRecursive += ( (*pp)*(*pp) );
104 for (icount=low; icount<=high; icount++) {
108 tmpIndex = startIndex+icount-20;
113 nrjRecursive = nrjRecursive + (*ppe)*(*ppe);
115 energy[tmpIndex] = nrjRecursive;
124 crossDot = (float) 0.0;
126 for (j=0; j<ilow; j++) {
127 crossDot += target[j]*(*pp++);
133 ppi = buffer-icount-4;
134 for (j=ilow; j<icount; j++) {
135 weighted = ((float)1.0-alfa)*(*ppo)+alfa*(*ppi);
138 energy[tmpIndex] += weighted*weighted;
139 crossDot += target[j]*weighted;
145 pp = buffer - icount;
146 for (j=icount; j<SUBL; j++) {
147 energy[tmpIndex] += (*pp)*(*pp);
148 crossDot += target[j]*(*pp++);
151 if (energy[tmpIndex]>0.0) {
152 invenergy[tmpIndex]=(float)1.0/(energy[tmpIndex]+EPS);
154 invenergy[tmpIndex] = (float) 0.0;
158 measure = (float)-10000000.0;
160 if (crossDot > 0.0) {
161 measure = crossDot*crossDot*invenergy[tmpIndex];
165 measure = crossDot*crossDot*invenergy[tmpIndex];
169 ftmp = crossDot*invenergy[tmpIndex];
171 if ((measure>*max_measure) && (fabs(ftmp)<CB_MAXGAIN)) {
177 *best_index = tmpIndex;
178 *max_measure = measure;
190 void createAugmentedVec(
198 float *pp, *ppo, *ppi, alfa, alfa1, weighted;
205 memcpy(cbVec,pp,
sizeof(
float)*index);
212 ppi = buffer-index-5;
213 for (j=ilow; j<index; j++) {
214 weighted = ((float)1.0-alfa)*(*ppo)+alfa*(*ppi);
224 memcpy(cbVec+index,pp,
sizeof(
float)*(SUBL-index));