comparison frtest/decode-r.c @ 285:cfa3006a66da

gsmfr-decode-r: convert to libgsmfr2
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Apr 2024 06:04:32 +0000
parents 14b627682458
children
comparison
equal deleted inserted replaced
284:8d3cfa65a6c2 285:cfa3006a66da
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 "../libgsmfrp/gsm_fr_preproc.h"
11 #include "../libtest/binreader.h" 10 #include "../libtest/binreader.h"
12 #include "../libtest/robewrite.h" 11 #include "../libtest/robewrite.h"
13 12
14 main(argc, argv) 13 main(argc, argv)
15 char **argv; 14 char **argv;
16 { 15 {
17 FILE *binf, *outf; 16 FILE *binf, *outf;
18 gsm dec_state; 17 struct gsmfr_fulldec_state *fd_state;
19 struct gsmfr_preproc_state *pp_state;
20 uint8_t frame[BINFILE_MAX_FRAME]; 18 uint8_t frame[BINFILE_MAX_FRAME];
21 int16_t pcm[160]; 19 int16_t pcm[160];
22 int rc, bfi, taf; 20 int rc, bfi, taf;
23 21
24 if (argc != 3) { 22 if (argc != 3) {
33 outf = fopen(argv[2], "w"); 31 outf = fopen(argv[2], "w");
34 if (!outf) { 32 if (!outf) {
35 perror(argv[2]); 33 perror(argv[2]);
36 exit(1); 34 exit(1);
37 } 35 }
38 dec_state = gsm_create(); 36 fd_state = gsmfr_fulldec_create();
39 if (!dec_state) { 37 if (!fd_state) {
40 fprintf(stderr, "gsm_create() failed!\n"); 38 fprintf(stderr, "gsmfr_fulldec_create() failed!\n");
41 exit(1);
42 }
43 pp_state = gsmfr_preproc_create();
44 if (!pp_state) {
45 fprintf(stderr, "gsmfr_preproc_create() failed!\n");
46 exit(1); 39 exit(1);
47 } 40 }
48 for (;;) { 41 for (;;) {
49 rc = binfile_read_frame(binf, frame); 42 rc = binfile_read_frame(binf, frame);
50 if (rc < 0) { 43 if (rc < 0) {
62 fprintf(stderr, "error: %s is not in FR codec format\n", 55 fprintf(stderr, "error: %s is not in FR codec format\n",
63 argv[1]); 56 argv[1]);
64 exit(1); 57 exit(1);
65 } 58 }
66 if (bfi) 59 if (bfi)
67 gsmfr_preproc_bfi(pp_state, taf, frame); 60 gsmfr_fulldec_bfi(fd_state, taf, pcm);
68 else 61 else
69 gsmfr_preproc_good_frame(pp_state, frame); 62 gsmfr_fulldec_good_frame(fd_state, frame, pcm);
70 gsm_decode(dec_state, frame, pcm);
71 write_pcm_to_robe(outf, pcm); 63 write_pcm_to_robe(outf, pcm);
72 } 64 }
73 fclose(outf); 65 fclose(outf);
74 exit(0); 66 exit(0);
75 } 67 }