annotate intercom/ilbc/StateSearchW.c @ 3:c6c5a16ce2f2

compilation fixes
author Peter Meerwald <pmeerw@cosy.sbg.ac.at>
date Fri, 25 Jun 2010 09:59:25 +0200
parents 13be24d74cd2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
1
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
2 /******************************************************************
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
3
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
4 iLBC Speech Coder ANSI-C Source Code
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
5
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
6 StateSearchW.c
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
7
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
8 Copyright (C) The Internet Society (2004).
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
9 All Rights Reserved.
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
10
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
11 ******************************************************************/
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
12
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
13 #include <math.h>
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
14 #include <string.h>
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
15
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
16 #include "iLBC_define.h"
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
17 #include "constants.h"
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
18 #include "filter.h"
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
19 #include "helpfun.h"
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
20
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
21 /*----------------------------------------------------------------*
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
22 * predictive noise shaping encoding of scaled start state
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
23 * (subrutine for StateSearchW)
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
24 *---------------------------------------------------------------*/
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
25
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
26 void AbsQuantW(iLBC_Enc_Inst_t * iLBCenc_inst,
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
27 /* (i) Encoder instance */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
28 float *in, /* (i) vector to encode */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
29 float *syntDenum, /* (i) denominator of synthesis filter */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
30 float *weightDenum, /* (i) denominator of weighting filter */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
31 int *out, /* (o) vector of quantizer indexes */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
32 int len, /* (i) length of vector to encode and
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
33 vector of quantizer indexes */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
34 int state_first /* (i) position of start state in the
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
35 80 vec */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
36 )
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
37 {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
38 float *syntOut;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
39 float syntOutBuf[LPC_FILTERORDER + STATE_SHORT_LEN_30MS];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
40 float toQ, xq;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
41 int n;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
42 int index;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
43
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
44 /* initialization of buffer for filtering */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
45
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
46 memset(syntOutBuf, 0, LPC_FILTERORDER * sizeof(float));
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
47
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
48
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
49
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
50
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
51
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
52
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
53 /* initialization of pointer for filtering */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
54
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
55 syntOut = &syntOutBuf[LPC_FILTERORDER];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
56
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
57 /* synthesis and weighting filters on input */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
58
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
59 if (state_first) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
60 AllPoleFilter(in, weightDenum, SUBL, LPC_FILTERORDER);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
61 } else {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
62 AllPoleFilter(in, weightDenum,
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
63 iLBCenc_inst->state_short_len - SUBL, LPC_FILTERORDER);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
64 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
65
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
66 /* encoding loop */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
67
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
68 for (n = 0; n < len; n++) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
69
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
70 /* time update of filter coefficients */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
71
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
72 if ((state_first) && (n == SUBL)) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
73 syntDenum += (LPC_FILTERORDER + 1);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
74 weightDenum += (LPC_FILTERORDER + 1);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
75
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
76 /* synthesis and weighting filters on input */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
77 AllPoleFilter(&in[n], weightDenum, len - n, LPC_FILTERORDER);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
78
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
79 } else if ((state_first == 0) &&
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
80 (n == (iLBCenc_inst->state_short_len - SUBL))) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
81 syntDenum += (LPC_FILTERORDER + 1);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
82 weightDenum += (LPC_FILTERORDER + 1);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
83
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
84 /* synthesis and weighting filters on input */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
85 AllPoleFilter(&in[n], weightDenum, len - n, LPC_FILTERORDER);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
86
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
87 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
88
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
89 /* prediction of synthesized and weighted input */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
90
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
91 syntOut[n] = 0.0;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
92 AllPoleFilter(&syntOut[n], weightDenum, 1, LPC_FILTERORDER);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
93
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
94 /* quantization */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
95
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
96 toQ = in[n] - syntOut[n];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
97
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
98
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
99
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
100
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
101
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
102 sort_sq(&xq, &index, toQ, state_sq3Tbl, 8);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
103 out[n] = index;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
104 syntOut[n] = state_sq3Tbl[out[n]];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
105
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
106 /* update of the prediction filter */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
107
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
108 AllPoleFilter(&syntOut[n], weightDenum, 1, LPC_FILTERORDER);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
109 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
110 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
111
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
112 /*----------------------------------------------------------------*
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
113 * encoding of start state
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
114 *---------------------------------------------------------------*/
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
115
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
116 void StateSearchW(iLBC_Enc_Inst_t * iLBCenc_inst,
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
117 /* (i) Encoder instance */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
118 float *residual, /* (i) target residual vector */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
119 float *syntDenum, /* (i) lpc synthesis filter */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
120 float *weightDenum, /* (i) weighting filter denuminator */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
121 int *idxForMax, /* (o) quantizer index for maximum
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
122 amplitude */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
123 int *idxVec, /* (o) vector of quantization indexes */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
124 int len, /* (i) length of all vectors */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
125 int state_first /* (i) position of start state in the
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
126 80 vec */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
127 )
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
128 {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
129 float dtmp, maxVal;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
130 float tmpbuf[LPC_FILTERORDER + 2 * STATE_SHORT_LEN_30MS];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
131 float *tmp, numerator[1 + LPC_FILTERORDER];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
132 float foutbuf[LPC_FILTERORDER + 2 * STATE_SHORT_LEN_30MS], *fout;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
133 int k;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
134 float qmax, scal;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
135
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
136 /* initialization of buffers and filter coefficients */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
137
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
138 memset(tmpbuf, 0, LPC_FILTERORDER * sizeof(float));
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
139 memset(foutbuf, 0, LPC_FILTERORDER * sizeof(float));
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
140 for (k = 0; k < LPC_FILTERORDER; k++) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
141 numerator[k] = syntDenum[LPC_FILTERORDER - k];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
142 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
143 numerator[LPC_FILTERORDER] = syntDenum[0];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
144 tmp = &tmpbuf[LPC_FILTERORDER];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
145 fout = &foutbuf[LPC_FILTERORDER];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
146
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
147 /* circular convolution with the all-pass filter */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
148
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
149
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
150
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
151
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
152
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
153
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
154 memcpy(tmp, residual, len * sizeof(float));
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
155 memset(tmp + len, 0, len * sizeof(float));
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
156 ZeroPoleFilter(tmp, numerator, syntDenum, 2 * len,
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
157 LPC_FILTERORDER, fout);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
158 for (k = 0; k < len; k++) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
159 fout[k] += fout[k + len];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
160 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
161
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
162 /* identification of the maximum amplitude value */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
163
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
164 maxVal = fout[0];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
165 for (k = 1; k < len; k++) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
166
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
167 if (fout[k] * fout[k] > maxVal * maxVal) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
168 maxVal = fout[k];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
169 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
170 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
171 maxVal = (float) fabs(maxVal);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
172
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
173 /* encoding of the maximum amplitude value */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
174
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
175 if (maxVal < 10.0) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
176 maxVal = 10.0;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
177 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
178 maxVal = (float) log10(maxVal);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
179 sort_sq(&dtmp, idxForMax, maxVal, state_frgqTbl, 64);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
180
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
181 /* decoding of the maximum amplitude representation value,
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
182 and corresponding scaling of start state */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
183
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
184 maxVal = state_frgqTbl[*idxForMax];
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
185 qmax = (float) pow(10, maxVal);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
186 scal = (float) (4.5) / qmax;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
187 for (k = 0; k < len; k++) {
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
188 fout[k] *= scal;
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
189 }
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
190
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
191 /* predictive noise shaping encoding of scaled start state */
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
192
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
193 AbsQuantW(iLBCenc_inst, fout, syntDenum,
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
194 weightDenum, idxVec, len, state_first);
13be24d74cd2 import intercom-0.4.1
Peter Meerwald <pmeerw@cosy.sbg.ac.at>
parents:
diff changeset
195 }

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.