annotate libgsmhr1/pack_frame.c @ 542:f2d0f2f15d5f

libgsmefr: add wrapper for TW-TS-001 RTP input
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 28 Sep 2024 06:38:08 +0000
parents c275e57132f8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
490
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module holds our gsmhr_pack_ts101318() function: packing a single
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * GSM-HR codec frame from an array of broken-down parameters into TS 101 318
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * format.
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdint.h>
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include "tw_gsmhr.h"
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 void gsmhr_pack_ts101318(const int16_t *params, uint8_t *payload)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 {
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 uint8_t *c = payload;
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 if (params[5]) {
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 /* voiced modes */
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 *c++ = ((params[0] & 0x1F) << 3)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 | ((params[1] >> 8) & 0x7);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 *c++ = params[1] & 0xFF;
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 *c++ = ((params[2] >> 1) & 0xFF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 *c++ = ((params[2] & 0x1) << 7)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 | ((params[3] >> 1) & 0x7F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 *c++ = ((params[3] & 0x1) << 7)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 | ((params[4] & 0x1) << 6)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 | ((params[5] & 0x3) << 4)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 | ((params[6] >> 4) & 0xF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 *c++ = ((params[6] & 0xF) << 4)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 | ((params[7] >> 5) & 0xF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 *c++ = ((params[7] & 0x1F) << 3)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 | ((params[8] >> 2) & 0x7);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 *c++ = ((params[8] & 0x3) << 6)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 | ((params[9] & 0xF) << 2)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 | ((params[10] >> 7) & 0x3);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 *c++ = ((params[10] & 0x7F) << 1)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 | ((params[11] >> 4) & 0x1);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 *c++ = ((params[11] & 0xF) << 4)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 | (params[12] & 0xF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 *c++ = ((params[13] >> 1) & 0xFF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 *c++ = ((params[13] & 0x1) << 7)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 | ((params[14] & 0x1F) << 2)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 | ((params[15] >> 2) & 0x3);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 *c++ = ((params[15] & 0x3) << 6)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 | ((params[16] >> 3) & 0x3F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 *c++ = ((params[16] & 0x7) << 5)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 | (params[17] & 0x1F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 } else {
508
c275e57132f8 libgsmhr1/{pack,unpack}_frame.c: comment fix
Mychaela Falconia <falcon@freecalypso.org>
parents: 490
diff changeset
46 /* unvoiced mode */
490
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 *c++ = ((params[0] & 0x1F) << 3)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 | ((params[1] >> 8) & 0x7);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 *c++ = params[1] & 0xFF;
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 *c++ = ((params[2] >> 1) & 0xFF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 *c++ = ((params[2] & 0x1) << 7)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 | ((params[3] >> 1) & 0x7F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 *c++ = ((params[3] & 0x1) << 7)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 | ((params[4] & 0x1) << 6)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 | ((params[5] & 0x3) << 4)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 | ((params[6] >> 3) & 0xF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 *c++ = ((params[6] & 0x7) << 5)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 | ((params[7] >> 2) & 0x1F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 *c++ = ((params[7] & 0x3) << 6)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 | ((params[8] & 0x1F) << 1)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 | ((params[9] >> 6) & 0x1);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 *c++ = ((params[9] & 0x3F) << 2)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 | ((params[10] >> 5) & 0x3);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 *c++ = ((params[10] & 0x1F) << 3)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 | ((params[11] >> 2) & 0x7);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 *c++ = ((params[11] & 0x3) << 6)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 | ((params[12] >> 1) & 0x3F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 *c++ = ((params[12] & 0x1) << 7)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 | (params[13] & 0x7F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 *c++ = ((params[14] & 0x1F) << 3)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 | ((params[15] >> 4) & 0x7);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 *c++ = ((params[15] & 0xF) << 4)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 | ((params[16] >> 3) & 0xF);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 *c++ = ((params[16] & 0x7) << 5)
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 | (params[17] & 0x1F);
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 }
4d80730683d4 libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 }