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

Go to the source code of this file.

Macros

#define contrl_1   contrl_
 

Functions

int dyptrk_ (real *amdf, integer *ltau, integer *minptr, integer *voice, integer *pitch, integer *midx, struct lpc10_encoder_state *st)
 

Variables

struct {
   logical   corrp
 
   integer   lframe
 
   integer   order
 
contrl_
 

Macro Definition Documentation

◆ contrl_1

#define contrl_1   contrl_

Definition at line 49 of file dyptrk.c.

Function Documentation

◆ dyptrk_()

int dyptrk_ ( real amdf,
integer ltau,
integer minptr,
integer voice,
integer pitch,
integer midx,
struct lpc10_encoder_state st 
)

Definition at line 129 of file dyptrk.c.

132{
133 /* Initialized data */
134
135 real *s;
136 integer *p;
137 integer *ipoint;
138 real *alphax;
139
140 /* System generated locals */
141 integer i__1;
142
143 /* Local variables */
144 integer pbar;
145 real sbar;
146 integer iptr, i__, j;
147 real alpha, minsc, maxsc;
148
149/* Arguments */
150/* $Log$
151 * Revision 1.15 2004/06/26 03:50:14 markster
152 * Merge source cleanups (bug #1911)
153 *
154 * Revision 1.14 2003/02/12 13:59:15 matteo
155 * mer feb 12 14:56:57 CET 2003
156 *
157 * Revision 1.1.1.1 2003/02/12 13:59:15 matteo
158 * mer feb 12 14:56:57 CET 2003
159 *
160 * Revision 1.2 2000/01/05 08:20:39 markster
161 * Some OSS fixes and a few lpc changes to make it actually work
162 *
163 * Revision 1.2 1996/08/20 20:25:29 jaf
164 * Removed all static local variables that were SAVE'd in the Fortran
165 * code, and put them in struct lpc10_encoder_state that is passed as an
166 * argument.
167 *
168 * Removed init function, since all initialization is now done in
169 * init_lpc10_encoder_state().
170 *
171 * Revision 1.1 1996/08/19 22:32:26 jaf
172 * Initial revision
173 * */
174/* Revision 1.3 1996/03/29 22:05:55 jaf */
175/* Commented out the common block variables that are not needed by the */
176/* embedded version. */
177
178/* Revision 1.2 1996/03/26 19:34:50 jaf */
179/* Added comments indicating which constants are not needed in an */
180/* application that uses the LPC-10 coder. */
181
182/* Revision 1.1 1996/02/07 14:44:09 jaf */
183/* Initial revision */
184
185/* LPC Processing control variables: */
186
187/* *** Read-only: initialized in setup */
188
189/* Files for Speech, Parameter, and Bitstream Input & Output, */
190/* and message and debug outputs. */
191
192/* Here are the only files which use these variables: */
193
194/* lpcsim.f setup.f trans.f error.f vqsetup.f */
195
196/* Many files which use fdebug are not listed, since it is only used in */
197/* those other files conditionally, to print trace statements. */
198/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
199/* LPC order, Frame size, Quantization rate, Bits per frame, */
200/* Error correction */
201/* Subroutine SETUP is the only place where order is assigned a value, */
202/* and that value is 10. It could increase efficiency 1% or so to */
203/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as
204*/
205/* a variable in a COMMON block, since it is used in many places in the */
206/* core of the coding and decoding routines. Actually, I take that back.
207*/
208/* At least when compiling with f2c, the upper bound of DO loops is */
209/* stored in a local variable before the DO loop begins, and then that is
210*/
211/* compared against on each iteration. */
212/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
213/* Similarly for quant, which is given a value of 2400 in SETUP. quant */
214/* is used in only a few places, and never in the core coding and */
215/* decoding routines, so it could be eliminated entirely. */
216/* nbits is similar to quant, and is given a value of 54 in SETUP. */
217/* corrp is given a value of .TRUE. in SETUP, and is only used in the */
218/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */
219/* coder significantly whether it is .TRUE. or .FALSE., or whether it is
220*/
221/* a constant or a variable, since it is only examined once per frame. */
222/* Leaving it as a variable that is set to .TRUE. seems like a good */
223/* idea, since it does enable some error-correction capability for */
224/* unvoiced frames, with no change in the coding rate, and no noticeable
225*/
226/* quality difference in the decoded speech. */
227/* integer quant, nbits */
228/* *** Read/write: variables for debugging, not needed for LPC algorithm
229*/
230
231/* Current frame, Unstable frames, Output clip count, Max onset buffer,
232*/
233/* Debug listing detail level, Line count on listing page */
234
235/* nframe is not needed for an embedded LPC10 at all. */
236/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
237/* ERROR, which is only called from RCCHK. When LPC10 is embedded into */
238/* an application, I would recommend removing the call to ERROR in RCCHK,
239*/
240/* and remove ERROR and nunsfm completely. */
241/* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in
242*/
243/* sread.f. When LPC10 is embedded into an application, one might want */
244/* to cause it to be incremented in a routine that takes the output of */
245/* SYNTHS and sends it to an audio device. It could be optionally */
246/* displayed, for those that might want to know what it is. */
247/* maxosp is never initialized to 0 in SETUP, although it probably should
248*/
249/* be, and it is updated in subroutine ANALYS. I doubt that its value */
250/* would be of much interest to an application in which LPC10 is */
251/* embedded. */
252/* listl and lincnt are not needed for an embedded LPC10 at all. */
253/* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
254/* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
255/* common /contrl/ quant, nbits */
256/* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
257/* Parameters/constants */
258/* Local variables that need not be saved */
259/* Note that PATH is only used for debugging purposes, and can be */
260/* removed. */
261/* Local state */
262/* It would be a bit more "general" to define S(LTAU), if Fortran */
263/* allows the argument of a function to be used as the dimension of
264*/
265/* a local array variable. */
266/* IPOINT is always in the range 0 to DEPTH-1. */
267/* WARNING! */
268
269/* In the original version of this subroutine, IPOINT, ALPHAX, */
270/* every element of S, and potentially any element of P with the */
271/* second index value .NE. IPTR were read without being given */
272/* initial values (all indices of P with second index equal to */
273/* IPTR are all written before being read in this subroutine). */
274
275/* From examining the code carefully, it appears that all of these
276*/
277/* should be saved from one invocation to the next. */
278
279/* I've run lpcsim with the "-l 6" option to see all of the */
280/* debugging information that is printed out by this subroutine */
281/* below, and it appears that S, P, IPOINT, and ALPHAX are all */
282/* initialized to 0 (these initial values would likely be different
283*/
284/* on different platforms, compilers, etc.). Given that the output
285*/
286/* of the coder sounds reasonable, I'm going to initialize these */
287/* variables to 0 explicitly. */
288
289 s = &(st->s[0]);
290 p = &(st->p[0]);
291 ipoint = &(st->ipoint);
292 alphax = &(st->alphax);
293
294
295 /* Parameter adjustments */
296 if (amdf) {
297 --amdf;
298 }
299
300 /* Function Body */
301
302/* Calculate the confidence factor ALPHA, used as a threshold slope in
303*/
304/* SEESAW. If unvoiced, set high slope so that every point in P array
305*/
306/* is marked as a potential pitch frequency. A scaled up version (ALPHAX
307)*/
308/* is used to maintain arithmetic precision. */
309 if (*voice == 1) {
310 *alphax = *alphax * .75f + amdf[*minptr] / 2.f;
311 } else {
312 *alphax *= .984375f;
313 }
314 alpha = *alphax / 16;
315 if (*voice == 0 && *alphax < 128.f) {
316 alpha = 8.f;
317 }
318/* SEESAW: Construct a pitch pointer array and intermediate winner functio
319n*/
320/* Left to right pass: */
321 iptr = *ipoint + 1;
322 p[iptr * 60 - 60] = 1;
323 i__ = 1;
324 pbar = 1;
325 sbar = s[0];
326 i__1 = *ltau;
327 for (i__ = 1; i__ <= i__1; ++i__) {
328 sbar += alpha;
329 if (sbar < s[i__ - 1]) {
330 s[i__ - 1] = sbar;
331 p[i__ + iptr * 60 - 61] = pbar;
332 } else {
333 sbar = s[i__ - 1];
334 p[i__ + iptr * 60 - 61] = i__;
335 pbar = i__;
336 }
337 }
338/* Right to left pass: */
339 i__ = pbar - 1;
340 sbar = s[i__];
341 while(i__ >= 1) {
342 sbar += alpha;
343 if (sbar < s[i__ - 1]) {
344 s[i__ - 1] = sbar;
345 p[i__ + iptr * 60 - 61] = pbar;
346 } else {
347 pbar = p[i__ + iptr * 60 - 61];
348 i__ = pbar;
349 sbar = s[i__ - 1];
350 }
351 --i__;
352 }
353/* Update S using AMDF */
354/* Find maximum, minimum, and location of minimum */
355 s[0] += amdf[1] / 2;
356 minsc = s[0];
357 maxsc = minsc;
358 *midx = 1;
359 i__1 = *ltau;
360 for (i__ = 2; i__ <= i__1; ++i__) {
361 s[i__ - 1] += amdf[i__] / 2;
362 if (s[i__ - 1] > maxsc) {
363 maxsc = s[i__ - 1];
364 }
365 if (s[i__ - 1] < minsc) {
366 *midx = i__;
367 minsc = s[i__ - 1];
368 }
369 }
370/* Subtract MINSC from S to prevent overflow */
371 i__1 = *ltau;
372 for (i__ = 1; i__ <= i__1; ++i__) {
373 s[i__ - 1] -= minsc;
374 }
375 maxsc -= minsc;
376/* Use higher octave pitch if significant null there */
377 j = 0;
378 for (i__ = 20; i__ <= 40; i__ += 10) {
379 if (*midx > i__) {
380 if (s[*midx - i__ - 1] < maxsc / 4) {
381 j = i__;
382 }
383 }
384 }
385 *midx -= j;
386/* TRACE: look back two frames to find minimum cost pitch estimate */
387 j = *ipoint;
388 *pitch = *midx;
389 for (i__ = 1; i__ <= 2; ++i__) {
390 j = j % 2 + 1;
391 *pitch = p[*pitch + j * 60 - 61];
392 }
393
394/* The following statement subtracts one from IPOINT, mod DEPTH. I
395*/
396/* think the author chose to add DEPTH-1, instead of subtracting 1,
397*/
398/* because then it will work even if MOD doesn't work as desired on
399*/
400/* negative arguments. */
401
402 *ipoint = (*ipoint + 1) % 2;
403 return 0;
404} /* dyptrk_ */
float real
Definition: lpc10.h:79
INT32 integer
Definition: lpc10.h:80
real s[60]
Definition: lpc10.h:138
integer p[120]
Definition: lpc10.h:139
integer ipoint
Definition: lpc10.h:140

References lpc10_encoder_state::alphax, lpc10_encoder_state::ipoint, lpc10_encoder_state::p, and lpc10_encoder_state::s.

Referenced by analys_().

Variable Documentation

◆ 

struct { ... } contrl_

◆ corrp

logical corrp

Definition at line 46 of file dyptrk.c.

◆ lframe

integer lframe

Definition at line 45 of file dyptrk.c.

◆ order

integer order

Definition at line 45 of file dyptrk.c.