annotate libgsmfr2/unpack_frame.c @ 417:f17e42c63058

libtwamr: integrate ol_ltp.c
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 03:21:14 +0000
parents f0220c141d2c
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 /*
260
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
2 * This module holds our gsmfr_unpack_frame() function: unpacking a single
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
3 * GSM-FR frame from libgsm/RTP format into a broken-down struct of params.
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
260
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
9 void gsmfr_unpack_frame(const uint8_t *frame, struct gsmfr_param_frame *param)
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
260
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
14 param->LARc[0] = (*c++ & 0xF) << 2;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
15 param->LARc[0] |= (*c >> 6) & 0x3;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
16 param->LARc[1] = *c++ & 0x3F;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
17 param->LARc[2] = (*c >> 3) & 0x1F;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
18 param->LARc[3] = (*c++ & 0x7) << 2;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
19 param->LARc[3] |= (*c >> 6) & 0x3;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
20 param->LARc[4] = (*c >> 2) & 0xF;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
21 param->LARc[5] = (*c++ & 0x3) << 2;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
22 param->LARc[5] |= (*c >> 6) & 0x3;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
23 param->LARc[6] = (*c >> 3) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
24 param->LARc[7] = *c++ & 0x7;
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 for (sub = 0; sub < 4; sub++) {
260
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
26 param->Nc[sub] = (*c >> 1) & 0x7F;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
27 param->bc[sub] = (*c++ & 0x1) << 1;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
28 param->bc[sub] |= (*c >> 7) & 0x1;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
29 param->Mc[sub] = (*c >> 5) & 0x3;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
30 param->xmaxc[sub] = (*c++ & 0x1F) << 1;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
31 param->xmaxc[sub] |= (*c >> 7) & 0x1;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
32 param->xMc[sub][0] = (*c >> 4) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
33 param->xMc[sub][1] = (*c >> 1) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
34 param->xMc[sub][2] = (*c++ & 0x1) << 2;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
35 param->xMc[sub][2] |= (*c >> 6) & 0x3;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
36 param->xMc[sub][3] = (*c >> 3) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
37 param->xMc[sub][4] = *c++ & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
38 param->xMc[sub][5] = (*c >> 5) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
39 param->xMc[sub][6] = (*c >> 2) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
40 param->xMc[sub][7] = (*c++ & 0x3) << 1;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
41 param->xMc[sub][7] |= (*c >> 7) & 0x1;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
42 param->xMc[sub][8] = (*c >> 4) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
43 param->xMc[sub][9] = (*c >> 1) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
44 param->xMc[sub][10] = (*c++ & 0x1) << 2;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
45 param->xMc[sub][10] |= (*c >> 6) & 0x3;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
46 param->xMc[sub][11] = (*c >> 3) & 0x7;
f0220c141d2c libgsmfr2: implement gsmfr_unpack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents: 258
diff changeset
47 param->xMc[sub][12] = *c++ & 0x7;
258
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 }
c344b4f35eb7 libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }