FreeCalypso > hg > gsm-codec-lib
annotate efrtest/encode-r.c @ 536:a3300483ae74
doc/FR1-library-API: document return value from gsmfr_tfo_xfrm_*
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 21 Sep 2024 20:48:58 +0000 |
parents | cab6690535ec |
children |
rev | line source |
---|---|
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
156
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
2 * gsmefr-encode-r is just like gsmefr-encode, but reads the source |
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
3 * linear PCM data to be encoded from a raw BE file ("robe") |
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
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> |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
10 #include <string.h> |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
11 #include <strings.h> |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
12 #include "../libgsmefr/gsm_efr.h" |
156
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
13 #include "../libtest/roberead.h" |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 main(argc, argv) |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 char **argv; |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
18 char *infname, *outfname; |
156
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
19 FILE *inf, *binf; |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
20 struct EFR_encoder_state *state; |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 int16_t pcm[160]; |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
22 uint8_t frame[EFR_RTP_FRAME_LEN]; |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
23 int dtx, rc; |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
25 if (argc == 3 && argv[1][0] != '-') { |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
26 dtx = 0; |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
27 infname = argv[1]; |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
28 outfname = argv[2]; |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
29 } else if (argc == 4 && !strcmp(argv[1], "-d")) { |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
30 dtx = 1; |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
31 infname = argv[2]; |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
32 outfname = argv[3]; |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
33 } else { |
294
cab6690535ec
gsmefr-encode-r: fix usage message
Mychaela Falconia <falcon@freecalypso.org>
parents:
156
diff
changeset
|
34 fprintf(stderr, "usage: %s [-d] input.robe output.gsmx\n", |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
35 argv[0]); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
156
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
38 inf = fopen(infname, "r"); |
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
39 if (!inf) { |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
40 perror(infname); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
43 binf = fopen(outfname, "w"); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 if (!binf) { |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
45 perror(outfname); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
48 state = EFR_encoder_create(dtx); |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
49 if (!state) { |
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
50 perror("EFR_encoder_create()"); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 exit(1); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 for (;;) { |
156
3f3674c27840
gsmefr-encode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
54 rc = robe_get_pcm_block(inf, pcm); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 if (!rc) |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 break; |
121
b51295fcbbae
gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents:
14
diff
changeset
|
57 EFR_encode_frame(state, pcm, frame, (int *) 0, (int *) 0); |
14
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 fwrite(frame, 1, sizeof frame, binf); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 } |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 fclose(binf); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 exit(0); |
69ed7af28473
gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |