FreeCalypso > hg > gsm-codec-lib
comparison hrutil/cod2hex.c @ 557:129c895a0564
hrutil: new program gsmhr-cod2hex
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 06 Feb 2025 08:38:27 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
556:18aca50d68df | 557:129c895a0564 |
---|---|
1 /* | |
2 * This program reads an HRv1 *.cod file in ETSI test sequence format | |
3 * (encoder output format) and converts it into TW-TS-005 Annex B | |
4 * hexadecimal format. | |
5 */ | |
6 | |
7 #include <stdio.h> | |
8 #include <stdint.h> | |
9 #include <stdlib.h> | |
10 #include <string.h> | |
11 #include <strings.h> | |
12 #include <unistd.h> | |
13 #include "../libgsmhr1/tw_gsmhr.h" | |
14 | |
15 main(argc, argv) | |
16 char **argv; | |
17 { | |
18 char *infname, *outfname; | |
19 FILE *inf, *outf; | |
20 int opt, rc, big_endian = 0, emit_5993 = 0; | |
21 unsigned frame_no; | |
22 int16_t params[GSMHR_NUM_PARAMS_ENC]; | |
23 extern int optind; | |
24 | |
25 while ((opt = getopt(argc, argv, "bx")) != EOF) { | |
26 switch (opt) { | |
27 case 'b': | |
28 big_endian = 1; | |
29 continue; | |
30 case 'x': | |
31 emit_5993 = 1; | |
32 continue; | |
33 default: | |
34 usage: | |
35 fprintf(stderr, | |
36 "usage: %s [-b] [-x] input.cod output.hex\n", | |
37 argv[0]); | |
38 exit(1); | |
39 } | |
40 } | |
41 if (argc != optind + 2) | |
42 goto usage; | |
43 infname = argv[optind]; | |
44 outfname = argv[optind+1]; | |
45 | |
46 inf = fopen(infname, "r"); | |
47 if (!inf) { | |
48 perror(infname); | |
49 exit(1); | |
50 } | |
51 outf = fopen(outfname, "w"); | |
52 if (!outf) { | |
53 perror(outfname); | |
54 exit(1); | |
55 } | |
56 | |
57 for (frame_no = 0; ; frame_no++) { | |
58 rc = read_cod_frame(inf, big_endian, params, infname, frame_no); | |
59 if (!rc) | |
60 break; | |
61 emit_cod_to_tw5b(outf, params, emit_5993); | |
62 } | |
63 exit(0); | |
64 } |