FreeCalypso > hg > gsm-codec-lib
annotate miscutil/gsmrec-dump.c @ 555:62943a1ad64e
doc/FR1-Rx-DTX-detail: grammar fix
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 11 Oct 2024 00:22:47 +0000 |
parents | b5f8ea41362b |
children |
rev | line source |
---|---|
23
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program reads a binary file in our extended-libgsm format |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * and dumps all frames in human-readable form. |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdint.h> |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
471
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
9 #include <string.h> |
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
10 #include <strings.h> |
281
3816ba89a5a0
gsmrec-dump: use libgsmfr2 instead of old libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
11 #include "../libgsmfr2/tw_gsmfr.h" |
46
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
12 #include "../libgsmefr/gsm_efr.h" |
23
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "../libtest/binreader.h" |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 main(argc, argv) |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 char **argv; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 FILE *binf; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 unsigned frame_index; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 uint8_t frame[BINFILE_MAX_FRAME]; |
281
3816ba89a5a0
gsmrec-dump: use libgsmfr2 instead of old libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
21 int16_t params[GSMFR_NUM_PARAMS]; |
23
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 int rc, i, j, n; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (argc != 2) { |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 fprintf(stderr, "usage: %s bin-stream-file\n", argv[0]); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(1); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 binf = fopen(argv[1], "r"); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!binf) { |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 perror(argv[1]); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 exit(1); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 for (frame_index = 0; ; frame_index++) { |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 rc = binfile_read_frame(binf, frame); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 if (rc < 0) { |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 fprintf(stderr, "error: garbage in %s\n", argv[1]); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 exit(1); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 if (!rc) |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 break; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 printf("#%u: ", frame_index); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 switch (frame[0] & 0xF0) { |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 case 0xB0: |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 printf("BFI TAF=%u\n", frame[1] & 1); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 break; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 case 0xC0: |
46
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
47 printf("EFR SID=%d LPC", EFR_sid_classify(frame)); |
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
48 EFR_frame2params(frame, params); |
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
49 n = 0; |
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
50 for (i = 0; i < 5; i++) |
128
a5ffec18e4cd
test programs: use printf %d format for codec parameters
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
51 printf(" %d", params[n++]); |
471
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
52 if (!bcmp(frame, EFR_decoder_homing_frame, |
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
53 EFR_RTP_FRAME_LEN)) |
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
54 fputs(" (DHF)", stdout); |
46
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
55 putchar('\n'); |
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
56 for (i = 0; i < 4; i++) { |
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
57 putchar(' '); |
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
58 for (j = 0; j < 13; j++) |
128
a5ffec18e4cd
test programs: use printf %d format for codec parameters
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
59 printf(" %d", params[n++]); |
46
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
60 putchar('\n'); |
edd2e20e7090
gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents:
23
diff
changeset
|
61 } |
23
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 break; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 case 0xD0: |
293
fa8845306e07
gsmrec-dump: print SID classification for FRv1
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
64 printf("FR SID=%d", gsmfr_preproc_sid_classify(frame)); |
281
3816ba89a5a0
gsmrec-dump: use libgsmfr2 instead of old libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
65 gsmfr_unpack_to_array(frame, params); |
23
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 n = 0; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 for (i = 0; i < 8; i++) |
128
a5ffec18e4cd
test programs: use printf %d format for codec parameters
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
68 printf(" %d", params[n++]); |
471
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
69 if (!bcmp(frame, gsmfr_decoder_homing_frame, |
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
70 GSMFR_RTP_FRAME_LEN)) |
b5f8ea41362b
gsmrec-dump: report DHF matches
Mychaela Falconia <falcon@freecalypso.org>
parents:
293
diff
changeset
|
71 fputs(" (DHF)", stdout); |
23
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 putchar('\n'); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 for (i = 0; i < 4; i++) { |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 putchar(' '); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 for (j = 0; j < 17; j++) |
128
a5ffec18e4cd
test programs: use printf %d format for codec parameters
Mychaela Falconia <falcon@freecalypso.org>
parents:
46
diff
changeset
|
76 printf(" %d", params[n++]); |
23
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 putchar('\n'); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 break; |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 } |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 } |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 exit(0); |
baadb1cb744d
new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 } |