FreeCalypso > hg > gsm-codec-lib
diff hrutil/encode-r.c @ 629:32cc4b709e0e
hrutil: new program gsmhr-encode-r
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Thu, 12 Mar 2026 05:59:37 +0000 |
| parents | hrutil/encode.c@c53ce88d67a7 |
| children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hrutil/encode-r.c Thu Mar 12 05:59:37 2026 +0000 @@ -0,0 +1,73 @@ +/* + * This file is the main module for gsmhr-encode-r utility. This utility + * is intended to serve as the "precision" speech encoder for GSM-HR, + * reading speech input in robe format and emitting GSM-HR output in + * TW-TS-005 Annex B hex format. + */ + +#include <stdio.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include <unistd.h> +#include "../libgsmhr1/tw_gsmhr.h" +#include "../libtest/roberead.h" + +main(argc, argv) + char **argv; +{ + char *infname, *outfname; + FILE *inf, *outf; + struct gsmhr_encoder_state *state; + int16_t pcm[160]; + int16_t prm_out[GSMHR_NUM_PARAMS_ENC]; + int opt, rc, dtx = 0, emit_5993 = 0; + extern int optind; + + while ((opt = getopt(argc, argv, "dx")) != EOF) { + switch (opt) { + case 'd': + dtx = 1; + continue; + case 'x': + emit_5993 = 1; + continue; + default: + usage: + fprintf(stderr, + "usage: %s [-d] [-x] input.robe 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); + } + state = gsmhr_encoder_create(dtx); + if (!state) { + perror("gsmhr_encoder_create()"); + exit(1); + } + for (;;) { + rc = robe_get_pcm_block(inf, pcm); + if (!rc) + break; + gsmhr_encode_frame(state, pcm, prm_out); + emit_cod_to_tw5b(outf, prm_out, emit_5993); + } + fclose(outf); + exit(0); +}
