annotate dhf/efr-dhf-hexout.c @ 50:0db059f4632d

efr-sid OS#6538: more sensible 2-bit errors
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 12 Aug 2024 02:49:28 +0000
parents 307fe06fabec
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This little program takes EFR and MR122 DHFs provided in array-of-params
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * form by libtwamr, turns them into EFR RTP format using libgsmefr function,
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * and emits those two RTP-encoded EFR frames in hex, for inclusion in other
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 * C sources.
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 */
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdio.h>
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdint.h>
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <gsm_efr.h>
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <tw_amr.h>
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 static void
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
15 emit_one_frame(params, filename, cname)
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 const int16_t *params;
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
17 char *filename, *cname;
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 {
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 uint8_t efr_rtp[EFR_RTP_FRAME_LEN];
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
20 FILE *outf;
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 unsigned n;
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 EFR_params2frame(params, efr_rtp);
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
24 outf = fopen(filename, "w");
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
25 if (!outf) {
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
26 perror(filename);
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
27 exit(1);
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
28 }
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
29 fputs("#include <stdint.h>\n\n", outf);
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
30 fprintf(outf, "const uint8_t %s[31] = {\n", cname);
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 for (n = 0; n < EFR_RTP_FRAME_LEN; n++) {
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
32 fprintf(outf, "0x%02X,", efr_rtp[n]);
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (n == 15 || n == 30)
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
34 putc('\n', outf);
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
36 fputs("};\n", outf);
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
37 fclose(outf);
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 main(argc, argv)
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 char **argv;
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 {
34
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
43 if (argc != 3) {
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
44 fprintf(stderr, "usage: %s efr-dhf-out mr122-dhf-out\n",
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
45 argv[0]);
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
46 exit(1);
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
47 }
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
48 emit_one_frame(amr_dhf_gsmefr, argv[1], "efr_dhf_bytes");
307fe06fabec dhf: generate EFR hex DHF in C form
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
49 emit_one_frame(amr_dhf_mr122, argv[2], "mr122_dhf_bytes");
32
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 exit(0);
baf74dff5368 dhf: generate hex forms of EFR DHF
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 }