5
|
1 /*
|
|
2 * SpanDSP - a series of DSP components for telephony
|
|
3 *
|
|
4 * lpc10.h - LPC10 low bit rate speech codec.
|
|
5 *
|
|
6 * Written by Steve Underwood <steveu@coppice.org>
|
|
7 *
|
|
8 * Copyright (C) 2006 Steve Underwood
|
|
9 *
|
|
10 * All rights reserved.
|
|
11 *
|
|
12 * This program is free software; you can redistribute it and/or modify
|
|
13 * it under the terms of the GNU General Public License version 2, as
|
|
14 * published by the Free Software Foundation.
|
|
15 *
|
|
16 * This program is distributed in the hope that it will be useful,
|
|
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
19 * GNU General Public License for more details.
|
|
20 *
|
|
21 * You should have received a copy of the GNU General Public License
|
|
22 * along with this program; if not, write to the Free Software
|
|
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
24 *
|
|
25 * $Id: lpc10.h,v 1.10 2006/11/21 13:57:40 steveu Exp $
|
|
26 */
|
|
27
|
|
28 #if !defined(_LPC10_H_)
|
|
29 #define _LPC10_H_
|
|
30
|
|
31 /*! \page lpc10_page LPC10 encoding and decoding
|
|
32 \section lpc10_page_sec_1 What does it do?
|
|
33 The LPC10 module implements the US Department of Defense LPC10
|
|
34 codec. This codec produces compressed data at 2400bps. At such
|
|
35 a low rate high fidelity cannot be expected. However, the speech
|
|
36 clarity is quite good, and this codec is unencumbered by patent
|
|
37 or other restrictions.
|
|
38
|
|
39 \section lpc10_page_sec_2 How does it work?
|
|
40 ???.
|
|
41 */
|
|
42
|
|
43 #define LPC10_SAMPLES_PER_FRAME 180
|
|
44 #define LPC10_BITS_IN_COMPRESSED_FRAME 54
|
|
45
|
|
46 /*!
|
|
47 LPC10 codec unpacked frame.
|
|
48 */
|
|
49 typedef struct
|
|
50 {
|
|
51 int32_t ipitch;
|
|
52 int32_t irms;
|
|
53 int32_t irc[10];
|
|
54 } lpc10_frame_t;
|
|
55
|
|
56 /*!
|
|
57 LPC10 codec encoder state descriptor. This defines the state of
|
|
58 a single working instance of the LPC10 encoder.
|
|
59 */
|
|
60 typedef struct
|
|
61 {
|
|
62 int error_correction;
|
|
63
|
|
64 /* State used only by function high_pass_100hz */
|
|
65 float z11;
|
|
66 float z21;
|
|
67 float z12;
|
|
68 float z22;
|
|
69
|
|
70 /* State used by function lpc10_analyse */
|
|
71 float inbuf[LPC10_SAMPLES_PER_FRAME*3];
|
|
72 float pebuf[LPC10_SAMPLES_PER_FRAME*3];
|
|
73 float lpbuf[696];
|
|
74 float ivbuf[312];
|
|
75 float bias;
|
|
76 int32_t osbuf[10]; /* No initial value necessary */
|
|
77 int32_t osptr; /* Initial value 1 */
|
|
78 int32_t obound[3];
|
|
79 int32_t vwin[3][2]; /* Initial value vwin[2][0] = 307; vwin[2][1] = 462; */
|
|
80 int32_t awin[3][2]; /* Initial value awin[2][0] = 307; awin[2][1] = 462; */
|
|
81 int32_t voibuf[4][2];
|
|
82 float rmsbuf[3];
|
|
83 float rcbuf[3][10];
|
|
84 float zpre;
|
|
85
|
|
86 /* State used by function onset */
|
|
87 float n;
|
|
88 float d__; /* Initial value 1.0f */
|
|
89 float fpc; /* No initial value necessary */
|
|
90 float l2buf[16];
|
|
91 float l2sum1;
|
|
92 int32_t l2ptr1; /* Initial value 1 */
|
|
93 int32_t l2ptr2; /* Initial value 9 */
|
|
94 int32_t lasti; /* No initial value necessary */
|
|
95 int hyst; /* Initial value FALSE */
|
|
96
|
|
97 /* State used by function lpc10_voicing */
|
|
98 float dither; /* Initial value 20.0f */
|
|
99 float snr;
|
|
100 float maxmin;
|
|
101 float voice[3][2]; /* Initial value is probably unnecessary */
|
|
102 int32_t lbve;
|
|
103 int32_t lbue;
|
|
104 int32_t fbve;
|
|
105 int32_t fbue;
|
|
106 int32_t ofbue;
|
|
107 int32_t sfbue;
|
|
108 int32_t olbue;
|
|
109 int32_t slbue;
|
|
110
|
|
111 /* State used by function dynamic_pitch_tracking */
|
|
112 float s[60];
|
|
113 int32_t p[2][60];
|
|
114 int32_t ipoint;
|
|
115 float alphax;
|
|
116
|
|
117 /* State used by function lpc10_pack */
|
|
118 int32_t isync;
|
|
119 } lpc10_encode_state_t;
|
|
120
|
|
121 /*!
|
|
122 LPC10 codec decoder state descriptor. This defines the state of
|
|
123 a single working instance of the LPC10 decoder.
|
|
124 */
|
|
125 typedef struct
|
|
126 {
|
|
127 int error_correction;
|
|
128
|
|
129 /* State used by function decode */
|
|
130 int32_t iptold; /* Initial value 60 */
|
|
131 int first; /* Initial value TRUE */
|
|
132 int32_t ivp2h;
|
|
133 int32_t iovoic;
|
|
134 int32_t iavgp; /* Initial value 60 */
|
|
135 int32_t erate;
|
|
136 int32_t drc[10][3];
|
|
137 int32_t dpit[3];
|
|
138 int32_t drms[3];
|
|
139
|
|
140 /* State used by function synths */
|
|
141 float buf[LPC10_SAMPLES_PER_FRAME*2];
|
|
142 int32_t buflen; /* Initial value LPC10_SAMPLES_PER_FRAME */
|
|
143
|
|
144 /* State used by function pitsyn */
|
|
145 int32_t ivoico; /* No initial value necessary as long as first_pitsyn is initially TRUE_ */
|
|
146 int32_t ipito; /* No initial value necessary as long as first_pitsyn is initially TRUE_ */
|
|
147 float rmso; /* Initial value 1.0f */
|
|
148 float rco[10]; /* No initial value necessary as long as first_pitsyn is initially TRUE_ */
|
|
149 int32_t jsamp; /* Nno initial value necessary as long as first_pitsyn is initially TRUE_ */
|
|
150 int first_pitsyn; /* Initial value TRUE */
|
|
151
|
|
152 /* State used by function bsynz */
|
|
153 int32_t ipo;
|
|
154 float exc[166];
|
|
155 float exc2[166];
|
|
156 float lpi[3];
|
|
157 float hpi[3];
|
|
158 float rmso_bsynz;
|
|
159
|
|
160 /* State used by function random */
|
|
161 int32_t j;
|
|
162 int32_t k;
|
|
163 int16_t y[5];
|
|
164
|
|
165 /* State used by function deemp */
|
|
166 float dei[2];
|
|
167 float deo[3];
|
|
168 } lpc10_decode_state_t;
|
|
169
|
|
170 #ifdef __cplusplus
|
|
171 extern "C" {
|
|
172 #endif
|
|
173
|
|
174 /*! Initialise an LPC10e encode context.
|
|
175 \param s The LPC10e context
|
|
176 \param error_correction ???
|
|
177 \return A pointer to the LPC10e context, or NULL for error. */
|
|
178 lpc10_encode_state_t *lpc10_encode_init(lpc10_encode_state_t *s, int error_correction);
|
|
179
|
|
180 int lpc10_encode_release(lpc10_encode_state_t *s);
|
|
181
|
|
182 /*! Encode a buffer of linear PCM data to LPC10e.
|
|
183 \param s The LPC10e context.
|
|
184 \param ima_data The LPC10e data produced.
|
|
185 \param amp The audio sample buffer.
|
|
186 \param len The number of samples in the buffer.
|
|
187 \return The number of bytes of LPC10e data produced. */
|
|
188 int lpc10_encode(lpc10_encode_state_t *s, uint8_t code[], const int16_t amp[], int quant);
|
|
189
|
|
190 /*! Initialise an LPC10e decode context.
|
|
191 \param s The LPC10e context
|
|
192 \param error_correction ???
|
|
193 \return A pointer to the LPC10e context, or NULL for error. */
|
|
194 lpc10_decode_state_t *lpc10_decode_init(lpc10_decode_state_t *st, int error_correction);
|
|
195
|
|
196 int lpc10_decode_release(lpc10_decode_state_t *s);
|
|
197
|
|
198 /*! Decode a buffer of LPC10e data to linear PCM.
|
|
199 \param s The LPC10e context.
|
|
200 \param amp The audio sample buffer.
|
|
201 \param code The LPC10e data.
|
|
202 \param quant The number of frames of LPC10e data to be decoded.
|
|
203 \return The number of samples returned. */
|
|
204 int lpc10_decode(lpc10_decode_state_t *s, int16_t amp[], const uint8_t code[], int quant);
|
|
205
|
|
206
|
|
207 #ifdef __cplusplus
|
|
208 }
|
|
209 #endif
|
|
210
|
|
211 #endif
|
|
212 /*- End of include ---------------------------------------------------------*/
|