annotate efrtest/decode-tw5-r.c @ 555:62943a1ad64e

doc/FR1-Rx-DTX-detail: grammar fix
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 00:22:47 +0000
parents 583dc4cbee95
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
548
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
2 * This file is the main module for gsmefr-decode-tw5-r utility. It is just
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
3 * like the original gsmefr-decode-r, but reads the GSM-EFR speech recording
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
4 * from TW-TS-005 Annex A hexadecimal format instead of the old gsmx
538
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
5 * binary format. The output format is robe, as indicated by the -r suffix.
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 */
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdint.h>
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
548
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
11 #include "../libgsmefr/gsm_efr.h"
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
12 #include "../libtest/tw5reader.h"
538
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
13 #include "../libtest/robewrite.h"
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 main(argc, argv)
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 char **argv;
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 {
538
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
18 FILE *hexf, *outf;
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
19 unsigned lineno;
548
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
20 struct EFR_decoder_state *state;
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
21 uint8_t frame[TWTS005_MAX_FRAME];
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
22 unsigned frame_len;
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 int16_t pcm[160];
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
24 int rc;
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 if (argc != 3) {
538
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
27 fprintf(stderr, "usage: %s input.hex output.robe\n", argv[0]);
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 exit(1);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
30 hexf = fopen(argv[1], "r");
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
31 if (!hexf) {
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 perror(argv[1]);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 exit(1);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
35 lineno = 0;
538
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
36 outf = fopen(argv[2], "w");
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
37 if (!outf) {
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 perror(argv[2]);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 exit(1);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
548
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
41 state = EFR_decoder_create();
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
42 if (!state) {
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
43 perror("EFR_decoder_create()");
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 exit(1);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 for (;;) {
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
47 rc = twts005_read_frame(hexf, &lineno, frame, &frame_len);
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 if (rc < 0) {
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
49 fprintf(stderr, "%s line %u: not valid TW-TS-005\n",
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
50 argv[1], lineno);
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 exit(1);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 if (!rc)
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 break;
548
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
55 rc = EFR_decode_rtp(state, frame, frame_len, pcm);
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
56 if (rc < 0) {
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
57 fprintf(stderr,
548
583dc4cbee95 efrtest: new program gsmefr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 538
diff changeset
58 "%s line %u: not a valid GSM-EFR frame\n",
537
f9eefb61fb2f frtest: new program gsmfr-decode-tw5
Mychaela Falconia <falcon@freecalypso.org>
parents: 284
diff changeset
59 argv[1], lineno);
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 exit(1);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 }
538
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
62 write_pcm_to_robe(outf, pcm);
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 }
538
4d596bfdf8d9 frtest: new program gsmfr-decode-tw5-r
Mychaela Falconia <falcon@freecalypso.org>
parents: 537
diff changeset
64 fclose(outf);
12
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 exit(0);
f88817a233fb gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }