comparison libgsmefr/params2frame.c @ 33:88468d5b3590

libgsmefr: implement frame packing
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 24 Nov 2022 01:57:57 +0000
parents
children
comparison
equal deleted inserted replaced
32:9639a44ae2e7 33:88468d5b3590
1 /*
2 * In this module we implement our EFR_params2frame() packing function.
3 */
4
5 #include "gsm_efr.h"
6
7 #define EFR_MAGIC 0xC
8
9 void EFR_params2frame(const int16_t *params, uint8_t *frame)
10 {
11 uint8_t *c = frame;
12
13 *c++ = ((EFR_MAGIC & 0xF) << 4)
14 | ((params[0] >> 3) & 0xF);
15 *c++ = ((params[0] & 0x7) << 5)
16 | ((params[1] >> 3) & 0x1F);
17 *c++ = ((params[1] & 0x7) << 5)
18 | ((params[2] >> 4) & 0x1F);
19 *c++ = ((params[2] & 0xF) << 4)
20 | ((params[3] >> 4) & 0xF);
21 *c++ = ((params[3] & 0xF) << 4)
22 | ((params[4] >> 2) & 0xF);
23 *c++ = ((params[4] & 0x3) << 6)
24 | ((params[5] >> 3) & 0x3F);
25 *c++ = ((params[5] & 0x7) << 5)
26 | ((params[6] & 0xF) << 1)
27 | ((params[7] >> 3) & 0x1);
28 *c++ = ((params[7] & 0x7) << 5)
29 | ((params[8] & 0xF) << 1)
30 | ((params[9] >> 3) & 0x1);
31 *c++ = ((params[9] & 0x7) << 5)
32 | ((params[10] & 0xF) << 1)
33 | ((params[11] >> 3) & 0x1);
34 *c++ = ((params[11] & 0x7) << 5)
35 | ((params[12] & 0x7) << 2)
36 | ((params[13] >> 1) & 0x3);
37 *c++ = ((params[13] & 0x1) << 7)
38 | ((params[14] & 0x7) << 4)
39 | ((params[15] & 0x7) << 1)
40 | ((params[16] >> 2) & 0x1);
41 *c++ = ((params[16] & 0x3) << 6)
42 | ((params[17] & 0x1F) << 1)
43 | ((params[18] >> 5) & 0x1);
44 *c++ = ((params[18] & 0x1F) << 3)
45 | ((params[19] >> 1) & 0x7);
46 *c++ = ((params[19] & 0x1) << 7)
47 | ((params[20] & 0xF) << 3)
48 | ((params[21] >> 1) & 0x7);
49 *c++ = ((params[21] & 0x1) << 7)
50 | ((params[22] & 0xF) << 3)
51 | ((params[23] >> 1) & 0x7);
52 *c++ = ((params[23] & 0x1) << 7)
53 | ((params[24] & 0xF) << 3)
54 | (params[25] & 0x7);
55 *c++ = ((params[26] & 0x7) << 5)
56 | ((params[27] & 0x7) << 2)
57 | ((params[28] >> 1) & 0x3);
58 *c++ = ((params[28] & 0x1) << 7)
59 | ((params[29] & 0x7) << 4)
60 | ((params[30] >> 1) & 0xF);
61 *c++ = ((params[30] & 0x1) << 7)
62 | ((params[31] >> 2) & 0x7F);
63 *c++ = ((params[31] & 0x3) << 6)
64 | ((params[32] & 0xF) << 2)
65 | ((params[33] >> 2) & 0x3);
66 *c++ = ((params[33] & 0x3) << 6)
67 | ((params[34] & 0xF) << 2)
68 | ((params[35] >> 2) & 0x3);
69 *c++ = ((params[35] & 0x3) << 6)
70 | ((params[36] & 0xF) << 2)
71 | ((params[37] >> 2) & 0x3);
72 *c++ = ((params[37] & 0x3) << 6)
73 | ((params[38] & 0x7) << 3)
74 | (params[39] & 0x7);
75 *c++ = ((params[40] & 0x7) << 5)
76 | ((params[41] & 0x7) << 2)
77 | ((params[42] >> 1) & 0x3);
78 *c++ = ((params[42] & 0x1) << 7)
79 | ((params[43] & 0x1F) << 2)
80 | ((params[44] >> 4) & 0x3);
81 *c++ = ((params[44] & 0xF) << 4)
82 | (params[45] & 0xF);
83 *c++ = ((params[46] & 0xF) << 4)
84 | (params[47] & 0xF);
85 *c++ = ((params[48] & 0xF) << 4)
86 | (params[49] & 0xF);
87 *c++ = ((params[50] & 0xF) << 4)
88 | ((params[51] & 0x7) << 1)
89 | ((params[52] >> 2) & 0x1);
90 *c++ = ((params[52] & 0x3) << 6)
91 | ((params[53] & 0x7) << 3)
92 | (params[54] & 0x7);
93 *c++ = ((params[55] & 0x7) << 5)
94 | (params[56] & 0x1F);
95 }