Utilise new MergeSym feature to no longer overwrite the source .DEF file when buildin...
[openh323.git] / src / iLBC / StateConstructW.c
blobb5f77e0e3eccacf702a898e327b6afe1beada33e
2 /******************************************************************
4 iLBC Speech Coder ANSI-C Source Code
6 StateConstructW.c
8 Copyright (c) 2001,
9 Global IP Sound AB.
10 All rights reserved.
12 ******************************************************************/
14 #include <math.h>
15 #include <string.h>
17 #include "iLBC_define.h"
18 #include "constants.h"
19 #include "filter.h"
21 /*----------------------------------------------------------------*
22 * decoding of the start state
23 *---------------------------------------------------------------*/
25 void StateConstructW(
26 int idxForMax, /* (i) 6-bit index for the quantization of
27 max amplitude */
28 int *idxVec, /* (i) vector of quantization indexes */
29 float *syntDenum, /* (i) synthesis filter denumerator */
30 float *out, /* (o) the decoded state vector */
31 int len /* (i) length of a state vector */
32 ){
33 float maxVal, tmpbuf[LPC_FILTERORDER+2*STATE_LEN], *tmp,
34 numerator[LPC_FILTERORDER+1];
35 float foutbuf[LPC_FILTERORDER+2*STATE_LEN], *fout;
36 int k,tmpi;
38 /* decoding of the maximum value */
40 maxVal = state_frgqTbl[idxForMax];
41 maxVal = (float)pow(10,maxVal)/(float)4.5;
43 /* initialization of buffers and coefficients */
45 memset(tmpbuf, 0, LPC_FILTERORDER*sizeof(float));
46 memset(foutbuf, 0, LPC_FILTERORDER*sizeof(float));
47 for (k=0; k<LPC_FILTERORDER; k++) {
48 numerator[k]=syntDenum[LPC_FILTERORDER-k];
50 numerator[LPC_FILTERORDER]=syntDenum[0];
51 tmp = &tmpbuf[LPC_FILTERORDER];
55 fout = &foutbuf[LPC_FILTERORDER];
57 /* decoding of the sample values */
59 for (k=0; k<len; k++) {
60 tmpi = len-1-k;
61 /* maxVal = 1/scal */
62 tmp[k] = maxVal*state_sq3Tbl[idxVec[tmpi]];
65 /* circular convolution with all-pass filter */
67 memset(tmp+len, 0, len*sizeof(float));
68 ZeroPoleFilter(tmp, numerator, syntDenum, 2*len,
69 LPC_FILTERORDER, fout);
70 for (k=0;k<len;k++) {
71 out[k] = fout[len-1-k]+fout[2*len-1-k];