aboutsummaryrefslogtreecommitdiffstats
path: root/codecs/ilbc/StateConstructW.c
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-15 04:36:52 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-15 04:36:52 +0000
commit9fa1f6563a431a73d7eb0c8a284e4cf419cbc2fa (patch)
tree468bcd1944564d1b84b5a9d46b2eb437fe3c73a3 /codecs/ilbc/StateConstructW.c
parent0cc1bf692bcfc7f3f9ffef9d62c6621cd9ab9f4a (diff)
Add iLBC codec
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@852 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'codecs/ilbc/StateConstructW.c')
-rwxr-xr-xcodecs/ilbc/StateConstructW.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/codecs/ilbc/StateConstructW.c b/codecs/ilbc/StateConstructW.c
new file mode 100755
index 000000000..c694106ae
--- /dev/null
+++ b/codecs/ilbc/StateConstructW.c
@@ -0,0 +1,72 @@
+
+/******************************************************************
+
+ iLBC Speech Coder ANSI-C Source Code
+
+ StateConstructW.c
+
+ Copyright (c) 2001,
+ Global IP Sound AB.
+ All rights reserved.
+
+******************************************************************/
+
+#include <math.h>
+#include <string.h>
+
+#include "iLBC_define.h"
+#include "constants.h"
+#include "filter.h"
+
+/*----------------------------------------------------------------*
+ * decoding of the start state
+ *---------------------------------------------------------------*/
+
+void StateConstructW(
+ int idxForMax, /* (i) 6-bit index for the quantization of
+ max amplitude */
+ int *idxVec, /* (i) vector of quantization indexes */
+ float *syntDenum, /* (i) synthesis filter denumerator */
+ float *out, /* (o) the decoded state vector */
+ int len /* (i) length of a state vector */
+){
+ float maxVal, tmpbuf[LPC_FILTERORDER+2*STATE_LEN], *tmp,
+ numerator[LPC_FILTERORDER+1];
+ float foutbuf[LPC_FILTERORDER+2*STATE_LEN], *fout;
+ int k,tmpi;
+
+ /* decoding of the maximum value */
+
+ maxVal = state_frgqTbl[idxForMax];
+ maxVal = (float)pow(10,maxVal)/(float)4.5;
+
+ /* initialization of buffers and coefficients */
+
+ memset(tmpbuf, 0, LPC_FILTERORDER*sizeof(float));
+ memset(foutbuf, 0, LPC_FILTERORDER*sizeof(float));
+ for(k=0; k<LPC_FILTERORDER; k++){
+ numerator[k]=syntDenum[LPC_FILTERORDER-k];
+ }
+ numerator[LPC_FILTERORDER]=syntDenum[0];
+ tmp = &tmpbuf[LPC_FILTERORDER];
+ fout = &foutbuf[LPC_FILTERORDER];
+
+ /* decoding of the sample values */
+
+ for(k=0; k<len; k++){
+ tmpi = len-1-k;
+ /* maxVal = 1/scal */
+ tmp[k] = maxVal*state_sq3Tbl[idxVec[tmpi]];
+ }
+
+ /* circular convolution with all-pass filter */
+
+ memset(tmp+len, 0, len*sizeof(float));
+ ZeroPoleFilter(tmp, numerator, syntDenum, 2*len,
+ LPC_FILTERORDER, fout);
+ for(k=0;k<len;k++){
+ out[k] = fout[len-1-k]+fout[2*len-1-k];
+ }
+}
+
+