open_loop_pitch(sw, nsf, end, nsf, &ol_pitch);  if (ol_pitch-N<start) ol_pitch=start+N; if (ol_pitch+N>end) ol_pitch=end-N;  for (pitch=ol_pitch-N; pitch<=ol_pitch+N; pitch++) { for (j=0;j<nsf;j++) exc[j]=0; err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, par, pitch, p, nsf, bits, stack, exc2, &cdbk_index); if (err<best_err || best_err<0) { for (j=0;j<nsf;j++) best_exc[j]=exc[j]; best_err=err; best_pitch=pitch; best_gain_index=cdbk_index; } }
int pitch_search_3tap(float target[],                 /* Target vector */float *sw,float ak[],                     /* LPCs for this subframe */float awk1[],                   /* Weighted LPCs #1 for this subframe */float awk2[],                   /* Weighted LPCs #2 for this subframe */float exc[],                    /* Excitation */void *par,int   start,                    /* Smallest pitch value allowed */int   end,                      /* Largest pitch value allowed */int   p,                        /* Number of LPC coeffs */int   nsf,                      /* Number of samples in subframe */SpeexBits *bits,float *stack,float *exc2){   int i,j;   int cdbk_index, pitch, ol_pitch, best_gain_index=0;   float *best_exc;   int best_pitch=0;   float err, best_err=-1;   int N=1;   ltp_params *params;   params = (ltp_params*) par;   best_exc=PUSH(stack,nsf);   open_loop_pitch(sw, start, nsf, nsf, &ol_pitch);   if (ol_pitch-N<start)      ol_pitch=start+N;   if (ol_pitch+N>end)      ol_pitch=end-N;   for (pitch=ol_pitch-N; pitch<=ol_pitch+N; pitch++)   {      for (j=0;j<nsf;j++)         exc[j]=0;      err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, par, pitch, p, nsf,                             bits, stack, exc2, &cdbk_index);      if (err<best_err || best_err<0)      {         for (j=0;j<nsf;j++)            best_exc[j]=exc[j];         best_err=err;         best_pitch=pitch;         best_gain_index=cdbk_index;      }   }   open_loop_pitch(sw, nsf, end, nsf, &ol_pitch);   if (ol_pitch-N<start)      ol_pitch=start+N;   if (ol_pitch+N>end)      ol_pitch=end-N;   for (pitch=ol_pitch-N; pitch<=ol_pitch+N; pitch++)   {      for (j=0;j<nsf;j++)         exc[j]=0;      err=pitch_gain_search_3tap(target, ak, awk1, awk2, exc, par, pitch, p, nsf,                             bits, stack, exc2, &cdbk_index);      if (err<best_err || best_err<0)      {         for (j=0;j<nsf;j++)            best_exc[j]=exc[j];         best_err=err;         best_pitch=pitch;         best_gain_index=cdbk_index;      }   }   /*printf ("pitch: %d %d\n", best_pitch, best_gain_index);*/   speex_bits_pack(bits, best_pitch-start, params->pitch_bits);   speex_bits_pack(bits, best_gain_index, params->gain_bits);   /*printf ("encode pitch: %d %d\n", best_pitch, best_gain_index);*/   for (i=0;i<nsf;i++)      exc[i]=best_exc[i];   POP(stack);   return pitch;}