FreeCalypso > hg > gsm-codec-lib
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 628:c53ce88d67a7 | 629:32cc4b709e0e |
|---|---|
| 1 /* | |
| 2 * This file is the main module for gsmhr-encode-r utility. This utility | |
| 3 * is intended to serve as the "precision" speech encoder for GSM-HR, | |
| 4 * reading speech input in robe format and emitting GSM-HR output in | |
| 5 * TW-TS-005 Annex B hex format. | |
| 6 */ | |
| 7 | |
| 8 #include <stdio.h> | |
| 9 #include <stdint.h> | |
| 10 #include <stdlib.h> | |
| 11 #include <string.h> | |
| 12 #include <strings.h> | |
| 13 #include <unistd.h> | |
| 14 #include "../libgsmhr1/tw_gsmhr.h" | |
| 15 #include "../libtest/roberead.h" | |
| 16 | |
| 17 main(argc, argv) | |
| 18 char **argv; | |
| 19 { | |
| 20 char *infname, *outfname; | |
| 21 FILE *inf, *outf; | |
| 22 struct gsmhr_encoder_state *state; | |
| 23 int16_t pcm[160]; | |
| 24 int16_t prm_out[GSMHR_NUM_PARAMS_ENC]; | |
| 25 int opt, rc, dtx = 0, emit_5993 = 0; | |
| 26 extern int optind; | |
| 27 | |
| 28 while ((opt = getopt(argc, argv, "dx")) != EOF) { | |
| 29 switch (opt) { | |
| 30 case 'd': | |
| 31 dtx = 1; | |
| 32 continue; | |
| 33 case 'x': | |
| 34 emit_5993 = 1; | |
| 35 continue; | |
| 36 default: | |
| 37 usage: | |
| 38 fprintf(stderr, | |
| 39 "usage: %s [-d] [-x] input.robe output.hex\n", | |
| 40 argv[0]); | |
| 41 exit(1); | |
| 42 } | |
| 43 } | |
| 44 if (argc != optind + 2) | |
| 45 goto usage; | |
| 46 infname = argv[optind]; | |
| 47 outfname = argv[optind+1]; | |
| 48 | |
| 49 inf = fopen(infname, "r"); | |
| 50 if (!inf) { | |
| 51 perror(infname); | |
| 52 exit(1); | |
| 53 } | |
| 54 outf = fopen(outfname, "w"); | |
| 55 if (!outf) { | |
| 56 perror(outfname); | |
| 57 exit(1); | |
| 58 } | |
| 59 state = gsmhr_encoder_create(dtx); | |
| 60 if (!state) { | |
| 61 perror("gsmhr_encoder_create()"); | |
| 62 exit(1); | |
| 63 } | |
| 64 for (;;) { | |
| 65 rc = robe_get_pcm_block(inf, pcm); | |
| 66 if (!rc) | |
| 67 break; | |
| 68 gsmhr_encode_frame(state, pcm, prm_out); | |
| 69 emit_cod_to_tw5b(outf, prm_out, emit_5993); | |
| 70 } | |
| 71 fclose(outf); | |
| 72 exit(0); | |
| 73 } |
