/****************************************************************** iLBC Speech Coder ANSI-C Source Code StateSearchW.c Copyright (c) 2001, Global IP Sound AB. All rights reserved. ******************************************************************/ #include #include #include "iLBC_define.h" #include "constants.h" #include "filter.h" #include "helpfun.h" #include "StateSearchW.h" /*----------------------------------------------------------------* * predictive noise shaping encoding of scaled start state * (subrutine for StateSearchW) *---------------------------------------------------------------*/ void AbsQuantW( float *in, /* (i) vector to encode */ float *syntDenum, /* (i) denominator of synthesis filter */ float *weightDenum, /* (i) denominator of weighting filter */ int *out, /* (o) vector of quantizer indexes */ int len, /* (i) length of vector to encode and vector of quantizer indexes */ int state_first /* (i) position of start state in the 80 vec */ ){ float *syntOut, syntOutBuf[LPC_FILTERORDER+STATE_SHORT_LEN]; float toQ, xq; int n; int index; /* initialization of buffer for filtering */ memset(syntOutBuf, 0, LPC_FILTERORDER*sizeof(float)); /* initialization of pointer for filtering */ syntOut = &syntOutBuf[LPC_FILTERORDER]; /* synthesis and weighting filters on input */ if (state_first) { AllPoleFilter (in, weightDenum, SUBL, LPC_FILTERORDER); } else { AllPoleFilter (in, weightDenum, STATE_SHORT_LEN-SUBL, LPC_FILTERORDER); } /* encoding loop */ for(n=0;n maxVal*maxVal){ maxVal = fout[k]; } } maxVal=(float)fabs(maxVal); /* encoding of the maximum amplitude value */ if(maxVal < 10.0){ maxVal = 10.0; } maxVal = (float)log10(maxVal); sort_sq(&dtmp, idxForMax, maxVal, state_frgqTbl, 64); /* decoding of the maximum amplitude representation value, and corresponding scaling of start state */ maxVal=state_frgqTbl[*idxForMax]; qmax = (float)pow(10,maxVal); scal = (float)(4.5)/qmax; for(k=0;k