Asterisk - The Open Source Telephony Project  18.5.0
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Functions
getCBvec.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void getCBvec (float *cbvec, float *mem, int index, int lMem, int cbveclen)
 

Function Documentation

◆ getCBvec()

void getCBvec ( float *  cbvec,
float *  mem,
int  index,
int  lMem,
int  cbveclen 
)

Definition at line 21 of file getCBvec.c.

References CB_FILTERLEN, CB_HALFFILTERLEN, CB_MEML, cbfiltersTbl, and SUBL.

Referenced by iCBConstruct().

32  {
33  int j, k, n, memInd, sFilt;
34  float tmpbuf[CB_MEML];
35  int base_size;
36  int ilow, ihigh;
37  float alfa, alfa1;
38 
39  /* Determine size of codebook sections */
40 
41  base_size=lMem-cbveclen+1;
42 
43  if (cbveclen==SUBL) {
44  base_size+=cbveclen/2;
45  }
46 
47  /* No filter -> First codebook section */
48 
49  if (index<lMem-cbveclen+1) {
50 
51  /* first non-interpolated vectors */
52 
53  k=index+cbveclen;
54  /* get vector */
55  memcpy(cbvec, mem+lMem-k, cbveclen*sizeof(float));
56 
57  } else if (index < base_size) {
58 
59  k=2*(index-(lMem-cbveclen+1))+cbveclen;
60 
61  ihigh=k/2;
62  ilow=ihigh-5;
63 
64  /* Copy first noninterpolated part */
65 
66  memcpy(cbvec, mem+lMem-k/2, ilow*sizeof(float));
67 
68  /* interpolation */
69 
70  alfa1=(float)0.2;
71  alfa=0.0;
72  for (j=ilow; j<ihigh; j++) {
73  cbvec[j]=((float)1.0-alfa)*mem[lMem-k/2+j]+
74  alfa*mem[lMem-k+j];
75 
76 
77 
78 
79 
80  alfa+=alfa1;
81  }
82 
83  /* Copy second noninterpolated part */
84 
85  memcpy(cbvec+ihigh, mem+lMem-k+ihigh,
86  (cbveclen-ihigh)*sizeof(float));
87 
88  }
89 
90  /* Higher codebook section based on filtering */
91 
92  else {
93 
94  /* first non-interpolated vectors */
95 
96  if (index-base_size<lMem-cbveclen+1) {
97  float tempbuff2[CB_MEML+CB_FILTERLEN+1];
98  float *pos;
99  float *pp, *pp1;
100 
101  memset(tempbuff2, 0,
102  CB_HALFFILTERLEN*sizeof(float));
103  memcpy(&tempbuff2[CB_HALFFILTERLEN], mem,
104  lMem*sizeof(float));
105  memset(&tempbuff2[lMem+CB_HALFFILTERLEN], 0,
106  (CB_HALFFILTERLEN+1)*sizeof(float));
107 
108  k=index-base_size+cbveclen;
109  sFilt=lMem-k;
110  memInd=sFilt+1-CB_HALFFILTERLEN;
111 
112  /* do filtering */
113  pos=cbvec;
114  memset(pos, 0, cbveclen*sizeof(float));
115  for (n=0; n<cbveclen; n++) {
116  pp=&tempbuff2[memInd+n+CB_HALFFILTERLEN];
117  pp1=&cbfiltersTbl[CB_FILTERLEN-1];
118  for (j=0; j<CB_FILTERLEN; j++) {
119  (*pos)+=(*pp++)*(*pp1--);
120  }
121  pos++;
122  }
123  }
124 
125  /* interpolated vectors */
126 
127  else {
128 
129 
130 
131 
132 
133  float tempbuff2[CB_MEML+CB_FILTERLEN+1];
134 
135  float *pos;
136  float *pp, *pp1;
137  int i;
138 
139  memset(tempbuff2, 0,
140  CB_HALFFILTERLEN*sizeof(float));
141  memcpy(&tempbuff2[CB_HALFFILTERLEN], mem,
142  lMem*sizeof(float));
143  memset(&tempbuff2[lMem+CB_HALFFILTERLEN], 0,
144  (CB_HALFFILTERLEN+1)*sizeof(float));
145 
146  k=2*(index-base_size-
147  (lMem-cbveclen+1))+cbveclen;
148  sFilt=lMem-k;
149  memInd=sFilt+1-CB_HALFFILTERLEN;
150 
151  /* do filtering */
152  pos=&tmpbuf[sFilt];
153  memset(pos, 0, k*sizeof(float));
154  for (i=0; i<k; i++) {
155  pp=&tempbuff2[memInd+i+CB_HALFFILTERLEN];
156  pp1=&cbfiltersTbl[CB_FILTERLEN-1];
157  for (j=0; j<CB_FILTERLEN; j++) {
158  (*pos)+=(*pp++)*(*pp1--);
159  }
160  pos++;
161  }
162 
163  ihigh=k/2;
164  ilow=ihigh-5;
165 
166  /* Copy first noninterpolated part */
167 
168  memcpy(cbvec, tmpbuf+lMem-k/2,
169  ilow*sizeof(float));
170 
171  /* interpolation */
172 
173  alfa1=(float)0.2;
174  alfa=0.0;
175  for (j=ilow; j<ihigh; j++) {
176  cbvec[j]=((float)1.0-alfa)*
177  tmpbuf[lMem-k/2+j]+alfa*tmpbuf[lMem-k+j];
178  alfa+=alfa1;
179  }
180 
181 
182 
183 
184 
185 
186  /* Copy second noninterpolated part */
187 
188  memcpy(cbvec+ihigh, tmpbuf+lMem-k+ihigh,
189  (cbveclen-ihigh)*sizeof(float));
190  }
191  }
192  }
#define CB_HALFFILTERLEN
Definition: iLBC_define.h:60
#define CB_MEML
Definition: iLBC_define.h:58
#define SUBL
Definition: iLBC_define.h:33
float cbfiltersTbl[CB_FILTERLEN]
Definition: constants.c:142
#define CB_FILTERLEN
Definition: iLBC_define.h:59