spandsp 3.0.0
v34_tables.h
1/*
2 * SpanDSP - a series of DSP components for telephony
3 *
4 * v34_tables.h - ITU V.34 modem tables.
5 *
6 * Written by Steve Underwood <steveu@coppice.org>
7 *
8 * Copyright (C) 2009 Steve Underwood
9 *
10 * All rights reserved.
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 2.1,
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26/* From Table 13/V.34 */
27static const int8_t conv_encode_input[8][8] =
28{
29 { 0, 0, 1, 1, 8, 8, 9, 9}, /* 0 */
30 { 3, 2, 2, 3, 11, 10, 10, 11}, /* 1 */
31 { 5, 5, 4, 4, 13, 13, 12, 12}, /* 2 */
32 { 6, 7, 7, 6, 14, 15, 15, 14}, /* 3 */
33 { 8, 8, 9, 9, 0, 0, 1, 1}, /* 4 */
34 {11, 10, 10, 11, 3, 2, 2, 3}, /* 5 */
35 {13, 13, 12, 12, 5, 5, 4, 4}, /* 6 */
36 {14, 15, 15, 14, 6, 7, 7, 6} /* 7 */
37};
38
39static const uint8_t v34_conv16_decode_table[16][16] =
40{
41 {0x00, 0x12, 0x64, 0x76},
42 {0x10, 0x02, 0x74, 0x66},
43 {0x20, 0x32, 0x44, 0x56},
44 {0x30, 0x22, 0x54, 0x46},
45 {0x40, 0x52, 0x24, 0x36},
46 {0x50, 0x42, 0x34, 0x26},
47 {0x60, 0x72, 0x04, 0x16},
48 {0x70, 0x62, 0x14, 0x06},
49 {0x49, 0x5B, 0x2D, 0x3F},
50 {0x59, 0x4B, 0x3D, 0x2F},
51 {0x69, 0x7B, 0x0D, 0x1F},
52 {0x79, 0x6B, 0x1D, 0x0F},
53 {0x09, 0x1B, 0x6D, 0x7F},
54 {0x19, 0x0B, 0x7D, 0x6F},
55 {0x29, 0x3B, 0x4D, 0x5F},
56 {0x39, 0x2B, 0x5D, 0x4F}
57};
58
59enum
60{
61 V34_BAUD_RATE_2400 = 0,
62 V34_BAUD_RATE_2743 = 1,
63 V34_BAUD_RATE_2800 = 2,
64 V34_BAUD_RATE_3000 = 3,
65 V34_BAUD_RATE_3200 = 4,
66 V34_BAUD_RATE_3429 = 5
67};
68
69enum
70{
71 V34_TRELLIS_16 = 0,
72 V34_TRELLIS_32 = 1,
73 V34_TRELLIS_64 = 2,
74 V34_TRELLIS_RESERVED = 3
75};
76
77enum tx_clock_source_e
78{
79 TX_CLOCK_SOURCE_INTERNAL = 0,
80 TX_CLOCK_SOURCE_SYNCED_TO_RX = 1,
81 TX_CLOCK_SOURCE_EXTERNAL = 2,
82 TX_CLOCK_SOURCE_RESERVED_FOR_ITU_T = 3
83};
84
85/* From Table 8/V.34 and Table 10/V.34 */
86typedef struct
87{
88 /* The number of bits in a high mapping frame */
89 uint8_t b;
90 uint8_t m[2];
91} mapping_t;
92
93static const mapping_t mappings_2400[] =
94{
95 { 8, { 1, 1}}, /* 2400bps */
96 { 9, { 1, 1}}, /* 2600bps */
97 {16, { 2, 2}}, /* 4800bps */
98 {17, { 2, 2}}, /* 5000bps */
99 {24, { 3, 4}}, /* 7200bps */
100 {25, { 4, 4}}, /* 7400bps */
101 {32, { 6, 7}}, /* 9600bps */
102 {33, { 7, 8}}, /* 9800bps */
103 {40, {12, 14}}, /* 12000bps */
104 {41, {13, 15}}, /* 12200bps */
105 {48, {12, 14}}, /* 14400bps */
106 {49, {13, 15}}, /* 14600bps */
107 {56, {12, 14}}, /* 16800bps */
108 {57, {13, 15}}, /* 17000bps */
109 {64, {12, 14}}, /* 19200bps */
110 {65, {13, 15}}, /* 19400bps */
111 {72, {12, 14}}, /* 21600bps */
112 {73, {13, 15}}, /* 21800bps */
113 { 0, { 0, 0}}, /* 24000bps */
114 { 0, { 0, 0}}, /* 24200bps */
115 { 0, { 0, 0}}, /* 26400bps */
116 { 0, { 0, 0}}, /* 26600bps */
117 { 0, { 0, 0}}, /* 28800bps */
118 { 0, { 0, 0}}, /* 29000bps */
119 { 0, { 0, 0}}, /* 31200bps */
120 { 0, { 0, 0}}, /* 31400bps */
121 { 0, { 0, 0}}, /* 33600bps */
122 { 0, { 0, 0}} /* 33800bps */
123};
124
125static const mapping_t mappings_2743[] =
126{
127 { 0, { 0, 0}}, /* 2400bps */
128 { 0, { 0, 0}}, /* 2600bps */
129 {14, { 2, 2}}, /* 4800bps */
130 {15, { 2, 2}}, /* 5000bps */
131 {21, { 3, 3}}, /* 7200bps */
132 {22, { 3, 3}}, /* 7400bps */
133 {28, { 4, 5}}, /* 9600bps */
134 {29, { 5, 5}}, /* 9800bps */
135 {35, { 8, 9}}, /* 12000bps */
136 {36, { 8, 10}}, /* 12200bps */
137 {42, {14, 17}}, /* 14400bps */
138 {43, {15, 18}}, /* 14600bps */
139 {49, {13, 15}}, /* 16800bps */
140 {50, {14, 17}}, /* 17000bps */
141 {56, {12, 14}}, /* 19200bps */
142 {57, {13, 15}}, /* 19400bps */
143 {63, {11, 13}}, /* 21600bps */
144 {64, {12, 14}}, /* 21800bps */
145 {70, {10, 12}}, /* 24000bps */
146 {71, {11, 13}}, /* 24200bps */
147 {77, { 9, 11}}, /* 26400bps */
148 {78, {10, 12}}, /* 26600bps */
149 { 0, { 0, 0}}, /* 28800bps */
150 { 0, { 0, 0}}, /* 29000bps */
151 { 0, { 0, 0}}, /* 31200bps */
152 { 0, { 0, 0}}, /* 31400bps */
153 { 0, { 0, 0}}, /* 33600bps */
154 { 0, { 0, 0}} /* 33800bps */
155};
156
157static const mapping_t mappings_2800[] =
158{
159 { 0, { 0, 0}}, /* 2400bps */
160 { 0, { 0, 0}}, /* 2600bps */
161 {14, { 2, 2}}, /* 4800bps */
162 {15, { 2, 2}}, /* 5000bps */
163 {21, { 3, 3}}, /* 7200bps */
164 {22, { 3, 3}}, /* 7400bps */
165 {28, { 4, 5}}, /* 9600bps */
166 {28, { 4, 5}}, /* 9800bps */
167 {35, { 8, 9}}, /* 12000bps */
168 {35, { 8, 9}}, /* 12200bps */
169 {42, {14, 17}}, /* 14400bps */
170 {42, {14, 17}}, /* 14600bps */
171 {48, {12, 14}}, /* 16800bps */
172 {49, {13, 15}}, /* 17000bps */
173 {55, {11, 13}}, /* 19200bps */
174 {56, {12, 14}}, /* 19400bps */
175 {62, {10, 12}}, /* 21600bps */
176 {63, {11, 13}}, /* 21800bps */
177 {69, { 9, 11}}, /* 24000bps */
178 {70, {10, 12}}, /* 24200bps */
179 {76, { 8, 10}}, /* 26400bps */
180 {76, { 8, 10}}, /* 26600bps */
181 { 0, { 0, 0}}, /* 28800bps */
182 { 0, { 0, 0}}, /* 29000bps */
183 { 0, { 0, 0}}, /* 31200bps */
184 { 0, { 0, 0}}, /* 31400bps */
185 { 0, { 0, 0}}, /* 33600bps */
186 { 0, { 0, 0}} /* 33800bps */
187};
188
189static const mapping_t mappings_3000[] =
190{
191 { 0, { 0, 0}}, /* 2400bps */
192 { 0, { 0, 0}}, /* 2600bps */
193 {13, { 2, 2}}, /* 4800bps */
194 {14, { 2, 2}}, /* 5000bps */
195 {20, { 2, 3}}, /* 7200bps */
196 {20, { 2, 3}}, /* 7400bps */
197 {26, { 4, 4}}, /* 9600bps */
198 {27, { 4, 5}}, /* 9800bps */
199 {32, { 6, 7}}, /* 12000bps */
200 {33, { 7, 8}}, /* 12200bps */
201 {39, {11, 13}}, /* 14400bps */
202 {39, {11, 13}}, /* 14600bps */
203 {45, { 9, 11}}, /* 16800bps */
204 {46, {10, 12}}, /* 17000bps */
205 {52, { 8, 10}}, /* 19200bps */
206 {52, { 8, 10}}, /* 19400bps */
207 {58, {14, 17}}, /* 21600bps */
208 {59, {15, 18}}, /* 21800bps */
209 {64, {12, 14}}, /* 24000bps */
210 {65, {13, 15}}, /* 24200bps */
211 {71, {11, 13}}, /* 26400bps */
212 {71, {11, 13}}, /* 26600bps */
213 {77, { 9, 11}}, /* 28800bps */
214 {78, {10, 12}}, /* 29000bps */
215 { 0, { 0, 0}}, /* 31200bps */
216 { 0, { 0, 0}}, /* 31400bps */
217 { 0, { 0, 0}}, /* 33600bps */
218 { 0, { 0, 0}} /* 33800bps */
219};
220
221static const mapping_t mappings_3200[] =
222{
223 { 0, { 0, 0}}, /* 2400bps */
224 { 0, { 0, 0}}, /* 2600bps */
225 {12, { 1, 1}}, /* 4800bps */
226 {13, { 2, 2}}, /* 5000bps */
227 {18, { 2, 2}}, /* 7200bps */
228 {19, { 2, 2}}, /* 7400bps */
229 {24, { 3, 4}}, /* 9600bps */
230 {25, { 4, 4}}, /* 9800bps */
231 {30, { 5, 6}}, /* 12000bps */
232 {31, { 6, 6}}, /* 12200bps */
233 {36, { 8, 10}}, /* 14400bps */
234 {37, { 9, 11}}, /* 14600bps */
235 {42, {14, 17}}, /* 16800bps */
236 {43, {15, 18}}, /* 17000bps */
237 {48, {12, 14}}, /* 19200bps */
238 {49, {13, 15}}, /* 19400bps */
239 {54, {10, 12}}, /* 21600bps */
240 {55, {11, 13}}, /* 21800bps */
241 {60, { 8, 10}}, /* 24000bps */
242 {61, { 9, 11}}, /* 24200bps */
243 {66, {14, 17}}, /* 26400bps */
244 {67, {15, 18}}, /* 26600bps */
245 {72, {12, 14}}, /* 28800bps */
246 {73, {13, 15}}, /* 29000bps */
247 {78, {10, 12}}, /* 31200bps */
248 {79, {11, 13}}, /* 31400bps */
249 { 0, { 0, 0}}, /* 33600bps */
250 { 0, { 0, 0}} /* 33800bps */
251};
252
253static const mapping_t mappings_3429[] =
254{
255 { 0, { 0, 0}}, /* 2400bps */
256 { 0, { 0, 0}}, /* 2600bps */
257 {12, { 1, 1}}, /* 4800bps */
258 {12, { 1, 1}}, /* 5000bps */
259 {17, { 2, 2}}, /* 7200bps */
260 {18, { 2, 2}}, /* 7400bps */
261 {23, { 3, 3}}, /* 9600bps */
262 {23, { 3, 3}}, /* 9800bps */
263 {28, { 4, 5}}, /* 12000bps */
264 {29, { 5, 5}}, /* 12200bps */
265 {34, { 7, 8}}, /* 14400bps */
266 {35, { 8, 9}}, /* 14600bps */
267 {40, {12, 14}}, /* 16800bps */
268 {40, {12, 14}}, /* 17000bps */
269 {45, { 9, 11}}, /* 19200bps */
270 {46, {10, 12}}, /* 19400bps */
271 {51, {15, 18}}, /* 21600bps */
272 {51, {15, 18}}, /* 21800bps */
273 {56, {12, 14}}, /* 24000bps */
274 {57, {13, 15}}, /* 24200bps */
275 {62, {10, 12}}, /* 26400bps */
276 {63, {11, 13}}, /* 26600bps */
277 {68, { 8, 10}}, /* 28800bps */
278 {68, { 8, 10}}, /* 29000bps */
279 {73, {13, 15}}, /* 31200bps */
280 {74, {14, 17}}, /* 31400bps */
281 {79, {11, 13}}, /* 33600bps */
282 {79, {11, 13}} /* 33800bps */
283};
284
285/* From Table 1/V.34, Table 2/V.34, Table 7/V.34 and Table 9/V.34 */
286typedef struct
287{
288 /*! Approximate baud rate (i.e. nearest integer value). */
290 int max_bit_rate;
291 int a;
292 int c;
293 /*! The numerator of the number of samples per symbol ratio. */
295 /*! The denominator of the number of samples per symbol ratio. */
297 struct
298 {
299 int d;
300 int e;
301 } low_high[2];
302 int j;
303 int p;
304 const mapping_t *mappings;
306
307static const baud_rate_parameters_t baud_rate_parameters[] =
308{
309 {2400, 21600/2400, 1, 1, 10, 3, {{2, 3}, {3, 4}}, 7, 12, mappings_2400}, /* 2400 baud */
310 {2743, 26400/2400, 8, 7, 35, 12, {{3, 5}, {2, 3}}, 8, 12, mappings_2743}, /* ~2743 baud */
311 {2800, 26400/2400, 7, 6, 20, 7, {{3, 5}, {2, 3}}, 7, 14, mappings_2800}, /* 2800 baud */
312 {3000, 28800/2400, 5, 4, 8, 3, {{3, 5}, {2, 3}}, 7, 15, mappings_3000}, /* 3000 baud */
313 {3200, 31200/2400, 4, 3, 5, 2, {{4, 7}, {3, 5}}, 7, 16, mappings_3200}, /* 3200 baud */
314 {3429, 33600/2400, 10, 7, 7, 3, {{4, 7}, {4, 7}}, 8, 15, mappings_3429} /* ~3429 baud */
315};
316
317#if defined(SPANDSP_USE_FIXED_POINT)
318#define PP_SYMBOL_SCALE(x) ((int16_t) (32767.0f*x + ((x >= 0.0) ? 0.5 : -0.5)))
319#else
320#define PP_SYMBOL_SCALE(x) (x)
321#endif
322
323#if defined(SPANDSP_USE_FIXED_POINT)
324#define LINE_PROBE_SCALE(x) ((int16_t) (x + ((x >= 0.0) ? 0.5 : -0.5)))
325#else
326#define LINE_PROBE_SCALE(x) (x)
327#endif
328
329static const uint8_t k_table[16][4] =
330{
331 {0, 1, 2, 3},
332 {2, 3, 0, 1},
333 {1, 0, 3, 2},
334 {3, 2, 1, 0},
335 {4, 5, 6, 7},
336 {6, 7, 4, 5},
337 {5, 4, 7, 6},
338 {7, 6, 5, 4},
339 {2, 3, 0, 1},
340 {0, 1, 2, 3},
341 {3, 2, 1, 0},
342 {1, 0, 3, 2},
343 {6, 7, 4, 5},
344 {4, 5, 6, 7},
345 {7, 6, 5, 4},
346 {5, 4, 7, 6}
347};
348
349/*! V.34/Table A.4 Modem control super-frame categories */
350enum
351{
352 V34_RATER = 0x00,
353 V34_RATEU = 0x03,
354 V34_PRECODER = 0x05,
355 V34_PRECODEU = 0x0A
356};
357
358static const v34_capabilities_t v34_capabilities =
359{
360 {true, true, true, true, true, true},
361 {true, true, true, true, true, true},
362 true,
363 0,
364 true,
365 TX_CLOCK_SOURCE_INTERNAL,
366 false,
367 true
368};
369
370/*- End of file ------------------------------------------------------------*/
Definition v34_tables.h:287
int baud_rate
Definition v34_tables.h:289
int samples_per_symbol_denominator
Definition v34_tables.h:296
int samples_per_symbol_numerator
Definition v34_tables.h:294
Definition v34_tables.h:87
Definition private/v34.h:182