comparison miscutil/gsmrec-dump.c @ 281:3816ba89a5a0

gsmrec-dump: use libgsmfr2 instead of old libgsm
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Apr 2024 05:09:52 +0000
parents a5ffec18e4cd
children fa8845306e07
comparison
equal deleted inserted replaced
280:356d9675701d 281:3816ba89a5a0
4 */ 4 */
5 5
6 #include <stdio.h> 6 #include <stdio.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <gsm.h> 9 #include "../libgsmfr2/tw_gsmfr.h"
10 #include "../libgsmefr/gsm_efr.h" 10 #include "../libgsmefr/gsm_efr.h"
11 #include "../libtest/binreader.h" 11 #include "../libtest/binreader.h"
12 12
13 main(argc, argv) 13 main(argc, argv)
14 char **argv; 14 char **argv;
15 { 15 {
16 FILE *binf; 16 FILE *binf;
17 gsm dummy_state;
18 unsigned frame_index; 17 unsigned frame_index;
19 uint8_t frame[BINFILE_MAX_FRAME]; 18 uint8_t frame[BINFILE_MAX_FRAME];
20 gsm_signal params[76]; 19 int16_t params[GSMFR_NUM_PARAMS];
21 int rc, i, j, n; 20 int rc, i, j, n;
22 21
23 if (argc != 2) { 22 if (argc != 2) {
24 fprintf(stderr, "usage: %s bin-stream-file\n", argv[0]); 23 fprintf(stderr, "usage: %s bin-stream-file\n", argv[0]);
25 exit(1); 24 exit(1);
26 } 25 }
27 binf = fopen(argv[1], "r"); 26 binf = fopen(argv[1], "r");
28 if (!binf) { 27 if (!binf) {
29 perror(argv[1]); 28 perror(argv[1]);
30 exit(1);
31 }
32 dummy_state = gsm_create();
33 if (!dummy_state) {
34 fprintf(stderr, "gsm_create() failed!\n");
35 exit(1); 29 exit(1);
36 } 30 }
37 for (frame_index = 0; ; frame_index++) { 31 for (frame_index = 0; ; frame_index++) {
38 rc = binfile_read_frame(binf, frame); 32 rc = binfile_read_frame(binf, frame);
39 if (rc < 0) { 33 if (rc < 0) {
61 putchar('\n'); 55 putchar('\n');
62 } 56 }
63 break; 57 break;
64 case 0xD0: 58 case 0xD0:
65 fputs("FR", stdout); 59 fputs("FR", stdout);
66 gsm_explode(dummy_state, frame, params); 60 gsmfr_unpack_to_array(frame, params);
67 n = 0; 61 n = 0;
68 for (i = 0; i < 8; i++) 62 for (i = 0; i < 8; i++)
69 printf(" %d", params[n++]); 63 printf(" %d", params[n++]);
70 putchar('\n'); 64 putchar('\n');
71 for (i = 0; i < 4; i++) { 65 for (i = 0; i < 4; i++) {