annotate efrtest/cod2gsmx.c @ 416:48c7f8e8c9af

libtwamr: integrate p_ol_wgh.c
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 07 May 2024 03:15:19 +0000
parents b8e095a9e360
children
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 /*
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
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
3 * and converts it into Themyscira gsmx format.
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
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 #include <stdio.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdint.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #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
12 #include "etsi.h"
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 main(argc, argv)
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char **argv;
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
17 char *infname, *outfname;
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
18 FILE *inf, *outf;
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
19 int big_endian;
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 unsigned frame_no;
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 uint8_t input_bits[ETSI_ENC_NWORDS], frame[EFR_RTP_FRAME_LEN];
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
22 int rc;
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
24 if (argc == 3 && argv[1][0] != '-') {
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
25 big_endian = 0;
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
26 infname = argv[1];
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
27 outfname = argv[2];
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
28 } else if (argc == 4 && !strcmp(argv[1], "-b")) {
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
29 big_endian = 1;
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
30 infname = argv[2];
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
31 outfname = argv[3];
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
32 } else {
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
33 fprintf(stderr, "usage: %s [-b] input.cod output.gsmx\n",
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
34 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 }
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
42 outf = fopen(outfname, "w");
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
43 if (!outf) {
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
44 perror(outfname);
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
45 exit(1);
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
46 }
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 for (frame_no = 0; ; frame_no++) {
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
48 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
49 ETSI_ENC_NWORDS, infname);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 if (!rc)
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 break;
148
bbe5669f0f29 gsmefr-cod-parse: add BE support
Mychaela Falconia <falcon@freecalypso.org>
parents: 147
diff changeset
52 bits2frame(input_bits, frame, infname, frame_no);
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
53 fwrite(frame, 1, sizeof frame, outf);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 }
239
b8e095a9e360 efrtest: new program gsmefr-cod2gsmx
Mychaela Falconia <falcon@freecalypso.org>
parents: 213
diff changeset
55 fclose(outf);
213
46a6e6b6841a gsmefr-{cod,dec}-parse: missed exit(0) at the end
Mychaela Falconia <falcon@freecalypso.org>
parents: 148
diff changeset
56 exit(0);
115
5a63294fa321 gsmefr-cod-parse test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 }