FreeCalypso > hg > gsm-codec-lib
annotate efrtest/dec-parse.c @ 147:90b9c7c3fa3b
gsmefr-cod-parse: use factored-out ETSI bit reader
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 14 Dec 2022 08:09:52 +0000 |
parents | 0fa0cd251a31 |
children | 95d47a34070a |
rev | line source |
---|---|
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
131
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
2 * This program reads an EFR *.dec file in ETSI test sequence format |
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
3 * (test input to the decoder) and converts it into human-readable format, |
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
4 * similar to what one would get from our gsmrec-dump utility. |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdint.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <string.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <strings.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "../libgsmefr/gsm_efr.h" |
146
0fa0cd251a31
gsmefr-dec-parse: use factored-out ETSI bit reader
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
13 #include "etsi.h" |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 main(argc, argv) |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 char **argv; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 FILE *inf; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 unsigned frame_no; |
131
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
20 uint8_t input_bits[ETSI_DEC_NWORDS], frame[EFR_RTP_FRAME_LEN]; |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 int16_t params[EFR_NUM_PARAMS]; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 int rc, i, j, n; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (argc != 2) { |
131
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
25 fprintf(stderr, "usage: %s file.dec\n", argv[0]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 exit(1); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 inf = fopen(argv[1], "r"); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!inf) { |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 perror(argv[1]); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 exit(1); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 } |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 for (frame_no = 0; ; frame_no++) { |
146
0fa0cd251a31
gsmefr-dec-parse: use factored-out ETSI bit reader
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
34 rc = read_etsi_bits(inf, 0, input_bits, ETSI_DEC_NWORDS, |
0fa0cd251a31
gsmefr-dec-parse: use factored-out ETSI bit reader
Mychaela Falconia <falcon@freecalypso.org>
parents:
131
diff
changeset
|
35 argv[1]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (!rc) |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 break; |
131
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
38 bits2frame(input_bits + 1, frame, argv[1], frame_no); |
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
39 printf("#%u: BFI=%u SID=%u TAF=%u LPC", frame_no, |
615f144b52c6
gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
40 input_bits[0], input_bits[245], input_bits[246]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 EFR_frame2params(frame, params); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 n = 0; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 for (i = 0; i < 5; i++) |
128
a5ffec18e4cd
test programs: use printf %d format for codec parameters
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
44 printf(" %d", params[n++]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 putchar('\n'); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 for (i = 0; i < 4; i++) { |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 putchar(' '); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 for (j = 0; j < 13; j++) |
128
a5ffec18e4cd
test programs: use printf %d format for codec parameters
Mychaela Falconia <falcon@freecalypso.org>
parents:
115
diff
changeset
|
49 printf(" %d", params[n++]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 putchar('\n'); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |