comb_gain = MULT16_16_Q15(DIV32_16(SHL(165,15),g), comb_gain);
comb_gain = MULT16_16_Q15(DIV32_16(SHL32(EXTEND32(165),15),g), comb_gain);
void comb_filter(spx_sig_t *exc,          /*decoded excitation*/spx_sig_t *new_exc,      /*enhanced excitation*/spx_coef_t *ak,           /*LPC filter coefs*/int p,               /*LPC order*/int nsf,             /*sub-frame size*/int pitch,           /*pitch period*/spx_word16_t *pitch_gain,   /*pitch gain (3-tap)*/spx_word16_t  comb_gain,    /*gain of comb filter*/CombFilterMem *mem){   int i;   spx_word16_t exc_energy=0, new_exc_energy=0;   spx_word16_t gain;   spx_word16_t step;   spx_word16_t fact;   /*Compute excitation amplitude prior to enhancement*/   exc_energy = compute_rms(exc, nsf);   /*for (i=0;i<nsf;i++)     exc_energy+=((float)exc[i])*exc[i];*/   /*Some gain adjustment if pitch is too high or if unvoiced*/#ifdef FIXED_POINT   {      spx_word16_t g = gain_3tap_to_1tap(pitch_gain)+gain_3tap_to_1tap(mem->last_pitch_gain);      if (g > 166)         comb_gain = MULT16_16_Q15(DIV32_16(SHL(165,15),g), comb_gain);      if (g < 64)         comb_gain = MULT16_16_Q15(SHL(g, 9), comb_gain);   }#else   {      float g=0;      g = GAIN_SCALING_1*.5*(gain_3tap_to_1tap(pitch_gain)+gain_3tap_to_1tap(mem->last_pitch_gain));      if (g>1.3)         comb_gain*=1.3/g;      if (g<.5)         comb_gain*=2.*g;   }#endif   step = DIV32(COMB_STEP, nsf);   fact=0;   /*Apply pitch comb-filter (filter out noise between pitch harmonics)*/   for (i=0;i<nsf;i++)   {      spx_word32_t exc1, exc2;      fact = ADD16(fact,step);            exc1 = SHL32(MULT16_32_Q15(SHL16(pitch_gain[0],7),exc[i-pitch+1]) +                 MULT16_32_Q15(SHL16(pitch_gain[1],7),exc[i-pitch]) +                 MULT16_32_Q15(SHL16(pitch_gain[2],7),exc[i-pitch-1]) , 2);      exc2 = SHL32(MULT16_32_Q15(SHL16(mem->last_pitch_gain[0],7),exc[i-mem->last_pitch+1]) +                 MULT16_32_Q15(SHL16(mem->last_pitch_gain[1],7),exc[i-mem->last_pitch]) +                 MULT16_32_Q15(SHL16(mem->last_pitch_gain[2],7),exc[i-mem->last_pitch-1]),2);      new_exc[i] = exc[i] + MULT16_32_Q15(comb_gain, ADD32(MULT16_32_Q15(fact,exc1), MULT16_32_Q15(SUB16(COMB_STEP,fact), exc2)));   }   mem->last_pitch_gain[0] = pitch_gain[0];   mem->last_pitch_gain[1] = pitch_gain[1];   mem->last_pitch_gain[2] = pitch_gain[2];   mem->last_pitch = pitch;   /*Amplitude after enhancement*/   new_exc_energy = compute_rms(new_exc, nsf);   if (exc_energy > new_exc_energy)      exc_energy = new_exc_energy;      gain = DIV32_16(SHL32(EXTEND32(exc_energy),15),ADD16(1,new_exc_energy));#ifdef FIXED_POINT   if (gain < 16384)      gain = 16384;#else   if (gain < .5)      gain=.5;#endif#ifdef FIXED_POINT   for (i=0;i<nsf;i++)   {      mem->smooth_gain = ADD16(MULT16_16_Q15(31457,mem->smooth_gain), MULT16_16_Q15(1311,gain));      new_exc[i] = MULT16_32_Q15(mem->smooth_gain, new_exc[i]);   }#else   for (i=0;i<nsf;i++)   {      mem->smooth_gain = .96*mem->smooth_gain + .04*gain;      new_exc[i] *= mem->smooth_gain;   }#endif}