2 * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
3 * Universitaet Berlin. See the accompanying file "COPYRIGHT" for
4 * details. THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
7 /* $Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/gsm_encode.c,v 1.2 1996/07/02 09:59:05 jutta Exp $ */
13 void gsm_encode
P3((s
, source
, c
), gsm s
, gsm_signal
* source
, gsm_byte
* c
)
15 word LARc
[8], Nc
[4], Mc
[4], bc
[4], xmaxc
[4], xmc
[13*4];
17 Gsm_Coder(s
, source
, LARc
, Nc
, bc
, Mc
, xmaxc
, xmc
);
109 s
->frame_index
= !s
->frame_index
;
110 if (s
->frame_index
) {
115 sr
= sr
>> 6 | LARc
[0] << 10;
116 sr
= sr
>> 6 | LARc
[1] << 10;
118 sr
= sr
>> 5 | LARc
[2] << 11;
120 sr
= sr
>> 5 | LARc
[3] << 11;
121 sr
= sr
>> 4 | LARc
[4] << 12;
123 sr
= sr
>> 4 | LARc
[5] << 12;
124 sr
= sr
>> 3 | LARc
[6] << 13;
126 sr
= sr
>> 3 | LARc
[7] << 13;
127 sr
= sr
>> 7 | Nc
[0] << 9;
129 sr
= sr
>> 2 | bc
[0] << 14;
130 sr
= sr
>> 2 | Mc
[0] << 14;
131 sr
= sr
>> 6 | xmaxc
[0] << 10;
133 sr
= sr
>> 3 | xmc
[0] << 13;
135 sr
= sr
>> 3 | xmc
[1] << 13;
136 sr
= sr
>> 3 | xmc
[2] << 13;
137 sr
= sr
>> 3 | xmc
[3] << 13;
139 sr
= sr
>> 3 | xmc
[4] << 13;
140 sr
= sr
>> 3 | xmc
[5] << 13;
141 sr
= sr
>> 3 | xmc
[6] << 13;
143 sr
= sr
>> 3 | xmc
[7] << 13;
144 sr
= sr
>> 3 | xmc
[8] << 13;
146 sr
= sr
>> 3 | xmc
[9] << 13;
147 sr
= sr
>> 3 | xmc
[10] << 13;
148 sr
= sr
>> 3 | xmc
[11] << 13;
150 sr
= sr
>> 3 | xmc
[12] << 13;
151 sr
= sr
>> 7 | Nc
[1] << 9;
153 sr
= sr
>> 2 | bc
[1] << 14;
154 sr
= sr
>> 2 | Mc
[1] << 14;
155 sr
= sr
>> 6 | xmaxc
[1] << 10;
157 sr
= sr
>> 3 | xmc
[13] << 13;
159 sr
= sr
>> 3 | xmc
[14] << 13;
160 sr
= sr
>> 3 | xmc
[15] << 13;
161 sr
= sr
>> 3 | xmc
[16] << 13;
163 sr
= sr
>> 3 | xmc
[17] << 13;
164 sr
= sr
>> 3 | xmc
[18] << 13;
165 sr
= sr
>> 3 | xmc
[19] << 13;
167 sr
= sr
>> 3 | xmc
[20] << 13;
168 sr
= sr
>> 3 | xmc
[21] << 13;
170 sr
= sr
>> 3 | xmc
[22] << 13;
171 sr
= sr
>> 3 | xmc
[23] << 13;
172 sr
= sr
>> 3 | xmc
[24] << 13;
174 sr
= sr
>> 3 | xmc
[25] << 13;
175 sr
= sr
>> 7 | Nc
[2] << 9;
177 sr
= sr
>> 2 | bc
[2] << 14;
178 sr
= sr
>> 2 | Mc
[2] << 14;
179 sr
= sr
>> 6 | xmaxc
[2] << 10;
181 sr
= sr
>> 3 | xmc
[26] << 13;
183 sr
= sr
>> 3 | xmc
[27] << 13;
184 sr
= sr
>> 3 | xmc
[28] << 13;
185 sr
= sr
>> 3 | xmc
[29] << 13;
187 sr
= sr
>> 3 | xmc
[30] << 13;
188 sr
= sr
>> 3 | xmc
[31] << 13;
189 sr
= sr
>> 3 | xmc
[32] << 13;
191 sr
= sr
>> 3 | xmc
[33] << 13;
192 sr
= sr
>> 3 | xmc
[34] << 13;
194 sr
= sr
>> 3 | xmc
[35] << 13;
195 sr
= sr
>> 3 | xmc
[36] << 13;
196 sr
= sr
>> 3 | xmc
[37] << 13;
198 sr
= sr
>> 3 | xmc
[38] << 13;
199 sr
= sr
>> 7 | Nc
[3] << 9;
201 sr
= sr
>> 2 | bc
[3] << 14;
202 sr
= sr
>> 2 | Mc
[3] << 14;
203 sr
= sr
>> 6 | xmaxc
[3] << 10;
205 sr
= sr
>> 3 | xmc
[39] << 13;
207 sr
= sr
>> 3 | xmc
[40] << 13;
208 sr
= sr
>> 3 | xmc
[41] << 13;
209 sr
= sr
>> 3 | xmc
[42] << 13;
211 sr
= sr
>> 3 | xmc
[43] << 13;
212 sr
= sr
>> 3 | xmc
[44] << 13;
213 sr
= sr
>> 3 | xmc
[45] << 13;
215 sr
= sr
>> 3 | xmc
[46] << 13;
216 sr
= sr
>> 3 | xmc
[47] << 13;
218 sr
= sr
>> 3 | xmc
[48] << 13;
219 sr
= sr
>> 3 | xmc
[49] << 13;
220 sr
= sr
>> 3 | xmc
[50] << 13;
222 sr
= sr
>> 3 | xmc
[51] << 13;
231 sr
= sr
>> 4 | s
->frame_chain
<< 12;
232 sr
= sr
>> 6 | LARc
[0] << 10;
234 sr
= sr
>> 6 | LARc
[1] << 10;
236 sr
= sr
>> 5 | LARc
[2] << 11;
237 sr
= sr
>> 5 | LARc
[3] << 11;
239 sr
= sr
>> 4 | LARc
[4] << 12;
240 sr
= sr
>> 4 | LARc
[5] << 12;
242 sr
= sr
>> 3 | LARc
[6] << 13;
243 sr
= sr
>> 3 | LARc
[7] << 13;
245 sr
= sr
>> 7 | Nc
[0] << 9;
246 sr
= sr
>> 2 | bc
[0] << 14;
248 sr
= sr
>> 2 | Mc
[0] << 14;
249 sr
= sr
>> 6 | xmaxc
[0] << 10;
251 sr
= sr
>> 3 | xmc
[0] << 13;
252 sr
= sr
>> 3 | xmc
[1] << 13;
253 sr
= sr
>> 3 | xmc
[2] << 13;
255 sr
= sr
>> 3 | xmc
[3] << 13;
256 sr
= sr
>> 3 | xmc
[4] << 13;
258 sr
= sr
>> 3 | xmc
[5] << 13;
259 sr
= sr
>> 3 | xmc
[6] << 13;
260 sr
= sr
>> 3 | xmc
[7] << 13;
262 sr
= sr
>> 3 | xmc
[8] << 13;
263 sr
= sr
>> 3 | xmc
[9] << 13;
264 sr
= sr
>> 3 | xmc
[10] << 13;
266 sr
= sr
>> 3 | xmc
[11] << 13;
267 sr
= sr
>> 3 | xmc
[12] << 13;
269 sr
= sr
>> 7 | Nc
[1] << 9;
270 sr
= sr
>> 2 | bc
[1] << 14;
272 sr
= sr
>> 2 | Mc
[1] << 14;
273 sr
= sr
>> 6 | xmaxc
[1] << 10;
275 sr
= sr
>> 3 | xmc
[13] << 13;
276 sr
= sr
>> 3 | xmc
[14] << 13;
277 sr
= sr
>> 3 | xmc
[15] << 13;
279 sr
= sr
>> 3 | xmc
[16] << 13;
280 sr
= sr
>> 3 | xmc
[17] << 13;
282 sr
= sr
>> 3 | xmc
[18] << 13;
283 sr
= sr
>> 3 | xmc
[19] << 13;
284 sr
= sr
>> 3 | xmc
[20] << 13;
286 sr
= sr
>> 3 | xmc
[21] << 13;
287 sr
= sr
>> 3 | xmc
[22] << 13;
288 sr
= sr
>> 3 | xmc
[23] << 13;
290 sr
= sr
>> 3 | xmc
[24] << 13;
291 sr
= sr
>> 3 | xmc
[25] << 13;
293 sr
= sr
>> 7 | Nc
[2] << 9;
294 sr
= sr
>> 2 | bc
[2] << 14;
296 sr
= sr
>> 2 | Mc
[2] << 14;
297 sr
= sr
>> 6 | xmaxc
[2] << 10;
299 sr
= sr
>> 3 | xmc
[26] << 13;
300 sr
= sr
>> 3 | xmc
[27] << 13;
301 sr
= sr
>> 3 | xmc
[28] << 13;
303 sr
= sr
>> 3 | xmc
[29] << 13;
304 sr
= sr
>> 3 | xmc
[30] << 13;
306 sr
= sr
>> 3 | xmc
[31] << 13;
307 sr
= sr
>> 3 | xmc
[32] << 13;
308 sr
= sr
>> 3 | xmc
[33] << 13;
310 sr
= sr
>> 3 | xmc
[34] << 13;
311 sr
= sr
>> 3 | xmc
[35] << 13;
312 sr
= sr
>> 3 | xmc
[36] << 13;
314 sr
= sr
>> 3 | xmc
[37] << 13;
315 sr
= sr
>> 3 | xmc
[38] << 13;
317 sr
= sr
>> 7 | Nc
[3] << 9;
318 sr
= sr
>> 2 | bc
[3] << 14;
320 sr
= sr
>> 2 | Mc
[3] << 14;
321 sr
= sr
>> 6 | xmaxc
[3] << 10;
323 sr
= sr
>> 3 | xmc
[39] << 13;
324 sr
= sr
>> 3 | xmc
[40] << 13;
325 sr
= sr
>> 3 | xmc
[41] << 13;
327 sr
= sr
>> 3 | xmc
[42] << 13;
328 sr
= sr
>> 3 | xmc
[43] << 13;
330 sr
= sr
>> 3 | xmc
[44] << 13;
331 sr
= sr
>> 3 | xmc
[45] << 13;
332 sr
= sr
>> 3 | xmc
[46] << 13;
334 sr
= sr
>> 3 | xmc
[47] << 13;
335 sr
= sr
>> 3 | xmc
[48] << 13;
336 sr
= sr
>> 3 | xmc
[49] << 13;
338 sr
= sr
>> 3 | xmc
[50] << 13;
339 sr
= sr
>> 3 | xmc
[51] << 13;
349 *c
++ = ((GSM_MAGIC
& 0xF) << 4) /* 1 */
350 | ((LARc
[0] >> 2) & 0xF);
351 *c
++ = ((LARc
[0] & 0x3) << 6)
353 *c
++ = ((LARc
[2] & 0x1F) << 3)
354 | ((LARc
[3] >> 2) & 0x7);
355 *c
++ = ((LARc
[3] & 0x3) << 6)
356 | ((LARc
[4] & 0xF) << 2)
357 | ((LARc
[5] >> 2) & 0x3);
358 *c
++ = ((LARc
[5] & 0x3) << 6)
359 | ((LARc
[6] & 0x7) << 3)
361 *c
++ = ((Nc
[0] & 0x7F) << 1)
362 | ((bc
[0] >> 1) & 0x1);
363 *c
++ = ((bc
[0] & 0x1) << 7)
364 | ((Mc
[0] & 0x3) << 5)
365 | ((xmaxc
[0] >> 1) & 0x1F);
366 *c
++ = ((xmaxc
[0] & 0x1) << 7)
367 | ((xmc
[0] & 0x7) << 4)
368 | ((xmc
[1] & 0x7) << 1)
369 | ((xmc
[2] >> 2) & 0x1);
370 *c
++ = ((xmc
[2] & 0x3) << 6)
371 | ((xmc
[3] & 0x7) << 3)
373 *c
++ = ((xmc
[5] & 0x7) << 5) /* 10 */
374 | ((xmc
[6] & 0x7) << 2)
375 | ((xmc
[7] >> 1) & 0x3);
376 *c
++ = ((xmc
[7] & 0x1) << 7)
377 | ((xmc
[8] & 0x7) << 4)
378 | ((xmc
[9] & 0x7) << 1)
379 | ((xmc
[10] >> 2) & 0x1);
380 *c
++ = ((xmc
[10] & 0x3) << 6)
381 | ((xmc
[11] & 0x7) << 3)
383 *c
++ = ((Nc
[1] & 0x7F) << 1)
384 | ((bc
[1] >> 1) & 0x1);
385 *c
++ = ((bc
[1] & 0x1) << 7)
386 | ((Mc
[1] & 0x3) << 5)
387 | ((xmaxc
[1] >> 1) & 0x1F);
388 *c
++ = ((xmaxc
[1] & 0x1) << 7)
389 | ((xmc
[13] & 0x7) << 4)
390 | ((xmc
[14] & 0x7) << 1)
391 | ((xmc
[15] >> 2) & 0x1);
392 *c
++ = ((xmc
[15] & 0x3) << 6)
393 | ((xmc
[16] & 0x7) << 3)
395 *c
++ = ((xmc
[18] & 0x7) << 5)
396 | ((xmc
[19] & 0x7) << 2)
397 | ((xmc
[20] >> 1) & 0x3);
398 *c
++ = ((xmc
[20] & 0x1) << 7)
399 | ((xmc
[21] & 0x7) << 4)
400 | ((xmc
[22] & 0x7) << 1)
401 | ((xmc
[23] >> 2) & 0x1);
402 *c
++ = ((xmc
[23] & 0x3) << 6)
403 | ((xmc
[24] & 0x7) << 3)
405 *c
++ = ((Nc
[2] & 0x7F) << 1) /* 20 */
406 | ((bc
[2] >> 1) & 0x1);
407 *c
++ = ((bc
[2] & 0x1) << 7)
408 | ((Mc
[2] & 0x3) << 5)
409 | ((xmaxc
[2] >> 1) & 0x1F);
410 *c
++ = ((xmaxc
[2] & 0x1) << 7)
411 | ((xmc
[26] & 0x7) << 4)
412 | ((xmc
[27] & 0x7) << 1)
413 | ((xmc
[28] >> 2) & 0x1);
414 *c
++ = ((xmc
[28] & 0x3) << 6)
415 | ((xmc
[29] & 0x7) << 3)
417 *c
++ = ((xmc
[31] & 0x7) << 5)
418 | ((xmc
[32] & 0x7) << 2)
419 | ((xmc
[33] >> 1) & 0x3);
420 *c
++ = ((xmc
[33] & 0x1) << 7)
421 | ((xmc
[34] & 0x7) << 4)
422 | ((xmc
[35] & 0x7) << 1)
423 | ((xmc
[36] >> 2) & 0x1);
424 *c
++ = ((xmc
[36] & 0x3) << 6)
425 | ((xmc
[37] & 0x7) << 3)
427 *c
++ = ((Nc
[3] & 0x7F) << 1)
428 | ((bc
[3] >> 1) & 0x1);
429 *c
++ = ((bc
[3] & 0x1) << 7)
430 | ((Mc
[3] & 0x3) << 5)
431 | ((xmaxc
[3] >> 1) & 0x1F);
432 *c
++ = ((xmaxc
[3] & 0x1) << 7)
433 | ((xmc
[39] & 0x7) << 4)
434 | ((xmc
[40] & 0x7) << 1)
435 | ((xmc
[41] >> 2) & 0x1);
436 *c
++ = ((xmc
[41] & 0x3) << 6) /* 30 */
437 | ((xmc
[42] & 0x7) << 3)
439 *c
++ = ((xmc
[44] & 0x7) << 5)
440 | ((xmc
[45] & 0x7) << 2)
441 | ((xmc
[46] >> 1) & 0x3);
442 *c
++ = ((xmc
[46] & 0x1) << 7)
443 | ((xmc
[47] & 0x7) << 4)
444 | ((xmc
[48] & 0x7) << 1)
445 | ((xmc
[49] >> 2) & 0x1);
446 *c
++ = ((xmc
[49] & 0x3) << 6)
447 | ((xmc
[50] & 0x7) << 3)