annotate libgsmfr2/unpack_frame2.c @ 534:516e84085a15

libgsmfr2 is now at version 2.1.0
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 20 Sep 2024 00:17:35 +0000
parents cfcb3ce9c778
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
261
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
2 * This module holds our gsmfr_unpack_to_array() function: a drop-in
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
3 * replacement for gsm_explode() from classic libgsm.
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdint.h>
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include "tw_gsmfr.h"
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
261
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
9 void gsmfr_unpack_to_array(const uint8_t *frame, int16_t *params)
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 {
260
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
11 const uint8_t *c = frame;
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 unsigned sub;
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
261
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
14 params[0] = (*c++ & 0xF) << 2;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
15 params[0] |= (*c >> 6) & 0x3;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
16 params[1] = *c++ & 0x3F;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
17 params[2] = (*c >> 3) & 0x1F;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
18 params[3] = (*c++ & 0x7) << 2;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
19 params[3] |= (*c >> 6) & 0x3;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
20 params[4] = (*c >> 2) & 0xF;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
21 params[5] = (*c++ & 0x3) << 2;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
22 params[5] |= (*c >> 6) & 0x3;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
23 params[6] = (*c >> 3) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
24 params[7] = *c++ & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
25 params += 8;
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 for (sub = 0; sub < 4; sub++) {
261
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
27 params[0] = (*c >> 1) & 0x7F;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
28 params[1] = (*c++ & 0x1) << 1;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
29 params[1] |= (*c >> 7) & 0x1;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
30 params[2] = (*c >> 5) & 0x3;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
31 params[3] = (*c++ & 0x1F) << 1;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
32 params[3] |= (*c >> 7) & 0x1;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
33 params[4] = (*c >> 4) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
34 params[5] = (*c >> 1) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
35 params[6] = (*c++ & 0x1) << 2;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
36 params[6] |= (*c >> 6) & 0x3;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
37 params[7] = (*c >> 3) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
38 params[8] = *c++ & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
39 params[9] = (*c >> 5) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
40 params[10] = (*c >> 2) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
41 params[11] = (*c++ & 0x3) << 1;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
42 params[11] |= (*c >> 7) & 0x1;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
43 params[12] = (*c >> 4) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
44 params[13] = (*c >> 1) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
45 params[14] = (*c++ & 0x1) << 2;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
46 params[14] |= (*c >> 6) & 0x3;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
47 params[15] = (*c >> 3) & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
48 params[16] = *c++ & 0x7;
cfcb3ce9c778 libgsmfr2: implement gsmfr_unpack_to_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 260
diff changeset
49 params += 17;
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }