annotate miscutil/gsmrec-dump.c @ 409:4184ccc136a3

libtwamr/typedef.h: drop Pfloat from EFR, not used in AMR
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 01:04:17 +0000
parents fa8845306e07
children b5f8ea41362b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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>
281
3816ba89a5a0 gsmrec-dump: use libgsmfr2 instead of old libgsm
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
9 #include "../libgsmfr2/tw_gsmfr.h"
46
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
10 #include "../libgsmefr/gsm_efr.h"
23
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "../libtest/binreader.h"
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 main(argc, argv)
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 char **argv;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 FILE *binf;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 unsigned frame_index;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 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
19 int16_t params[GSMFR_NUM_PARAMS];
23
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int rc, i, j, n;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (argc != 2) {
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fprintf(stderr, "usage: %s bin-stream-file\n", argv[0]);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 exit(1);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 binf = fopen(argv[1], "r");
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (!binf) {
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 perror(argv[1]);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 for (frame_index = 0; ; frame_index++) {
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 rc = binfile_read_frame(binf, frame);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (rc < 0) {
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 fprintf(stderr, "error: garbage in %s\n", argv[1]);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 exit(1);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!rc)
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 break;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 printf("#%u: ", frame_index);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 switch (frame[0] & 0xF0) {
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 case 0xB0:
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 printf("BFI TAF=%u\n", frame[1] & 1);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 break;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 case 0xC0:
46
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
45 printf("EFR SID=%d LPC", EFR_sid_classify(frame));
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
46 EFR_frame2params(frame, params);
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
47 n = 0;
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
48 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
49 printf(" %d", params[n++]);
46
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
50 putchar('\n');
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
51 for (i = 0; i < 4; i++) {
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
52 putchar(' ');
edd2e20e7090 gsmrec-dump: decode EFR frames
Mychaela Falconia <falcon@freecalypso.org>
parents: 23
diff changeset
53 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
54 printf(" %d", params[n++]);
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 }
23
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 break;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 case 0xD0:
293
fa8845306e07 gsmrec-dump: print SID classification for FRv1
Mychaela Falconia <falcon@freecalypso.org>
parents: 281
diff changeset
59 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
60 gsmfr_unpack_to_array(frame, params);
23
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 n = 0;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 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
63 printf(" %d", params[n++]);
23
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 putchar('\n');
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 for (i = 0; i < 4; i++) {
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 putchar(' ');
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 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
68 printf(" %d", params[n++]);
23
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 putchar('\n');
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 }
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 break;
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 }
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 }
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 exit(0);
baadb1cb744d new debug utility gsmrec-dump
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 }