2
|
1 /* v1.0 - 12/Apr/1994
|
|
2 =============================================================================
|
|
3
|
|
4 U U GGG SSSS TTTTT
|
|
5 U U G S T
|
|
6 U U G GG SSSS T
|
|
7 U U G G S T
|
|
8 UUU GG SSS T
|
|
9
|
|
10 ========================================
|
|
11 ITU-T - USER'S GROUP ON SOFTWARE TOOLS
|
|
12 ========================================
|
|
13
|
|
14 MODULE: RPELTP.C - GSM 06.10 RPE-LTP SPEECH ENCODING ALGORITHM
|
|
15
|
|
16 ORIGINAL BY:
|
|
17
|
|
18 The driving routines of this module were written by:
|
|
19 Simao Ferraz de Campos Neto
|
|
20 DDS/Pr11 Tel: +55-192-39-6637
|
|
21 CPqD/Telebras Fax: +55-192-39-6125
|
|
22 13088-061 Campinas SP Brazil E-mail: <simao@cpqd.ansp.br>
|
|
23
|
|
24 The true implementation was done by
|
|
25 Jutta Deneger (jutta@cs.tu-berlin.de)
|
|
26 Carsten Borman (cabo@cs.tu-berlin.de)
|
|
27 Communications and Operating Systems Research Group (KBS)
|
|
28 Technishe Universitaet Berlin
|
|
29
|
|
30 The portability changes on the code and rearrangement were done by <simao>
|
|
31
|
|
32 DATE: 12/Apr/1994: 18H00 -3H00GMT
|
|
33
|
|
34 RELEASE: 1.00
|
|
35
|
|
36 PROTOTYPES: see rpeltp.h for driving-routine prototypes, gsm.h for
|
|
37 general prototypes, and private.h for special definitions.
|
|
38
|
|
39 OBSERVATION:
|
|
40 Copyright note by the original authors:
|
|
41 " Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
|
|
42 Universitaet Berlin. See the accompanying file "COPYRIGHT" for
|
|
43 details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE."
|
|
44
|
|
45 FUNCTIONS: (Only UGST user-level functions!)
|
|
46
|
|
47 rpeltp_init() ......... Initializes the state variable for the encoding or
|
|
48 the decoding algorithm. Each need a separate state
|
|
49 variable!!!
|
|
50
|
|
51 rpeltp_delete ......... Delete the state variable allocation, etc (an alias).
|
|
52
|
|
53 rpeltp_encode ......... Entry-level function for the encoding algorithm.
|
|
54
|
|
55 rpeltp_decode ......... Entry-level function for the decoding algorithm.
|
|
56
|
|
57 ============================================================================
|
|
58 */
|
|
59 #include <stdio.h> /* For NULL */
|
|
60 #include "private.h"
|
|
61 #include "gsm.h"
|
|
62 #include "rpeltp.h"
|
|
63
|
|
64 /* *** Alias functions *** */
|
|
65 /*
|
|
66 ------------------------------------------------------------------------
|
|
67 void rpeltp_delete(gsm_state *st);
|
|
68 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
69
|
|
70 Description:
|
|
71 ~~~~~~~~~~~~
|
|
72 Frees memory of a state variable previously initialized by a call to
|
|
73 rpeltp_init(). This is an alias to the function gsm_destroy() implemented
|
|
74 by the original authors of the module.
|
|
75
|
|
76 Variables:
|
|
77 ~~~~~~~~~~
|
|
78 A pointer to a valid encoder or decoder state variable.
|
|
79
|
|
80 Return value:
|
|
81 ~~~~~~~~~~~~~
|
|
82 None.
|
|
83
|
|
84 Prototype: in gsm.h
|
|
85 ~~~~~~~~~~
|
|
86
|
|
87 Original author:
|
|
88 ~~~~~~~~~~~~~~~~
|
|
89 Simao Ferraz de Campos Neto
|
|
90 DDS/Pr11 Tel: +55-192-39-6637
|
|
91 CPqD/Telebras Fax: +55-192-39-6125
|
|
92 13088-061 Campinas SP Brazil E-mail: <simao@cpqd.ansp.br>
|
|
93
|
|
94 Log of changes:
|
|
95 ~~~~~~~~~~~~~~~
|
|
96 12.Apr.94 v.1.0 created.
|
|
97
|
|
98 ------------------------------------------------------------------------
|
|
99 */
|
|
100 /* #define rpeltp_delete gsm_destroy / * This is already done in rpeltp.h !!! */
|
|
101 /* ................... End of rpeltp_delete() ......................... */
|
|
102
|
|
103
|
|
104 /* *** True functions *** */
|
|
105
|
|
106 /*
|
|
107 ------------------------------------------------------------------------
|
|
108 gsm_state *rpeltp_init(void);
|
|
109 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
110
|
|
111 Description:
|
|
112 ~~~~~~~~~~~~
|
|
113 Allocates memory for the state variable of the encoder or the decoder,
|
|
114 and resets flags to proper initial values. This includes processing
|
|
115 strictly according to the Rec. GSM 06.10.
|
|
116
|
|
117 In a encoder plus decoder calling program there must exist different
|
|
118 state variables for the encoder and for the decoder.
|
|
119
|
|
120 Variables:
|
|
121 ~~~~~~~~~~
|
|
122 None.
|
|
123
|
|
124 Return value:
|
|
125 ~~~~~~~~~~~~~
|
|
126 Returns a pointer to a valid encoder or decoder state variable. On
|
|
127 failure, returns NULL.
|
|
128
|
|
129 Prototype: in rpeltp.h
|
|
130 ~~~~~~~~~~
|
|
131
|
|
132 Original author:
|
|
133 ~~~~~~~~~~~~~~~~
|
|
134 Simao Ferraz de Campos Neto
|
|
135 DDS/Pr11 Tel: +55-192-39-6637
|
|
136 CPqD/Telebras Fax: +55-192-39-6125
|
|
137 13088-061 Campinas SP Brazil E-mail: <simao@cpqd.ansp.br>
|
|
138
|
|
139 Log of changes:
|
|
140 ~~~~~~~~~~~~~~~
|
|
141 12.Apr.94 v.1.0 created.
|
|
142
|
|
143 ------------------------------------------------------------------------
|
|
144 */
|
|
145 gsm rpeltp_init()
|
|
146 {
|
|
147 gsm rpe_state;
|
|
148 int gsm_compliant = 0;
|
|
149
|
|
150 /* Initializa state variable */
|
|
151 if (!(rpe_state = gsm_create()))
|
|
152 return ((gsm) (NULL));
|
|
153
|
|
154 /* The gsm_{en,de}code() routines may operate on a compliant mode, or
|
|
155 * in a non-compliant, faster mode - here we use the complyant one */
|
|
156 (void) gsm_option(rpe_state, GSM_OPT_FAST, &gsm_compliant);
|
|
157
|
|
158 return (rpe_state);
|
|
159 }
|
|
160
|
|
161 /* ................... End of rpeltp_init() ......................... */
|
|
162
|
|
163
|
|
164 /*
|
|
165 ------------------------------------------------------------------------
|
|
166 void gsm_state *rpeltp_encode (gsm_state *rpe_state, short *inp_buf,
|
|
167 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ short *rpe_frame);
|
|
168
|
|
169
|
|
170 Description:
|
|
171 ~~~~~~~~~~~~
|
|
172 Process the input buffer inp_buf with left-aligned 16-bit linear-format,
|
|
173 2-complement samples using 13-bit resolution, i.e., the lower 3 bits of
|
|
174 each input sample are ignored.
|
|
175
|
|
176 The rpe-ltp frame buffer rpe_frame is word-oriented (16-bit samples),
|
|
177 right-aligned i.e., the lower bits are the most significatives.
|
|
178 They follow the sequence specified by the `parameter number' in
|
|
179 Table 1.1 of the Rec.GSM-06.10.
|
|
180
|
|
181 The input buffer has always 160 samples, and the generated frame has
|
|
182 always 76 samples.
|
|
183
|
|
184 Variables:
|
|
185 ~~~~~~~~~~
|
|
186 rpe_state ... state variable initialized by a previous call to rpeltp_init()
|
|
187 inp_buf ..... pointer to a buffer with 160 16-bit, left aligned samples
|
|
188 rpe_frame ... pointer to a rpe-ltp encoded frame buffer. Has length of 76.
|
|
189 The samples are 16-bit, right-aligned.
|
|
190
|
|
191 Return value:
|
|
192 ~~~~~~~~~~~~~
|
|
193 None.
|
|
194
|
|
195 Prototype: in rpeltp.h
|
|
196 ~~~~~~~~~~
|
|
197
|
|
198 Original author:
|
|
199 ~~~~~~~~~~~~~~~~
|
|
200 Simao Ferraz de Campos Neto
|
|
201 DDS/Pr11 Tel: +55-192-39-6637
|
|
202 CPqD/Telebras Fax: +55-192-39-6125
|
|
203 13088-061 Campinas SP Brazil E-mail: <simao@cpqd.ansp.br>
|
|
204
|
|
205 Log of changes:
|
|
206 ~~~~~~~~~~~~~~~
|
|
207 12.Apr.94 v.1.0 created.
|
|
208
|
|
209 ------------------------------------------------------------------------
|
|
210 */
|
|
211 void rpeltp_encode(rpe_state, inp_buf, rpe_frame)
|
|
212 gsm rpe_state;
|
|
213 short *inp_buf, *rpe_frame;
|
|
214 {
|
|
215 gsm_frame rpe_packed_frame;
|
|
216
|
|
217 /* Run both and save decoded samples */
|
|
218 gsm_encode(rpe_state, inp_buf, rpe_packed_frame);
|
|
219 gsm_explode(rpe_state, rpe_packed_frame, rpe_frame);
|
|
220 }
|
|
221
|
|
222 /* ................... End of rpeltp_encode() ......................... */
|
|
223
|
|
224
|
|
225 /*
|
|
226 ------------------------------------------------------------------------
|
|
227 void gsm_state *rpeltp_decode (gsm_state *rpe_state, short *rpe_frame,
|
|
228 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ short *out_buf);
|
|
229
|
|
230
|
|
231 Description:
|
|
232 ~~~~~~~~~~~~
|
|
233 Decode the input rpe-ltp encoded frame buffer rpe_buf with 76 righ-aligned
|
|
234 16-bit samples, generating 160 decoded 16-bit, left-aligned linear
|
|
235 2's-complement samples with 13-bit resolution, i.e., the lower 3 bits of
|
|
236 each input sample are zeroed. These are saved in out_buf.
|
|
237
|
|
238 The rpe-ltp frame buffer rpe_frame sample has the sequence specified by
|
|
239 the `parameter number' in Table 1.1 of the Rec.GSM-06.10.
|
|
240
|
|
241 Variables:
|
|
242 ~~~~~~~~~~
|
|
243 rpe_state ... state variable initialized by a previous call to rpeltp_init()
|
|
244 rpe_frame ... pointer to a rpe-ltp encoded frame buffer. Has length of 76.
|
|
245 The samples are 16-bit, right-aligned.
|
|
246 out_buf ..... pointer to the decode sample's buffer with 160 16-bit,
|
|
247 left aligned samples
|
|
248
|
|
249 Return value:
|
|
250 ~~~~~~~~~~~~~
|
|
251 None.
|
|
252
|
|
253 Prototype: in rpeltp.h
|
|
254 ~~~~~~~~~~
|
|
255
|
|
256 Original author:
|
|
257 ~~~~~~~~~~~~~~~~
|
|
258 Simao Ferraz de Campos Neto
|
|
259 DDS/Pr11 Tel: +55-192-39-6637
|
|
260 CPqD/Telebras Fax: +55-192-39-6125
|
|
261 13088-061 Campinas SP Brazil E-mail: <simao@cpqd.ansp.br>
|
|
262
|
|
263 Log of changes:
|
|
264 ~~~~~~~~~~~~~~~
|
|
265 12.Apr.94 v.1.0 created.
|
|
266
|
|
267 ------------------------------------------------------------------------
|
|
268 */
|
|
269 void rpeltp_decode(rpe_state, rpe_frame, out_buf)
|
|
270 gsm rpe_state;
|
|
271 short *out_buf, *rpe_frame;
|
|
272 {
|
|
273 gsm_frame rpe_packed_frame;
|
|
274
|
|
275 /* Pack frame, run only the decoder and save the decoded samples */
|
|
276 gsm_implode(rpe_state, rpe_frame, rpe_packed_frame);
|
|
277 gsm_decode(rpe_state, rpe_packed_frame, out_buf);
|
|
278 }
|
|
279
|
|
280 /* ................... End of rpeltp_decode() ......................... */
|
|
281
|
|
282 /* -------------------------- END OF RPELTP.C ------------------------ */
|