4 Revision 1.3 2008/03/21 13:34:21 robs
5 fix (I hope) [1913986] Error during make of static sox
7 Revision 1.2 2007/12/26 16:12:42 robs
8 support out-of-source-build
10 Revision 1.1 2007/04/16 21:57:22 rrt
11 LPC-10 support, documentation still to come; I wanted to land the code
12 before 14.0.0 went into test, and I'll be busy tomorrow.
14 Not highly tested either, but it's just a format, doesn't interfere
15 with anything else, and I'll get on that case before we go stable.
17 * Revision 1.1 1996/08/19 22:47:31 jaf
29 #define analys_ lsx_lpc10_analys_
30 #define bsynz_ lsx_lpc10_bsynz_
31 #define chanrd_ lsx_lpc10_chanrd_
32 #define chanwr_ lsx_lpc10_chanwr_
33 #define contrl_ lsx_lpc10_contrl_
34 #define create_lpc10_decoder_state lsx_lpc10_create_decoder_state
35 #define create_lpc10_encoder_state lsx_lpc10_create_encoder_state
36 #define dcbias_ lsx_lpc10_dcbias_
37 #define decode_ lsx_lpc10_decode_
38 #define deemp_ lsx_lpc10_deemp_
39 #define difmag_ lsx_lpc10_difmag_
40 #define dyptrk_ lsx_lpc10_dyptrk_
41 #define encode_ lsx_lpc10_encode_
42 #define energy_ lsx_lpc10_energy_
43 #define ham84_ lsx_lpc10_ham84_
44 #define hp100_ lsx_lpc10_hp100_
45 #define i_nint lsx_lpc10_i_nint
46 #define init_lpc10_decoder_state lsx_lpc10_init_decoder_state
47 #define init_lpc10_encoder_state lsx_lpc10_init_encoder_state
48 #define invert_ lsx_lpc10_invert_
49 #define irc2pc_ lsx_lpc10_irc2pc_
50 #define ivfilt_ lsx_lpc10_ivfilt_
51 #define lpc10_decode lsx_lpc10_decode
52 #define lpc10_encode lsx_lpc10_encode
53 #define lpcini_ lsx_lpc10_lpcini_
54 #define lpfilt_ lsx_lpc10_lpfilt_
55 #define median_ lsx_lpc10_median_
56 #define mload_ lsx_lpc10_mload_
57 #define onset_ lsx_lpc10_onset_
58 #define pitsyn_ lsx_lpc10_pitsyn_
59 #define placea_ lsx_lpc10_placea_
60 #define placev_ lsx_lpc10_placev_
61 #define pow_ii lsx_lpc10_pow_ii
62 #define preemp_ lsx_lpc10_preemp_
63 #define prepro_ lsx_lpc10_prepro_
64 #define random_ lsx_lpc10_random_
65 #define rcchk_ lsx_lpc10_rcchk_
66 #define r_sign lsx_lpc10_r_sign
67 #define synths_ lsx_lpc10_synths_
68 #define tbdm_ lsx_lpc10_tbdm_
69 #define voicin_ lsx_lpc10_voicin_
70 #define vparms_ lsx_lpc10_vparms_
72 #define LPC10_SAMPLES_PER_FRAME 180
73 #define LPC10_BITS_IN_COMPRESSED_FRAME 54
76 #if defined(SHRT_MAX) && defined(SHRT_MIN) && SHRT_MAX==32767 && SHRT_MIN==(-32768)
78 #elif defined(INT_MAX) && defined(INT_MIN) && INT_MAX==32767 && INT_MIN==(-32768)
81 #error Unable to determine an appropriate definition for INT16.
84 #if defined(INT_MAX) && defined(INT_MIN) && INT_MAX==2147483647 && INT_MIN==(-2147483647-1)
86 #elif defined(LONG_MAX) && defined(LONG_MIN) && LONG_MAX==2147483647 && LONG_MIN==(-2147483647-1)
89 #error Unable to determine an appropriate definition for INT32.
93 /* The initial values for every member of this structure is 0, except
94 where noted in comments. */
96 /* These two lines are copied from f2c.h. There should be a more
97 elegant way of doing this than having the same declarations in two
101 typedef INT32 integer
;
102 typedef INT32 logical
;
103 typedef INT16 shortint
;
105 struct lpc10_encoder_state
{
106 /* State used only by function hp100 */
112 /* State used by function analys */
113 real inbuf
[540], pebuf
[540];
114 real lpbuf
[696], ivbuf
[312];
116 integer osbuf
[10]; /* no initial value necessary */
117 integer osptr
; /* initial value 1 */
119 integer vwin
[6] /* was [2][3] */; /* initial value vwin[4] = 307; vwin[5] = 462; */
120 integer awin
[6] /* was [2][3] */; /* initial value awin[4] = 307; awin[5] = 462; */
121 integer voibuf
[8] /* was [2][4] */;
123 real rcbuf
[30] /* was [10][3] */;
127 /* State used by function onset */
129 real d__
; /* initial value 1.f */
130 real fpc
; /* no initial value necessary */
133 integer l2ptr1
; /* initial value 1 */
134 integer l2ptr2
; /* initial value 9 */
135 integer lasti
; /* no initial value necessary */
136 logical hyst
; /* initial value FALSE_ */
138 /* State used by function voicin */
139 real dither
; /* initial value 20.f */
142 real voice
[6] /* was [2][3] */; /* initial value is probably unnecessary */
143 integer lbve
, lbue
, fbve
, fbue
;
144 integer ofbue
, sfbue
;
145 integer olbue
, slbue
;
155 snr = (real) (fbve / fbue << 6);
158 /* State used by function dyptrk */
160 integer p
[120] /* was [60][2] */;
164 /* State used by function chanwr */
170 struct lpc10_decoder_state
{
172 /* State used by function decode */
173 integer iptold
; /* initial value 60 */
174 logical first
; /* initial value TRUE_ */
177 integer iavgp
; /* initial value 60 */
179 integer drc
[30] /* was [3][10] */;
183 /* State used by function synths */
185 integer buflen
; /* initial value 180 */
187 /* State used by function pitsyn */
188 integer ivoico
; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
189 integer ipito
; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
190 real rmso
; /* initial value 1.f */
191 real rco
[10]; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
192 integer jsamp
; /* no initial value necessary as long as first_pitsyn is initially TRUE_ */
193 logical first_pitsyn
; /* initial value TRUE_ */
195 /* State used by function bsynz */
207 /* State used by function random */
208 integer j
; /* initial value 2 */
209 integer k
; /* initial value 5 */
210 shortint y
[5]; /* initial value { -21161,-8478,30892,-10216,16950 } */
212 /* State used by function deemp */
227 Call create_lpc10_encoder_state(), which returns a pointer to an
228 already initialized lpc10_encoder_state structure.
230 lpc10_encode reads indices 0 through (LPC10_SAMPLES_PER_FRAME-1) of
231 array speech[], and writes indices 0 through
232 (LPC10_BITS_IN_COMPRESSED_FRAME-1) of array bits[], and both reads
233 and writes the lpc10_encoder_state structure contents. The
234 lpc10_encoder_state structure should *not* be initialized for every
235 frame of encoded speech. Once at the beginning of execution, done
236 automatically for you by create_lpc10_encoder_state(), is enough.
238 init_lpc10_encoder_state() reinitializes the lpc10_encoder_state
239 structure. This might be useful if you are finished processing one
240 sound sample, and want to reuse the same lpc10_encoder_state
241 structure to process another sound sample. There might be other
244 Note that the comments in the lpc10/lpcenc.c file imply that indices
245 1 through 180 of array speech[] are read. These comments were
246 written for the Fortran version of the code, before it was
247 automatically converted to C by the conversion program f2c. f2c
248 seems to use the convention that the pointers to arrays passed as
249 function arguments point to the first index used in the Fortran
250 code, whatever index that might be (usually 1), and then it modifies
251 the pointer inside of the function, like so:
257 So that the code can access the first value at index 1 and the last
258 at index 180. This makes the translated C code "closer" to the
259 original Fortran code.
261 The calling sequence for the decoder is similar to the encoder. The
262 only significant difference is that the array bits[] is read
263 (indices 0 through (LPC10_BITS_IN_COMPRESSED_FRAME-1)), and the
264 array speech[] is written (indices 0 through
265 (LPC10_SAMPLES_PER_FRAME-1)).
269 struct lpc10_encoder_state
* create_lpc10_encoder_state (void);
270 void init_lpc10_encoder_state (struct lpc10_encoder_state
*st
);
271 int lpc10_encode (real
*speech
, INT32
*bits
, struct lpc10_encoder_state
*st
);
273 struct lpc10_decoder_state
* create_lpc10_decoder_state (void);
274 void init_lpc10_decoder_state (struct lpc10_decoder_state
*st
);
275 int lpc10_decode (INT32
*bits
, real
*speech
, struct lpc10_decoder_state
*st
);
277 #endif /* __LPC10_H__ */