FreeCalypso > hg > gsm-codec-lib
comparison frtest/decode-rb.c @ 296:e0d42e87da96
frtest: new utility gsmfr-decode-rb
| author | Mychaela Falconia <falcon@freecalypso.org> | 
|---|---|
| date | Sun, 14 Apr 2024 20:36:29 +0000 | 
| parents | frtest/decode-r.c@cfa3006a66da | 
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 295:962861d46ccf | 296:e0d42e87da96 | 
|---|---|
| 1 /* | |
| 2 * gsmfr-decode-rb is a "raw basic" decoder: only the basic GSM 06.10 decoder | |
| 3 * is applied (no Rx DTX preprocessor), and the output format is raw BE. | |
| 4 */ | |
| 5 | |
| 6 #include <stdio.h> | |
| 7 #include <stdint.h> | |
| 8 #include <stdlib.h> | |
| 9 #include "../libgsmfr2/tw_gsmfr.h" | |
| 10 #include "../libtest/binreader.h" | |
| 11 #include "../libtest/robewrite.h" | |
| 12 | |
| 13 main(argc, argv) | |
| 14 char **argv; | |
| 15 { | |
| 16 FILE *binf, *outf; | |
| 17 struct gsmfr_0610_state *dec_state; | |
| 18 uint8_t frame[BINFILE_MAX_FRAME]; | |
| 19 int16_t pcm[160]; | |
| 20 int rc; | |
| 21 | |
| 22 if (argc != 3) { | |
| 23 fprintf(stderr, "usage: %s input.gsm output.robe\n", argv[0]); | |
| 24 exit(1); | |
| 25 } | |
| 26 binf = fopen(argv[1], "r"); | |
| 27 if (!binf) { | |
| 28 perror(argv[1]); | |
| 29 exit(1); | |
| 30 } | |
| 31 outf = fopen(argv[2], "w"); | |
| 32 if (!outf) { | |
| 33 perror(argv[2]); | |
| 34 exit(1); | |
| 35 } | |
| 36 dec_state = gsmfr_0610_create(); | |
| 37 if (!dec_state) { | |
| 38 fprintf(stderr, "gsmfr_0610_create() failed!\n"); | |
| 39 exit(1); | |
| 40 } | |
| 41 for (;;) { | |
| 42 rc = binfile_read_frame(binf, frame); | |
| 43 if (rc < 0) { | |
| 44 fprintf(stderr, "error: garbage in %s\n", argv[1]); | |
| 45 exit(1); | |
| 46 } | |
| 47 if (!rc) | |
| 48 break; | |
| 49 if (frame[0] == 0xBF) { | |
| 50 fprintf(stderr, "error: %s contains disallowed BFI\n", | |
| 51 argv[1]); | |
| 52 exit(1); | |
| 53 } | |
| 54 if ((frame[0] & 0xF0) != 0xD0) { | |
| 55 fprintf(stderr, "error: %s is not in FR codec format\n", | |
| 56 argv[1]); | |
| 57 exit(1); | |
| 58 } | |
| 59 gsmfr_0610_decode_frame(dec_state, frame, pcm); | |
| 60 write_pcm_to_robe(outf, pcm); | |
| 61 } | |
| 62 fclose(outf); | |
| 63 exit(0); | |
| 64 } | 
