annotate libgsmefr/sid_class.c @ 462:bada654a859b

CHANGES: document rm of gsmfr-hand-test and gsmfr-max-out
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 11 May 2024 19:48:56 +0000
parents b5726d659915
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
31
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
2 * EFR_sid_classify() utility function classifies an EFR frame
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
3 * in RTP encoding according to the rules of GSM 06.81 section 6.1.1,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
4 * judging it as SID=0, SID=1 or SID=2.
2
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
31
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
7 #include "gsm_efr.h"
2
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
31
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
9 static const uint8_t SID_codeword_bit_idx[95] =
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
10 {
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
11 45, 46, 48, 49, 50, 51, 52, 53, 54, 55,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
12 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
13 66, 67, 68, 94, 95, 96, 98, 99, 100, 101,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
14 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
15 112, 113, 114, 115, 116, 117, 118, 148, 149, 150,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
16 151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
17 161, 162, 163, 164, 165, 166, 167, 168, 169, 170,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
18 171, 196, 197, 198, 199, 200, 201, 202, 203, 204,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
19 205, 206, 207, 208, 209, 212, 213, 214, 215, 216,
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
20 217, 218, 219, 220, 221
2
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 };
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
31
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
23 static inline int get_bit(const uint8_t *frame, unsigned bitnum)
2
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 {
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 unsigned bytenum = bitnum >> 3;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 unsigned bit_in_byte = 7 - (bitnum & 7);
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 unsigned bitmask = 1 << bit_in_byte;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (frame[bytenum] & bitmask)
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 return 1;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 else
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 return 0;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 }
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
31
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
35 int EFR_sid_classify(const uint8_t *frame)
2
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 {
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 unsigned idx, n;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 n = 0;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 for (idx = 0; idx < 95; idx++) {
31
19a90fa1f608 libgsmefr: implement SID classification
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
41 if (!get_bit(frame, SID_codeword_bit_idx[idx] + 4))
2
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 n++;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (n >= 16)
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 return 0;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (n < 2)
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 return 2;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 else
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 return 1;
2b5770c715ee libgsmfrp: compiling utility functions
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }