Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Functions | Variables
vparms.c File Reference
#include "f2c.h"
Include dependency graph for vparms.c:

Go to the source code of this file.

Functions

int vparms_ (integer *vwin, real *inbuf, real *lpbuf, integer *buflim, integer *half, real *dither, integer *mintau, integer *zc, integer *lbe, integer *fbe, real *qs, real *rc1, real *ar_b__, real *ar_f__)
 

Variables

static real c_b2 = 1.f
 

Function Documentation

◆ vparms_()

int vparms_ ( integer vwin,
real inbuf,
real lpbuf,
integer buflim,
integer half,
real dither,
integer mintau,
integer zc,
integer lbe,
integer fbe,
real qs,
real rc1,
real ar_b__,
real ar_f__ 
)

Definition at line 134 of file vparms.c.

138{
139 /* System generated locals */
140 integer inbuf_offset, lpbuf_offset, i__1;
141 real r__1, r__2;
142
143 /* Builtin functions */
144 double r_sign(real *, real *);
146
147 /* Local variables */
148 integer vlen, stop, i__;
149 real e_pre__;
150 integer start;
151 real ap_rms__, e_0__, oldsgn, lp_rms__, e_b__, e_f__, r_b__, r_f__, e0ap;
152
153/* Arguments */
154/* Local variables that need not be saved */
155/* Calculate zero crossings (ZC) and several energy and correlation */
156/* measures on low band and full band speech. Each measure is taken */
157/* over either the first or the second half of the voicing window, */
158/* depending on the variable HALF. */
159 /* Parameter adjustments */
160 --vwin;
161 --buflim;
162 lpbuf_offset = buflim[3];
163 lpbuf -= lpbuf_offset;
164 inbuf_offset = buflim[1];
165 inbuf -= inbuf_offset;
166
167 /* Function Body */
168 lp_rms__ = 0.f;
169 ap_rms__ = 0.f;
170 e_pre__ = 0.f;
171 e0ap = 0.f;
172 *rc1 = 0.f;
173 e_0__ = 0.f;
174 e_b__ = 0.f;
175 e_f__ = 0.f;
176 r_f__ = 0.f;
177 r_b__ = 0.f;
178 *zc = 0;
179 vlen = vwin[2] - vwin[1] + 1;
180 start = vwin[1] + (*half - 1) * vlen / 2 + 1;
181 stop = start + vlen / 2 - 1;
182
183/* I'll use the symbol HVL in the table below to represent the value */
184/* VLEN/2. Note that if VLEN is odd, then HVL should be rounded down, */
185/* i.e., HVL = (VLEN-1)/2. */
186
187/* HALF START STOP */
188
189/* 1 VWIN(1)+1 VWIN(1)+HVL */
190/* 2 VWIN(1)+HVL+1 VWIN(1)+2*HVL */
191
192/* Note that if VLEN is even and HALF is 2, then STOP will be */
193/* VWIN(1)+VLEN = VWIN(2)+1. That could be bad, if that index of INBUF */
194/* is undefined. */
195
196 r__1 = inbuf[start - 1] - *dither;
197 oldsgn = (real)r_sign(&c_b2, &r__1);
198 i__1 = stop;
199 for (i__ = start; i__ <= i__1; ++i__) {
200 lp_rms__ += (r__1 = lpbuf[i__], abs(r__1));
201 ap_rms__ += (r__1 = inbuf[i__], abs(r__1));
202 e_pre__ += (r__1 = inbuf[i__] - inbuf[i__ - 1], abs(r__1));
203/* Computing 2nd power */
204 r__1 = inbuf[i__];
205 e0ap += r__1 * r__1;
206 *rc1 += inbuf[i__] * inbuf[i__ - 1];
207/* Computing 2nd power */
208 r__1 = lpbuf[i__];
209 e_0__ += r__1 * r__1;
210/* Computing 2nd power */
211 r__1 = lpbuf[i__ - *mintau];
212 e_b__ += r__1 * r__1;
213/* Computing 2nd power */
214 r__1 = lpbuf[i__ + *mintau];
215 e_f__ += r__1 * r__1;
216 r_f__ += lpbuf[i__] * lpbuf[i__ + *mintau];
217 r_b__ += lpbuf[i__] * lpbuf[i__ - *mintau];
218 r__1 = inbuf[i__] + *dither;
219 if (r_sign(&c_b2, &r__1) != oldsgn) {
220 ++(*zc);
221 oldsgn = -oldsgn;
222 }
223 *dither = -(*dither);
224 }
225/* Normalized short-term autocovariance coefficient at unit sample delay
226 */
227 *rc1 /= max(e0ap,1.f);
228/* Ratio of the energy of the first difference signal (6 dB/oct preemphas
229is)*/
230/* to the energy of the full band signal */
231/* Computing MAX */
232 r__1 = ap_rms__ * 2.f;
233 *qs = e_pre__ / max(r__1,1.f);
234/* aR_b is the product of the forward and reverse prediction gains, */
235/* looking backward in time (the causal case). */
236 *ar_b__ = r_b__ / max(e_b__,1.f) * (r_b__ / max(e_0__,1.f));
237/* aR_f is the same as aR_b, but looking forward in time (non causal case
238).*/
239 *ar_f__ = r_f__ / max(e_f__,1.f) * (r_f__ / max(e_0__,1.f));
240/* Normalize ZC, LBE, and FBE to old fixed window length of 180. */
241/* (The fraction 90/VLEN has a range of .58 to 1) */
242 r__2 = (real) (*zc << 1);
243 r__1 = r__2 * (90.f / vlen);
244 *zc = i_nint(&r__1);
245/* Computing MIN */
246 r__1 = lp_rms__ / 4 * (90.f / vlen);
247 i__1 = i_nint(&r__1);
248 *lbe = min(i__1,32767);
249/* Computing MIN */
250 r__1 = ap_rms__ / 4 * (90.f / vlen);
251 i__1 = i_nint(&r__1);
252 *fbe = min(i__1,32767);
253 return 0;
254} /* vparms_ */
unsigned int stop
Definition: app_sla.c:336
double r_sign(real *a, real *b)
Definition: f2clib.c:64
#define abs(x)
Definition: f2c.h:195
integer i_nint(real *x)
Definition: f2clib.c:80
#define min(a, b)
Definition: f2c.h:197
#define max(a, b)
Definition: f2c.h:198
float real
Definition: lpc10.h:79
INT32 integer
Definition: lpc10.h:80
static int inbuf(struct baseio *bio, FILE *fi)
utility used by inchar(), for base_encode()
Definition: utils.c:590
static real c_b2
Definition: vparms.c:35

References abs, c_b2, i_nint(), inbuf(), max, min, r_sign(), and stop.

Referenced by voicin_().

Variable Documentation

◆ c_b2

real c_b2 = 1.f
static

Definition at line 35 of file vparms.c.

Referenced by vparms_().