Asterisk - The Open Source Telephony Project  18.5.0
Macros | Functions | Variables
lpcini.c File Reference
#include "asterisk.h"
#include "f2c.h"
Include dependency graph for lpcini.c:

Go to the source code of this file.

Macros

#define ASTMM_LIBC   ASTMM_REDIRECT
 
#define contrl_1   contrl_
 

Functions

struct lpc10_decoder_statecreate_lpc10_decoder_state ()
 
struct lpc10_encoder_statecreate_lpc10_encoder_state ()
 
void init_lpc10_decoder_state (struct lpc10_decoder_state *st)
 
void init_lpc10_encoder_state (struct lpc10_encoder_state *st)
 
int lpcini_ (void)
 

Variables

struct {
   logical   corrp
 
   integer   lframe
 
   integer   order
 
contrl_
 

Macro Definition Documentation

◆ ASTMM_LIBC

#define ASTMM_LIBC   ASTMM_REDIRECT

Definition at line 37 of file lpcini.c.

◆ contrl_1

#define contrl_1   contrl_

Definition at line 55 of file lpcini.c.

Referenced by lpcini_().

Function Documentation

◆ create_lpc10_decoder_state()

struct lpc10_decoder_state* create_lpc10_decoder_state ( void  )

Definition at line 369 of file lpcini.c.

References init_lpc10_decoder_state(), and malloc().

Referenced by lpc10_dec_new().

370 {
371  struct lpc10_decoder_state *st;
372 
373  st = (struct lpc10_decoder_state *)
374  malloc((unsigned) sizeof (struct lpc10_decoder_state));
375  if (st != 0) {
377  }
378  return (st);
379 }
char * malloc()
void init_lpc10_decoder_state(struct lpc10_decoder_state *st)
Definition: lpcini.c:383

◆ create_lpc10_encoder_state()

struct lpc10_encoder_state* create_lpc10_encoder_state ( void  )

Definition at line 258 of file lpcini.c.

References init_lpc10_encoder_state(), and malloc().

Referenced by lpc10_enc_new().

259 {
260  struct lpc10_encoder_state *st;
261 
262  st = (struct lpc10_encoder_state *)
263  malloc((unsigned) sizeof (struct lpc10_encoder_state));
264  if (st != 0) {
266  }
267  return (st);
268 }
char * malloc()
void init_lpc10_encoder_state(struct lpc10_encoder_state *st)
Definition: lpcini.c:272

◆ init_lpc10_decoder_state()

void init_lpc10_decoder_state ( struct lpc10_decoder_state st)

Definition at line 383 of file lpcini.c.

References lpc10_decoder_state::buf, lpc10_decoder_state::buflen, lpc10_decoder_state::dei1, lpc10_decoder_state::dei2, lpc10_decoder_state::deo1, lpc10_decoder_state::deo2, lpc10_decoder_state::deo3, lpc10_decoder_state::dpit, lpc10_decoder_state::drc, lpc10_decoder_state::drms, lpc10_decoder_state::erate, lpc10_decoder_state::exc, lpc10_decoder_state::exc2, lpc10_decoder_state::first, lpc10_decoder_state::first_pitsyn, lpc10_decoder_state::hpi1, lpc10_decoder_state::hpi2, lpc10_decoder_state::hpi3, lpc10_decoder_state::iavgp, lpc10_decoder_state::iovoic, lpc10_decoder_state::ipo, lpc10_decoder_state::iptold, lpc10_decoder_state::ivp2h, lpc10_decoder_state::j, lpc10_decoder_state::k, lpcini_(), lpc10_decoder_state::lpi1, lpc10_decoder_state::lpi2, lpc10_decoder_state::lpi3, lpc10_decoder_state::rmso, lpc10_decoder_state::rmso_bsynz, TRUE_, and lpc10_decoder_state::y.

Referenced by create_lpc10_decoder_state().

384 {
385  int i;
386 
387  lpcini_();
388 
389  /* State used by function decode */
390  st->iptold = 60;
391  st->first = TRUE_;
392  st->ivp2h = 0;
393  st->iovoic = 0;
394  st->iavgp = 60;
395  st->erate = 0;
396  for (i = 0; i < 30; i++) {
397  st->drc[i] = 0;
398  }
399  for (i = 0; i < 3; i++) {
400  st->dpit[i] = 0;
401  st->drms[i] = 0;
402  }
403 
404  /* State used by function synths */
405  for (i = 0; i < 360; i++) {
406  st->buf[i] = 0.0f;
407  }
408  st->buflen = 180;
409 
410  /* State used by function pitsyn */
411  /* ivoico; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
412  /* ipito; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
413  st->rmso = 1.0f;
414  /* rco[10]; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
415  /* integer jsamp; */ /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
416  st->first_pitsyn = TRUE_;
417 
418  /* State used by function bsynz */
419  st->ipo = 0;
420  for (i = 0; i < 166; i++) {
421  st->exc[i] = 0.0f;
422  st->exc2[i] = 0.0f;
423  }
424  st->lpi1 = 0.0f;
425  st->lpi2 = 0.0f;
426  st->lpi3 = 0.0f;
427  st->hpi1 = 0.0f;
428  st->hpi2 = 0.0f;
429  st->hpi3 = 0.0f;
430  st->rmso_bsynz = 0.0f;
431 
432  /* State used by function random */
433  st->j = 2;
434  st->k = 5;
435  st->y[0] = (shortint) -21161;
436  st->y[1] = (shortint) -8478;
437  st->y[2] = (shortint) 30892;
438  st->y[3] = (shortint) -10216;
439  st->y[4] = (shortint) 16950;
440 
441  /* State used by function deemp */
442  st->dei1 = 0.0f;
443  st->dei2 = 0.0f;
444  st->deo1 = 0.0f;
445  st->deo2 = 0.0f;
446  st->deo3 = 0.0f;
447 }
#define TRUE_
Definition: f2c.h:67
integer buflen
Definition: lpc10.h:164
integer erate
Definition: lpc10.h:157
integer iavgp
Definition: lpc10.h:156
logical first
Definition: lpc10.h:153
integer iptold
Definition: lpc10.h:152
shortint y[5]
Definition: lpc10.h:189
integer drms[3]
Definition: lpc10.h:160
real exc[166]
Definition: lpc10.h:176
integer iovoic
Definition: lpc10.h:155
integer drc[30]
Definition: lpc10.h:158
integer dpit[3]
Definition: lpc10.h:159
real exc2[166]
Definition: lpc10.h:177
integer ivp2h
Definition: lpc10.h:154
int lpcini_(void)
Definition: lpcini.c:94
logical first_pitsyn
Definition: lpc10.h:172
real buf[360]
Definition: lpc10.h:163
INT16 shortint
Definition: lpc10.h:82

◆ init_lpc10_encoder_state()

void init_lpc10_encoder_state ( struct lpc10_encoder_state st)

Definition at line 272 of file lpcini.c.

References lpc10_encoder_state::alphax, lpc10_encoder_state::awin, lpc10_encoder_state::bias, lpc10_encoder_state::d__, lpc10_encoder_state::dither, FALSE_, lpc10_encoder_state::fbue, lpc10_encoder_state::fbve, lpc10_encoder_state::hyst, lpc10_encoder_state::inbuf, lpc10_encoder_state::ipoint, lpc10_encoder_state::isync, lpc10_encoder_state::ivbuf, lpc10_encoder_state::l2buf, lpc10_encoder_state::l2ptr1, lpc10_encoder_state::l2ptr2, lpc10_encoder_state::l2sum1, lpc10_encoder_state::lbue, lpc10_encoder_state::lbve, lpc10_encoder_state::lpbuf, lpcini_(), lpc10_encoder_state::maxmin, lpc10_encoder_state::n, lpc10_encoder_state::obound, lpc10_encoder_state::ofbue, lpc10_encoder_state::olbue, lpc10_encoder_state::osptr, lpc10_encoder_state::p, lpc10_encoder_state::pebuf, lpc10_encoder_state::rcbuf, lpc10_encoder_state::rmsbuf, lpc10_encoder_state::s, lpc10_encoder_state::sfbue, lpc10_encoder_state::slbue, lpc10_encoder_state::snr, lpc10_encoder_state::voibuf, lpc10_encoder_state::voice, lpc10_encoder_state::vwin, lpc10_encoder_state::z11, lpc10_encoder_state::z12, lpc10_encoder_state::z21, lpc10_encoder_state::z22, and lpc10_encoder_state::zpre.

Referenced by create_lpc10_encoder_state().

273 {
274  int i;
275 
276  lpcini_();
277 
278  /* State used only by function hp100 */
279  st->z11 = 0.0f;
280  st->z21 = 0.0f;
281  st->z12 = 0.0f;
282  st->z22 = 0.0f;
283 
284  /* State used by function analys */
285  for (i = 0; i < 540; i++) {
286  st->inbuf[i] = 0.0f;
287  st->pebuf[i] = 0.0f;
288  }
289  for (i = 0; i < 696; i++) {
290  st->lpbuf[i] = 0.0f;
291  }
292  for (i = 0; i < 312; i++) {
293  st->ivbuf[i] = 0.0f;
294  }
295  st->bias = 0.0f;
296  /* integer osbuf[10]; */ /* no initial value necessary */
297  st->osptr = 1;
298  for (i = 0; i < 3; i++) {
299  st->obound[i] = 0;
300  }
301  st->vwin[4] = 307;
302  st->vwin[5] = 462;
303  st->awin[4] = 307;
304  st->awin[5] = 462;
305  for (i = 0; i < 8; i++) {
306  st->voibuf[i] = 0;
307  }
308  for (i = 0; i < 3; i++) {
309  st->rmsbuf[i] = 0.0f;
310  }
311  for (i = 0; i < 30; i++) {
312  st->rcbuf[i] = 0.0f;
313  }
314  st->zpre = 0.0f;
315 
316 
317  /* State used by function onset */
318  st->n = 0.0f;
319  st->d__ = 1.0f;
320  /* real fpc; */ /* no initial value necessary */
321  for (i = 0; i < 16; i++) {
322  st->l2buf[i] = 0.0f;
323  }
324  st->l2sum1 = 0.0f;
325  st->l2ptr1 = 1;
326  st->l2ptr2 = 9;
327  /* integer lasti; */ /* no initial value necessary */
328  st->hyst = FALSE_;
329 
330  /* State used by function voicin */
331  st->dither = 20.0f;
332  st->maxmin = 0.0f;
333  for (i = 0; i < 6; i++) {
334  st->voice[i] = 0.0f;
335  }
336  st->lbve = 3000;
337  st->fbve = 3000;
338  st->fbue = 187;
339  st->ofbue = 187;
340  st->sfbue = 187;
341  st->lbue = 93;
342  st->olbue = 93;
343  st->slbue = 93;
344  st->snr = (real) (st->fbve / st->fbue << 6);
345 
346  /* State used by function dyptrk */
347  for (i = 0; i < 60; i++) {
348  st->s[i] = 0.0f;
349  }
350  for (i = 0; i < 120; i++) {
351  st->p[i] = 0;
352  }
353  st->ipoint = 0;
354  st->alphax = 0.0f;
355 
356  /* State used by function chanwr */
357  st->isync = 0;
358 
359 }
integer fbve
Definition: lpc10.h:122
integer fbue
Definition: lpc10.h:122
integer olbue
Definition: lpc10.h:124
real rcbuf[30]
Definition: lpc10.h:102
integer awin[6]
Definition: lpc10.h:99
integer lbve
Definition: lpc10.h:122
integer vwin[6]
Definition: lpc10.h:98
real lpbuf[696]
Definition: lpc10.h:93
integer l2ptr1
Definition: lpc10.h:112
integer slbue
Definition: lpc10.h:124
integer sfbue
Definition: lpc10.h:123
integer p[120]
Definition: lpc10.h:139
real rmsbuf[3]
Definition: lpc10.h:101
integer obound[3]
Definition: lpc10.h:97
real inbuf[540]
Definition: lpc10.h:92
logical hyst
Definition: lpc10.h:115
integer voibuf[8]
Definition: lpc10.h:100
real pebuf[540]
Definition: lpc10.h:92
float real
Definition: lpc10.h:79
integer lbue
Definition: lpc10.h:122
real voice[6]
Definition: lpc10.h:121
real ivbuf[312]
Definition: lpc10.h:93
integer isync
Definition: lpc10.h:144
integer osptr
Definition: lpc10.h:96
integer ofbue
Definition: lpc10.h:123
real l2buf[16]
Definition: lpc10.h:110
int lpcini_(void)
Definition: lpcini.c:94
integer l2ptr2
Definition: lpc10.h:113
real s[60]
Definition: lpc10.h:138
integer ipoint
Definition: lpc10.h:140
#define FALSE_
Definition: f2c.h:68

◆ lpcini_()

int lpcini_ ( void  )

Definition at line 94 of file lpcini.c.

References contrl_1, and TRUE_.

Referenced by init_lpc10_decoder_state(), and init_lpc10_encoder_state().

95 {
96 
97 /* $Log$
98  * Revision 1.18 2003/10/21 18:08:11 markster
99  * Fix include order
100  *
101  * Revision 1.5 2003/10/21 18:08:11 markster
102  * Fix include order
103  *
104  * Revision 1.4 2003/10/21 02:57:29 markster
105  * FreeBSD patch, take 2
106  *
107  * Revision 1.3 2003/10/16 21:11:30 martinp
108  * Revert the previous patch since it's braking compilation
109  *
110  * Revision 1.1 2003/02/12 13:59:15 matteo
111  * Initial revision
112  *
113  * Revision 1.2 2000/01/05 08:20:39 markster
114  * Some OSS fixes and a few lpc changes to make it actually work
115  *
116  * Revision 1.2 1996/08/20 20:35:41 jaf
117  * Added functions for allocating and initializing lpc10_encoder_state
118  * and lpc10_decoder_state structures.
119  *
120  * Revision 1.1 1996/08/19 22:31:40 jaf
121  * Initial revision
122  * */
123 /* Revision 1.3 1996/03/29 22:03:47 jaf */
124 /* Removed definitions for any constants that were no longer used. */
125 
126 /* Revision 1.2 1996/03/26 19:34:33 jaf */
127 /* Added comments indicating which constants are not needed in an */
128 /* application that uses the LPC-10 coder. */
129 
130 /* Revision 1.1 1996/02/07 14:43:51 jaf */
131 /* Initial revision */
132 
133 /* LPC Configuration parameters: */
134 /* Frame size, Prediction order, Pitch period */
135 /* $Log$
136  * Revision 1.18 2003/10/21 18:08:11 markster
137  * Fix include order
138  *
139  * Revision 1.5 2003/10/21 18:08:11 markster
140  * Fix include order
141  *
142  * Revision 1.4 2003/10/21 02:57:29 markster
143  * FreeBSD patch, take 2
144  *
145  * Revision 1.3 2003/10/16 21:11:30 martinp
146  * Revert the previous patch since it's braking compilation
147  *
148  * Revision 1.1 2003/02/12 13:59:15 matteo
149  * Initial revision
150  *
151  * Revision 1.2 2000/01/05 08:20:39 markster
152  * Some OSS fixes and a few lpc changes to make it actually work
153  *
154  * Revision 1.2 1996/08/20 20:35:41 jaf
155  * Added functions for allocating and initializing lpc10_encoder_state
156  * and lpc10_decoder_state structures.
157  *
158  * Revision 1.1 1996/08/19 22:31:40 jaf
159  * Initial revision
160  * */
161 /* Revision 1.3 1996/03/29 22:05:55 jaf */
162 /* Commented out the common block variables that are not needed by the */
163 /* embedded version. */
164 
165 /* Revision 1.2 1996/03/26 19:34:50 jaf */
166 /* Added comments indicating which constants are not needed in an */
167 /* application that uses the LPC-10 coder. */
168 
169 /* Revision 1.1 1996/02/07 14:44:09 jaf */
170 /* Initial revision */
171 
172 /* LPC Processing control variables: */
173 
174 /* *** Read-only: initialized in setup */
175 
176 /* Files for Speech, Parameter, and Bitstream Input & Output, */
177 /* and message and debug outputs. */
178 
179 /* Here are the only files which use these variables: */
180 
181 /* lpcsim.f setup.f trans.f error.f vqsetup.f */
182 
183 /* Many files which use fdebug are not listed, since it is only used in */
184 /* those other files conditionally, to print trace statements. */
185 /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
186 /* LPC order, Frame size, Quantization rate, Bits per frame, */
187 /* Error correction */
188 /* Subroutine SETUP is the only place where order is assigned a value, */
189 /* and that value is 10. It could increase efficiency 1% or so to */
190 /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as
191 */
192 /* a variable in a COMMON block, since it is used in many places in the */
193 /* core of the coding and decoding routines. Actually, I take that back.
194 */
195 /* At least when compiling with f2c, the upper bound of DO loops is */
196 /* stored in a local variable before the DO loop begins, and then that is
197 */
198 /* compared against on each iteration. */
199 /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
200 /* Similarly for quant, which is given a value of 2400 in SETUP. quant */
201 /* is used in only a few places, and never in the core coding and */
202 /* decoding routines, so it could be eliminated entirely. */
203 /* nbits is similar to quant, and is given a value of 54 in SETUP. */
204 /* corrp is given a value of .TRUE. in SETUP, and is only used in the */
205 /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */
206 /* coder significantly whether it is .TRUE. or .FALSE., or whether it is
207 */
208 /* a constant or a variable, since it is only examined once per frame. */
209 /* Leaving it as a variable that is set to .TRUE. seems like a good */
210 /* idea, since it does enable some error-correction capability for */
211 /* unvoiced frames, with no change in the coding rate, and no noticeable
212 */
213 /* quality difference in the decoded speech. */
214 /* integer quant, nbits */
215 /* *** Read/write: variables for debugging, not needed for LPC algorithm
216 */
217 
218 /* Current frame, Unstable frames, Output clip count, Max onset buffer,
219 */
220 /* Debug listing detail level, Line count on listing page */
221 
222 /* nframe is not needed for an embedded LPC10 at all. */
223 /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
224 /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */
225 /* an application, I would recommend removing the call to ERROR in RCCHK,
226 */
227 /* and remove ERROR and nunsfm completely. */
228 /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in
229 */
230 /* sread.f. When LPC10 is embedded into an application, one might want */
231 /* to cause it to be incremented in a routine that takes the output of */
232 /* SYNTHS and sends it to an audio device. It could be optionally */
233 /* displayed, for those that might want to know what it is. */
234 /* maxosp is never initialized to 0 in SETUP, although it probably should
235 */
236 /* be, and it is updated in subroutine ANALYS. I doubt that its value */
237 /* would be of much interest to an application in which LPC10 is */
238 /* embedded. */
239 /* listl and lincnt are not needed for an embedded LPC10 at all. */
240 /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
241 /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
242 /* common /contrl/ quant, nbits */
243 /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
244  contrl_1.order = 10;
245  contrl_1.lframe = 180;
246  contrl_1.corrp = TRUE_;
247  return 0;
248 } /* lpcini_ */
#define TRUE_
Definition: f2c.h:67
#define contrl_1
Definition: lpcini.c:55

Variable Documentation

◆ contrl_

struct { ... } contrl_

◆ corrp

logical corrp

Definition at line 52 of file lpcini.c.

◆ lframe

integer lframe

Definition at line 51 of file lpcini.c.

◆ order

integer order

Definition at line 51 of file lpcini.c.