FreeCalypso > hg > gsm-net-reveng
comparison trau-decode/gsmhr_unpack.c @ 28:9bcdb091c24d
trau-decode: new program trau-hr-dump
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 18 Aug 2024 08:37:02 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
27:f508dacf2cf9 | 28:9bcdb091c24d |
---|---|
1 /* | |
2 * This module has been copied from WIP libgsmhr1: it holds the function that | |
3 * unpacks a single GSM-HR codec frame from TS 101 318 packed format into | |
4 * the codec's native array of parameters. | |
5 */ | |
6 | |
7 #include <stdint.h> | |
8 #include "gsmhr_unpack.h" | |
9 | |
10 void gsmhr_unpack_ts101318(const uint8_t *payload, int16_t *params) | |
11 { | |
12 const uint8_t *c = payload; | |
13 | |
14 params[0] = (*c >> 3) & 0x1F; | |
15 params[1] = (*c++ & 0x7) << 8; | |
16 params[1] |= *c++; | |
17 params[2] = (*c++ & 0xFF) << 1; | |
18 params[2] |= (*c >> 7) & 0x1; | |
19 params[3] = (*c++ & 0x7F) << 1; | |
20 params[3] |= (*c >> 7) & 0x1; | |
21 params[4] = (*c >> 6) & 0x1; | |
22 params[5] = (*c >> 4) & 0x3; | |
23 if (params[5]) { | |
24 /* voiced modes */ | |
25 params[6] = (*c++ & 0xF) << 4; | |
26 params[6] |= (*c >> 4) & 0xF; | |
27 params[7] = (*c++ & 0xF) << 5; | |
28 params[7] |= (*c >> 3) & 0x1F; | |
29 params[8] = (*c++ & 0x7) << 2; | |
30 params[8] |= (*c >> 6) & 0x3; | |
31 params[9] = (*c >> 2) & 0xF; | |
32 params[10] = (*c++ & 0x3) << 7; | |
33 params[10] |= (*c >> 1) & 0x7F; | |
34 params[11] = (*c++ & 0x1) << 4; | |
35 params[11] |= (*c >> 4) & 0xF; | |
36 params[12] = *c++ & 0xF; | |
37 params[13] = (*c++ & 0xFF) << 1; | |
38 params[13] |= (*c >> 7) & 0x1; | |
39 params[14] = (*c >> 2) & 0x1F; | |
40 params[15] = (*c++ & 0x3) << 2; | |
41 params[15] |= (*c >> 6) & 0x3; | |
42 params[16] = (*c++ & 0x3F) << 3; | |
43 params[16] |= (*c >> 5) & 0x7; | |
44 params[17] = *c++ & 0x1F; | |
45 } else { | |
46 /* unvoiced mode */ | |
47 params[6] = (*c++ & 0xF) << 3; | |
48 params[6] |= (*c >> 5) & 0x7; | |
49 params[7] = (*c++ & 0x1F) << 2; | |
50 params[7] |= (*c >> 6) & 0x3; | |
51 params[8] = (*c >> 1) & 0x1F; | |
52 params[9] = (*c++ & 0x1) << 6; | |
53 params[9] |= (*c >> 2) & 0x3F; | |
54 params[10] = (*c++ & 0x3) << 5; | |
55 params[10] |= (*c >> 3) & 0x1F; | |
56 params[11] = (*c++ & 0x7) << 2; | |
57 params[11] |= (*c >> 6) & 0x3; | |
58 params[12] = (*c++ & 0x3F) << 1; | |
59 params[12] |= (*c >> 7) & 0x1; | |
60 params[13] = *c++ & 0x7F; | |
61 params[14] = (*c >> 3) & 0x1F; | |
62 params[15] = (*c++ & 0x7) << 4; | |
63 params[15] |= (*c >> 4) & 0xF; | |
64 params[16] = (*c++ & 0xF) << 3; | |
65 params[16] |= (*c >> 5) & 0x7; | |
66 params[17] = *c++ & 0x1F; | |
67 } | |
68 } |