annotate libgsmfr2/pack_frame2.c @ 398:df14b0c17e6d

libtwamr: integrate pred_lt.c
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 06 May 2024 19:07:10 +0000
parents bebae251e5ee
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 /*
259
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
2 * This module holds our gsmfr_pack_from_array() function: a drop-in
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
3 * replacement for gsm_implode() 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
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #define GSM_FR_MAGIC 0xD
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
259
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
11 void gsmfr_pack_from_array(const int16_t *params, uint8_t *frame)
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 {
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 uint8_t *c = frame;
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 unsigned sub;
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 *c++ = (GSM_FR_MAGIC << 4)
259
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
17 | ((params[0] >> 2) & 0xF);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
18 *c++ = ((params[0] & 0x3) << 6)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
19 | (params[1] & 0x3F);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
20 *c++ = ((params[2] & 0x1F) << 3)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
21 | ((params[3] >> 2) & 0x7);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
22 *c++ = ((params[3] & 0x3) << 6)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
23 | ((params[4] & 0xF) << 2)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
24 | ((params[5] >> 2) & 0x3);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
25 *c++ = ((params[5] & 0x3) << 6)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
26 | ((params[6] & 0x7) << 3)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
27 | (params[7] & 0x7);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
28 params += 8;
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 for (sub = 0; sub < 4; sub++) {
259
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
30 *c++ = ((params[0] & 0x7F) << 1)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
31 | ((params[1] >> 1) & 0x1);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
32 *c++ = ((params[1] & 0x1) << 7)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
33 | ((params[2] & 0x3) << 5)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
34 | ((params[3] >> 1) & 0x1F);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
35 *c++ = ((params[3] & 0x1) << 7)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
36 | ((params[4] & 0x7) << 4)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
37 | ((params[5] & 0x7) << 1)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
38 | ((params[6] >> 2) & 0x1);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
39 *c++ = ((params[6] & 0x3) << 6)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
40 | ((params[7] & 0x7) << 3)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
41 | (params[8] & 0x7);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
42 *c++ = ((params[9] & 0x7) << 5)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
43 | ((params[10] & 0x7) << 2)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
44 | ((params[11] >> 1) & 0x3);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
45 *c++ = ((params[11] & 0x1) << 7)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
46 | ((params[12] & 0x7) << 4)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
47 | ((params[13] & 0x7) << 1)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
48 | ((params[14] >> 2) & 0x1);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
49 *c++ = ((params[14] & 0x3) << 6)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
50 | ((params[15] & 0x7) << 3)
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
51 | (params[16] & 0x7);
bebae251e5ee libgsmfr2: implement gsmfr_pack_from_array()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
52 params += 17;
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 }
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }