FreeCalypso > hg > gsm-codec-lib
comparison miscutil/gsmrec-dump.c @ 23:baadb1cb744d
new debug utility gsmrec-dump
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 20 Nov 2022 08:05:32 +0000 |
parents | |
children | edd2e20e7090 |
comparison
equal
deleted
inserted
replaced
22:3db7af1249cb | 23:baadb1cb744d |
---|---|
1 /* | |
2 * This program reads a binary file in our extended-libgsm format | |
3 * and dumps all frames in human-readable form. | |
4 */ | |
5 | |
6 #include <stdio.h> | |
7 #include <stdint.h> | |
8 #include <stdlib.h> | |
9 #include <gsm.h> | |
10 #include "../libtest/binreader.h" | |
11 | |
12 main(argc, argv) | |
13 char **argv; | |
14 { | |
15 FILE *binf; | |
16 gsm dummy_state; | |
17 unsigned frame_index; | |
18 uint8_t frame[BINFILE_MAX_FRAME]; | |
19 gsm_signal fr_params[76]; | |
20 int rc, i, j, n; | |
21 | |
22 if (argc != 2) { | |
23 fprintf(stderr, "usage: %s bin-stream-file\n", argv[0]); | |
24 exit(1); | |
25 } | |
26 binf = fopen(argv[1], "r"); | |
27 if (!binf) { | |
28 perror(argv[1]); | |
29 exit(1); | |
30 } | |
31 dummy_state = gsm_create(); | |
32 if (!dummy_state) { | |
33 fprintf(stderr, "gsm_create() failed!\n"); | |
34 exit(1); | |
35 } | |
36 for (frame_index = 0; ; frame_index++) { | |
37 rc = binfile_read_frame(binf, frame); | |
38 if (rc < 0) { | |
39 fprintf(stderr, "error: garbage in %s\n", argv[1]); | |
40 exit(1); | |
41 } | |
42 if (!rc) | |
43 break; | |
44 printf("#%u: ", frame_index); | |
45 switch (frame[0] & 0xF0) { | |
46 case 0xB0: | |
47 printf("BFI TAF=%u\n", frame[1] & 1); | |
48 break; | |
49 case 0xC0: | |
50 puts("EFR (decoding not implemented)"); | |
51 break; | |
52 case 0xD0: | |
53 fputs("FR", stdout); | |
54 gsm_explode(dummy_state, frame, fr_params); | |
55 n = 0; | |
56 for (i = 0; i < 8; i++) | |
57 printf(" %u", fr_params[n++]); | |
58 putchar('\n'); | |
59 for (i = 0; i < 4; i++) { | |
60 putchar(' '); | |
61 for (j = 0; j < 17; j++) | |
62 printf(" %u", fr_params[n++]); | |
63 putchar('\n'); | |
64 } | |
65 break; | |
66 } | |
67 } | |
68 exit(0); | |
69 } |