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