Mercurial > hg > audiostuff
comparison intercom/ilbc/StateConstructW.c @ 2:13be24d74cd2
import intercom-0.4.1
author | Peter Meerwald <pmeerw@cosy.sbg.ac.at> |
---|---|
date | Fri, 25 Jun 2010 09:57:52 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:9cadc470e3da | 2:13be24d74cd2 |
---|---|
1 | |
2 /****************************************************************** | |
3 | |
4 iLBC Speech Coder ANSI-C Source Code | |
5 | |
6 StateConstructW.c | |
7 | |
8 Copyright (C) The Internet Society (2004). | |
9 All Rights Reserved. | |
10 | |
11 ******************************************************************/ | |
12 | |
13 #include <math.h> | |
14 #include <string.h> | |
15 | |
16 #include "iLBC_define.h" | |
17 #include "constants.h" | |
18 #include "filter.h" | |
19 | |
20 /*----------------------------------------------------------------* | |
21 * decoding of the start state | |
22 *---------------------------------------------------------------*/ | |
23 | |
24 void StateConstructW(int idxForMax, /* (i) 6-bit index for the quantization of | |
25 max amplitude */ | |
26 int *idxVec, /* (i) vector of quantization indexes */ | |
27 float *syntDenum, /* (i) synthesis filter denumerator */ | |
28 float *out, /* (o) the decoded state vector */ | |
29 int len /* (i) length of a state vector */ | |
30 ) | |
31 { | |
32 float maxVal, tmpbuf[LPC_FILTERORDER + 2 * STATE_LEN], *tmp, | |
33 numerator[LPC_FILTERORDER + 1]; | |
34 float foutbuf[LPC_FILTERORDER + 2 * STATE_LEN], *fout; | |
35 int k, tmpi; | |
36 | |
37 /* decoding of the maximum value */ | |
38 | |
39 maxVal = state_frgqTbl[idxForMax]; | |
40 maxVal = (float) pow(10, maxVal) / (float) 4.5; | |
41 | |
42 /* initialization of buffers and coefficients */ | |
43 | |
44 memset(tmpbuf, 0, LPC_FILTERORDER * sizeof(float)); | |
45 memset(foutbuf, 0, LPC_FILTERORDER * sizeof(float)); | |
46 for (k = 0; k < LPC_FILTERORDER; k++) { | |
47 numerator[k] = syntDenum[LPC_FILTERORDER - k]; | |
48 } | |
49 numerator[LPC_FILTERORDER] = syntDenum[0]; | |
50 tmp = &tmpbuf[LPC_FILTERORDER]; | |
51 fout = &foutbuf[LPC_FILTERORDER]; | |
52 | |
53 /* decoding of the sample values */ | |
54 | |
55 for (k = 0; k < len; k++) { | |
56 tmpi = len - 1 - k; | |
57 /* maxVal = 1/scal */ | |
58 tmp[k] = maxVal * state_sq3Tbl[idxVec[tmpi]]; | |
59 } | |
60 | |
61 /* circular convolution with all-pass filter */ | |
62 | |
63 memset(tmp + len, 0, len * sizeof(float)); | |
64 ZeroPoleFilter(tmp, numerator, syntDenum, 2 * len, | |
65 LPC_FILTERORDER, fout); | |
66 for (k = 0; k < len; k++) { | |
67 out[k] = fout[len - 1 - k] + fout[2 * len - 1 - k]; | |
68 } | |
69 } |