float *exc2, float *r,
spx_sig_t *exc2, spx_sig_t *r,
static float pitch_gain_search_3tap(float target[],                 /* Target vector */spx_coef_t ak[],                     /* LPCs for this subframe */spx_coef_t awk1[],                   /* Weighted LPCs #1 for this subframe */spx_coef_t awk2[],                   /* Weighted LPCs #2 for this subframe */float exc[],                    /* Excitation */void *par,int   pitch,                    /* Pitch value */int   p,                        /* Number of LPC coeffs */int   nsf,                      /* Number of samples in subframe */SpeexBits *bits,char *stack,float *exc2,float *r,int  *cdbk_index,int cdbk_offset){   int i,j;   float *tmp, *tmp2;   float *x[3];   float *e[3];   float corr[3];   float A[3][3];   float gain[3];   int   gain_cdbk_size;   signed char *gain_cdbk;   float err1,err2;   ltp_params *params;   params = (ltp_params*) par;   gain_cdbk_size = 1<<params->gain_bits;   gain_cdbk = params->gain_cdbk + 3*gain_cdbk_size*cdbk_offset;   tmp = PUSH(stack, 3*nsf, float);   tmp2 = PUSH(stack, 3*nsf, float);   x[0]=tmp;   x[1]=tmp+nsf;   x[2]=tmp+2*nsf;   e[0]=tmp2;   e[1]=tmp2+nsf;   e[2]=tmp2+2*nsf;      for (i=2;i>=0;i--)   {      int pp=pitch+1-i;      for (j=0;j<nsf;j++)      {         if (j-pp<0)            e[i][j]=exc2[j-pp];         else if (j-pp-pitch<0)            e[i][j]=exc2[j-pp-pitch];         else            e[i][j]=0;      }      if (i==2)         syn_percep_zero(e[i], ak, awk1, awk2, x[i], nsf, p, stack);      else {         for (j=0;j<nsf-1;j++)            x[i][j+1]=x[i+1][j];         x[i][0]=0;         for (j=0;j<nsf;j++)            x[i][j]+=e[i][0]*r[j]/SIG_SCALING;      }   }   for (i=0;i<3;i++)      corr[i]=inner_prod(x[i],target,nsf);      for (i=0;i<3;i++)      for (j=0;j<=i;j++)         A[i][j]=A[j][i]=inner_prod(x[i],x[j],nsf);      {      float C[9];      signed char *ptr=gain_cdbk;      int best_cdbk=0;      float best_sum=0;      C[0]=corr[2];      C[1]=corr[1];      C[2]=corr[0];      C[3]=A[1][2];      C[4]=A[0][1];      C[5]=A[0][2];      C[6]=A[2][2];      C[7]=A[1][1];      C[8]=A[0][0];            for (i=0;i<gain_cdbk_size;i++)      {         float sum=0;         float g0,g1,g2;         ptr = gain_cdbk+3*i;         g0=0.015625*ptr[0]+.5;         g1=0.015625*ptr[1]+.5;         g2=0.015625*ptr[2]+.5;         sum += C[0]*g0;         sum += C[1]*g1;         sum += C[2]*g2;         sum -= C[3]*g0*g1;         sum -= C[4]*g2*g1;         sum -= C[5]*g2*g0;         sum -= .5*C[6]*g0*g0;         sum -= .5*C[7]*g1*g1;         sum -= .5*C[8]*g2*g2;         /* If 1, force "safe" pitch values to handle packet loss better */         if (0) {            float tot = fabs(ptr[1]);            if (ptr[0]>0)               tot+=ptr[0];            if (ptr[2]>0)               tot+=ptr[2];            if (tot>1)               continue;         }         if (sum>best_sum || i==0)         {            best_sum=sum;            best_cdbk=i;         }      }      gain[0] = 0.015625*gain_cdbk[best_cdbk*3]  + .5;      gain[1] = 0.015625*gain_cdbk[best_cdbk*3+1]+ .5;      gain[2] = 0.015625*gain_cdbk[best_cdbk*3+2]+ .5;      *cdbk_index=best_cdbk;   }      for (i=0;i<nsf;i++)      exc[i]=gain[0]*e[2][i]+gain[1]*e[1][i]+gain[2]*e[0][i];      err1=0;   err2=0;   for (i=0;i<nsf;i++)      err1+=target[i]*target[i];   for (i=0;i<nsf;i++)      err2+=(target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i])      * (target[i]-gain[2]*x[0][i]-gain[1]*x[1][i]-gain[0]*x[2][i]);   return err2;}