comparison libgsmfr2/unpack_frame2.c @ 261:cfcb3ce9c778

libgsmfr2: implement gsmfr_unpack_to_array()
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Apr 2024 23:29:18 +0000
parents libgsmfr2/unpack_frame.c@f0220c141d2c
children
comparison
equal deleted inserted replaced
260:f0220c141d2c 261:cfcb3ce9c778
1 /*
2 * This module holds our gsmfr_unpack_to_array() function: a drop-in
3 * replacement for gsm_explode() from classic libgsm.
4 */
5
6 #include <stdint.h>
7 #include "tw_gsmfr.h"
8
9 void gsmfr_unpack_to_array(const uint8_t *frame, int16_t *params)
10 {
11 const uint8_t *c = frame;
12 unsigned sub;
13
14 params[0] = (*c++ & 0xF) << 2;
15 params[0] |= (*c >> 6) & 0x3;
16 params[1] = *c++ & 0x3F;
17 params[2] = (*c >> 3) & 0x1F;
18 params[3] = (*c++ & 0x7) << 2;
19 params[3] |= (*c >> 6) & 0x3;
20 params[4] = (*c >> 2) & 0xF;
21 params[5] = (*c++ & 0x3) << 2;
22 params[5] |= (*c >> 6) & 0x3;
23 params[6] = (*c >> 3) & 0x7;
24 params[7] = *c++ & 0x7;
25 params += 8;
26 for (sub = 0; sub < 4; sub++) {
27 params[0] = (*c >> 1) & 0x7F;
28 params[1] = (*c++ & 0x1) << 1;
29 params[1] |= (*c >> 7) & 0x1;
30 params[2] = (*c >> 5) & 0x3;
31 params[3] = (*c++ & 0x1F) << 1;
32 params[3] |= (*c >> 7) & 0x1;
33 params[4] = (*c >> 4) & 0x7;
34 params[5] = (*c >> 1) & 0x7;
35 params[6] = (*c++ & 0x1) << 2;
36 params[6] |= (*c >> 6) & 0x3;
37 params[7] = (*c >> 3) & 0x7;
38 params[8] = *c++ & 0x7;
39 params[9] = (*c >> 5) & 0x7;
40 params[10] = (*c >> 2) & 0x7;
41 params[11] = (*c++ & 0x3) << 1;
42 params[11] |= (*c >> 7) & 0x1;
43 params[12] = (*c >> 4) & 0x7;
44 params[13] = (*c >> 1) & 0x7;
45 params[14] = (*c++ & 0x1) << 2;
46 params[14] |= (*c >> 6) & 0x3;
47 params[15] = (*c >> 3) & 0x7;
48 params[16] = *c++ & 0x7;
49 params += 17;
50 }
51 }