FreeCalypso > hg > vband-misc
annotate ae-dec-dhf/gen-test-frames.c @ 39:ab7c80f6f02d
ae-dec-dhf: initial generation
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 14 May 2024 08:13:01 +0000 |
parents | |
children |
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 } |