g = DIV32(corr[i-start], 10+SHR(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
g = DIV32(corr[i-start], 10+SHR32(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));
void open_loop_nbest_pitch(spx_sig_t *sw, int start, int end, int len, int *pitch, spx_word16_t *gain, int N, char *stack){   int i,j,k;   VARDECL(spx_word32_t *best_score);   spx_word32_t e0;   VARDECL(spx_word32_t *corr);   VARDECL(spx_word32_t *energy);   VARDECL(spx_word32_t *score);   VARDECL(spx_word16_t *swn2);   spx_word16_t *swn;   ALLOC(best_score, N, spx_word32_t);   ALLOC(corr, end-start+1, spx_word32_t);   ALLOC(energy, end-start+2, spx_word32_t);   ALLOC(score, end-start+1, spx_word32_t);#ifdef FIXED_POINT   ALLOC(swn2, end+len, spx_word16_t);   normalize16(sw-end, swn2, 16384, end+len);   swn = swn2 + end;#else   swn = sw;#endif   for (i=0;i<N;i++)   {        best_score[i]=-1;        pitch[i]=start;   }   energy[0]=inner_prod(swn-start, swn-start, len);   e0=inner_prod(swn, swn, len);   for (i=start;i<=end;i++)   {      /* Update energy for next pitch*/      energy[i-start+1] = energy[i-start] + SHR(MULT16_16(swn[-i-1],swn[-i-1]),6) - SHR(MULT16_16(swn[-i+len-1],swn[-i+len-1]),6);   }   pitch_xcorr(swn, swn-end, corr, len, end-start+1, stack);#ifdef FIXED_POINT   {      VARDECL(spx_word16_t *corr16);      VARDECL(spx_word16_t *ener16);      ALLOC(corr16, end-start+1, spx_word16_t);      ALLOC(ener16, end-start+1, spx_word16_t);      normalize16(corr, corr16, 16384, end-start+1);      normalize16(energy, ener16, 16384, end-start+1);      for (i=start;i<=end;i++)      {         spx_word16_t g;         spx_word32_t tmp;         tmp = corr16[i-start];         if (tmp>0)         {            if (SHR(corr16[i-start],4)>ener16[i-start])               tmp = SHL((spx_word32_t)ener16[i-start],14);            else if (-SHR(corr16[i-start],4)>ener16[i-start])               tmp = -SHL((spx_word32_t)ener16[i-start],14);            else               tmp = SHL(tmp,10);            g = DIV32_16(tmp, 8+ener16[i-start]);            score[i-start] = MULT16_16(corr16[i-start],g);         } else         {            score[i-start] = 1;         }      }   }#else   for (i=start;i<=end;i++)   {      float g = corr[i-start]/(1+energy[i-start]);      if (g>16)         g = 16;      else if (g<-16)         g = -16;      score[i-start] = g*corr[i-start];   }#endif   /* Extract best scores */   for (i=start;i<=end;i++)   {      if (score[i-start]>best_score[N-1])      {         for (j=0;j<N;j++)         {            if (score[i-start] > best_score[j])            {               for (k=N-1;k>j;k--)               {                  best_score[k]=best_score[k-1];                  pitch[k]=pitch[k-1];               }               best_score[j]=score[i-start];               pitch[j]=i;               break;            }         }      }   }   /* Compute open-loop gain */   if (gain)   {       for (j=0;j<N;j++)       {          spx_word16_t g;          i=pitch[j];          g = DIV32(corr[i-start], 10+SHR(MULT16_16(spx_sqrt(e0),spx_sqrt(energy[i-start])),6));          /* FIXME: g = max(g,corr/energy) */                   if (g<0)                   g = 0;             gain[j]=g;       }   }}