annotate efrtest/dec-parse.c @ 170:b9af126bfddb

rtp-cont-check utility written
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 26 Dec 2022 21:24:00 +0000
parents 95d47a34070a
children 46a6e6b6841a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 {
149
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
18 char *infname;
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 FILE *inf;
149
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
20 int big_endian;
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned frame_no;
131
615f144b52c6 gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
22 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
23 int16_t params[EFR_NUM_PARAMS];
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 int rc, i, j, n;
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
149
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
26 if (argc == 2 && argv[1][0] != '-') {
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
27 big_endian = 0;
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
28 infname = argv[1];
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
29 } else if (argc == 3 && !strcmp(argv[1], "-b")) {
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
30 big_endian = 1;
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
31 infname = argv[2];
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
32 } else {
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
33 fprintf(stderr, "usage: %s [-b] file.dec\n", argv[0]);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 exit(1);
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
149
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
36 inf = fopen(infname, "r");
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!inf) {
149
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
38 perror(infname);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 exit(1);
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 for (frame_no = 0; ; frame_no++) {
149
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
42 rc = read_etsi_bits(inf, big_endian, input_bits,
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
43 ETSI_DEC_NWORDS, infname);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (!rc)
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 break;
149
95d47a34070a gsmefr-dec-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 146
diff changeset
46 bits2frame(input_bits + 1, frame, infname, frame_no);
131
615f144b52c6 gsmefr-dec-parse utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 128
diff changeset
47 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
48 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
49 EFR_frame2params(frame, params);
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 n = 0;
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 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
52 printf(" %d", params[n++]);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 putchar('\n');
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 for (i = 0; i < 4; i++) {
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 putchar(' ');
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 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
57 printf(" %d", params[n++]);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 putchar('\n');
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 }
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 }