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

Go to the source code of this file.

Functions

void AbsQuantW (iLBC_Enc_Inst_t *iLBCenc_inst, float *in, float *syntDenum, float *weightDenum, int *out, int len, int state_first)
 
void StateSearchW (iLBC_Enc_Inst_t *iLBCenc_inst, float *residual, float *syntDenum, float *weightDenum, int *idxForMax, int *idxVec, int len, int state_first)
 

Function Documentation

◆ AbsQuantW()

void AbsQuantW ( iLBC_Enc_Inst_t iLBCenc_inst,
float *  in,
float *  syntDenum,
float *  weightDenum,
int *  out,
int  len,
int  state_first 
)

Definition at line 26 of file StateSearchW.c.

References AllPoleFilter(), len(), LPC_FILTERORDER, sort_sq(), iLBC_Enc_Inst_t_::state_short_len, STATE_SHORT_LEN_30MS, state_sq3Tbl, and SUBL.

Referenced by StateSearchW().

37  {
38  float *syntOut;
39  float syntOutBuf[LPC_FILTERORDER+STATE_SHORT_LEN_30MS];
40  float toQ, xq;
41  int n;
42  int index;
43 
44  /* initialization of buffer for filtering */
45 
46  memset(syntOutBuf, 0, LPC_FILTERORDER*sizeof(float));
47 
48 
49 
50 
51 
52 
53  /* initialization of pointer for filtering */
54 
55  syntOut = &syntOutBuf[LPC_FILTERORDER];
56 
57  /* synthesis and weighting filters on input */
58 
59  if (state_first) {
60  AllPoleFilter (in, weightDenum, SUBL, LPC_FILTERORDER);
61  } else {
62  AllPoleFilter (in, weightDenum,
63  iLBCenc_inst->state_short_len-SUBL,
65  }
66 
67  /* encoding loop */
68 
69  for (n=0; n<len; n++) {
70 
71  /* time update of filter coefficients */
72 
73  if ((state_first)&&(n==SUBL)){
74  syntDenum += (LPC_FILTERORDER+1);
75  weightDenum += (LPC_FILTERORDER+1);
76 
77  /* synthesis and weighting filters on input */
78  AllPoleFilter (&in[n], weightDenum, len-n,
80 
81  } else if ((state_first==0)&&
82  (n==(iLBCenc_inst->state_short_len-SUBL))) {
83  syntDenum += (LPC_FILTERORDER+1);
84  weightDenum += (LPC_FILTERORDER+1);
85 
86  /* synthesis and weighting filters on input */
87  AllPoleFilter (&in[n], weightDenum, len-n,
89 
90  }
91 
92  /* prediction of synthesized and weighted input */
93 
94  syntOut[n] = 0.0;
95  AllPoleFilter (&syntOut[n], weightDenum, 1,
97 
98  /* quantization */
99 
100  toQ = in[n]-syntOut[n];
101 
102 
103 
104 
105 
106  sort_sq(&xq, &index, toQ, state_sq3Tbl, 8);
107  out[n]=index;
108  syntOut[n] = state_sq3Tbl[out[n]];
109 
110  /* update of the prediction filter */
111 
112  AllPoleFilter(&syntOut[n], weightDenum, 1,
114  }
115  }
#define STATE_SHORT_LEN_30MS
Definition: iLBC_define.h:35
void AllPoleFilter(float *InOut, float *Coef, int lengthInOut, int orderCoef)
Definition: filter.c:19
float state_sq3Tbl[8]
Definition: constants.c:97
FILE * in
Definition: utils/frame.c:33
#define SUBL
Definition: iLBC_define.h:33
#define LPC_FILTERORDER
Definition: iLBC_define.h:40
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void sort_sq(float *xq, int *index, float x, const float *cb, int cb_size)
Definition: helpfun.c:235
FILE * out
Definition: utils/frame.c:33

◆ StateSearchW()

void StateSearchW ( iLBC_Enc_Inst_t iLBCenc_inst,
float *  residual,
float *  syntDenum,
float *  weightDenum,
int *  idxForMax,
int *  idxVec,
int  len,
int  state_first 
)

Definition at line 121 of file StateSearchW.c.

References AbsQuantW(), len(), LPC_FILTERORDER, sort_sq(), state_frgqTbl, STATE_SHORT_LEN_30MS, tmp(), and ZeroPoleFilter().

Referenced by iLBC_encode().

133  {
134  float dtmp, maxVal;
135  float tmpbuf[LPC_FILTERORDER+2*STATE_SHORT_LEN_30MS];
136  float *tmp, numerator[1+LPC_FILTERORDER];
137  float foutbuf[LPC_FILTERORDER+2*STATE_SHORT_LEN_30MS], *fout;
138  int k;
139  float qmax, scal;
140 
141  /* initialization of buffers and filter coefficients */
142 
143  memset(tmpbuf, 0, LPC_FILTERORDER*sizeof(float));
144  memset(foutbuf, 0, LPC_FILTERORDER*sizeof(float));
145  for (k=0; k<LPC_FILTERORDER; k++) {
146  numerator[k]=syntDenum[LPC_FILTERORDER-k];
147  }
148  numerator[LPC_FILTERORDER]=syntDenum[0];
149  tmp = &tmpbuf[LPC_FILTERORDER];
150  fout = &foutbuf[LPC_FILTERORDER];
151 
152  /* circular convolution with the all-pass filter */
153 
154 
155 
156 
157 
158 
159  memcpy(tmp, residual, len*sizeof(float));
160  memset(tmp+len, 0, len*sizeof(float));
161  ZeroPoleFilter(tmp, numerator, syntDenum, 2*len,
162  LPC_FILTERORDER, fout);
163  for (k=0; k<len; k++) {
164  fout[k] += fout[k+len];
165  }
166 
167  /* identification of the maximum amplitude value */
168 
169  maxVal = fout[0];
170  for (k=1; k<len; k++) {
171 
172  if (fout[k]*fout[k] > maxVal*maxVal){
173  maxVal = fout[k];
174  }
175  }
176  maxVal=(float)fabs(maxVal);
177 
178  /* encoding of the maximum amplitude value */
179 
180  if (maxVal < 10.0) {
181  maxVal = 10.0;
182  }
183  maxVal = (float)log10(maxVal);
184  sort_sq(&dtmp, idxForMax, maxVal, state_frgqTbl, 64);
185 
186  /* decoding of the maximum amplitude representation value,
187  and corresponding scaling of start state */
188 
189  maxVal=state_frgqTbl[*idxForMax];
190  qmax = (float)pow(10,maxVal);
191  scal = (float)(4.5)/qmax;
192  for (k=0; k<len; k++){
193  fout[k] *= scal;
194  }
195 
196  /* predictive noise shaping encoding of scaled start state */
197 
198  AbsQuantW(iLBCenc_inst, fout,syntDenum,
199  weightDenum,idxVec, len, state_first);
200  }
#define STATE_SHORT_LEN_30MS
Definition: iLBC_define.h:35
static int tmp()
Definition: bt_open.c:389
float state_frgqTbl[64]
Definition: constants.c:108
#define LPC_FILTERORDER
Definition: iLBC_define.h:40
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
void sort_sq(float *xq, int *index, float x, const float *cb, int cb_size)
Definition: helpfun.c:235
void ZeroPoleFilter(float *In, float *ZeroCoef, float *PoleCoef, int lengthInOut, int orderCoef, float *Out)
Definition: filter.c:80
void AbsQuantW(iLBC_Enc_Inst_t *iLBCenc_inst, float *in, float *syntDenum, float *weightDenum, int *out, int len, int state_first)
Definition: StateSearchW.c:26