comparison efrtest/encode-r.c @ 156:3f3674c27840

gsmefr-encode-r utility put together
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 15 Dec 2022 01:42:31 +0000
parents efrtest/encode.c@b51295fcbbae
children cab6690535ec
comparison
equal deleted inserted replaced
155:9814041e8096 156:3f3674c27840
1 /*
2 * gsmefr-encode-r is just like gsmefr-encode, but reads the source
3 * linear PCM data to be encoded from a raw BE file ("robe")
4 * instead of WAV.
5 */
6
7 #include <stdio.h>
8 #include <stdint.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <strings.h>
12 #include "../libgsmefr/gsm_efr.h"
13 #include "../libtest/roberead.h"
14
15 main(argc, argv)
16 char **argv;
17 {
18 char *infname, *outfname;
19 FILE *inf, *binf;
20 struct EFR_encoder_state *state;
21 int16_t pcm[160];
22 uint8_t frame[EFR_RTP_FRAME_LEN];
23 int dtx, rc;
24
25 if (argc == 3 && argv[1][0] != '-') {
26 dtx = 0;
27 infname = argv[1];
28 outfname = argv[2];
29 } else if (argc == 4 && !strcmp(argv[1], "-d")) {
30 dtx = 1;
31 infname = argv[2];
32 outfname = argv[3];
33 } else {
34 fprintf(stderr, "usage: %s [-d] input.wav output.gsmx\n",
35 argv[0]);
36 exit(1);
37 }
38 inf = fopen(infname, "r");
39 if (!inf) {
40 perror(infname);
41 exit(1);
42 }
43 binf = fopen(outfname, "w");
44 if (!binf) {
45 perror(outfname);
46 exit(1);
47 }
48 state = EFR_encoder_create(dtx);
49 if (!state) {
50 perror("EFR_encoder_create()");
51 exit(1);
52 }
53 for (;;) {
54 rc = robe_get_pcm_block(inf, pcm);
55 if (!rc)
56 break;
57 EFR_encode_frame(state, pcm, frame, (int *) 0, (int *) 0);
58 fwrite(frame, 1, sizeof frame, binf);
59 }
60 fclose(binf);
61 exit(0);
62 }