comparison efrtest/cod2gsmx.c @ 239:b8e095a9e360

efrtest: new program gsmefr-cod2gsmx
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 08 May 2023 07:19:26 +0000
parents efrtest/cod-parse.c@46a6e6b6841a
children
comparison
equal deleted inserted replaced
238:de1b52304d26 239:b8e095a9e360
1 /*
2 * This program reads an EFR *.cod file in ETSI test sequence format
3 * and converts it into Themyscira gsmx format.
4 */
5
6 #include <stdio.h>
7 #include <stdint.h>
8 #include <stdlib.h>
9 #include <string.h>
10 #include <strings.h>
11 #include "../libgsmefr/gsm_efr.h"
12 #include "etsi.h"
13
14 main(argc, argv)
15 char **argv;
16 {
17 char *infname, *outfname;
18 FILE *inf, *outf;
19 int big_endian;
20 unsigned frame_no;
21 uint8_t input_bits[ETSI_ENC_NWORDS], frame[EFR_RTP_FRAME_LEN];
22 int rc;
23
24 if (argc == 3 && argv[1][0] != '-') {
25 big_endian = 0;
26 infname = argv[1];
27 outfname = argv[2];
28 } else if (argc == 4 && !strcmp(argv[1], "-b")) {
29 big_endian = 1;
30 infname = argv[2];
31 outfname = argv[3];
32 } else {
33 fprintf(stderr, "usage: %s [-b] input.cod output.gsmx\n",
34 argv[0]);
35 exit(1);
36 }
37 inf = fopen(infname, "r");
38 if (!inf) {
39 perror(infname);
40 exit(1);
41 }
42 outf = fopen(outfname, "w");
43 if (!outf) {
44 perror(outfname);
45 exit(1);
46 }
47 for (frame_no = 0; ; frame_no++) {
48 rc = read_etsi_bits(inf, big_endian, input_bits,
49 ETSI_ENC_NWORDS, infname);
50 if (!rc)
51 break;
52 bits2frame(input_bits, frame, infname, frame_no);
53 fwrite(frame, 1, sizeof frame, outf);
54 }
55 fclose(outf);
56 exit(0);
57 }