annotate efrtest/tidsp.c @ 554:b66fb6be73c3

CHANGES: list those planned for inclusion in gsm-codec-lib-r4
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 07 Oct 2024 18:21:32 +0000
parents 5efc377326da
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
140
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The utility function implemented in this module extracts a 244-bit EFR
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * codec frame from a 33-byte readout of Calypso DSP buffer, and presents
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * this frame in the RTP encoding format of ETSI TS 101 318.
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdint.h>
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 static const uint16_t efr_to_tidsp_table[244] = {
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 50, 24, 25, 37, 38, 43, 44, 26, 42, 27, 39, 40,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 45, 51, 52, 41, 46, 28, 29, 47, 53, 77, 78, 30,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 54, 55, 79, 56, 80, 109, 110, 111, 112, 113, 114, 115,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 180, 181, 0, 1, 2, 3, 4, 5, 20, 31, 32, 16,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 73, 105, 157, 81, 118, 138, 165, 82, 119, 139, 166, 83,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 120, 140, 167, 84, 121, 141, 168, 85, 122, 186, 200, 204,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 224, 244, 205, 225, 245, 206, 226, 246, 207, 227, 247, 208,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 228, 248, 17, 61, 101, 153, 161, 12, 13, 22, 35, 48,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 116, 18, 74, 106, 158, 86, 123, 142, 169, 87, 124, 143,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 170, 88, 125, 144, 171, 89, 126, 145, 172, 90, 127, 189,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 201, 209, 229, 249, 210, 230, 250, 211, 231, 251, 212, 232,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 252, 213, 233, 253, 19, 62, 102, 154, 162, 6, 7, 8,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 9, 10, 11, 21, 33, 34, 57, 75, 107, 159, 91, 128,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 146, 173, 92, 129, 147, 174, 93, 130, 148, 175, 94, 131,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 149, 176, 95, 132, 192, 202, 214, 234, 254, 215, 235, 255,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 216, 236, 256, 217, 237, 257, 218, 238, 258, 59, 63, 103,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 155, 163, 14, 15, 23, 36, 49, 117, 58, 76, 108, 160,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 96, 133, 150, 177, 97, 134, 198, 199, 98, 135, 151, 178,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 99, 136, 152, 179, 100, 137, 195, 203, 219, 239, 259, 220,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 240, 260, 221, 241, 261, 222, 242, 262, 223, 243, 263, 60,
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 64, 104, 156, 164
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 };
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 static int
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 msb_get_bit(buf, bn)
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 uint8_t *buf;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 {
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 int pos_byte = bn >> 3;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 int pos_bit = 7 - (bn & 7);
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 return (buf[pos_byte] >> pos_bit) & 1;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 static void
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 msb_set_bit(buf, bn, bit)
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 uint8_t *buf;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 {
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 int pos_byte = bn >> 3;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 int pos_bit = 7 - (bn & 7);
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (bit)
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 buf[pos_byte] |= (1 << pos_bit);
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 else
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 buf[pos_byte] &= ~(1 << pos_bit);
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 void
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 efr_tidsp_to_std(inbytes, outbytes)
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 uint8_t *inbytes, *outbytes;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 {
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 int i, si;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 outbytes[0] = 0xC0;
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 for (i = 0; i < 244; i++) {
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 si = efr_to_tidsp_table[i];
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 msb_set_bit(outbytes, i + 4, msb_get_bit(inbytes, si));
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }
5efc377326da gsmefr-dlcap-gsmx: EFR counterpart to gsmfr-cvt-dlcap
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }