1 /*
2
3 $Log$
4 Revision 1.2 2006/08/01 13:06:50 rjongbloed
5 Added a raft of unvalidated audio codecs from OpenH323 tree
6
7 Revision 1.1.2.1 2006/07/22 14:03:17 rjongbloed
8 Added more plug ins
9
10 Revision 1.1.2.1 2006/05/08 13:49:57 rjongbloed
11 Imported all the audio codec plug ins from OpenH323
12
13 Revision 1.1 2004/05/04 11:16:43 csoutheren
14 Initial version
15
16 Revision 1.1 2000/06/05 04:45:12 robertj
17 Added LPC-10 2400bps codec
18
19 * Revision 1.2 1996/08/20 20:30:11 jaf
20 * Removed all static local variables that were SAVE'd in the Fortran
21 * code, and put them in struct lpc10_encoder_state that is passed as an
22 * argument.
23 *
24 * Removed init function, since all initialization is now done in
25 * init_lpc10_encoder_state().
26 *
27 * Changed name of function from lpcenc_ to lpc10_encode, simply to make
28 * all lpc10 functions have more consistent naming with each other.
29 *
30 * Revision 1.1 1996/08/19 22:31:48 jaf
31 * Initial revision
32 *
33
34 */
35
36 #ifdef P_R_O_T_O_T_Y_P_E_S
37 extern int lpcdec_(integer *bits, real *speech);
38 extern int initlpcdec_(void);
39 /* comlen contrl_ 12 */
40 /*:ref: chanrd_ 14 5 4 4 4 4 4 */
41 /*:ref: decode_ 14 7 4 4 4 4 4 6 6 */
42 /*:ref: synths_ 14 6 4 4 6 6 6 4 */
43 /*:ref: initdecode_ 14 0 */
44 /*:ref: initsynths_ 14 0 */
45 #endif
46
47 /* -- translated by f2c (version 19951025).
48 You must link the resulting object file with the libraries:
49 -lf2c -lm (in that order)
50 */
51
52 #include "f2c.h"
53
54 /* Common Block Declarations */
55
56 extern struct {
57 integer order, lframe;
58 logical corrp;
59 } contrl_;
60
61 #define contrl_1 contrl_
62
63 /* Table of constant values */
64
65 static integer c__10 = 10;
66
67 /* ***************************************************************** */
68
69 /* $Log$
70 /* Revision 1.2 2006/08/01 13:06:50 rjongbloed
71 /* Added a raft of unvalidated audio codecs from OpenH323 tree
72 /*
73 /* Revision 1.1.2.1 2006/07/22 14:03:17 rjongbloed
74 /* Added more plug ins
75 /*
76 /* Revision 1.1.2.1 2006/05/08 13:49:57 rjongbloed
77 /* Imported all the audio codec plug ins from OpenH323
78 /*
79 /* Revision 1.1 2004/05/04 11:16:43 csoutheren
80 /* Initial version
81 /*
82 /* Revision 1.1 2000/06/05 04:45:12 robertj
83 /* Added LPC-10 2400bps codec
84 /*
85 * Revision 1.2 1996/08/20 20:30:11 jaf
86 * Removed all static local variables that were SAVE'd in the Fortran
87 * code, and put them in struct lpc10_encoder_state that is passed as an
88 * argument.
89 *
90 * Removed init function, since all initialization is now done in
91 * init_lpc10_encoder_state().
92 *
93 * Changed name of function from lpcenc_ to lpc10_encode, simply to make
94 * all lpc10 functions have more consistent naming with each other.
95 *
96 * Revision 1.1 1996/08/19 22:31:48 jaf
97 * Initial revision
98 * */
99 /* Revision 1.1 1996/03/28 00:03:00 jaf */
100 /* Initial revision */
101
102
103 /* ***************************************************************** */
104
105 /* Decode 54 bits to one frame of 180 speech samples. */
106
107 /* Input: */
108 /* BITS - 54 encoded bits, stored 1 per array element. */
109 /* Indices 1 through 53 read (SYNC bit ignored). */
110 /* Output: */
111 /* SPEECH - Speech encoded as real values in the range [-1,+1]. */
112 /* Indices 1 through 180 written. */
113
114 /* This subroutine maintains local state from one call to the next. If */
115 /* you want to switch to using a new audio stream for this filter, or */
116 /* reinitialize its state for any other reason, call the ENTRY */
117 /* INITLPCDEC. */
118
lpc10_decode(integer * bits,real * speech,struct lpc10_decoder_state * st)119 /* Subroutine */ int lpc10_decode(integer *bits, real *speech,
120 struct lpc10_decoder_state *st)
121 {
122 integer irms, voice[2], pitch, ipitv;
123 extern /* Subroutine */ int decode_(integer *, integer *, integer *,
124 integer *, integer *, real *, real *, struct lpc10_decoder_state *);
125 real rc[10];
126 extern /* Subroutine */ int chanrd_(integer *, integer *, integer *,
127 integer *, integer *), synths_(integer *,
128 integer *, real *, real *, real *, integer *,
129 struct lpc10_decoder_state *);
130 integer irc[10], len;
131 real rms;
132
133 /* $Log$
134 /* Revision 1.2 2006/08/01 13:06:50 rjongbloed
135 /* Added a raft of unvalidated audio codecs from OpenH323 tree
136 /*
137 /* Revision 1.1.2.1 2006/07/22 14:03:17 rjongbloed
138 /* Added more plug ins
139 /*
140 /* Revision 1.1.2.1 2006/05/08 13:49:57 rjongbloed
141 /* Imported all the audio codec plug ins from OpenH323
142 /*
143 /* Revision 1.1 2004/05/04 11:16:43 csoutheren
144 /* Initial version
145 /*
146 /* Revision 1.1 2000/06/05 04:45:12 robertj
147 /* Added LPC-10 2400bps codec
148 /*
149 * Revision 1.2 1996/08/20 20:30:11 jaf
150 * Removed all static local variables that were SAVE'd in the Fortran
151 * code, and put them in struct lpc10_encoder_state that is passed as an
152 * argument.
153 *
154 * Removed init function, since all initialization is now done in
155 * init_lpc10_encoder_state().
156 *
157 * Changed name of function from lpcenc_ to lpc10_encode, simply to make
158 * all lpc10 functions have more consistent naming with each other.
159 *
160 * Revision 1.1 1996/08/19 22:31:48 jaf
161 * Initial revision
162 * */
163 /* Revision 1.3 1996/03/29 22:03:47 jaf */
164 /* Removed definitions for any constants that were no longer used. */
165
166 /* Revision 1.2 1996/03/26 19:34:33 jaf */
167 /* Added comments indicating which constants are not needed in an */
168 /* application that uses the LPC-10 coder. */
169
170 /* Revision 1.1 1996/02/07 14:43:51 jaf */
171 /* Initial revision */
172
173 /* LPC Configuration parameters: */
174 /* Frame size, Prediction order, Pitch period */
175 /* Arguments */
176 /* $Log$
177 /* Revision 1.2 2006/08/01 13:06:50 rjongbloed
178 /* Added a raft of unvalidated audio codecs from OpenH323 tree
179 /*
180 /* Revision 1.1.2.1 2006/07/22 14:03:17 rjongbloed
181 /* Added more plug ins
182 /*
183 /* Revision 1.1.2.1 2006/05/08 13:49:57 rjongbloed
184 /* Imported all the audio codec plug ins from OpenH323
185 /*
186 /* Revision 1.1 2004/05/04 11:16:43 csoutheren
187 /* Initial version
188 /*
189 /* Revision 1.1 2000/06/05 04:45:12 robertj
190 /* Added LPC-10 2400bps codec
191 /*
192 * Revision 1.2 1996/08/20 20:30:11 jaf
193 * Removed all static local variables that were SAVE'd in the Fortran
194 * code, and put them in struct lpc10_encoder_state that is passed as an
195 * argument.
196 *
197 * Removed init function, since all initialization is now done in
198 * init_lpc10_encoder_state().
199 *
200 * Changed name of function from lpcenc_ to lpc10_encode, simply to make
201 * all lpc10 functions have more consistent naming with each other.
202 *
203 * Revision 1.1 1996/08/19 22:31:48 jaf
204 * Initial revision
205 * */
206 /* Revision 1.3 1996/03/29 22:05:55 jaf */
207 /* Commented out the common block variables that are not needed by the */
208 /* embedded version. */
209
210 /* Revision 1.2 1996/03/26 19:34:50 jaf */
211 /* Added comments indicating which constants are not needed in an */
212 /* application that uses the LPC-10 coder. */
213
214 /* Revision 1.1 1996/02/07 14:44:09 jaf */
215 /* Initial revision */
216
217 /* LPC Processing control variables: */
218
219 /* *** Read-only: initialized in setup */
220
221 /* Files for Speech, Parameter, and Bitstream Input & Output, */
222 /* and message and debug outputs. */
223
224 /* Here are the only files which use these variables: */
225
226 /* lpcsim.f setup.f trans.f error.f vqsetup.f */
227
228 /* Many files which use fdebug are not listed, since it is only used in */
229 /* those other files conditionally, to print trace statements. */
230 /* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
231 /* LPC order, Frame size, Quantization rate, Bits per frame, */
232 /* Error correction */
233 /* Subroutine SETUP is the only place where order is assigned a value, */
234 /* and that value is 10. It could increase efficiency 1% or so to */
235 /* declare order as a constant (i.e., a Fortran PARAMETER) instead of as
236 */
237 /* a variable in a COMMON block, since it is used in many places in the */
238 /* core of the coding and decoding routines. Actually, I take that back.
239 */
240 /* At least when compiling with f2c, the upper bound of DO loops is */
241 /* stored in a local variable before the DO loop begins, and then that is
242 */
243 /* compared against on each iteration. */
244 /* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
245 /* Similarly for quant, which is given a value of 2400 in SETUP. quant */
246 /* is used in only a few places, and never in the core coding and */
247 /* decoding routines, so it could be eliminated entirely. */
248 /* nbits is similar to quant, and is given a value of 54 in SETUP. */
249 /* corrp is given a value of .TRUE. in SETUP, and is only used in the */
250 /* subroutines ENCODE and DECODE. It doesn't affect the speed of the */
251 /* coder significantly whether it is .TRUE. or .FALSE., or whether it is
252 */
253 /* a constant or a variable, since it is only examined once per frame. */
254 /* Leaving it as a variable that is set to .TRUE. seems like a good */
255 /* idea, since it does enable some error-correction capability for */
256 /* unvoiced frames, with no change in the coding rate, and no noticeable
257 */
258 /* quality difference in the decoded speech. */
259 /* integer quant, nbits */
260 /* *** Read/write: variables for debugging, not needed for LPC algorithm
261 */
262
263 /* Current frame, Unstable frames, Output clip count, Max onset buffer,
264 */
265 /* Debug listing detail level, Line count on listing page */
266
267 /* nframe is not needed for an embedded LPC10 at all. */
268 /* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
269 /* ERROR, which is only called from RCCHK. When LPC10 is embedded into */
270 /* an application, I would recommend removing the call to ERROR in RCCHK,
271 */
272 /* and remove ERROR and nunsfm completely. */
273 /* iclip is initialized to 0 in SETUP, and incremented in entry SWRITE in
274 */
275 /* sread.f. When LPC10 is embedded into an application, one might want */
276 /* to cause it to be incremented in a routine that takes the output of */
277 /* SYNTHS and sends it to an audio device. It could be optionally */
278 /* displayed, for those that might want to know what it is. */
279 /* maxosp is never initialized to 0 in SETUP, although it probably should
280 */
281 /* be, and it is updated in subroutine ANALYS. I doubt that its value */
282 /* would be of much interest to an application in which LPC10 is */
283 /* embedded. */
284 /* listl and lincnt are not needed for an embedded LPC10 at all. */
285 /* integer nframe, nunsfm, iclip, maxosp, listl, lincnt */
286 /* common /contrl/ fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
287 /* common /contrl/ quant, nbits */
288 /* common /contrl/ nframe, nunsfm, iclip, maxosp, listl, lincnt */
289 /* Local variables that need not be saved */
290 /* Uncoded speech parameters */
291 /* Coded speech parameters */
292 /* Others */
293 /* Local state */
294 /* None */
295 /* Parameter adjustments */
296 if (bits) {
297 --bits;
298 }
299 if (speech) {
300 --speech;
301 }
302
303 /* Function Body */
304
305 chanrd_(&c__10, &ipitv, &irms, irc, &bits[1]);
306 decode_(&ipitv, &irms, irc, voice, &pitch, &rms, rc, st);
307 synths_(voice, &pitch, &rms, rc, &speech[1], &len, st);
308 return 0;
309 } /* lpcdec_ */
310