38 float ftmp1, ftmp2, ftmp3;
41 if ((bLen-sRange-lag)<0) {
48 for (i=0; i<sRange; i++) {
49 ftmp1 += buffer[bLen-sRange+i] *
50 buffer[bLen-sRange+i-lag];
51 ftmp2 += buffer[bLen-sRange+i-lag] *
52 buffer[bLen-sRange+i-lag];
53 ftmp3 += buffer[bLen-sRange+i] *
54 buffer[bLen-sRange+i];
58 *cc = ftmp1*ftmp1/ftmp2;
59 *gc = (float)fabs(ftmp1/ftmp2);
60 *pm=(float)fabs(ftmp1)/
61 ((float)sqrt(ftmp2)*(float)sqrt(ftmp3));
93 float gain_comp, maxcc_comp, per, max_per=0;
95 float ftmp, randvec[
BLOCKL_MAX], pitchfact, energy;
106 if (iLBCdec_inst->
prevPLI != 1) {
114 lag, iLBCdec_inst->
blockl, 60);
115 for (i=inlag-2;i<=inlag+3;i++) {
116 compCorr(&maxcc_comp, &gain_comp, &per,
118 i, iLBCdec_inst->
blockl, 60);
120 if (maxcc_comp>maxcc) {
139 max_per=iLBCdec_inst->
per;
148 iLBCdec_inst->
blockl>2*320)
151 iLBCdec_inst->
blockl>3*320)
154 iLBCdec_inst->
blockl>4*320)
158 ftmp=(float)sqrt(max_per);
160 pitchfact=(float)1.0;
161 else if (ftmp>(
float)0.4)
162 pitchfact=(ftmp-(float)0.4)/((float)0.7-(
float)0.4);
181 for (i=0; i<iLBCdec_inst->
blockl; i++) {
185 iLBCdec_inst->
seed=(iLBCdec_inst->
seed*69069L+1) &
187 randlag = 50 + ((
signed long) iLBCdec_inst->
seed)%70;
193 iLBCdec_inst->
blockl+pick];
195 randvec[i] = randvec[pick];
204 iLBCdec_inst->
blockl+pick];
206 PLCresidual[i] = PLCresidual[pick];
212 PLCresidual[i] = use_gain*(pitchfact *
214 ((float)1.0 - pitchfact) * randvec[i]);
216 PLCresidual[i] = (float)0.95*use_gain*(pitchfact *
218 ((
float)1.0 - pitchfact) * randvec[i]);
220 PLCresidual[i] = (float)0.9*use_gain*(pitchfact *
222 ((
float)1.0 - pitchfact) * randvec[i]);
224 energy += PLCresidual[i] * PLCresidual[i];
234 if (sqrt(energy/(
float)iLBCdec_inst->
blockl) < 30.0) {
236 for (i=0; i<iLBCdec_inst->
blockl; i++) {
237 PLCresidual[i] = randvec[i];
243 memcpy(PLClpc,iLBCdec_inst->
prevLpc,
251 memcpy(PLCresidual, decresidual,
252 iLBCdec_inst->
blockl*
sizeof(
float));
261 iLBCdec_inst->
per=max_per;
265 memcpy(iLBCdec_inst->
prevLpc, PLClpc,
268 iLBCdec_inst->
blockl*
sizeof(
float));
float prevResidual[NSUB_MAX *SUBL]
void compCorr(float *cc, float *gc, float *pm, float *buffer, int lag, int bLen, int sRange)
void doThePLC(float *PLCresidual, float *PLClpc, int PLI, float *decresidual, float *lpc, int inlag, iLBC_Dec_Inst_t *iLBCdec_inst)
float prevLpc[LPC_FILTERORDER+1]