comparison frtest/encode-r.c @ 155:9814041e8096

gsmfr-encode-r utility put together
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 15 Dec 2022 01:30:59 +0000
parents frtest/encode.c@69ed7af28473
children e0b46ac2c326
comparison
equal deleted inserted replaced
154:01ce75ea1c8e 155:9814041e8096
1 /*
2 * gsmfr-encode-r is just like gsmfr-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 <gsm.h>
11 #include "../libtest/roberead.h"
12
13 main(argc, argv)
14 char **argv;
15 {
16 FILE *inf, *binf;
17 gsm enc_state;
18 int16_t pcm[160];
19 uint8_t frame[33];
20 int rc;
21
22 if (argc != 3) {
23 fprintf(stderr, "usage: %s input.wav output.gsm\n", argv[0]);
24 exit(1);
25 }
26 inf = fopen(argv[1], "r");
27 if (!inf) {
28 perror(argv[1]);
29 exit(1);
30 }
31 binf = fopen(argv[2], "w");
32 if (!binf) {
33 perror(argv[2]);
34 exit(1);
35 }
36 enc_state = gsm_create();
37 if (!enc_state) {
38 fprintf(stderr, "gsm_create() failed!\n");
39 exit(1);
40 }
41 for (;;) {
42 rc = robe_get_pcm_block(inf, pcm);
43 if (!rc)
44 break;
45 gsm_encode(enc_state, pcm, frame);
46 fwrite(frame, 1, sizeof frame, binf);
47 }
48 fclose(binf);
49 exit(0);
50 }