FreeCalypso > hg > gsm-codec-lib
annotate frtest/decode-rb.c @ 496:af70bf42eb1b
libgsmhr1: implement DHF const array
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 18 Jun 2024 00:15:46 +0000 |
parents | e0d42e87da96 |
children |
rev | line source |
---|---|
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
296
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
2 * gsmfr-decode-rb is a "raw basic" decoder: only the basic GSM 06.10 decoder |
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
3 * is applied (no Rx DTX preprocessor), and the output format is raw BE. |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdio.h> |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdint.h> |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
285
cfa3006a66da
gsmfr-decode-r: convert to libgsmfr2
Mychaela Falconia <falcon@freecalypso.org>
parents:
153
diff
changeset
|
9 #include "../libgsmfr2/tw_gsmfr.h" |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include "../libtest/binreader.h" |
153
14b627682458
gsmfr-decode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
11 #include "../libtest/robewrite.h" |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 main(argc, argv) |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 char **argv; |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
153
14b627682458
gsmfr-decode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
16 FILE *binf, *outf; |
296
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
17 struct gsmfr_0610_state *dec_state; |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 uint8_t frame[BINFILE_MAX_FRAME]; |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 int16_t pcm[160]; |
296
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
20 int rc; |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (argc != 3) { |
153
14b627682458
gsmfr-decode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
23 fprintf(stderr, "usage: %s input.gsm output.robe\n", argv[0]); |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 exit(1); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 } |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 binf = fopen(argv[1], "r"); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (!binf) { |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 perror(argv[1]); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 exit(1); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 } |
153
14b627682458
gsmfr-decode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
31 outf = fopen(argv[2], "w"); |
14b627682458
gsmfr-decode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
32 if (!outf) { |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 perror(argv[2]); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 exit(1); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |
296
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
36 dec_state = gsmfr_0610_create(); |
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
37 if (!dec_state) { |
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
38 fprintf(stderr, "gsmfr_0610_create() failed!\n"); |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 exit(1); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 for (;;) { |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 rc = binfile_read_frame(binf, frame); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 if (rc < 0) { |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 fprintf(stderr, "error: garbage in %s\n", argv[1]); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 exit(1); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 } |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 if (!rc) |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 break; |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (frame[0] == 0xBF) { |
296
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
50 fprintf(stderr, "error: %s contains disallowed BFI\n", |
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
51 argv[1]); |
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
52 exit(1); |
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
53 } |
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
54 if ((frame[0] & 0xF0) != 0xD0) { |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 fprintf(stderr, "error: %s is not in FR codec format\n", |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 argv[1]); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 exit(1); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 } |
296
e0d42e87da96
frtest: new utility gsmfr-decode-rb
Mychaela Falconia <falcon@freecalypso.org>
parents:
285
diff
changeset
|
59 gsmfr_0610_decode_frame(dec_state, frame, pcm); |
153
14b627682458
gsmfr-decode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
60 write_pcm_to_robe(outf, pcm); |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
153
14b627682458
gsmfr-decode-r utility put together
Mychaela Falconia <falcon@freecalypso.org>
parents:
16
diff
changeset
|
62 fclose(outf); |
12
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 exit(0); |
f88817a233fb
gsmfr-decode test program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } |