FreeCalypso > hg > gsm-codec-lib
changeset 584:fc7a59deb3c3 default tip
hrutil: new program gsmhr-tfo-xfrm
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 14 Feb 2025 01:34:48 +0000 |
parents | 9cda792c0dd7 |
children | |
files | .hgignore hrutil/Makefile hrutil/tfo-xfrm.c |
diffstat | 3 files changed, 92 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Thu Feb 13 23:43:40 2025 +0000 +++ b/.hgignore Fri Feb 14 01:34:48 2025 +0000 @@ -86,6 +86,7 @@ ^hrutil/gsmhr-hex2dec$ ^hrutil/gsmhr-hex2rpf$ ^hrutil/gsmhr-rpf2hex$ +^hrutil/gsmhr-tfo-xfrm$ ^hrutil/tw5b-dump$ ^libgsmhr1/dhf_packed\.c$
--- a/hrutil/Makefile Thu Feb 13 23:43:40 2025 +0000 +++ b/hrutil/Makefile Fri Feb 14 01:34:48 2025 +0000 @@ -1,6 +1,6 @@ PROGS= gsmhr-cod-craft gsmhr-cod-parse gsmhr-cod2hex gsmhr-dec-craft \ gsmhr-dec-parse gsmhr-dec2hex gsmhr-hex2dec gsmhr-hex2rpf gsmhr-rpf2hex\ - tw5b-dump + gsmhr-tfo-xfrm tw5b-dump LIBHR1= ../libgsmhr1/libgsmhr1.a LIBTEST=../libtest/libtest.a LIBS= ${LIBHR1} ${LIBTEST} @@ -36,6 +36,9 @@ gsmhr-rpf2hex: rpf2hex.o ${LIBHR1} ${CC} ${CFLAGS} -o $@ $^ +gsmhr-tfo-xfrm: tfo-xfrm.o tw5b-out-cod.o ${LIBS} + ${CC} ${CFLAGS} -o $@ $^ + tw5b-dump: print-frame.o tw5b-dump.o ${LIBS} ${CC} ${CFLAGS} -o $@ $^
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hrutil/tfo-xfrm.c Fri Feb 14 01:34:48 2025 +0000 @@ -0,0 +1,87 @@ +/* + * This program exercises our ThemWi implementation of TFO transform for + * GSM-HR. It reads a stream of radio leg A Rx frames from a TW-TS-005 Annex B + * hex file and writes the "pristine" stream intended for radio leg B Tx + * into another TW-TS-005 Annex B hex file. DTXd can be enabled or disabled; + * the output can be in either TS 101 318 or RFC 5993 format. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <unistd.h> +#include "../libgsmhr1/tw_gsmhr.h" +#include "../libtest/tw5reader.h" + +main(argc, argv) + char **argv; +{ + char *infname, *outfname; + FILE *inf, *outf; + unsigned lineno; + struct gsmhr_rxfe_state *state; + uint8_t frame_in[TWTS005_MAX_FRAME]; + unsigned frame_in_len; + int16_t prm_in[GSMHR_NUM_PARAMS_DEC], prm_out[GSMHR_NUM_PARAMS_ENC]; + int opt, rc, dtxd = 0, emit_5993 = 0; + extern int optind; + + while ((opt = getopt(argc, argv, "dx")) != EOF) { + switch (opt) { + case 'd': + dtxd = 1; + continue; + case 'x': + emit_5993 = 1; + continue; + default: + usage: + fprintf(stderr, + "usage: %s [-d] [-x] input.hex output.hex\n", + argv[0]); + exit(1); + } + } + if (argc != optind + 2) + goto usage; + infname = argv[optind]; + outfname = argv[optind+1]; + + inf = fopen(infname, "r"); + if (!inf) { + perror(infname); + exit(1); + } + lineno = 0; + outf = fopen(outfname, "w"); + if (!outf) { + perror(outfname); + exit(1); + } + state = gsmhr_rxfe_create(); + if (!state) { + fprintf(stderr, "gsmhr_rxfe_create() failed!\n"); + exit(1); + } + for (;;) { + rc = twts005_read_frame(inf, &lineno, frame_in, &frame_in_len); + if (rc < 0) { + fprintf(stderr, "%s line %u: not valid TW-TS-005\n", + argv[1], lineno); + exit(1); + } + if (!rc) + break; + rc = gsmhr_rtp_in_direct(frame_in, frame_in_len, prm_in); + if (rc < 0) { + fprintf(stderr, + "%s line %u: not a valid GSM-HR frame\n", + infname, lineno); + exit(1); + } + gsmhr_tfo_xfrm(state, dtxd, prm_in, prm_out); + emit_cod_to_tw5b(outf, prm_out, emit_5993); + } + fclose(outf); + exit(0); +}