annotate efr-sid/mk-sid-test.c @ 57:a64e5ed217c0 default tip

top Makefile: add fr-sid
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 22 Aug 2024 06:43:31 +0000
parents 8bfc517fda3b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
43
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program generates a sequence of 95 EFR codec frames that starts
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * with a perfect SID and is degraded by one bit in the SID field
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 * on every output frame.
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <gsm_efr.h>
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "etsi.h"
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 extern const uint8_t SID_codeword_bit_idx[95];
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 static void
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 read_input_file(filename, cod_frame)
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char *filename;
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 uint8_t *cod_frame;
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 FILE *inf;
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 inf = fopen(filename, "r");
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 if (!inf) {
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 perror(filename);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 exit(1);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 }
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 read_etsi_bits(inf, 0, cod_frame, ETSI_ENC_NWORDS, filename);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 fclose(inf);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 }
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 main(argc, argv)
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 char **argv;
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 {
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 uint8_t cod_frame[ETSI_ENC_NWORDS], packed_frame[EFR_RTP_FRAME_LEN];
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 FILE *outf;
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 unsigned nf;
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 if (argc != 3) {
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 fprintf(stderr, "usage: %s input.cod output.gsmx\n", argv[0]);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 exit(1);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 }
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 read_input_file(argv[1], cod_frame);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 outf = fopen(argv[2], "w");
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (!outf) {
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 perror(argv[2]);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 exit(1);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 for (nf = 0; nf < 95; nf++) {
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 bits2frame(cod_frame, packed_frame, argv[1], 0);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 fwrite(packed_frame, 1, EFR_RTP_FRAME_LEN, outf);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 cod_frame[SID_codeword_bit_idx[nf]] = 0;
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 fclose(outf);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 exit(0);
8bfc517fda3b efr-sid: hack created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 }