comparison libgsmfr2/unpack_frame.c @ 260:f0220c141d2c

libgsmfr2: implement gsmfr_unpack_frame()
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 12 Apr 2024 23:09:23 +0000
parents libgsmfr2/pack_frame.c@c344b4f35eb7
children
comparison
equal deleted inserted replaced
259:bebae251e5ee 260:f0220c141d2c
1 /*
2 * This module holds our gsmfr_unpack_frame() function: unpacking a single
3 * GSM-FR frame from libgsm/RTP format into a broken-down struct of params.
4 */
5
6 #include <stdint.h>
7 #include "tw_gsmfr.h"
8
9 void gsmfr_unpack_frame(const uint8_t *frame, struct gsmfr_param_frame *param)
10 {
11 const uint8_t *c = frame;
12 unsigned sub;
13
14 param->LARc[0] = (*c++ & 0xF) << 2;
15 param->LARc[0] |= (*c >> 6) & 0x3;
16 param->LARc[1] = *c++ & 0x3F;
17 param->LARc[2] = (*c >> 3) & 0x1F;
18 param->LARc[3] = (*c++ & 0x7) << 2;
19 param->LARc[3] |= (*c >> 6) & 0x3;
20 param->LARc[4] = (*c >> 2) & 0xF;
21 param->LARc[5] = (*c++ & 0x3) << 2;
22 param->LARc[5] |= (*c >> 6) & 0x3;
23 param->LARc[6] = (*c >> 3) & 0x7;
24 param->LARc[7] = *c++ & 0x7;
25 for (sub = 0; sub < 4; sub++) {
26 param->Nc[sub] = (*c >> 1) & 0x7F;
27 param->bc[sub] = (*c++ & 0x1) << 1;
28 param->bc[sub] |= (*c >> 7) & 0x1;
29 param->Mc[sub] = (*c >> 5) & 0x3;
30 param->xmaxc[sub] = (*c++ & 0x1F) << 1;
31 param->xmaxc[sub] |= (*c >> 7) & 0x1;
32 param->xMc[sub][0] = (*c >> 4) & 0x7;
33 param->xMc[sub][1] = (*c >> 1) & 0x7;
34 param->xMc[sub][2] = (*c++ & 0x1) << 2;
35 param->xMc[sub][2] |= (*c >> 6) & 0x3;
36 param->xMc[sub][3] = (*c >> 3) & 0x7;
37 param->xMc[sub][4] = *c++ & 0x7;
38 param->xMc[sub][5] = (*c >> 5) & 0x7;
39 param->xMc[sub][6] = (*c >> 2) & 0x7;
40 param->xMc[sub][7] = (*c++ & 0x3) << 1;
41 param->xMc[sub][7] |= (*c >> 7) & 0x1;
42 param->xMc[sub][8] = (*c >> 4) & 0x7;
43 param->xMc[sub][9] = (*c >> 1) & 0x7;
44 param->xMc[sub][10] = (*c++ & 0x1) << 2;
45 param->xMc[sub][10] |= (*c >> 6) & 0x3;
46 param->xMc[sub][11] = (*c >> 3) & 0x7;
47 param->xMc[sub][12] = *c++ & 0x7;
48 }
49 }