FreeCalypso > hg > gsm-net-reveng
comparison trau-ul-prep/efrdec2tsrc.c @ 22:8957383370c5
trau-ul-prep: implement efrdec2tsrc
| author | Mychaela Falconia <falcon@freecalypso.org> | 
|---|---|
| date | Sun, 23 Jun 2024 22:24:39 +0000 | 
| parents | |
| children | 
   comparison
  equal
  deleted
  inserted
  replaced
| 21:453461ad9c15 | 22:8957383370c5 | 
|---|---|
| 1 /* | |
| 2 * This program reads an EFR *.dec file in ETSI test sequence format | |
| 3 * and converts it into ASCII source for TRAU-UL construction. | |
| 4 */ | |
| 5 | |
| 6 #include <stdio.h> | |
| 7 #include <stdint.h> | |
| 8 #include <stdlib.h> | |
| 9 #include <string.h> | |
| 10 #include <strings.h> | |
| 11 #include <unistd.h> | |
| 12 #include <gsm_efr.h> | |
| 13 #include "etsi.h" | |
| 14 | |
| 15 main(argc, argv) | |
| 16 char **argv; | |
| 17 { | |
| 18 char *infname, *outfname; | |
| 19 FILE *inf, *outf; | |
| 20 int big_endian = 0; | |
| 21 unsigned frame_no; | |
| 22 uint8_t input_bits[ETSI_DEC_NWORDS], frame[EFR_RTP_FRAME_LEN]; | |
| 23 int16_t params[EFR_NUM_PARAMS]; | |
| 24 int rc, i, j, n; | |
| 25 extern int optind; | |
| 26 | |
| 27 while ((rc = getopt(argc, argv, "b")) != EOF) { | |
| 28 switch (rc) { | |
| 29 case 'b': | |
| 30 big_endian = 1; | |
| 31 continue; | |
| 32 default: | |
| 33 usage: | |
| 34 fprintf(stderr, | |
| 35 "usage: %s [-b] input.dec [output.tsrc]\n", | |
| 36 argv[0]); | |
| 37 exit(1); | |
| 38 } | |
| 39 } | |
| 40 if (argc < optind + 1 || argc > optind + 2) | |
| 41 goto usage; | |
| 42 infname = argv[optind]; | |
| 43 outfname = argv[optind+1]; | |
| 44 | |
| 45 inf = fopen(infname, "r"); | |
| 46 if (!inf) { | |
| 47 perror(infname); | |
| 48 exit(1); | |
| 49 } | |
| 50 if (outfname) { | |
| 51 outf = fopen(outfname, "w"); | |
| 52 if (!outf) { | |
| 53 perror(outfname); | |
| 54 exit(1); | |
| 55 } | |
| 56 } else | |
| 57 outf = stdout; | |
| 58 for (frame_no = 0; ; frame_no++) { | |
| 59 rc = read_etsi_bits(inf, big_endian, input_bits, | |
| 60 ETSI_DEC_NWORDS, infname); | |
| 61 if (!rc) | |
| 62 break; | |
| 63 bits2frame(input_bits + 1, frame, infname, frame_no); | |
| 64 fprintf(outf, "# input frame %u\nFrame_EFR {\n", frame_no); | |
| 65 if (input_bits[246]) | |
| 66 fputs("\t# TAF position\n", outf); | |
| 67 fprintf(outf, "\tBFI %u\n", input_bits[0]); | |
| 68 EFR_frame2params(frame, params); | |
| 69 n = 0; | |
| 70 fputs("\tLPC", outf); | |
| 71 for (i = 0; i < 5; i++) | |
| 72 fprintf(outf, " %d", params[n++]); | |
| 73 putc('\n', outf); | |
| 74 for (i = 0; i < 4; i++) { | |
| 75 fputs("\tsf", outf); | |
| 76 for (j = 0; j < 13; j++) | |
| 77 fprintf(outf, " %d", params[n++]); | |
| 78 putc('\n', outf); | |
| 79 } | |
| 80 fprintf(outf, "\tSID %u\n", input_bits[245]); | |
| 81 fputs("}\n\n", outf); | |
| 82 } | |
| 83 exit(0); | |
| 84 } | 
