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