float tmp;
void *nb_encoder_init(SpeexMode *m){   EncState *st;   SpeexNBMode *mode;   int i;   float tmp;   mode=m->mode;   st = malloc(sizeof(EncState));   st->mode=m;   /* Codec parameters, should eventually have several "modes"*/   st->frameSize = mode->frameSize;   st->windowSize = mode->windowSize;   st->nbSubframes=mode->frameSize/mode->subframeSize;   st->subframeSize=mode->subframeSize;   st->lpcSize = mode->lpcSize;   st->bufSize = mode->bufSize;   st->gamma1=mode->gamma1;   st->gamma2=mode->gamma2;   st->min_pitch=mode->pitchStart;   st->max_pitch=mode->pitchEnd;   st->lag_factor=mode->lag_factor;   st->lpc_floor = mode->lpc_floor;   st->preemph = mode->preemph;     st->lsp_quant = mode->lsp_quant;   st->ltp_quant = mode->ltp_quant;   st->ltp_params = mode->ltp_params;   st->innovation_quant = mode->innovation_quant;   st->innovation_params = mode->innovation_params;   st->pre_mem=0;   st->pre_mem2=0;   /* Over-sampling filter (fractional pitch)*/   st->os_fact=4;   st->os_filt_ord2=4*st->os_fact;   st->os_filt = malloc((1+2*st->os_filt_ord2)*sizeof(float));   st->os_filt[st->os_filt_ord2] = 1;   for (i=1;i<=st->os_filt_ord2;i++)   {      float x=M_PI*i/st->os_fact;      st->os_filt[st->os_filt_ord2-i] = st->os_filt[st->os_filt_ord2+i]=sin(x)/x*(.5+.5*cos(M_PI*i/st->os_filt_ord2));   }   /* Normalizing the over-sampling filter */   tmp=0;   for (i=0;i<2*st->os_filt_ord2+1;i++)      tmp += st->os_filt[i];   tmp=1/tmp;   for (i=0;i<2*st->os_filt_ord2+1;i++)      st->os_filt[i] *= tmp;   /*for (i=0;i<2*st->os_filt_ord2+1;i++)      printf ("%f ", st->os_filt[i]);      printf ("\n");*/   /* Allocating input buffer */   st->inBuf = calloc(st->bufSize,sizeof(float));   st->frame = st->inBuf + st->bufSize - st->windowSize;   /* Allocating excitation buffer */   st->excBuf = calloc(st->bufSize,sizeof(float));   st->exc = st->excBuf + st->bufSize - st->windowSize;   st->swBuf = calloc(st->bufSize,sizeof(float));   st->sw = st->swBuf + st->bufSize - st->windowSize;   st->exc2Buf = calloc(st->bufSize,sizeof(float));   st->exc2 = st->exc2Buf + st->bufSize - st->windowSize;   /* Hanning window */   st->window = malloc(st->windowSize*sizeof(float));   for (i=0;i<st->windowSize;i++)      st->window[i]=.5*(1-cos(2*M_PI*i/st->windowSize));   /* Create the window for autocorrelation (lag-windowing) */   st->lagWindow = malloc((st->lpcSize+1)*sizeof(float));   for (i=0;i<st->lpcSize+1;i++)      st->lagWindow[i]=exp(-.5*sqr(2*M_PI*st->lag_factor*i));   st->autocorr = malloc((st->lpcSize+1)*sizeof(float));   st->stack = calloc(20000, sizeof(float));   st->buf2 = malloc(st->windowSize*sizeof(float));   st->lpc = malloc((st->lpcSize+1)*sizeof(float));   st->interp_lpc = malloc((st->lpcSize+1)*sizeof(float));   st->interp_qlpc = malloc((st->lpcSize+1)*sizeof(float));   st->bw_lpc1 = malloc((st->lpcSize+1)*sizeof(float));   st->bw_lpc2 = malloc((st->lpcSize+1)*sizeof(float));   st->lsp = malloc(st->lpcSize*sizeof(float));   st->qlsp = malloc(st->lpcSize*sizeof(float));   st->old_lsp = malloc(st->lpcSize*sizeof(float));   st->old_qlsp = malloc(st->lpcSize*sizeof(float));   st->interp_lsp = malloc(st->lpcSize*sizeof(float));   st->interp_qlsp = malloc(st->lpcSize*sizeof(float));   st->rc = malloc(st->lpcSize*sizeof(float));   st->first = 1;      st->mem_sp = calloc(st->lpcSize, sizeof(float));   st->mem_sw = calloc(st->lpcSize, sizeof(float));   st->pi_gain = calloc(st->nbSubframes, sizeof(float));   st->pitch = calloc(st->nbSubframes, sizeof(int));   return st;}