annotate frtest/encode-r.c @ 212:0beafaa0623f

amr-cod-parse: handle Mode=-1 in NO_DATA frames
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 20 Apr 2023 02:23:35 +0000
parents 9814041e8096
children e0b46ac2c326
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>
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <gsm.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;
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 gsm enc_state;
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) {
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fprintf(stderr, "usage: %s input.wav output.gsm\n", argv[0]);
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 }
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 enc_state = gsm_create();
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 if (!enc_state) {
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 fprintf(stderr, "gsm_create() failed!\n");
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;
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 gsm_encode(enc_state, pcm, frame);
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 }