FreeCalypso > hg > gsm-codec-lib
annotate efrtest/cod-parse.c @ 183:452c1d5a6268
libgsmefr BFI w/o data: emit zero output after decoder reset
In real-life usage, each EFR decoder session will most likely begin
with lots of BFI frames before the first real frame arrives. However,
because the spec-defined home state of the decoder is speech rather
than CN, our regular logic for BFI w/o data would have to feed
pseudorandom noise to the decoder (in the "fixed codebook excitation
pulses" part), which is silly to do at the beginning of the decoder
session right out of reset. Therefore, let's check reset_flag_old,
and if we are still in the reset state, simply emit zero output.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 03 Jan 2023 00:12:18 +0000 |
parents | bbe5669f0f29 |
children | 46a6e6b6841a |
rev | line source |
---|---|
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program reads an EFR *.cod file in ETSI test sequence format |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * (output from either ETSI's official coder program or our gsmefr-etsi-enc) |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * and converts it into human-readable format, similar to what one would get |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * from our gsmrec-dump utility. |
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 |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <string.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <strings.h> |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "../libgsmefr/gsm_efr.h" |
147
90b9c7c3fa3b
gsmefr-cod-parse: use factored-out ETSI bit reader
Mychaela Falconia <falcon@freecalypso.org>
parents:
128
diff
changeset
|
14 #include "etsi.h" |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 main(argc, argv) |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char **argv; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 { |
148
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
19 char *infname; |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 FILE *inf; |
148
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
21 int big_endian; |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 unsigned frame_no; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 uint8_t input_bits[ETSI_ENC_NWORDS], frame[EFR_RTP_FRAME_LEN]; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 int16_t params[EFR_NUM_PARAMS]; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 int rc, i, j, n; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 |
148
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
27 if (argc == 2 && argv[1][0] != '-') { |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
28 big_endian = 0; |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
29 infname = argv[1]; |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
30 } else if (argc == 3 && !strcmp(argv[1], "-b")) { |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
31 big_endian = 1; |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
32 infname = argv[2]; |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
33 } else { |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
34 fprintf(stderr, "usage: %s [-b] file.cod\n", argv[0]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 exit(1); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 } |
148
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
37 inf = fopen(infname, "r"); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (!inf) { |
148
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
39 perror(infname); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 exit(1); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 for (frame_no = 0; ; frame_no++) { |
148
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
43 rc = read_etsi_bits(inf, big_endian, input_bits, |
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
44 ETSI_ENC_NWORDS, infname); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (!rc) |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 break; |
148
bbe5669f0f29
gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents:
147
diff
changeset
|
47 bits2frame(input_bits, frame, infname, frame_no); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 printf("#%u: VAD=%u SP=%u SID=%d LPC", frame_no, |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 input_bits[244], input_bits[245], |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 EFR_sid_classify(frame)); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 EFR_frame2params(frame, params); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 n = 0; |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 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
|
54 printf(" %d", params[n++]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 putchar('\n'); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 for (i = 0; i < 4; i++) { |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 putchar(' '); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
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:
115
diff
changeset
|
59 printf(" %d", params[n++]); |
115
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 putchar('\n'); |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |
5a63294fa321
gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |