3 * Revision 1.2 1996/08/20 20:45:00 jaf
4 * Removed all static local variables that were SAVE'd in the Fortran
5 * code, and put them in struct lpc10_encoder_state that is passed as an
8 * Removed init function, since all initialization is now done in
9 * init_lpc10_encoder_state().
11 * Revision 1.1 1996/08/19 22:30:14 jaf
17 /* -- translated by f2c (version 19951025).
18 You must link the resulting object file with the libraries:
19 -lf2c -lm (in that order)
24 extern int voicin_(integer
*vwin
, real
*inbuf
, real
*lpbuf
, integer
*buflim
, integer
*half
, real
*minamd
, real
*maxamd
, integer
*mintau
, real
*ivrc
, integer
*obound
, integer
*voibuf
, integer
*af
, struct lpc10_encoder_state
*st
);
26 /* Common Block Declarations */
29 integer order
, lframe
;
33 #define contrl_1 contrl_
35 /****************************************************************************/
37 /* VOICIN Version 52 */
40 * Revision 1.2 1996/08/20 20:45:00 jaf
41 * Removed all static local variables that were SAVE'd in the Fortran
42 * code, and put them in struct lpc10_encoder_state that is passed as an
45 * Removed init function, since all initialization is now done in
46 * init_lpc10_encoder_state().
48 * Revision 1.1 1996/08/19 22:30:14 jaf
51 /* Revision 1.10 1996/03/29 17:59:14 jaf */
52 /* Avoided using VALUE(9), although it shouldn't affect the function of */
53 /* the code at all, because it was always multiplied by VDC(9,SNRL), */
54 /* which is 0 for all values of SNRL. Still, if VALUE(9) had an initial */
55 /* value of IEEE NaN, it might cause trouble (I don't know how IEEE */
56 /* defines Nan * 0. It should either be NaN or 0.) */
58 /* Revision 1.9 1996/03/29 17:54:46 jaf */
59 /* Added a few comments about the accesses made to argument array VOIBUF */
60 /* and the local saved array VOICE. */
62 /* Revision 1.8 1996/03/27 18:19:54 jaf */
63 /* Added an assignment to VSTATE that does not affect the function of the */
64 /* program at all. The only reason I put it in was so that the tracing */
65 /* statements at the end, when enabled, will print a consistent value for */
66 /* VSTATE when HALF .EQ. 1, rather than a garbage value that could change */
67 /* from one call to the next. */
69 /* Revision 1.7 1996/03/26 20:00:06 jaf */
70 /* Removed the inclusion of the file "vcomm.fh", and put its contents */
71 /* into this file. It was included nowhere else but here. */
73 /* Revision 1.6 1996/03/26 19:38:09 jaf */
74 /* Commented out trace statements. */
76 /* Revision 1.5 1996/03/19 20:43:45 jaf */
77 /* Added comments about which indices of OBOUND and VOIBUF can be */
78 /* accessed, and whether they are read or written. VOIBUF is fairly */
81 /* Revision 1.4 1996/03/19 15:00:58 jaf */
82 /* Moved the DATA statements for the *VDC* variables later, as it is */
83 /* apparently illegal to have DATA statements before local variable */
86 /* Revision 1.3 1996/03/19 00:10:49 jaf */
87 /* Heavily commented the local variables that are saved from one */
88 /* invocation to the next, and how the local variable FIRST is used to */
89 /* avoid the need to assign most of them initial values with DATA */
92 /* A few should be initialized, but aren't. I've guessed initial values */
93 /* for two of these, SFBUE and SLBUE, and I've convinced myself that for */
94 /* VOICE, the effects of uninitialized values will die out after 2 or 3 */
95 /* frame times. It would still be good to choose initial values for */
96 /* these, but I don't know what reasonable values would be (0 comes to */
99 /* Revision 1.2 1996/03/13 16:09:28 jaf */
100 /* Comments added explaining which of the local variables of this */
101 /* subroutine need to be saved from one invocation to the next, and which */
104 /* WARNING! Some of them that should are never given initial values in */
105 /* this code. Hopefully, Fortran 77 defines initial values for them, but */
106 /* even so, giving them explicit initial values is preferable. */
108 /* WARNING! VALUE(9) is used, but never assigned a value. It should */
109 /* probably be eliminated from the code. */
111 /* Revision 1.1 1996/02/07 14:50:28 jaf */
112 /* Initial revision */
115 /****************************************************************************/
117 /* Voicing Detection (VOICIN) makes voicing decisions for each half */
118 /* frame of input speech. Tentative voicing decisions are made two frames*/
119 /* in the future (2F) for each half frame. These decisions are carried */
120 /* through one frame in the future (1F) to the present (P) frame where */
121 /* they are examined and smoothed, resulting in the final voicing */
122 /* decisions for each half frame. */
123 /* The voicing parameter (signal measurement) column vector (VALUE) */
124 /* is based on a rectangular window of speech samples determined by the */
125 /* window placement algorithm. The voicing parameter vector contains the*/
126 /* AMDF windowed maximum-to-minimum ratio, the zero crossing rate, energy*/
127 /* measures, reflection coefficients, and prediction gains. The voicing */
128 /* window is placed to avoid contamination of the voicing parameter vector*/
129 /* with speech onsets. */
130 /* The input signal is then classified as unvoiced (including */
131 /* silence) or voiced. This decision is made by a linear discriminant */
132 /* function consisting of a dot product of the voicing decision */
133 /* coefficient (VDC) row vector with the measurement column vector */
134 /* (VALUE). The VDC vector is 2-dimensional, each row vector is optimized*/
135 /* for a particular signal-to-noise ratio (SNR). So, before the dot */
136 /* product is performed, the SNR is estimated to select the appropriate */
138 /* The smoothing algorithm is a modified median smoother. The */
139 /* voicing discriminant function is used by the smoother to determine how*/
140 /* strongly voiced or unvoiced a signal is. The smoothing is further */
141 /* modified if a speech onset and a voicing decision transition occur */
142 /* within one half frame. In this case, the voicing decision transition */
143 /* is extended to the speech onset. For transmission purposes, there are*/
144 /* constraints on the duration and transition of voicing decisions. The */
145 /* smoother takes these constraints into account. */
146 /* Finally, the energy estimates are updated along with the dither */
147 /* threshold used to calculate the zero crossing rate (ZC). */
150 /* VWIN - Voicing window limits */
151 /* The indices read of arrays VWIN, INBUF, LPBUF, and BUFLIM */
152 /* are the same as those read by subroutine VPARMS. */
153 /* INBUF - Input speech buffer */
154 /* LPBUF - Low-pass filtered speech buffer */
155 /* BUFLIM - INBUF and LPBUF limits */
156 /* HALF - Present analysis half frame number */
157 /* MINAMD - Minimum value of the AMDF */
158 /* MAXAMD - Maximum value of the AMDF */
159 /* MINTAU - Pointer to the lag of the minimum AMDF value */
160 /* IVRC(2) - Inverse filter's RC's */
161 /* Only index 2 of array IVRC read under normal operation. */
162 /* (Index 1 is also read when debugging is turned on.) */
163 /* OBOUND - Onset boundary descriptions */
164 /* Indices 1 through 3 read if (HALF .NE. 1), otherwise untouched.
166 /* AF - The analysis frame number */
168 /* VOIBUF(2,0:AF) - Buffer of voicing decisions */
169 /* Index (HALF,3) written. */
170 /* If (HALF .EQ. 1), skip down to "Read (HALF,3)" below. */
171 /* Indices (1,2), (2,1), (1,2), and (2,2) read. */
172 /* One of the following is then done: */
173 /* read (1,3) and possibly write (1,2) */
174 /* read (1,3) and write (1,2) or (2,2) */
176 /* write (2,1) or (1,2) */
177 /* read (1,0) and (1,3) and then write (2,2) or (1,1) */
178 /* no reads or writes on VOIBUF */
179 /* Finally, read (HALF,3) */
181 /* QS - Ratio of preemphasized to full-band energies */
182 /* RC1 - First reflection coefficient */
183 /* AR_B - Product of the causal forward and reverse pitch prediction gain
185 /* AR_F - Product of the noncausal forward and rev. pitch prediction gain
187 /* ZC - Zero crossing rate */
188 /* DITHER - Zero crossing threshold level */
189 /* MAXMIN - AMDF's 1 octave windowed maximum-to-minimum ratio */
190 /* MINPTR - Location of minimum AMDF value */
191 /* NVDC - Number of elements in each VDC vector */
192 /* NVDCL - Number of VDC vectors */
193 /* VDCL - SNR values corresponding to the set of VDC's */
194 /* VDC - 2-D voicing decision coefficient vector */
195 /* VALUE(9) - Voicing Parameters */
196 /* VOICE(2,3)- History of LDA results */
197 /* On every call when (HALF .EQ. 1), VOICE(*,I+1) is */
198 /* shifted back to VOICE(*,I), for I=1,2. */
199 /* VOICE(HALF,3) is written on every call. */
200 /* Depending on several conditions, one or more of */
201 /* (1,1), (1,2), (2,1), and (2,2) might then be read. */
202 /* LBE - Ratio of low-band instantaneous to average energies */
203 /* FBE - Ratio of full-band instantaneous to average energies */
204 /* LBVE - Low band voiced energy */
205 /* LBUE - Low band unvoiced energy */
206 /* FBVE - Full band voiced energy */
207 /* FBUE - Full band unvoiced energy */
208 /* OFBUE - Previous full-band unvoiced energy */
209 /* OLBUE - Previous low-band unvoiced energy */
210 /* REF - Reference energy for initialization and DITHER threshold */
211 /* SNR - Estimate of signal-to-noise ratio */
212 /* SNR2 - Estimate of low-band signal-to-noise ratio */
213 /* SNRL - SNR level number */
214 /* OT - Onset transition present */
215 /* VSTATE - Decimal interpretation of binary voicing classifications */
216 /* FIRST - First call flag */
218 /* This subroutine maintains local state from one call to the next. If */
219 /* you want to switch to using a new audio stream for this filter, or */
220 /* reinitialize its state for any other reason, call the ENTRY */
223 /* Subroutine */ int voicin_(integer
*vwin
, real
*inbuf
, real
*
224 lpbuf
, integer
*buflim
, integer
*half
, real
*minamd
, real
*maxamd
,
225 integer
*mintau
, real
*ivrc
, integer
*obound
, integer
*voibuf
,
226 integer
*af
, struct lpc10_encoder_state
*st
)
228 /* Initialized data */
231 static real vdc
[100] /* was [10][10] */ = { 0.f
,1714.f
,-110.f
,
232 334.f
,-4096.f
,-654.f
,3752.f
,3769.f
,0.f
,1181.f
,0.f
,874.f
,-97.f
,
233 300.f
,-4096.f
,-1021.f
,2451.f
,2527.f
,0.f
,-500.f
,0.f
,510.f
,-70.f
,
234 250.f
,-4096.f
,-1270.f
,2194.f
,2491.f
,0.f
,-1500.f
,0.f
,500.f
,-10.f
,
235 200.f
,-4096.f
,-1300.f
,2e3f
,2e3f
,0.f
,-2e3f
,0.f
,500.f
,0.f
,0.f
,
236 -4096.f
,-1300.f
,2e3f
,2e3f
,0.f
,-2500.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,
237 0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,
238 0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,
239 0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
};
240 static integer nvdcl
= 5;
241 static real vdcl
[10] = { 600.f
,450.f
,300.f
,200.f
,0.f
,0.f
,0.f
,0.f
,0.f
,0.f
}
244 /* System generated locals */
245 integer inbuf_offset
= 0, lpbuf_offset
= 0, i__1
, i__2
;
248 /* Builtin functions */
249 integer
i_nint(real
*);
250 double sqrt(doublereal
);
252 /* Local variables */
254 integer
*lbve
, *lbue
, *fbve
, *fbue
;
256 integer
*ofbue
, *sfbue
;
258 integer
*olbue
, *slbue
;
266 extern /* Subroutine */ int vparms_(integer
*, real
*, real
*, integer
*,
267 integer
*, real
*, integer
*, integer
*, integer
*, integer
*,
268 real
*, real
*, real
*, real
*);
274 /* Global Variables: */
277 /* LPC Processing control variables: */
279 /* *** Read-only: initialized in setup */
281 /* Files for Speech, Parameter, and Bitstream Input & Output, */
282 /* and message and debug outputs. */
284 /* Here are the only files which use these variables: */
286 /* lpcsim.f setup.f trans.f error.f vqsetup.f */
288 /* Many files which use fdebug are not listed, since it is only used in */
289 /* those other files conditionally, to print trace statements. */
290 /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
291 /* LPC order, Frame size, Quantization rate, Bits per frame, */
292 /* Error correction */
293 /* Subroutine SETUP is the only place where order is assigned a value, */
294 /* and that value is 10. It could increase efficiency 1% or so to */
295 /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as
297 /* a variable in a COMMON block, since it is used in many places in the */
298 /* core of the coding and decoding routines. Actually, I take that back.
300 /* At least when compiling with f2c, the upper bound of DO loops is */
301 /* stored in a local variable before the DO loop begins, and then that is
303 /* compared against on each iteration. */
304 /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
305 /* Similarly for quant, which is given a value of 2400 in SETUP. quant */
306 /* is used in only a few places, and never in the core coding and */
307 /* decoding routines, so it could be eliminated entirely. */
308 /* nbits is similar to quant, and is given a value of 54 in SETUP. */
309 /* corrp is given a value of .TRUE. in SETUP, and is only used in the */
310 /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */
311 /* coder significantly whether it is .TRUE. or .FALSE., or whether it is
313 /* a constant or a variable, since it is only examined once per frame. */
314 /* Leaving it as a variable that is set to .TRUE. seems like a good */
315 /* idea, since it does enable some error-correction capability for */
316 /* unvoiced frames, with no change in the coding rate, and no noticeable
318 /* quality difference in the decoded speech. */
319 /* integer quant, nbits */
320 /* *** Read/write: variables for debugging, not needed for LPC algorithm
323 /* Current frame, Unstable frames, Output clip count, Max onset buffer,
325 /* Debug listing detail level, Line count on listing page */
327 /* nframe is not needed for an embedded LPC10 at all. */
328 /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
329 /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */
330 /* an application, I would recommend removing the call to ERROR in RCCHK,
332 /* and remove ERROR and nunsfm completely. */
333 /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in
335 /* sread.f. When LPC10 is embedded into an application, one might want */
336 /* to cause it to be incremented in a routine that takes the output of */
337 /* SYNTHS and sends it to an audio device. It could be optionally */
338 /* displayed, for those that might want to know what it is. */
339 /* maxosp is never initialized to 0 in SETUP, although it probably should
341 /* be, and it is updated in subroutine ANALYS. I doubt that its value */
342 /* would be of much interest to an application in which LPC10 is */
344 /* listl and lincnt are not needed for an embedded LPC10 at all. */
345 /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
346 /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
347 /* common /contrl/ quant, nbits */
348 /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
349 /* Parameters/constants */
350 /* Voicing coefficient and Linear Discriminant Analysis variables:
352 /* Max number of VDC's and VDC levels */
353 /* The following are not Fortran PARAMETER's, but they are */
354 /* initialized with DATA statements, and never modified. */
355 /* Actual number of VDC's and levels */
356 /* Local variables that need not be saved */
359 /* VALUE(1) through VALUE(8) are assigned values, but VALUE(9) */
360 /* never is. Yet VALUE(9) is read in the loop that begins "DO I =
362 /* 1, 9" below. I believe that this doesn't cause any problems in
364 /* this subroutine, because all VDC(9,*) array elements are 0, and
366 /* this is what is multiplied by VALUE(9) in all cases. Still, it
368 /* would save a multiplication to change the loop to "DO I = 1, 8".
373 /* VOICE, SFBUE, and SLBUE should be saved from one invocation to */
374 /* the next, but they are never given an initial value. */
376 /* Does Fortran 77 specify some default initial value, like 0, or */
377 /* is it undefined? If it is undefined, then this code should be */
378 /* corrected to specify an initial value. */
380 /* For VOICE, note that it is "shifted" in the statement that */
381 /* begins "IF (HALF .EQ. 1) THEN" below. Also, uninitialized */
382 /* values in the VOICE array can only affect entries in the VOIBUF
384 /* array that are for the same frame, or for an older frame. Thus
386 /* the effects of uninitialized values in VOICE cannot linger on */
387 /* for more than 2 or 3 frame times. */
389 /* For SFBUE and SLBUE, the effects of uninitialized values can */
390 /* linger on for many frame times, because their previous values */
391 /* are exponentially decayed. Thus it is more important to choose
393 /* initial values for these variables. I would guess that a */
394 /* reasonable initial value for SFBUE is REF/16, the same as used */
395 /* for FBUE and OFBUE. Similarly, SLBUE can be initialized to */
396 /* REF/32, the same as for LBUE and OLBUE. */
398 /* These guessed initial values should be validated by re-running */
399 /* the modified program on some audio samples. */
401 /* Declare and initialize filters: */
403 dither
= (&st
->dither
);
405 maxmin
= (&st
->maxmin
);
406 voice
= (&st
->voice
[0]);
411 ofbue
= (&st
->ofbue
);
412 olbue
= (&st
->olbue
);
413 sfbue
= (&st
->sfbue
);
414 slbue
= (&st
->slbue
);
416 /* Parameter adjustments */
424 inbuf_offset
= buflim
[1];
425 inbuf
-= inbuf_offset
;
428 lpbuf_offset
= buflim
[3];
429 lpbuf
-= lpbuf_offset
;
443 /* The following variables are saved from one invocation to the */
444 /* next, but are not initialized with DATA statements. This is */
445 /* acceptable, because FIRST is initialized ot .TRUE., and the */
446 /* first time that this subroutine is then called, they are all */
447 /* given initial values. */
450 /* LBVE, LBUE, FBVE, FBUE, OFBUE, OLBUE */
452 /* MAXMIN is initialized on the first call, assuming that HALF */
453 /* .EQ. 1 on first call. This is how ANALYS calls this subroutine.
456 /* Voicing Decision Parameter vector (* denotes zero coefficient): */
466 /* * LOG(LBE/LBVE) */
467 /* Define 2-D voicing decision coefficient vector according to the voicin
469 /* parameter order above. Each row (VDC vector) is optimized for a speci
471 /* SNR. The last element of the vector is the constant. */
472 /* E ZC RC1 Qs IVRC2 aRb aRf c */
474 /* The VOICE array contains the result of the linear discriminant functio
476 /* (analog values). The VOIBUF array contains the hard-limited binary
478 /* voicing decisions. The VOICE and VOIBUF arrays, according to FORTRAN
480 /* memory allocation, are addressed as: */
482 /* (half-frame number, future-frame number) */
484 /* | Past | Present | Future1 | Future2 | */
485 /* | 1,0 | 2,0 | 1,1 | 2,1 | 1,2 | 2,2 | 1,3 | 2,3 | ---> time */
487 /* Update linear discriminant function history each frame: */
493 *maxmin
= *maxamd
/ max(*minamd
,1.f
);
495 /* Calculate voicing parameters twice per frame: */
496 vparms_(&vwin
[1], &inbuf
[inbuf_offset
], &lpbuf
[lpbuf_offset
], &buflim
[1],
497 half
, dither
, mintau
, &zc
, &lbe
, &fbe
, &qs
, &rc1
, &ar_b__
, &
499 /* Estimate signal-to-noise ratio to select the appropriate VDC vector.
501 /* The SNR is estimated as the running average of the ratio of the */
502 /* running average full-band voiced energy to the running average */
503 /* full-band unvoiced energy. SNR filter has gain of 63. */
504 r__1
= (*snr
+ *fbve
/ (real
) max(*fbue
,1)) * 63 / 64.f
;
505 *snr
= (real
) i_nint(&r__1
);
506 snr2
= *snr
* *fbue
/ max(*lbue
,1);
507 /* Quantize SNR to SNRL according to VDCL thresholds. */
510 for (snrl
= 1; snrl
<= i__1
; ++snrl
) {
511 if (snr2
> vdcl
[snrl
- 1]) {
515 /* (Note: SNRL = NVDCL here) */
517 /* Linear discriminant voicing parameters: */
519 value
[1] = (real
) lbe
/ max(*lbve
,1);
520 value
[2] = (real
) zc
;
526 /* Evaluation of linear discriminant function: */
527 voice
[*half
+ 3] = vdc
[snrl
* 10 - 1];
528 for (i__
= 1; i__
<= 8; ++i__
) {
529 voice
[*half
+ 3] += vdc
[i__
+ snrl
* 10 - 11] * value
[i__
- 1];
531 /* Classify as voiced if discriminant > 0, otherwise unvoiced */
532 /* Voicing decision for current half-frame: 1 = Voiced; 0 = Unvoiced */
533 if (voice
[*half
+ 3] > 0.f
) {
534 voibuf
[*half
+ 6] = 1;
536 voibuf
[*half
+ 6] = 0;
538 /* Skip voicing decision smoothing in first half-frame: */
539 /* Give a value to VSTATE, so that trace statements below will print
541 /* a consistent value from one call to the next when HALF .EQ. 1. */
542 /* The value of VSTATE is not used for any other purpose when this is
549 /* Voicing decision smoothing rules (override of linear combination): */
551 /* Unvoiced half-frames: At least two in a row. */
552 /* -------------------- */
554 /* Voiced half-frames: At least two in a row in one frame. */
555 /* ------------------- Otherwise at least three in a row. */
556 /* (Due to the way transition frames are encoded) */
558 /* In many cases, the discriminant function determines how to smooth. */
559 /* In the following chart, the decisions marked with a * may be overridden
562 /* Voicing override of transitions at onsets: */
563 /* If a V/UV or UV/V voicing decision transition occurs within one-half
565 /* frame of an onset bounding a voicing window, then the transition is */
566 /* moved to occur at the onset. */
571 /* 0 0 0* 1 (If there is an onset there) */
572 /* 0 0 1* 0* (Based on 2F and discriminant distance) */
574 /* 0 1* 0 0 (Always) */
575 /* 0 1* 0* 1 (Based on discriminant distance) */
576 /* 0* 1 1 0* (Based on past, 2F, and discriminant distance) */
577 /* 0 1* 1 1 (If there is an onset there) */
578 /* 1 0* 0 0 (If there is an onset there) */
580 /* 1 0* 1* 0 (Based on discriminant distance) */
581 /* 1 0* 1 1 (Always) */
583 /* 1 1 0* 1* (Based on 2F and discriminant distance) */
584 /* 1 1 1* 0 (If there is an onset there) */
587 /* Determine if there is an onset transition between P and 1F. */
588 /* OT (Onset Transition) is true if there is an onset between */
589 /* P and 1F but not after 1F. */
590 ot
= ((obound
[1] & 2) != 0 || obound
[2] == 1) && (obound
[3] & 1) == 0;
591 /* Multi-way dispatch on voicing decision history: */
592 vstate
= (voibuf
[3] << 3) + (voibuf
[4] << 2) + (voibuf
[5] << 1) + voibuf
[
594 switch (vstate
+ 1) {
613 if (ot
&& voibuf
[7] == 1) {
618 if (voibuf
[7] == 0 || voice
[2] < -voice
[3]) {
628 if (voice
[1] < -voice
[2]) {
634 /* VOIBUF(2,0) must be 0 */
636 if (voibuf
[1] == 1 || voibuf
[7] == 1 || voice
[3] > voice
[0]) {
653 if (voice
[2] < -voice
[1]) {
663 if (voibuf
[7] == 0 && voice
[3] < -voice
[2]) {
670 if (ot
&& voibuf
[7] == 0) {
675 /* Now update parameters: */
676 /* ---------------------- */
678 /* During unvoiced half-frames, update the low band and full band unvoice
680 /* energy estimates (LBUE and FBUE) and also the zero crossing */
681 /* threshold (DITHER). (The input to the unvoiced energy filters is */
682 /* restricted to be less than 10dB above the previous inputs of the */
684 /* During voiced half-frames, update the low-pass (LBVE) and all-pass */
685 /* (FBVE) voiced energy estimates. */
686 if (voibuf
[*half
+ 6] == 0) {
688 i__1
= fbe
, i__2
= *ofbue
* 3;
689 r__1
= (*sfbue
* 63 + (min(i__1
,i__2
) << 3)) / 64.f
;
690 *sfbue
= i_nint(&r__1
);
694 i__1
= lbe
, i__2
= *olbue
* 3;
695 r__1
= (*slbue
* 63 + (min(i__1
,i__2
) << 3)) / 64.f
;
696 *slbue
= i_nint(&r__1
);
700 r__1
= (*lbve
* 63 + lbe
) / 64.f
;
701 *lbve
= i_nint(&r__1
);
702 r__1
= (*fbve
* 63 + fbe
) / 64.f
;
703 *fbve
= i_nint(&r__1
);
705 /* Set dither threshold to yield proper zero crossing rates in the */
706 /* presence of low frequency noise and low level signal input. */
707 /* NOTE: The divisor is a function of REF, the expected energies. */
710 r__2
= sqrt((real
) (*lbue
* *lbve
)) * 64 / 3000;
711 r__1
= max(r__2
,1.f
);
712 *dither
= min(r__1
,20.f
);
713 /* Voicing decisions are returned in VOIBUF. */