FreeCalypso > hg > gsm-codec-lib
changeset 282:9ee8ad3d4d30
frtest: rm gsmfr-hand-test and gsmfr-max-out utils
These hack programs were never properly documented and were written
only as part of a debug chase, in pursuit of a bug that ultimately
turned out to be in our then-hacky patch to osmo-bts-sysmo,
before beginning of proper patches in Osmocom. These hack programs
need to be dropped from the present sw package because they depend
on old libgsm, and we are eliminating that dependency.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Apr 2024 05:44:47 +0000 |
parents | 3816ba89a5a0 |
children | 25649b3a83e9 |
files | .hgignore frtest/Makefile frtest/hand-test.c frtest/max-out.c |
diffstat | 4 files changed, 1 insertions(+), 310 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgignore Sun Apr 14 05:09:52 2024 +0000 +++ b/.hgignore Sun Apr 14 05:44:47 2024 +0000 @@ -54,8 +54,6 @@ ^frtest/gsmfr-dlcap-parse$ ^frtest/gsmfr-encode$ ^frtest/gsmfr-encode-r$ -^frtest/gsmfr-hand-test$ -^frtest/gsmfr-max-out$ ^frtest/gsmfr-preproc$ ^miscutil/gsmrec-dump$
--- a/frtest/Makefile Sun Apr 14 05:09:52 2024 +0000 +++ b/frtest/Makefile Sun Apr 14 05:44:47 2024 +0000 @@ -1,8 +1,7 @@ CC= gcc CFLAGS= -O2 PROGS= gsmfr-cod2std gsmfr-decode gsmfr-decode-r gsmfr-dlcap-gsmx \ - gsmfr-dlcap-parse gsmfr-encode gsmfr-encode-r gsmfr-hand-test \ - gsmfr-max-out gsmfr-preproc + gsmfr-dlcap-parse gsmfr-encode gsmfr-encode-r gsmfr-preproc LIBPP= ../libgsmfrp/libgsmfrp.a LIBTEST=../libtest/libtest.a LIBDEC= ${LIBTEST} ${LIBPP} @@ -31,12 +30,6 @@ gsmfr-encode-r: encode-r.o ${LIBTEST} ${CC} ${CFLAGS} -o $@ encode-r.o ${LIBTEST} -lgsm -gsmfr-hand-test: hand-test.o - ${CC} ${CFLAGS} -o $@ hand-test.o -lgsm - -gsmfr-max-out: max-out.o ${LIBDEC} - ${CC} ${CFLAGS} -o $@ max-out.o ${LIBDEC} -lgsm - gsmfr-preproc: preproc.o ${LIBDEC} ${CC} ${CFLAGS} -o $@ preproc.o ${LIBDEC}
--- a/frtest/hand-test.c Sun Apr 14 05:09:52 2024 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,179 +0,0 @@ -/* - * This program is a debug aid that allows a developer to hand-craft input - * to the GSM 06.10 decoder (libgsm) and see what output magnitude it results - * in, in the style of gsmfr-max-out. This program reads input from an - * ASCII text file in the same format as gsmrec-dump, performs gsm_implode() - * and gsm_decode() operations and reports maximum output magnitude for - * each processed frame. - */ - -#include <ctype.h> -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> -#include <string.h> -#include <strings.h> -#include <gsm.h> - -static char *infname; -static FILE *inf; -static char linebuf[256]; -static int lineno; - -static -get_line() -{ - if (!fgets(linebuf, sizeof linebuf, inf)) - return 0; - lineno++; - if (!index(linebuf, '\n')) { - fprintf(stderr, "%s line %d: too long or missing newline\n", - infname, lineno); - exit(1); - } - return 1; -} - -static -read_lar_params(params) - gsm_signal *params; -{ - char *cp; - unsigned n; - - for (;;) { - if (!get_line()) - return 0; - for (cp = linebuf; isspace(*cp); cp++) - ; - if (*cp) - break; - } - if (*cp == '#') { - cp++; - if (!isdigit(*cp)) { -inv_syntax: fprintf(stderr, - "%s line %d: invalid syntax (expected LAR)\n", - infname, lineno); - exit(1); - } - while (isdigit(*cp)) - cp++; - if (*cp++ != ':') - goto inv_syntax; - while (isspace(*cp)) - cp++; - } - if (cp[0] != 'F' || cp[1] != 'R' || !isspace(cp[2])) - goto inv_syntax; - cp += 3; - for (n = 0; n < 8; n++) { - while (isspace(*cp)) - cp++; - if (!isdigit(*cp)) - goto inv_syntax; - params[n] = strtoul(cp, &cp, 10); - if (!isspace(*cp)) - goto inv_syntax; - } - fputs(linebuf, stdout); - return 1; -} - -static void -read_subframe_params(params) - gsm_signal *params; -{ - char *cp; - unsigned n; - - for (;;) { - if (!get_line()) { - fprintf(stderr, - "%s bad: EOF in the middle of a frame\n", - infname); - exit(1); - } - for (cp = linebuf; isspace(*cp); cp++) - ; - if (*cp) - break; - } - for (n = 0; n < 17; n++) { - while (isspace(*cp)) - cp++; - if (!isdigit(*cp)) { -inv_syntax: fprintf(stderr, - "%s line %d: invalid syntax (expected subframe)\n", - infname, lineno); - exit(1); - } - params[n] = strtoul(cp, &cp, 10); - if (!isspace(*cp)) - goto inv_syntax; - } - fputs(linebuf, stdout); -} - -static -read_frame(params) - gsm_signal *params; -{ - int rc; - unsigned n, idx; - - rc = read_lar_params(params); - if (!rc) - return 0; - idx = 8; - for (n = 0; n < 4; n++) { - read_subframe_params(params + idx); - idx += 17; - } - return 1; -} - -main(argc, argv) - char **argv; -{ - gsm dec_state; - gsm_signal params[76]; - uint8_t frame[33]; - int16_t pcm[160]; - int rc, i; - unsigned samp_abs, samp_max; - - if (argc != 2) { - fprintf(stderr, "usage: %s input-file\n", argv[0]); - exit(1); - } - infname = argv[1]; - inf = fopen(infname, "r"); - if (!inf) { - perror(infname); - exit(1); - } - dec_state = gsm_create(); - if (!dec_state) { - fprintf(stderr, "gsm_create() failed!\n"); - exit(1); - } - for (;;) { - rc = read_frame(params); - if (!rc) - break; - gsm_implode(dec_state, params, frame); - gsm_decode(dec_state, frame, pcm); - samp_max = 0; - for (i = 0; i < 160; i++) { - if (pcm[i] >= 0) - samp_abs = pcm[i]; - else - samp_abs = -pcm[i]; - if (samp_abs > samp_max) - samp_max = samp_abs; - } - printf(" MAX=%u\n", samp_max); - } - exit(0); -}
--- a/frtest/max-out.c Sun Apr 14 05:09:52 2024 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -/* - * This program reads an extended-libgsm binary file (which must be in FR - * codec format, not EFR) and performs the following processing, in this - * order: - * - * 1) dumps every frame in human-readable form just like gsmrec-dump; - * 2) passes the frame stream through our DTX Rx preprocessor; - * 3) dumps the output from the preprocessor; - * 4) feeds this output to the standard 06.10 decoder (libgsm); - * 5) finds the highest-magnitude PCM sample in the decoder output and - * reports this maximum output magnitude. - * - * This program is intended to serve as a debug aid, for troubleshooting - * of our libgsmfrp+libgsm stack. - */ - -#include <stdio.h> -#include <stdint.h> -#include <stdlib.h> -#include <gsm.h> -#include "../libgsmfrp/gsm_fr_preproc.h" -#include "../libtest/binreader.h" - -main(argc, argv) - char **argv; -{ - FILE *binf; - gsm dec_state; - struct gsmfr_preproc_state *pp_state; - unsigned frame_index; - uint8_t frame[BINFILE_MAX_FRAME]; - int16_t pcm[160]; - gsm_signal fr_params[76]; - int rc, bfi, taf; - int i, j, n; - unsigned samp_abs, samp_max; - - if (argc != 2) { - fprintf(stderr, "usage: %s bin-stream-file\n", argv[0]); - exit(1); - } - binf = fopen(argv[1], "r"); - if (!binf) { - perror(argv[1]); - exit(1); - } - dec_state = gsm_create(); - if (!dec_state) { - fprintf(stderr, "gsm_create() failed!\n"); - exit(1); - } - pp_state = gsmfr_preproc_create(); - if (!pp_state) { - fprintf(stderr, "gsmfr_preproc_create() failed!\n"); - exit(1); - } - 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; - printf("#%u: ", frame_index); - switch (frame[0] & 0xF0) { - case 0xB0: - bfi = 1; - taf = frame[1] & 1; - printf("BFI TAF=%u\n", taf); - break; - case 0xD0: - bfi = 0; - fputs("FR", stdout); - gsm_explode(dec_state, frame, fr_params); - n = 0; - for (i = 0; i < 8; i++) - printf(" %d", fr_params[n++]); - putchar('\n'); - for (i = 0; i < 4; i++) { - putchar(' '); - for (j = 0; j < 17; j++) - printf(" %d", fr_params[n++]); - putchar('\n'); - } - break; - default: - fprintf(stderr, "error: %s is not in FR codec format\n", - argv[1]); - exit(1); - } - if (bfi) - gsmfr_preproc_bfi(pp_state, taf, frame); - else - gsmfr_preproc_good_frame(pp_state, frame); - fputs("Xform:", stdout); - gsm_explode(dec_state, frame, fr_params); - n = 0; - for (i = 0; i < 8; i++) - printf(" %d", fr_params[n++]); - putchar('\n'); - for (i = 0; i < 4; i++) { - putchar(' '); - for (j = 0; j < 17; j++) - printf(" %d", fr_params[n++]); - putchar('\n'); - } - gsm_decode(dec_state, frame, pcm); - samp_max = 0; - for (i = 0; i < 160; i++) { - if (pcm[i] >= 0) - samp_abs = pcm[i]; - else - samp_abs = -pcm[i]; - if (samp_abs > samp_max) - samp_max = samp_abs; - } - printf(" MAX=%u\n", samp_max); - } - exit(0); -}