FreeCalypso > hg > gsm-codec-lib
annotate libgsmhr1/unpack_frame.c @ 545:b07dba7b8a4f
doc/EFR-library-API: document RTP input wrapper
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 03 Oct 2024 09:26:04 +0000 |
parents | c275e57132f8 |
children |
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_unpack_ts101318() function: unpacking 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 TS 101 318 packed format into the codec's native |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * array of parameters. |
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_unpack_ts101318(const uint8_t *payload, int16_t *params) |
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 const 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 params[0] = (*c >> 3) & 0x1F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 params[1] = (*c++ & 0x7) << 8; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 params[1] |= *c++; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 params[2] = (*c++ & 0xFF) << 1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 params[2] |= (*c >> 7) & 0x1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 params[3] = (*c++ & 0x7F) << 1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 params[3] |= (*c >> 7) & 0x1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 params[4] = (*c >> 6) & 0x1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 params[5] = (*c >> 4) & 0x3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (params[5]) { |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 /* voiced modes */ |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 params[6] = (*c++ & 0xF) << 4; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 params[6] |= (*c >> 4) & 0xF; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 params[7] = (*c++ & 0xF) << 5; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 params[7] |= (*c >> 3) & 0x1F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 params[8] = (*c++ & 0x7) << 2; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 params[8] |= (*c >> 6) & 0x3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 params[9] = (*c >> 2) & 0xF; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 params[10] = (*c++ & 0x3) << 7; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 params[10] |= (*c >> 1) & 0x7F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 params[11] = (*c++ & 0x1) << 4; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 params[11] |= (*c >> 4) & 0xF; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 params[12] = *c++ & 0xF; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 params[13] = (*c++ & 0xFF) << 1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 params[13] |= (*c >> 7) & 0x1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 params[14] = (*c >> 2) & 0x1F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 params[15] = (*c++ & 0x3) << 2; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 params[15] |= (*c >> 6) & 0x3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 params[16] = (*c++ & 0x3F) << 3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 params[16] |= (*c >> 5) & 0x7; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 params[17] = *c++ & 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 params[6] = (*c++ & 0xF) << 3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 params[6] |= (*c >> 5) & 0x7; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 params[7] = (*c++ & 0x1F) << 2; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 params[7] |= (*c >> 6) & 0x3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 params[8] = (*c >> 1) & 0x1F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 params[9] = (*c++ & 0x1) << 6; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 params[9] |= (*c >> 2) & 0x3F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 params[10] = (*c++ & 0x3) << 5; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 params[10] |= (*c >> 3) & 0x1F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 params[11] = (*c++ & 0x7) << 2; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 params[11] |= (*c >> 6) & 0x3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 params[12] = (*c++ & 0x3F) << 1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 params[12] |= (*c >> 7) & 0x1; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 params[13] = *c++ & 0x7F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 params[14] = (*c >> 3) & 0x1F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 params[15] = (*c++ & 0x7) << 4; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 params[15] |= (*c >> 4) & 0xF; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 params[16] = (*c++ & 0xF) << 3; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 params[16] |= (*c >> 5) & 0x7; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 params[17] = *c++ & 0x1F; |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 } |
4d80730683d4
libgsmhr1: implement TS 101 318 packing and unpacking
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |