FreeCalypso > hg > gsm-codec-lib
annotate frtest/encode-r.c @ 455:287063b9cf43
CHANGES: document the build process change
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 10 May 2024 06:22:42 +0000 |
parents | 962861d46ccf |
children |
rev | line source |
---|---|
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
155
9814041e8096
gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
2 * gsmfr-encode-r is just like gsmfr-encode, but reads the source |
9814041e8096
gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
3 * linear PCM data to be encoded from a raw BE file ("robe") |
9814041e8096
gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
4 * instead of WAV. |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
5 * |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
6 * Addendum: gsmfr-encode-r -h flag enables the later-spec feature |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
7 * of encoder homing. This option is not replicated in WAV-reading |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
8 * gsmfr-encode because it is deemed to be of no use with WAV. |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 */ |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdio.h> |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdint.h> |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <stdlib.h> |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
14 #include <string.h> |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
15 #include <strings.h> |
288
e0b46ac2c326
gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents:
155
diff
changeset
|
16 #include "../libgsmfr2/tw_gsmfr.h" |
155
9814041e8096
gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
17 #include "../libtest/roberead.h" |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 main(argc, argv) |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 char **argv; |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 { |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
22 char *infname, *outfname; |
155
9814041e8096
gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
23 FILE *inf, *binf; |
288
e0b46ac2c326
gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents:
155
diff
changeset
|
24 struct gsmfr_0610_state *enc_state; |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 int16_t pcm[160]; |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 uint8_t frame[33]; |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
27 int homing, rc; |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
29 if (argc == 3 && argv[1][0] != '-') { |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
30 homing = 0; |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
31 infname = argv[1]; |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
32 outfname = argv[2]; |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
33 } else if (argc == 4 && !strcmp(argv[1], "-h")) { |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
34 homing = 1; |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
35 infname = argv[2]; |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
36 outfname = argv[3]; |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
37 } else { |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
38 fprintf(stderr, "usage: %s [-h] input.robe output.gsm\n", |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
39 argv[0]); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 } |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
42 inf = fopen(infname, "r"); |
155
9814041e8096
gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
43 if (!inf) { |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
44 perror(infname); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
47 binf = fopen(outfname, "w"); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (!binf) { |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
49 perror(outfname); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
288
e0b46ac2c326
gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents:
155
diff
changeset
|
52 enc_state = gsmfr_0610_create(); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 if (!enc_state) { |
288
e0b46ac2c326
gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents:
155
diff
changeset
|
54 fprintf(stderr, "gsmfr_0610_create() failed!\n"); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 } |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 for (;;) { |
155
9814041e8096
gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
58 rc = robe_get_pcm_block(inf, pcm); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (!rc) |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 break; |
288
e0b46ac2c326
gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents:
155
diff
changeset
|
61 gsmfr_0610_encode_frame(enc_state, pcm, frame); |
295
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
62 if (homing) |
962861d46ccf
gsmfr-encode-r: add -h option for encoder homing
Mychaela Falconia <falcon@freecalypso.org>
parents:
288
diff
changeset
|
63 gsmfr_0610_encoder_homing(enc_state, pcm); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 fwrite(frame, 1, sizeof frame, binf); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 fclose(binf); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 exit(0); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } |