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