FreeCalypso > hg > gsm-net-reveng
view trau-ul-prep/gsmx2tsrc.c @ 69:cf60172895fe default tip
pathloss: add sysmo-example-10w
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 25 Oct 2024 16:26:26 +0000 |
parents | 7cd046ffefe7 |
children |
line wrap: on
line source
/* * This program reads a binary file in ThemWi gsmx format * and converts it into ASCII source for TRAU-UL construction. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <tw_gsmfr.h> #include <gsm_efr.h> #include "binreader.h" main(argc, argv) char **argv; { FILE *binf, *outf; unsigned frame_index; uint8_t frame[BINFILE_MAX_FRAME]; int16_t params[GSMFR_NUM_PARAMS]; int rc, i, j, n; if (argc < 2 || argc > 3) { fprintf(stderr, "usage: %s input.gsmx [output.tsrc]\n", argv[0]); exit(1); } binf = fopen(argv[1], "r"); if (!binf) { perror(argv[1]); exit(1); } if (argc > 2) { outf = fopen(argv[2], "w"); if (!outf) { perror(argv[2]); exit(1); } } else outf = stdout; for (frame_index = 0; ; frame_index++) { rc = binfile_read_frame(binf, frame); if (rc < 0) { fprintf(stderr, "error: garbage in %s\n", argv[1]); exit(1); } if (!rc) break; switch (frame[0] & 0xF0) { case 0xB0: fprintf(outf, "# input frame %u is BFI\n\n", frame_index); break; case 0xC0: fprintf(outf, "# input frame %u\nFrame_EFR {\n", frame_index); EFR_frame2params(frame, params); n = 0; fputs("\tLPC", outf); for (i = 0; i < 5; i++) fprintf(outf, " %d", params[n++]); putc('\n', outf); for (i = 0; i < 4; i++) { fputs("\tsf", outf); for (j = 0; j < 13; j++) fprintf(outf, " %d", params[n++]); putc('\n', outf); } fputs("}\n\n", outf); break; case 0xD0: fprintf(outf, "# input frame %u\nFrame_FR {\n", frame_index); gsmfr_unpack_to_array(frame, params); n = 0; fputs("\tLARc", outf); for (i = 0; i < 8; i++) fprintf(outf, " %d", params[n++]); putc('\n', outf); for (i = 0; i < 4; i++) { fputs("\tsf", outf); for (j = 0; j < 17; j++) fprintf(outf, " %d", params[n++]); putc('\n', outf); } fputs("}\n\n", outf); break; } } exit(0); }