StateConstructW.c 2.2 KB

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