FreeCalypso > hg > gsm-codec-lib
annotate libgsmfr2/pack_frame.c @ 268:0cfb7c95cce2
libgsmfr2: integrate lpc.c from libgsm
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Apr 2024 01:50:48 +0000 |
parents | c344b4f35eb7 |
children |
rev | line source |
---|---|
258
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module holds our gsmfr_pack_frame() function: packing a single GSM-FR |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * frame from a struct of broken-down parameters into libgsm/RTP format. |
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 |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 void gsmfr_pack_frame(const struct gsmfr_param_frame *param, uint8_t *frame) |
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) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 | ((param->LARc[0] >> 2) & 0xF); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 *c++ = ((param->LARc[0] & 0x3) << 6) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 | (param->LARc[1] & 0x3F); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 *c++ = ((param->LARc[2] & 0x1F) << 3) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 | ((param->LARc[3] >> 2) & 0x7); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 *c++ = ((param->LARc[3] & 0x3) << 6) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 | ((param->LARc[4] & 0xF) << 2) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 | ((param->LARc[5] >> 2) & 0x3); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 *c++ = ((param->LARc[5] & 0x3) << 6) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 | ((param->LARc[6] & 0x7) << 3) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 | (param->LARc[7] & 0x7); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 for (sub = 0; sub < 4; sub++) { |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 *c++ = ((param->Nc[sub] & 0x7F) << 1) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 | ((param->bc[sub] >> 1) & 0x1); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 *c++ = ((param->bc[sub] & 0x1) << 7) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 | ((param->Mc[sub] & 0x3) << 5) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 | ((param->xmaxc[sub] >> 1) & 0x1F); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 *c++ = ((param->xmaxc[sub] & 0x1) << 7) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 | ((param->xMc[sub][0] & 0x7) << 4) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 | ((param->xMc[sub][1] & 0x7) << 1) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 | ((param->xMc[sub][2] >> 2) & 0x1); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 *c++ = ((param->xMc[sub][2] & 0x3) << 6) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 | ((param->xMc[sub][3] & 0x7) << 3) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 | (param->xMc[sub][4] & 0x7); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 *c++ = ((param->xMc[sub][5] & 0x7) << 5) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 | ((param->xMc[sub][6] & 0x7) << 2) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 | ((param->xMc[sub][7] >> 1) & 0x3); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 *c++ = ((param->xMc[sub][7] & 0x1) << 7) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 | ((param->xMc[sub][8] & 0x7) << 4) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 | ((param->xMc[sub][9] & 0x7) << 1) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 | ((param->xMc[sub][10] >> 2) & 0x1); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 *c++ = ((param->xMc[sub][10] & 0x3) << 6) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 | ((param->xMc[sub][11] & 0x7) << 3) |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 | (param->xMc[sub][12] & 0x7); |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
c344b4f35eb7
libgsmfr2: implement gsmfr_pack_frame()
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |