FreeCalypso > hg > gsm-codec-lib
changeset 295:962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 14 Apr 2024 20:05:58 +0000 |
parents | cab6690535ec |
children | e0d42e87da96 |
files | frtest/encode-r.c |
diffstat | 1 files changed, 25 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/frtest/encode-r.c Sun Apr 14 19:51:57 2024 +0000 +++ b/frtest/encode-r.c Sun Apr 14 20:05:58 2024 +0000 @@ -2,35 +2,51 @@ * gsmfr-encode-r is just like gsmfr-encode, but reads the source * linear PCM data to be encoded from a raw BE file ("robe") * instead of WAV. + * + * Addendum: gsmfr-encode-r -h flag enables the later-spec feature + * of encoder homing. This option is not replicated in WAV-reading + * gsmfr-encode because it is deemed to be of no use with WAV. */ #include <stdio.h> #include <stdint.h> #include <stdlib.h> +#include <string.h> +#include <strings.h> #include "../libgsmfr2/tw_gsmfr.h" #include "../libtest/roberead.h" main(argc, argv) char **argv; { + char *infname, *outfname; FILE *inf, *binf; struct gsmfr_0610_state *enc_state; int16_t pcm[160]; uint8_t frame[33]; - int rc; + int homing, rc; - if (argc != 3) { - fprintf(stderr, "usage: %s input.robe output.gsm\n", argv[0]); + if (argc == 3 && argv[1][0] != '-') { + homing = 0; + infname = argv[1]; + outfname = argv[2]; + } else if (argc == 4 && !strcmp(argv[1], "-h")) { + homing = 1; + infname = argv[2]; + outfname = argv[3]; + } else { + fprintf(stderr, "usage: %s [-h] input.robe output.gsm\n", + argv[0]); exit(1); } - inf = fopen(argv[1], "r"); + inf = fopen(infname, "r"); if (!inf) { - perror(argv[1]); + perror(infname); exit(1); } - binf = fopen(argv[2], "w"); + binf = fopen(outfname, "w"); if (!binf) { - perror(argv[2]); + perror(outfname); exit(1); } enc_state = gsmfr_0610_create(); @@ -43,6 +59,8 @@ if (!rc) break; gsmfr_0610_encode_frame(enc_state, pcm, frame); + if (homing) + gsmfr_0610_encoder_homing(enc_state, pcm); fwrite(frame, 1, sizeof frame, binf); } fclose(binf);