annotate frtest/encode-r.c @ 294:cab6690535ec

gsmefr-encode-r: fix usage message
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 14 Apr 2024 19:51:57 +0000
parents e0b46ac2c326
children 962861d46ccf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 */
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdlib.h>
288
e0b46ac2c326 gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
10 #include "../libgsmfr2/tw_gsmfr.h"
155
9814041e8096 gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
11 #include "../libtest/roberead.h"
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 main(argc, argv)
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 char **argv;
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 {
155
9814041e8096 gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
16 FILE *inf, *binf;
288
e0b46ac2c326 gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
17 struct gsmfr_0610_state *enc_state;
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 int16_t pcm[160];
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 uint8_t frame[33];
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int rc;
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (argc != 3) {
288
e0b46ac2c326 gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
23 fprintf(stderr, "usage: %s input.robe output.gsm\n", argv[0]);
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 exit(1);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
155
9814041e8096 gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
26 inf = fopen(argv[1], "r");
9814041e8096 gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
27 if (!inf) {
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 perror(argv[1]);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 binf = fopen(argv[2], "w");
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 if (!binf) {
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 perror(argv[2]);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 exit(1);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 }
288
e0b46ac2c326 gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
36 enc_state = gsmfr_0610_create();
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!enc_state) {
288
e0b46ac2c326 gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
38 fprintf(stderr, "gsmfr_0610_create() failed!\n");
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 exit(1);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 }
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 for (;;) {
155
9814041e8096 gsmfr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
42 rc = robe_get_pcm_block(inf, pcm);
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 if (!rc)
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 break;
288
e0b46ac2c326 gsmfr-encode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents: 155
diff changeset
45 gsmfr_0610_encode_frame(enc_state, pcm, frame);
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 fwrite(frame, 1, sizeof frame, binf);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 }
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 fclose(binf);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 exit(0);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }