# HG changeset patch # User Mychaela Falconia # Date 1738831107 0 # Node ID 129c895a05642d8beabff4765171ee671a9990eb # Parent 18aca50d68df3eb9ce7190673be807c253773e24 hrutil: new program gsmhr-cod2hex diff -r 18aca50d68df -r 129c895a0564 .hgignore --- a/.hgignore Fri Oct 11 01:54:00 2024 +0000 +++ b/.hgignore Thu Feb 06 08:38:27 2025 +0000 @@ -78,6 +78,7 @@ ^frtest/gsmfr-tfo-xfrm$ ^hrutil/gsmhr-cod-parse$ +^hrutil/gsmhr-cod2hex$ ^hrutil/gsmhr-dec-craft$ ^hrutil/gsmhr-dec-parse$ diff -r 18aca50d68df -r 129c895a0564 hrutil/Makefile --- a/hrutil/Makefile Fri Oct 11 01:54:00 2024 +0000 +++ b/hrutil/Makefile Thu Feb 06 08:38:27 2025 +0000 @@ -1,5 +1,6 @@ -PROGS= gsmhr-cod-parse gsmhr-dec-craft gsmhr-dec-parse +PROGS= gsmhr-cod-parse gsmhr-cod2hex gsmhr-dec-craft gsmhr-dec-parse LIBHR1= ../libgsmhr1/libgsmhr1.a +LIBTEST=../libtest/libtest.a include ../config.defs @@ -8,6 +9,9 @@ gsmhr-cod-parse: cod-parse.o print-frame.o read-cod.o ${LIBHR1} ${CC} ${CFLAGS} -o $@ $^ +gsmhr-cod2hex: cod2hex.o read-cod.o tw5b-out-cod.o ${LIBHR1} ${LIBTEST} + ${CC} ${CFLAGS} -o $@ $^ + gsmhr-dec-craft: dec-craft.o ${LIBHR1} ${CC} ${CFLAGS} -o $@ $^ diff -r 18aca50d68df -r 129c895a0564 hrutil/cod2hex.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hrutil/cod2hex.c Thu Feb 06 08:38:27 2025 +0000 @@ -0,0 +1,64 @@ +/* + * This program reads an HRv1 *.cod file in ETSI test sequence format + * (encoder output format) and converts it into TW-TS-005 Annex B + * hexadecimal format. + */ + +#include +#include +#include +#include +#include +#include +#include "../libgsmhr1/tw_gsmhr.h" + +main(argc, argv) + char **argv; +{ + char *infname, *outfname; + FILE *inf, *outf; + int opt, rc, big_endian = 0, emit_5993 = 0; + unsigned frame_no; + int16_t params[GSMHR_NUM_PARAMS_ENC]; + extern int optind; + + while ((opt = getopt(argc, argv, "bx")) != EOF) { + switch (opt) { + case 'b': + big_endian = 1; + continue; + case 'x': + emit_5993 = 1; + continue; + default: + usage: + fprintf(stderr, + "usage: %s [-b] [-x] input.cod 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); + } + outf = fopen(outfname, "w"); + if (!outf) { + perror(outfname); + exit(1); + } + + for (frame_no = 0; ; frame_no++) { + rc = read_cod_frame(inf, big_endian, params, infname, frame_no); + if (!rc) + break; + emit_cod_to_tw5b(outf, params, emit_5993); + } + exit(0); +} diff -r 18aca50d68df -r 129c895a0564 hrutil/tw5b-out-cod.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hrutil/tw5b-out-cod.c Thu Feb 06 08:38:27 2025 +0000 @@ -0,0 +1,25 @@ +/* + * The helper function implemented in this module emits TW-TS-005 Annex B + * hex output based on an encoder output array, i.e., a cod-style frame. + * This helper function will be used for gsmhr-cod2hex, gsmhr-encode[-r] + * and gsmhr-tfo-xfrm utilities. + */ + +#include +#include +#include "../libgsmhr1/tw_gsmhr.h" +#include "../libtest/tw5writer.h" + +void +emit_cod_to_tw5b(outf, params, emit_5993) + FILE *outf; + int16_t *params; +{ + uint8_t frame[GSMHR_FRAME_LEN_5993]; + + gsmhr_encoder_twts002_out(params, frame); + if (emit_5993) + emit_hex_frame(outf, frame, GSMHR_FRAME_LEN_5993); + else + emit_hex_frame(outf, frame + 1, GSMHR_FRAME_LEN_RPF); +}