annotate efrtest/encode.c @ 556:18aca50d68df default tip

doc/Calypso-TCH-downlink: update for FR1 BFI-with-data
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 11 Oct 2024 01:54:00 +0000
parents b51295fcbbae
children
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 /*
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
2 * This file is the main module for gsmefr-encode utility.
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <stdio.h>
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <stdint.h>
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdlib.h>
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
8 #include <string.h>
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
9 #include <strings.h>
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
10 #include "../libgsmefr/gsm_efr.h"
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include "../libtest/wavreader.h"
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "../libtest/wavrdhelp.h"
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 main(argc, argv)
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 char **argv;
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 {
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
17 char *infname, *outfname;
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 void *wav;
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 FILE *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 {
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
34 fprintf(stderr, "usage: %s [-d] input.wav output.gsmx\n",
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 }
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
38 wav = wav_read_open(infname);
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 if (!wav) {
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 rc = wavrd_check_header(wav, infname);
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 if (rc < 0)
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 exit(1); /* error msg already printed */
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
46 binf = fopen(outfname, "w");
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 if (!binf) {
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
48 perror(outfname);
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 exit(1);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 }
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
51 state = EFR_encoder_create(dtx);
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
52 if (!state) {
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
53 perror("EFR_encoder_create()");
14
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 exit(1);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 }
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 for (;;) {
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 rc = wavrd_get_pcm_block(wav, pcm);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 if (!rc)
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 break;
121
b51295fcbbae gsmefr-encode utility written
Mychaela Falconia <falcon@freecalypso.org>
parents: 14
diff changeset
60 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
61 fwrite(frame, 1, sizeof frame, binf);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 }
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 fclose(binf);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 exit(0);
69ed7af28473 gsmfr-encode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 }