annotate ae-dec-dhf/gen-test-frames.c @ 42:982169986a14

efr-sid: starting with dtx01-frame71.cod as good SID
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 09 Jun 2024 05:28:22 +0000
parents ab7c80f6f02d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
39
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program generates some test EFR frames that are meant to be fed
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * to the uplink input of the alien GSM network under study, seeking to
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * test if the AMR-EFR hybrid decoder's handling of DHF matches our model.
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <gsm_efr.h>
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <tw_amr.h>
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 static FILE *outf;
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 static void
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 emit_mr122_dhf()
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 uint8_t frame[EFR_RTP_FRAME_LEN];
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 EFR_params2frame(amr_dhf_mr122, frame);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fwrite(frame, 1, EFR_RTP_FRAME_LEN, outf);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 }
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 static void
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 emit_mixed_dhf()
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 {
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 int16_t params[EFR_NUM_PARAMS];
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 uint8_t frame[EFR_RTP_FRAME_LEN];
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 memcpy(params, amr_dhf_gsmefr, sizeof(int16_t) * 18);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 memcpy(params + 18, amr_dhf_mr122 + 18, sizeof(int16_t) * 39);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 EFR_params2frame(params, frame);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 fwrite(frame, 1, EFR_RTP_FRAME_LEN, outf);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 }
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 main(argc, argv)
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 char **argv;
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 {
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if (argc != 2) {
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 fprintf(stderr, "usage: %s gsmx-out-file\n", argv[0]);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 exit(1);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 }
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 outf = fopen(argv[1], "w");
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 if (!outf) {
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 perror(argv[1]);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 exit(1);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 emit_mr122_dhf();
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 emit_mr122_dhf();
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 emit_mixed_dhf();
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 fwrite(EFR_decoder_homing_frame, 1, EFR_RTP_FRAME_LEN, outf);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 emit_mixed_dhf();
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 emit_mixed_dhf();
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 emit_mr122_dhf();
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 fclose(outf);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 exit(0);
ab7c80f6f02d ae-dec-dhf: initial generation
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 }