annotate amrdiff/readone-efr.c @ 17:39b3c24256ae

pcmu2efr: add stdefr-diff sanity check
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 16 Apr 2024 23:41:07 +0000
parents 5aeebdcbddad
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
4
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
2 * This program reads a single frame (the first one) from an EFR *.cod file
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
3 * and emits this frame of 244 bits as comma-separated ASCII. The intent is
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
4 * to extract the DHF in a form convenient for inclusion in amrdiff source.
2
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <string.h>
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <strings.h>
4
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
12 #include "etsi.h"
2
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 main(argc, argv)
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char **argv;
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 char *filename;
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 int bigend, rc;
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 FILE *inf;
4
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
20 uint8_t efr_bits[ETSI_ENC_NWORDS];
2
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (argc != 3) {
4
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
23 usage: fprintf(stderr, "usage: %s efr-cod-file be|le\n", argv[0]);
2
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 exit(1);
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 filename = argv[1];
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (!strcmp(argv[2], "be"))
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 bigend = 1;
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 else if (!strcmp(argv[2], "le"))
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 bigend = 0;
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 else
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 goto usage;
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 inf = fopen(filename, "r");
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 if (!inf) {
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 perror(filename);
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 exit(1);
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 }
4
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
38 rc = read_etsi_bits(inf, bigend, efr_bits, ETSI_ENC_NWORDS, filename);
2
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (!rc) {
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 fprintf(stderr, "error: %s is empty\n", filename);
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 exit(1);
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }
4
5aeebdcbddad readone-efr program written
Mychaela Falconia <falcon@freecalypso.org>
parents: 2
diff changeset
43 emit_frame244(efr_bits);
2
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 exit(0);
75ba83624a29 readone-amr program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 }