FreeCalypso > hg > gsm-codec-lib
annotate frtest/hand-test.c @ 101:d86f866489e9
gsm-amr2efr utility written
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 27 Nov 2022 05:15:39 +0000 |
parents | d21c68b8f16c |
children |
rev | line source |
---|---|
29
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program is a debug aid that allows a developer to hand-craft input |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * to the GSM 06.10 decoder (libgsm) and see what output magnitude it results |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * in, in the style of gsmfr-max-out. This program reads input from an |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 * ASCII text file in the same format as gsmrec-dump, performs gsm_implode() |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 * and gsm_decode() operations and reports maximum output magnitude for |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 * each processed frame. |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 */ |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <ctype.h> |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdio.h> |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdint.h> |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <stdlib.h> |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <string.h> |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #include <strings.h> |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #include <gsm.h> |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static char *infname; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static FILE *inf; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 static char linebuf[256]; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 static int lineno; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 static |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 get_line() |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 if (!fgets(linebuf, sizeof linebuf, inf)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 return 0; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 lineno++; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!index(linebuf, '\n')) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 fprintf(stderr, "%s line %d: too long or missing newline\n", |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 infname, lineno); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 exit(1); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 return 1; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 static |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 read_lar_params(params) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 gsm_signal *params; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 char *cp; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 unsigned n; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 for (;;) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (!get_line()) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return 0; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 for (cp = linebuf; isspace(*cp); cp++) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 ; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (*cp) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 break; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 if (*cp == '#') { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 cp++; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (!isdigit(*cp)) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 inv_syntax: fprintf(stderr, |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 "%s line %d: invalid syntax (expected LAR)\n", |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 infname, lineno); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 exit(1); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 while (isdigit(*cp)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 cp++; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 if (*cp++ != ':') |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 goto inv_syntax; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 while (isspace(*cp)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 cp++; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if (cp[0] != 'F' || cp[1] != 'R' || !isspace(cp[2])) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 goto inv_syntax; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 cp += 3; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 for (n = 0; n < 8; n++) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 while (isspace(*cp)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 cp++; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 if (!isdigit(*cp)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 goto inv_syntax; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 params[n] = strtoul(cp, &cp, 10); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 if (!isspace(*cp)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 goto inv_syntax; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 fputs(linebuf, stdout); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 return 1; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 static void |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 read_subframe_params(params) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 gsm_signal *params; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 char *cp; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 unsigned n; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 for (;;) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 if (!get_line()) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 fprintf(stderr, |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 "%s bad: EOF in the middle of a frame\n", |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 infname); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 exit(1); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 for (cp = linebuf; isspace(*cp); cp++) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 ; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 if (*cp) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 break; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 for (n = 0; n < 17; n++) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 while (isspace(*cp)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 cp++; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 if (!isdigit(*cp)) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 inv_syntax: fprintf(stderr, |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 "%s line %d: invalid syntax (expected subframe)\n", |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 infname, lineno); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 exit(1); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 params[n] = strtoul(cp, &cp, 10); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 if (!isspace(*cp)) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 goto inv_syntax; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 fputs(linebuf, stdout); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 static |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 read_frame(params) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 gsm_signal *params; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 int rc; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 unsigned n, idx; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 rc = read_lar_params(params); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 if (!rc) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 return 0; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 idx = 8; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 for (n = 0; n < 4; n++) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 read_subframe_params(params + idx); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 idx += 17; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 return 1; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 main(argc, argv) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 char **argv; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 gsm dec_state; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 gsm_signal params[76]; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 uint8_t frame[33]; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 int16_t pcm[160]; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 int rc, i; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 unsigned samp_abs, samp_max; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 if (argc != 2) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 fprintf(stderr, "usage: %s input-file\n", argv[0]); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 exit(1); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 infname = argv[1]; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 inf = fopen(infname, "r"); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 if (!inf) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 perror(infname); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 exit(1); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 dec_state = gsm_create(); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 if (!dec_state) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 fprintf(stderr, "gsm_create() failed!\n"); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 exit(1); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 for (;;) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 rc = read_frame(params); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 if (!rc) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 break; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 gsm_implode(dec_state, params, frame); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 gsm_decode(dec_state, frame, pcm); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 samp_max = 0; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 for (i = 0; i < 160; i++) { |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 if (pcm[i] >= 0) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 samp_abs = pcm[i]; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 else |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 samp_abs = -pcm[i]; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 if (samp_abs > samp_max) |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 samp_max = samp_abs; |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 printf(" MAX=%u\n", samp_max); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 } |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 exit(0); |
d21c68b8f16c
gsmfr-hand-test: yet another debug aid
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 } |