StateConstructW.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /******************************************************************
  2. iLBC Speech Coder ANSI-C Source Code
  3. StateConstructW.c
  4. Copyright (C) The Internet Society (2004).
  5. All Rights Reserved.
  6. ******************************************************************/
  7. #include <math.h>
  8. #include <string.h>
  9. #include "iLBC_define.h"
  10. #include "StateConstructW.h"
  11. #include "constants.h"
  12. #include "filter.h"
  13. /*----------------------------------------------------------------*
  14. * decoding of the start state
  15. *---------------------------------------------------------------*/
  16. void StateConstructW(
  17. int idxForMax, /* (i) 6-bit index for the quantization of
  18. max amplitude */
  19. int *idxVec, /* (i) vector of quantization indexes */
  20. float *syntDenum, /* (i) synthesis filter denumerator */
  21. float *out, /* (o) the decoded state vector */
  22. int len /* (i) length of a state vector */
  23. ){
  24. float maxVal, tmpbuf[LPC_FILTERORDER+2*STATE_LEN], *tmp,
  25. numerator[LPC_FILTERORDER+1];
  26. float foutbuf[LPC_FILTERORDER+2*STATE_LEN], *fout;
  27. int k,tmpi;
  28. /* decoding of the maximum value */
  29. maxVal = state_frgqTbl[idxForMax];
  30. maxVal = (float)pow(10,maxVal)/(float)4.5;
  31. /* initialization of buffers and coefficients */
  32. memset(tmpbuf, 0, LPC_FILTERORDER*sizeof(float));
  33. memset(foutbuf, 0, LPC_FILTERORDER*sizeof(float));
  34. for (k=0; k<LPC_FILTERORDER; k++) {
  35. numerator[k]=syntDenum[LPC_FILTERORDER-k];
  36. }
  37. numerator[LPC_FILTERORDER]=syntDenum[0];
  38. tmp = &tmpbuf[LPC_FILTERORDER];
  39. fout = &foutbuf[LPC_FILTERORDER];
  40. /* decoding of the sample values */
  41. for (k=0; k<len; k++) {
  42. tmpi = len-1-k;
  43. /* maxVal = 1/scal */
  44. tmp[k] = maxVal*state_sq3Tbl[idxVec[tmpi]];
  45. }
  46. /* circular convolution with all-pass filter */
  47. memset(tmp+len, 0, len*sizeof(float));
  48. ZeroPoleFilter(tmp, numerator, syntDenum, 2*len,
  49. LPC_FILTERORDER, fout);
  50. for (k=0;k<len;k++) {
  51. out[k] = fout[len-1-k]+fout[2*len-1-k];
  52. }
  53. }