FreeCalypso > hg > gsm-codec-lib
comparison frtest/dlcap-parse.c @ 286:251aed72925e
gsmfr-dlcap-parse: convert to libgsmfr2
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Sun, 14 Apr 2024 06:11:39 +0000 |
| parents | 5fe0b3eb35c1 |
| children |
comparison
equal
deleted
inserted
replaced
| 285:cfa3006a66da | 286:251aed72925e |
|---|---|
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 #include <string.h> | 12 #include <string.h> |
| 13 #include <strings.h> | 13 #include <strings.h> |
| 14 #include <gsm.h> | 14 #include "../libgsmfr2/tw_gsmfr.h" |
| 15 #include "../libgsmfrp/gsm_fr_preproc.h" | |
| 16 | 15 |
| 17 static void | 16 static void |
| 18 process_record(lineno, fn_mod_104, status_words, tidsp_bytes, dummy_state) | 17 process_record(lineno, fn_mod_104, status_words, tidsp_bytes) |
| 19 int lineno; | 18 int lineno; |
| 20 unsigned fn_mod_104; | 19 unsigned fn_mod_104; |
| 21 uint16_t *status_words; | 20 uint16_t *status_words; |
| 22 uint8_t *tidsp_bytes; | 21 uint8_t *tidsp_bytes; |
| 23 gsm dummy_state; | |
| 24 { | 22 { |
| 25 uint8_t libgsm_bytes[33]; | 23 uint8_t libgsm_bytes[33]; |
| 26 int16_t params[76]; | 24 int16_t params[76]; |
| 27 int i, j, n; | 25 int i, j, n; |
| 28 | 26 |
| 31 gsm0610_tidsp_to_libgsm(tidsp_bytes, libgsm_bytes); | 29 gsm0610_tidsp_to_libgsm(tidsp_bytes, libgsm_bytes); |
| 32 fputs(" bits ", stdout); | 30 fputs(" bits ", stdout); |
| 33 for (i = 0; i < 33; i++) | 31 for (i = 0; i < 33; i++) |
| 34 printf("%02X", tidsp_bytes[i]); | 32 printf("%02X", tidsp_bytes[i]); |
| 35 printf(" SID=%d\n", gsmfr_preproc_sid_classify(libgsm_bytes)); | 33 printf(" SID=%d\n", gsmfr_preproc_sid_classify(libgsm_bytes)); |
| 36 gsm_explode(dummy_state, libgsm_bytes, params); | 34 gsmfr_unpack_to_array(libgsm_bytes, params); |
| 37 fputs(" FR", stdout); | 35 fputs(" FR", stdout); |
| 38 n = 0; | 36 n = 0; |
| 39 for (i = 0; i < 8; i++) | 37 for (i = 0; i < 8; i++) |
| 40 printf(" %d", params[n++]); | 38 printf(" %d", params[n++]); |
| 41 putchar('\n'); | 39 putchar('\n'); |
| 49 | 47 |
| 50 main(argc, argv) | 48 main(argc, argv) |
| 51 char **argv; | 49 char **argv; |
| 52 { | 50 { |
| 53 FILE *inf; | 51 FILE *inf; |
| 54 gsm dummy_state; | |
| 55 char linebuf[128]; | 52 char linebuf[128]; |
| 56 int lineno, rc; | 53 int lineno, rc; |
| 57 uint16_t status_words[3]; | 54 uint16_t status_words[3]; |
| 58 uint8_t tidsp_bytes[33]; | 55 uint8_t tidsp_bytes[33]; |
| 59 unsigned fn_mod_104; | 56 unsigned fn_mod_104; |
| 63 exit(1); | 60 exit(1); |
| 64 } | 61 } |
| 65 inf = fopen(argv[1], "r"); | 62 inf = fopen(argv[1], "r"); |
| 66 if (!inf) { | 63 if (!inf) { |
| 67 perror(argv[1]); | 64 perror(argv[1]); |
| 68 exit(1); | |
| 69 } | |
| 70 dummy_state = gsm_create(); | |
| 71 if (!dummy_state) { | |
| 72 fprintf(stderr, "gsm_create() failed!\n"); | |
| 73 exit(1); | 65 exit(1); |
| 74 } | 66 } |
| 75 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { | 67 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { |
| 76 /* support both old and new formats */ | 68 /* support both old and new formats */ |
| 77 if (isxdigit(linebuf[0]) && isxdigit(linebuf[1]) && | 69 if (isxdigit(linebuf[0]) && isxdigit(linebuf[1]) && |
| 100 if (!isdigit(linebuf[85])) | 92 if (!isdigit(linebuf[85])) |
| 101 goto invalid; | 93 goto invalid; |
| 102 fn_mod_104 = strtoul(linebuf + 85, 0, 10); | 94 fn_mod_104 = strtoul(linebuf + 85, 0, 10); |
| 103 } else | 95 } else |
| 104 goto invalid; | 96 goto invalid; |
| 105 process_record(lineno, fn_mod_104, status_words, tidsp_bytes, | 97 process_record(lineno, fn_mod_104, status_words, tidsp_bytes); |
| 106 dummy_state); | |
| 107 } | 98 } |
| 108 exit(0); | 99 exit(0); |
| 109 } | 100 } |
