comparison libgsmefr/frame2params.c @ 34:69b9cbca075b

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