FreeCalypso > hg > gsm-codec-lib
comparison miscutil/pcm16-to-alaw.c @ 219:dc52c3857bf7
miscutil: new program pcm16-to-alaw
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 22 Apr 2023 20:34:49 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
218:f4f68c652e98 | 219:dc52c3857bf7 |
---|---|
1 /* | |
2 * This program reads a 16-bit PCM recording in raw format (robe by default, | |
3 * or LE with -l option) and converts it to 8-bit PCM in European A-law | |
4 * encoding. It is based on toast_alaw.c from libgsm/toast package by | |
5 * Jutta Degener and Carsten Bormann, Technische Universitaet Berlin. | |
6 */ | |
7 | |
8 #include <stdio.h> | |
9 #include <stdint.h> | |
10 #include <stdlib.h> | |
11 #include <string.h> | |
12 #include <strings.h> | |
13 | |
14 #define S2A(x) (s2a[ ((unsigned short)(x)) >> 4 ]) | |
15 | |
16 static unsigned char s2a[] = { | |
17 213,212,215,214,209,208,211,210,221,220,223,222,217,216,219,218, | |
18 197,196,199,198,193,192,195,194,205,204,207,206,201,200,203,202, | |
19 245,245,244,244,247,247,246,246,241,241,240,240,243,243,242,242, | |
20 253,253,252,252,255,255,254,254,249,249,248,248,251,251,250,250, | |
21 229,229,229,229,228,228,228,228,231,231,231,231,230,230,230,230, | |
22 225,225,225,225,224,224,224,224,227,227,227,227,226,226,226,226, | |
23 237,237,237,237,236,236,236,236,239,239,239,239,238,238,238,238, | |
24 233,233,233,233,232,232,232,232,235,235,235,235,234,234,234,234, | |
25 149,149,149,149,149,149,149,149,148,148,148,148,148,148,148,148, | |
26 151,151,151,151,151,151,151,151,150,150,150,150,150,150,150,150, | |
27 145,145,145,145,145,145,145,145,144,144,144,144,144,144,144,144, | |
28 147,147,147,147,147,147,147,147,146,146,146,146,146,146,146,146, | |
29 157,157,157,157,157,157,157,157,156,156,156,156,156,156,156,156, | |
30 159,159,159,159,159,159,159,159,158,158,158,158,158,158,158,158, | |
31 153,153,153,153,153,153,153,153,152,152,152,152,152,152,152,152, | |
32 155,155,155,155,155,155,155,155,154,154,154,154,154,154,154,154, | |
33 133,133,133,133,133,133,133,133,133,133,133,133,133,133,133,133, | |
34 132,132,132,132,132,132,132,132,132,132,132,132,132,132,132,132, | |
35 135,135,135,135,135,135,135,135,135,135,135,135,135,135,135,135, | |
36 134,134,134,134,134,134,134,134,134,134,134,134,134,134,134,134, | |
37 129,129,129,129,129,129,129,129,129,129,129,129,129,129,129,129, | |
38 128,128,128,128,128,128,128,128,128,128,128,128,128,128,128,128, | |
39 131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131, | |
40 130,130,130,130,130,130,130,130,130,130,130,130,130,130,130,130, | |
41 141,141,141,141,141,141,141,141,141,141,141,141,141,141,141,141, | |
42 140,140,140,140,140,140,140,140,140,140,140,140,140,140,140,140, | |
43 143,143,143,143,143,143,143,143,143,143,143,143,143,143,143,143, | |
44 142,142,142,142,142,142,142,142,142,142,142,142,142,142,142,142, | |
45 137,137,137,137,137,137,137,137,137,137,137,137,137,137,137,137, | |
46 136,136,136,136,136,136,136,136,136,136,136,136,136,136,136,136, | |
47 139,139,139,139,139,139,139,139,139,139,139,139,139,139,139,139, | |
48 138,138,138,138,138,138,138,138,138,138,138,138,138,138,138,138, | |
49 181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181, | |
50 181,181,181,181,181,181,181,181,181,181,181,181,181,181,181,181, | |
51 180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180, | |
52 180,180,180,180,180,180,180,180,180,180,180,180,180,180,180,180, | |
53 183,183,183,183,183,183,183,183,183,183,183,183,183,183,183,183, | |
54 183,183,183,183,183,183,183,183,183,183,183,183,183,183,183,183, | |
55 182,182,182,182,182,182,182,182,182,182,182,182,182,182,182,182, | |
56 182,182,182,182,182,182,182,182,182,182,182,182,182,182,182,182, | |
57 177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177, | |
58 177,177,177,177,177,177,177,177,177,177,177,177,177,177,177,177, | |
59 176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176, | |
60 176,176,176,176,176,176,176,176,176,176,176,176,176,176,176,176, | |
61 179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179, | |
62 179,179,179,179,179,179,179,179,179,179,179,179,179,179,179,179, | |
63 178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178, | |
64 178,178,178,178,178,178,178,178,178,178,178,178,178,178,178,178, | |
65 189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189, | |
66 189,189,189,189,189,189,189,189,189,189,189,189,189,189,189,189, | |
67 188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188, | |
68 188,188,188,188,188,188,188,188,188,188,188,188,188,188,188,188, | |
69 191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, | |
70 191,191,191,191,191,191,191,191,191,191,191,191,191,191,191,191, | |
71 190,190,190,190,190,190,190,190,190,190,190,190,190,190,190,190, | |
72 190,190,190,190,190,190,190,190,190,190,190,190,190,190,190,190, | |
73 185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185, | |
74 185,185,185,185,185,185,185,185,185,185,185,185,185,185,185,185, | |
75 184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184, | |
76 184,184,184,184,184,184,184,184,184,184,184,184,184,184,184,184, | |
77 187,187,187,187,187,187,187,187,187,187,187,187,187,187,187,187, | |
78 187,187,187,187,187,187,187,187,187,187,187,187,187,187,187,187, | |
79 186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186, | |
80 186,186,186,186,186,186,186,186,186,186,186,186,186,186,186,186, | |
81 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
82 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
83 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
84 165,165,165,165,165,165,165,165,165,165,165,165,165,165,165,165, | |
85 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164, | |
86 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164, | |
87 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164, | |
88 164,164,164,164,164,164,164,164,164,164,164,164,164,164,164,164, | |
89 167,167,167,167,167,167,167,167,167,167,167,167,167,167,167,167, | |
90 167,167,167,167,167,167,167,167,167,167,167,167,167,167,167,167, | |
91 167,167,167,167,167,167,167,167,167,167,167,167,167,167,167,167, | |
92 167,167,167,167,167,167,167,167,167,167,167,167,167,167,167,167, | |
93 166,166,166,166,166,166,166,166,166,166,166,166,166,166,166,166, | |
94 166,166,166,166,166,166,166,166,166,166,166,166,166,166,166,166, | |
95 166,166,166,166,166,166,166,166,166,166,166,166,166,166,166,166, | |
96 166,166,166,166,166,166,166,166,166,166,166,166,166,166,166,166, | |
97 161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161, | |
98 161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161, | |
99 161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161, | |
100 161,161,161,161,161,161,161,161,161,161,161,161,161,161,161,161, | |
101 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160, | |
102 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160, | |
103 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160, | |
104 160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160, | |
105 163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163, | |
106 163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163, | |
107 163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163, | |
108 163,163,163,163,163,163,163,163,163,163,163,163,163,163,163,163, | |
109 162,162,162,162,162,162,162,162,162,162,162,162,162,162,162,162, | |
110 162,162,162,162,162,162,162,162,162,162,162,162,162,162,162,162, | |
111 162,162,162,162,162,162,162,162,162,162,162,162,162,162,162,162, | |
112 162,162,162,162,162,162,162,162,162,162,162,162,162,162,162,162, | |
113 173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173, | |
114 173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173, | |
115 173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173, | |
116 173,173,173,173,173,173,173,173,173,173,173,173,173,173,173,173, | |
117 172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172, | |
118 172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172, | |
119 172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172, | |
120 172,172,172,172,172,172,172,172,172,172,172,172,172,172,172,172, | |
121 175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175, | |
122 175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175, | |
123 175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175, | |
124 175,175,175,175,175,175,175,175,175,175,175,175,175,175,175,175, | |
125 174,174,174,174,174,174,174,174,174,174,174,174,174,174,174,174, | |
126 174,174,174,174,174,174,174,174,174,174,174,174,174,174,174,174, | |
127 174,174,174,174,174,174,174,174,174,174,174,174,174,174,174,174, | |
128 174,174,174,174,174,174,174,174,174,174,174,174,174,174,174,174, | |
129 169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169, | |
130 169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169, | |
131 169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169, | |
132 169,169,169,169,169,169,169,169,169,169,169,169,169,169,169,169, | |
133 168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168, | |
134 168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168, | |
135 168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168, | |
136 168,168,168,168,168,168,168,168,168,168,168,168,168,168,168,168, | |
137 171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171, | |
138 171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171, | |
139 171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171, | |
140 171,171,171,171,171,171,171,171,171,171,171,171,171,171,171,171, | |
141 170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170, | |
142 170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170, | |
143 170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170, | |
144 170,170,170,170,170,170,170,170,170,170,170,170,170,170,170,170, | |
145 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, | |
146 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, | |
147 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, | |
148 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, | |
149 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, | |
150 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, | |
151 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, | |
152 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, | |
153 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, | |
154 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, | |
155 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, | |
156 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, | |
157 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, | |
158 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, | |
159 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, | |
160 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, | |
161 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, | |
162 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, | |
163 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, | |
164 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, 46, | |
165 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | |
166 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | |
167 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | |
168 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, 47, | |
169 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, | |
170 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, | |
171 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, | |
172 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, | |
173 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, | |
174 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, | |
175 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, | |
176 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, | |
177 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, | |
178 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, | |
179 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, | |
180 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, | |
181 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, | |
182 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, | |
183 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, | |
184 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, | |
185 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, | |
186 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, | |
187 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, | |
188 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, | |
189 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, | |
190 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, | |
191 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, | |
192 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, | |
193 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, | |
194 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, | |
195 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, | |
196 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, | |
197 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, | |
198 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, | |
199 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, | |
200 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, 39, | |
201 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, | |
202 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, | |
203 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, | |
204 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, | |
205 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, | |
206 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, | |
207 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, | |
208 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, | |
209 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, | |
210 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, | |
211 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, | |
212 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, | |
213 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | |
214 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, | |
215 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, | |
216 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, | |
217 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, | |
218 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, | |
219 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, | |
220 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, | |
221 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, | |
222 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, | |
223 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, | |
224 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, | |
225 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, | |
226 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, 50, | |
227 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, | |
228 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, | |
229 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, | |
230 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, 48, | |
231 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | |
232 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, | |
233 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | |
234 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, | |
235 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, | |
236 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, | |
237 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, | |
238 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, 52, | |
239 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, | |
240 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, | |
241 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, | |
242 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, | |
243 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, | |
244 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, | |
245 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, | |
246 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, | |
247 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, | |
248 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, | |
249 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, | |
250 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, | |
251 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | |
252 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | |
253 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, | |
254 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, | |
255 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, | |
256 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, | |
257 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, | |
258 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, | |
259 30, 30, 30, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, | |
260 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, | |
261 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, | |
262 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 17, | |
263 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, | |
264 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, | |
265 106,106,106,106,107,107,107,107,104,104,104,104,105,105,105,105, | |
266 110,110,110,110,111,111,111,111,108,108,108,108,109,109,109,109, | |
267 98, 98, 98, 98, 99, 99, 99, 99, 96, 96, 96, 96, 97, 97, 97, 97, | |
268 102,102,102,102,103,103,103,103,100,100,100,100,101,101,101,101, | |
269 122,122,123,123,120,120,121,121,126,126,127,127,124,124,125,125, | |
270 114,114,115,115,112,112,113,113,118,118,119,119,116,116,117,117, | |
271 74, 75, 72, 73, 78, 79, 76, 77, 66, 67, 64, 65, 70, 71, 68, 69, | |
272 90, 91, 88, 89, 94, 95, 92, 93, 82, 83, 80, 81, 86, 87, 84, 85 | |
273 }; | |
274 | |
275 main(argc, argv) | |
276 char **argv; | |
277 { | |
278 int little_endian; | |
279 char *infname, *outfname; | |
280 FILE *inf, *outf; | |
281 uint8_t inb[2]; | |
282 uint16_t ins; | |
283 int cc; | |
284 | |
285 if (argc == 3 && argv[1][0] != '-') { | |
286 little_endian = 0; | |
287 infname = argv[1]; | |
288 outfname = argv[2]; | |
289 } else if (argc == 4 && !strcmp(argv[1], "-l")) { | |
290 little_endian = 1; | |
291 infname = argv[2]; | |
292 outfname = argv[3]; | |
293 } else { | |
294 fprintf(stderr, "usage: %s [-l] input.pcm16 output.alaw\n", | |
295 argv[0]); | |
296 exit(1); | |
297 } | |
298 inf = fopen(infname, "r"); | |
299 if (!inf) { | |
300 perror(infname); | |
301 exit(1); | |
302 } | |
303 outf = fopen(outfname, "w"); | |
304 if (!outf) { | |
305 perror(outfname); | |
306 exit(1); | |
307 } | |
308 for (;;) { | |
309 cc = fread(inb, 1, 2, inf); | |
310 if (cc <= 0) | |
311 break; | |
312 if (cc & 1) { | |
313 fprintf(stderr, "error: %s has odd number of bytes\n", | |
314 infname); | |
315 exit(1); | |
316 } | |
317 if (little_endian) | |
318 ins = ((uint16_t) inb[1] << 8) | ((uint16_t) inb[0]); | |
319 else | |
320 ins = ((uint16_t) inb[0] << 8) | ((uint16_t) inb[1]); | |
321 putc(S2A(ins), outf); | |
322 } | |
323 fclose(outf); | |
324 exit(0); | |
325 } |