3 * Revision 1.2 1996/08/20 20:35:41 jaf
4 * Added functions for allocating and initializing lpc10_encoder_state
5 * and lpc10_decoder_state structures.
7 * Revision 1.1 1996/08/19 22:31:40 jaf
13 /* -- translated by f2c (version 19951025).
14 You must link the resulting object file with the libraries:
15 -lf2c -lm (in that order)
22 extern int lpcini_(void);
24 /* Common Block Declarations */
27 integer order
, lframe
;
31 #define contrl_1 contrl_
33 /* ***************************************************************** */
36 * Revision 1.2 1996/08/20 20:35:41 jaf
37 * Added functions for allocating and initializing lpc10_encoder_state
38 * and lpc10_decoder_state structures.
40 * Revision 1.1 1996/08/19 22:31:40 jaf
43 /* Revision 1.1 1996/03/28 00:04:05 jaf */
44 /* Initial revision */
47 /* ***************************************************************** */
49 /* Initialize COMMON block variables used by LPC-10 encoder and decoder, */
50 /* and call initialization routines for both of them. */
52 /* Subroutine */ int lpcini_(void)
55 /* LPC Processing control variables: */
57 /* *** Read-only: initialized in setup */
59 /* Files for Speech, Parameter, and Bitstream Input & Output, */
60 /* and message and debug outputs. */
62 /* Here are the only files which use these variables: */
64 /* lpcsim.f setup.f trans.f error.f vqsetup.f */
66 /* Many files which use fdebug are not listed, since it is only used in */
67 /* those other files conditionally, to print trace statements. */
68 /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
69 /* LPC order, Frame size, Quantization rate, Bits per frame, */
70 /* Error correction */
71 /* Subroutine SETUP is the only place where order is assigned a value, */
72 /* and that value is 10. It could increase efficiency 1% or so to */
73 /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as
75 /* a variable in a COMMON block, since it is used in many places in the */
76 /* core of the coding and decoding routines. Actually, I take that back.
78 /* At least when compiling with f2c, the upper bound of DO loops is */
79 /* stored in a local variable before the DO loop begins, and then that is
81 /* compared against on each iteration. */
82 /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
83 /* Similarly for quant, which is given a value of 2400 in SETUP. quant */
84 /* is used in only a few places, and never in the core coding and */
85 /* decoding routines, so it could be eliminated entirely. */
86 /* nbits is similar to quant, and is given a value of 54 in SETUP. */
87 /* corrp is given a value of .TRUE. in SETUP, and is only used in the */
88 /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */
89 /* coder significantly whether it is .TRUE. or .FALSE., or whether it is
91 /* a constant or a variable, since it is only examined once per frame. */
92 /* Leaving it as a variable that is set to .TRUE. seems like a good */
93 /* idea, since it does enable some error-correction capability for */
94 /* unvoiced frames, with no change in the coding rate, and no noticeable
96 /* quality difference in the decoded speech. */
97 /* integer quant, nbits */
98 /* *** Read/write: variables for debugging, not needed for LPC algorithm
101 /* Current frame, Unstable frames, Output clip count, Max onset buffer,
103 /* Debug listing detail level, Line count on listing page */
105 /* nframe is not needed for an embedded LPC10 at all. */
106 /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
107 /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */
108 /* an application, I would recommend removing the call to ERROR in RCCHK,
110 /* and remove ERROR and nunsfm completely. */
111 /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in
113 /* sread.f. When LPC10 is embedded into an application, one might want */
114 /* to cause it to be incremented in a routine that takes the output of */
115 /* SYNTHS and sends it to an audio device. It could be optionally */
116 /* displayed, for those that might want to know what it is. */
117 /* maxosp is never initialized to 0 in SETUP, although it probably should
119 /* be, and it is updated in subroutine ANALYS. I doubt that its value */
120 /* would be of much interest to an application in which LPC10 is */
122 /* listl and lincnt are not needed for an embedded LPC10 at all. */
123 /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
124 /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
125 /* common /contrl/ quant, nbits */
126 /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
128 contrl_1
.lframe
= 180;
129 contrl_1
.corrp
= TRUE_
;
135 /* Allocate memory for, and initialize, the state that needs to be
136 kept from encoding one frame to the next for a single
137 LPC-10-compressed audio stream. Return 0 if malloc fails,
138 otherwise return pointer to new structure. */
140 struct lpc10_encoder_state
*
141 create_lpc10_encoder_state(void)
143 struct lpc10_encoder_state
*st
;
145 st
= (struct lpc10_encoder_state
*)
146 malloc((unsigned) sizeof (struct lpc10_encoder_state
));
148 init_lpc10_encoder_state(st
);
155 void init_lpc10_encoder_state(struct lpc10_encoder_state
*st
)
161 /* State used only by function hp100 */
167 /* State used by function analys */
168 for (i
= 0; i
< 540; i
++) {
172 for (i
= 0; i
< 696; i
++) {
175 for (i
= 0; i
< 312; i
++) {
179 /* integer osbuf[10]; no initial value necessary */
181 for (i
= 0; i
< 3; i
++) {
188 for (i
= 0; i
< 8; i
++) {
191 for (i
= 0; i
< 3; i
++) {
192 st
->rmsbuf
[i
] = 0.0f
;
194 for (i
= 0; i
< 30; i
++) {
200 /* State used by function onset */
203 /* real fpc; no initial value necessary */
204 for (i
= 0; i
< 16; i
++) {
210 /* integer lasti; no initial value necessary */
213 /* State used by function voicin */
216 for (i
= 0; i
< 6; i
++) {
227 st
->snr
= (real
) (st
->fbve
/ st
->fbue
<< 6);
229 /* State used by function dyptrk */
230 for (i
= 0; i
< 60; i
++) {
233 for (i
= 0; i
< 120; i
++) {
239 /* State used by function chanwr */
246 /* Allocate memory for, and initialize, the state that needs to be
247 kept from decoding one frame to the next for a single
248 LPC-10-compressed audio stream. Return 0 if malloc fails,
249 otherwise return pointer to new structure. */
251 struct lpc10_decoder_state
*
252 create_lpc10_decoder_state(void)
254 struct lpc10_decoder_state
*st
;
256 st
= (struct lpc10_decoder_state
*)
257 malloc((unsigned) sizeof (struct lpc10_decoder_state
));
259 init_lpc10_decoder_state(st
);
266 void init_lpc10_decoder_state(struct lpc10_decoder_state
*st
)
272 /* State used by function decode */
279 for (i
= 0; i
< 30; i
++) {
282 for (i
= 0; i
< 3; i
++) {
287 /* State used by function synths */
288 for (i
= 0; i
< 360; i
++) {
293 /* State used by function pitsyn */
294 /* ivoico; no initial value necessary as long as first_pitsyn is initially TRUE_ */
295 /* ipito; no initial value necessary as long as first_pitsyn is initially TRUE_ */
297 /* rco[10]; no initial value necessary as long as first_pitsyn is initially TRUE_ */
298 /* integer jsamp; no initial value necessary as long as first_pitsyn is initially TRUE_ */
299 st
->first_pitsyn
= TRUE_
;
301 /* State used by function bsynz */
303 for (i
= 0; i
< 166; i
++) {
313 st
->rmso_bsynz
= 0.0f
;
315 /* State used by function random */
318 st
->y
[0] = (shortint
) -21161;
319 st
->y
[1] = (shortint
) -8478;
320 st
->y
[2] = (shortint
) 30892;
321 st
->y
[3] = (shortint
) -10216;
322 st
->y
[4] = (shortint
) 16950;
324 /* State used by function deemp */