FreeCalypso > hg > gsm-net-reveng
annotate trau-ul-compile/trau-ul-compile.c @ 67:d8ccdccd8b2b
top Makefile: add pathloss
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 25 Oct 2024 08:13:18 +0000 |
parents | 8e9bbb83bd16 |
children |
rev | line source |
---|---|
24
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This program compile *.tsrc source format into *.tul binary format, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * see ../doc/TRAU-UL-testing article. |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <ctype.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdio.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdint.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <stdlib.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <string.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <strings.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include <tw_gsmfr.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include <gsm_efr.h> |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 #define MAX_FIELDS 18 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static char *infname, *outfname; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static FILE *inf, *outf; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 static int lineno; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static char linebuf[256]; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 static char *fields[MAX_FIELDS]; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 static unsigned nfields; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 static int is_efr; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 static int16_t speech_params[GSMFR_NUM_PARAMS]; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 static int global_params_set, subframe_count; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 static int bfi, bfi_set, sid, sid_set; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 static uint8_t crc_inv, crc_inv_set; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 static int |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 get_line() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 char *cp; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 if (!fgets(linebuf, sizeof linebuf, inf)) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 return 1; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 lineno++; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (!index(linebuf, '\n')) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 fprintf(stderr, "%s line %d: too long or missing newline\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 nfields = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 for (cp = linebuf; ; ) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 while (isspace(*cp)) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 cp++; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (*cp == '\0' || *cp == '#') |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 break; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 if (nfields >= MAX_FIELDS) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 fprintf(stderr, "%s line %d: too many fields\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 fields[nfields++] = cp; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 while (*cp && !isspace(*cp)) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 cp++; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (*cp) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 *cp++ = '\0'; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 return 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 static int |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 get_line_nonempty() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 int rc; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 for (;;) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 rc = get_line(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 if (rc) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 return rc; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 if (nfields) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 return 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 start_new_frame() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (nfields != 2 || strcmp(fields[1], "{")) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 fprintf(stderr, "%s line %d: invalid frame opening line\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 global_params_set = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 subframe_count = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 bfi = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 bfi_set = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 sid_set = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 crc_inv = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 crc_inv_set = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 set_speech_params(start_param) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 unsigned start_param; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 unsigned ni, no; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 u_long val; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 char *cp; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 no = start_param; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 for (ni = 1; ni < nfields; ni++) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 if (!isdigit(fields[ni][0])) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 inv_number: fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 "%s line %d: field \"%s\" is not a valid number\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 infname, lineno, fields[ni]); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 val = strtoul(fields[ni], &cp, 0); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 if (*cp) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 goto inv_number; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 if (val > 0x1FF) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 "%s line %d: number \"%s\" is too large for a speech parameter\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 infname, lineno, fields[ni]); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 speech_params[no++] = val; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 handle_larc() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 if (is_efr) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 fprintf(stderr, "%s line %d: LARc not valid for EFR\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 if (nfields != 9) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 "%s line %d: wrong number of arguments for LARc\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 if (global_params_set) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 fprintf(stderr, "%s line %d: LARc already set\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 set_speech_params(0); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 global_params_set = 1; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 handle_lpc() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 if (!is_efr) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 fprintf(stderr, "%s line %d: LPC not valid for FR\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 if (nfields != 6) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 "%s line %d: wrong number of arguments for LPC\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 if (global_params_set) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 fprintf(stderr, "%s line %d: LPC already set\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 set_speech_params(0); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 global_params_set = 1; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 handle_sf() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 if (is_efr) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 if (nfields != 14) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 "%s line %d: wrong number of arguments for EFR sf\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 } else { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 if (nfields != 18) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 "%s line %d: wrong number of arguments for FR sf\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 if (subframe_count >= 4) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 fprintf(stderr, "%s line %d: too many subframes\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 if (is_efr) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 set_speech_params(5 + subframe_count * 13); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 else |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 set_speech_params(8 + subframe_count * 17); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 subframe_count++; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 handle_bfi() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 if (nfields != 2) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 fprintf(stderr, "%s line %d: BFI takes one argument\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 if (bfi_set) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 fprintf(stderr, "%s line %d: BFI already set\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
212 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
213 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
214 if (fields[1][0] < '0' || fields[1][0] > '1' || fields[1][1]) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
215 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
216 "%s line %d: invalid BFI argument \"%s\" (must be 0 or 1)\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
217 infname, lineno, fields[1]); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
218 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
219 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
220 bfi = fields[1][0] - '0'; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
221 bfi_set = 1; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
222 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
223 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
224 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
225 handle_sid() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
226 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
227 if (nfields != 2) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
228 fprintf(stderr, "%s line %d: SID takes one argument\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
229 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
230 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
231 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
232 if (sid_set) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
233 fprintf(stderr, "%s line %d: SID already set\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
234 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
237 if (fields[1][0] < '0' || fields[1][0] > '2' || fields[1][1]) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
238 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
239 "%s line %d: invalid SID argument \"%s\" (must be 0, 1 or 2)\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
240 infname, lineno, fields[1]); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
241 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 sid = fields[1][0] - '0'; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 sid_set = 1; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 handle_crc_inv() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 unsigned nf; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 if (!is_efr) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 fprintf(stderr, "%s line %d: crc-inv not valid for FR\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 if (nfields < 2) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 "%s line %d: crc-inv requires at least 1 argument\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 if (crc_inv_set) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 fprintf(stderr, "%s line %d: crc-inv already set\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 for (nf = 1; nf < nfields; nf++) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 if (!strcasecmp(fields[nf], "all")) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 crc_inv = 0xF8; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 else if (fields[nf][0] >= '0' && fields[nf][0] <= '4' && |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 !fields[nf][1]) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 crc_inv |= 0x80 >> (fields[nf][0] - '0'); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 else { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 "%s line %d: \"%s\" is not a valid argument to crc-inv\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 infname, lineno, fields[nf]); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 crc_inv_set = 1; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 process_frame_interior() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 int rc; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 for (;;) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 rc = get_line_nonempty(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 if (rc) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 fprintf(stderr, "bad input: EOF inside frame block\n"); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 if (!strcasecmp(fields[0], "larc")) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 handle_larc(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 else if (!strcasecmp(fields[0], "lpc")) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 handle_lpc(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 else if (!strcasecmp(fields[0], "sf")) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 handle_sf(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 else if (!strcasecmp(fields[0], "bfi")) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 handle_bfi(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 else if (!strcasecmp(fields[0], "sid")) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 handle_sid(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 else if (!strcasecmp(fields[0], "crc-inv")) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 handle_crc_inv(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 else if (!strcmp(fields[0], "}")) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 if (nfields != 1) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 "%s line %d: stuff after } not permitted\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 return; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 } else { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 "%s line %d: non-understood keyword \"%s\"\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 infname, lineno, fields[0]); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 static void |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 finish_frame() |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 uint8_t bin[34]; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 if (!global_params_set) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 fprintf(stderr, "%s line %d: LARc/LPC parameters not set\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 if (subframe_count != 4) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 fprintf(stderr, "%s line %d: subframe parameters not set\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
339 if (is_efr) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 EFR_params2frame(speech_params, bin); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 if (!sid_set) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 sid = EFR_sid_classify(bin); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 bin[31] = crc_inv; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 bin[32] = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 } else { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 gsmfr_pack_from_array(speech_params, bin); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 if (!sid_set) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 sid = gsmfr_preproc_sid_classify(bin); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 bin[33] = (bfi << 7) | sid; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 fwrite(bin, 1, 34, outf); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 main(argc, argv) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 char **argv; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 int rc; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 if (argc != 3) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 fprintf(stderr, "usage: %s input.tsrc output.tul\n", argv[0]); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 infname = argv[1]; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 outfname = argv[2]; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 inf = fopen(infname, "r"); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 if (!inf) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 perror(infname); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 outf = fopen(outfname, "w"); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 if (!outf) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
373 perror(outfname); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 for (;;) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 rc = get_line_nonempty(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 if (rc) |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 break; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 if (!strcasecmp(fields[0], "frame_fr")) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 is_efr = 0; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 start_new_frame(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 } else if (!strcasecmp(fields[0], "frame_efr")) { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 is_efr = 1; |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 start_new_frame(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 } else { |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 fprintf(stderr, |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 "%s line %d: expected frame opening line, got something else\n", |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 infname, lineno); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 exit(1); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 process_frame_interior(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 finish_frame(); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 } |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 exit(0); |
8e9bbb83bd16
trau-ul-compile program written
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 } |