FreeCalypso > hg > gsm-codec-lib
comparison frtest/decode-tw5-r.c @ 538:4d596bfdf8d9
frtest: new program gsmfr-decode-tw5-r
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 21 Sep 2024 23:58:27 +0000 |
parents | frtest/decode-tw5.c@f9eefb61fb2f |
children |
comparison
equal
deleted
inserted
replaced
537:f9eefb61fb2f | 538:4d596bfdf8d9 |
---|---|
1 /* | |
2 * This file is the main module for gsmfr-decode-tw5-r utility. It is just | |
3 * like the original gsmfr-decode-r, but reads the GSM-FR speech recording | |
4 * from TW-TS-005 Annex A hexadecimal format instead of the old gsmx | |
5 * binary format. The output format is robe, as indicated by the -r suffix. | |
6 */ | |
7 | |
8 #include <stdio.h> | |
9 #include <stdint.h> | |
10 #include <stdlib.h> | |
11 #include "../libgsmfr2/tw_gsmfr.h" | |
12 #include "../libtest/tw5reader.h" | |
13 #include "../libtest/robewrite.h" | |
14 | |
15 main(argc, argv) | |
16 char **argv; | |
17 { | |
18 FILE *hexf, *outf; | |
19 unsigned lineno; | |
20 struct gsmfr_fulldec_state *fd_state; | |
21 uint8_t frame[TWTS005_MAX_FRAME]; | |
22 unsigned frame_len; | |
23 int16_t pcm[160]; | |
24 int rc; | |
25 | |
26 if (argc != 3) { | |
27 fprintf(stderr, "usage: %s input.hex output.robe\n", argv[0]); | |
28 exit(1); | |
29 } | |
30 hexf = fopen(argv[1], "r"); | |
31 if (!hexf) { | |
32 perror(argv[1]); | |
33 exit(1); | |
34 } | |
35 lineno = 0; | |
36 outf = fopen(argv[2], "w"); | |
37 if (!outf) { | |
38 perror(argv[2]); | |
39 exit(1); | |
40 } | |
41 fd_state = gsmfr_fulldec_create(); | |
42 if (!fd_state) { | |
43 fprintf(stderr, "gsmfr_fulldec_create() failed!\n"); | |
44 exit(1); | |
45 } | |
46 for (;;) { | |
47 rc = twts005_read_frame(hexf, &lineno, frame, &frame_len); | |
48 if (rc < 0) { | |
49 fprintf(stderr, "%s line %u: not valid TW-TS-005\n", | |
50 argv[1], lineno); | |
51 exit(1); | |
52 } | |
53 if (!rc) | |
54 break; | |
55 rc = gsmfr_fulldec_rtp_in(fd_state, frame, frame_len, pcm); | |
56 if (rc < 0) { | |
57 fprintf(stderr, | |
58 "%s line %u: not a valid GSM-FR frame\n", | |
59 argv[1], lineno); | |
60 exit(1); | |
61 } | |
62 write_pcm_to_robe(outf, pcm); | |
63 } | |
64 fclose(outf); | |
65 exit(0); | |
66 } |