FreeCalypso > hg > gsm-net-reveng
comparison trau-decode/parse-amr.c @ 78:00fd38c7c8fe
trau-decode: factor out parse-amr.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 08 Feb 2025 06:22:45 +0000 |
parents | trau-decode/parse-main.c@729dbac9df82 |
children | 8c1f20e845a1 |
comparison
equal
deleted
inserted
replaced
77:729dbac9df82 | 78:00fd38c7c8fe |
---|---|
1 /* | |
2 * This module contains a bit of code that has been factored out of | |
3 * trau-parse program; it handles AMR frames. | |
4 */ | |
5 | |
6 #include <stdio.h> | |
7 #include <stdint.h> | |
8 #include <stdlib.h> | |
9 #include <string.h> | |
10 #include <strings.h> | |
11 | |
12 static unsigned | |
13 bits_to_num(bits, nbits) | |
14 uint8_t *bits; | |
15 unsigned nbits; | |
16 { | |
17 unsigned accum; | |
18 unsigned n; | |
19 | |
20 accum = 0; | |
21 for (n = 0; n < nbits; n++) { | |
22 accum <<= 1; | |
23 if (*bits) | |
24 accum |= 1; | |
25 bits++; | |
26 } | |
27 return accum; | |
28 } | |
29 | |
30 void | |
31 print_amr_frame(frame_bits) | |
32 uint8_t *frame_bits; | |
33 { | |
34 unsigned c6_11; | |
35 | |
36 c6_11 = bits_to_num(frame_bits + 22, 6); | |
37 printf(" C6-C11: %u\n", c6_11); | |
38 printf(" RIF=%u C13=%u Config_Prot=%u%u%u Msg_No=%u%u\n", | |
39 frame_bits[28], frame_bits[29], frame_bits[30], | |
40 frame_bits[31], frame_bits[33], frame_bits[34], | |
41 frame_bits[35]); | |
42 printf(" DTXd=%u TFOE=%u FClass=%u%u CMI/CMR=%u%u%u\n", | |
43 frame_bits[36], frame_bits[37], frame_bits[38], | |
44 frame_bits[39], frame_bits[40], frame_bits[41], | |
45 frame_bits[42]); | |
46 if (!frame_bits[38] && !frame_bits[39]) | |
47 printf(" No_Spch_Class=%u%u%u CMI=%u%u%u CMR=%u%u%u\n", | |
48 frame_bits[76], frame_bits[77], frame_bits[78], | |
49 frame_bits[79], frame_bits[81], frame_bits[82], | |
50 frame_bits[83], frame_bits[84], frame_bits[85]); | |
51 printf(" T1=%u T2=%u T3=%u T4=%u\n", frame_bits[316], | |
52 frame_bits[317], frame_bits[318], frame_bits[319]); | |
53 } |