From a802976818b360f3add430ed2b687effeb3c882e Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 28 Apr 2009 14:42:18 +0000 Subject: [PATCH] update to snapshot spandsp-20090427 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13177 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/spandsp/src/async.c | 6 +- libs/spandsp/src/at_interpreter.c | 212 ++++++- libs/spandsp/src/fax.c | 4 +- libs/spandsp/src/g722.c | 21 +- libs/spandsp/src/libspandsp.2008.sln | 100 +++- libs/spandsp/src/make_at_dictionary.c | 8 +- libs/spandsp/src/spandsp/async.h | 8 +- libs/spandsp/src/spandsp/fax_modems.h | 6 +- libs/spandsp/src/spandsp/private/v22bis.h | 44 +- libs/spandsp/src/spandsp/v22bis.h | 30 +- libs/spandsp/src/spandsp/version.h | 6 +- libs/spandsp/src/t30.c | 4 +- libs/spandsp/src/v17rx.c | 12 +- libs/spandsp/src/v17tx.c | 12 +- libs/spandsp/src/v18.c | 11 +- libs/spandsp/src/v22bis_rx.c | 341 +++++------ libs/spandsp/src/v22bis_tx.c | 109 ++-- libs/spandsp/src/v27ter_rx.c | 10 +- libs/spandsp/src/v27ter_tx.c | 10 +- libs/spandsp/src/v29rx.c | 16 +- libs/spandsp/src/v29tx.c | 11 +- libs/spandsp/tests/Makefile.am | 23 +- libs/spandsp/tests/adsi_tests.c | 3 +- libs/spandsp/tests/at_interpreter_tests.c | 16 +- .../tests/complex_vector_float_tests.c | 3 +- libs/spandsp/tests/complex_vector_int_tests.c | 3 +- libs/spandsp/tests/fax_utils.c | 4 +- libs/spandsp/tests/g711_tests.c | 300 ++++++++-- libs/spandsp/tests/g722_tests.c | 551 +++++++++++------- libs/spandsp/tests/g726_tests.c | 277 ++++----- libs/spandsp/tests/gsm0610_tests.c | 46 +- libs/spandsp/tests/msvc/adsi_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/complex_tests.vcproj | 208 +++++++ .../msvc/complex_vector_float_tests.vcproj | 208 +++++++ .../msvc/complex_vector_int_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/dtmf_rx_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/dtmf_tx_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/queue_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/t38_core_tests.vcproj | 208 +++++++ .../msvc/t38_non_ecm_buffer_tests.vcproj | 208 +++++++ .../tests/msvc/t38_terminal_tests.vcproj | 202 +++++++ libs/spandsp/tests/msvc/v22bis_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/v29_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/v80_tests.vcproj | 208 +++++++ libs/spandsp/tests/msvc/v8_tests.vcproj | 208 +++++++ .../tests/msvc/vector_float_tests.vcproj | 208 +++++++ .../tests/msvc/vector_int_tests.vcproj | 208 +++++++ libs/spandsp/tests/t38_core_tests.c | 12 +- libs/spandsp/tests/t38_gateway_tests.c | 15 +- .../tests/t38_gateway_to_terminal_tests.c | 15 +- libs/spandsp/tests/t38_non_ecm_buffer_tests.c | 13 +- libs/spandsp/tests/t38_terminal_tests.c | 15 +- .../tests/t38_terminal_to_gateway_tests.c | 15 +- libs/spandsp/tests/v17_tests.c | 10 +- libs/spandsp/tests/v22bis_tests.c | 69 ++- libs/spandsp/tests/v27ter_tests.c | 10 +- libs/spandsp/tests/v29_tests.c | 10 +- libs/spandsp/tests/v8_tests.c | 4 +- libs/spandsp/tests/vector_float_tests.c | 3 +- libs/spandsp/tests/vector_int_tests.c | 3 +- 60 files changed, 4937 insertions(+), 786 deletions(-) create mode 100644 libs/spandsp/tests/msvc/adsi_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/complex_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/complex_vector_float_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/complex_vector_int_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/dtmf_rx_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/dtmf_tx_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/queue_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/t38_core_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/t38_non_ecm_buffer_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/t38_terminal_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/v22bis_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/v29_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/v80_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/v8_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/vector_float_tests.vcproj create mode 100644 libs/spandsp/tests/msvc/vector_int_tests.vcproj diff --git a/libs/spandsp/src/async.c b/libs/spandsp/src/async.c index 8c3f205c22..29974df2de 100644 --- a/libs/spandsp/src/async.c +++ b/libs/spandsp/src/async.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: async.c,v 1.18 2009/02/10 13:06:46 steveu Exp $ + * $Id: async.c,v 1.19 2009/04/23 14:12:34 steveu Exp $ */ /*! \file */ @@ -67,6 +67,10 @@ SPAN_DECLARE(const char *) signal_status_to_str(int status) return "Shutdown complete"; case SIG_STATUS_OCTET_REPORT: return "Octet report"; + case SIG_STATUS_POOR_SIGNAL_QUALITY: + return "Poor signal quality"; + case SIG_STATUS_MODEM_RETRAIN_OCCURRED: + return "Modem retrain occurred"; } return "???"; } diff --git a/libs/spandsp/src/at_interpreter.c b/libs/spandsp/src/at_interpreter.c index 7155cfa12e..a71f0a7d25 100644 --- a/libs/spandsp/src/at_interpreter.c +++ b/libs/spandsp/src/at_interpreter.c @@ -25,7 +25,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: at_interpreter.c,v 1.37 2009/03/23 14:17:42 steveu Exp $ + * $Id: at_interpreter.c,v 1.39 2009/04/24 22:35:25 steveu Exp $ */ /*! \file */ @@ -519,6 +519,64 @@ static int parse_2_out(at_state_t *s, const char **t, int *target1, int max_valu } /*- End of function --------------------------------------------------------*/ +static int parse_n_out(at_state_t *s, + const char **t, + int *targets[], + const int max_values[], + int entries, + const char *prefix, + const char *def) +{ + char buf[100]; + int val; + int len; + int i; + + switch (*(*t)++) + { + case '=': + switch (**t) + { + case '?': + /* Show possible values */ + (*t)++; + snprintf(buf, sizeof(buf), "%s%s", (prefix) ? prefix : "", def); + at_put_response(s, buf); + break; + default: + /* Set value */ + for (i = 0; i < entries; i++) + { + if ((val = parse_num(t, max_values[i])) < 0) + return FALSE; + if (targets[i]) + *targets[i] = val; + if (**t != ',') + break; + (*t)++; + } + break; + } + break; + case '?': + /* Show current value */ + len = snprintf(buf, sizeof(buf), "%s", (prefix) ? prefix : ""); + for (i = 0; i < entries; i++) + { + if (i > 0) + len += snprintf(&buf[len], sizeof(buf) - len, ","); + val = (targets[i]) ? *targets[i] : 0; + len += snprintf(&buf[len], sizeof(buf) - len, "%d", val); + } + at_put_response(s, buf); + break; + default: + return FALSE; + } + return TRUE; +} +/*- End of function --------------------------------------------------------*/ + static int parse_hex_out(at_state_t *s, const char **t, int *target, int max_value, const char *prefix, const char *def) { char buf[100]; @@ -3191,9 +3249,76 @@ static const char *at_cmd_plus_ER(at_state_t *s, const char *t) static const char *at_cmd_plus_ES(at_state_t *s, const char *t) { + static const int maxes[3] = + { + 7, 4, 9 + }; + int *locations[3]; + /* V.250 6.5.1 - Error control selection */ + + /* orig_rqst + 0: Direct mode + 1: Initiate call with Buffered mode only + 2: Initiate V.42 without Detection Phase. If Rec. V.8 is in use, this is a request to disable V.42 Detection Phase + 3: Initiate V.42 with Detection Phase + 4: Initiate Altemative Protocol + 5: Initiate Synchronous Mode when connection is completed, immediately after the entire CONNECT result code + is delivered. V.24 circuits 113 and 115 are activated when Data State is entered + 6: Initiate Synchronous Access Mode when connection is completed, and Data State is entered + 7: Initiate Frame Tunnelling Mode when connection is completed, and Data State is entered + + orig_fbk + 0: Error control optional (either LAPM or Alternative acceptable); if error control not established, maintain + DTE-DCE data rate and use V.14 buffered mode with flow control during non-error-control operation + 1: Error control optional (either LAPM or Alternative acceptable); if error control not established, change + DTE-DCE data rate to match line rate and use Direct mode + 2: Error control required (either LAPM or Alternative acceptable); if error control not established, disconnect + 3: Error control required (only LAPM acceptable); if error control not established, disconnect + 4: Error control required (only Altemative protocol acceptable); if error control not established, disconnect + + ans_fbk + 0: Direct mode + 1: Error control disabled, use Buffered mode + 2: Error control optional (either LAPM or Alternative acceptable); if error control not established, maintain + DTE-DCE data rate and use local buffering and flow control during non-error-control operation + 3: Error control optional (either LAPM or Alternative acceptable); if error control not established, change + DTE-DCE data rate to match line rate and use Direct mode + 4: Error control required (either LAPM or Alternative acceptable); if error control not established, disconnect + 5: Error control required (only LAPM acceptable); if error control not established, disconnect + 6: Error control required (only Alternative protocol acceptable); if error control not established, disconnect + 7: Initiate Synchronous Mode when connection is completed, immediately after the entire CONNECT result code + is delivered. V.24 cicuits 113 and 115 are activated when Data State is entered + 8: Initiate Synchronous Access Mode when connection is completed, and Data State is entered + 9: Initiate Frame Tunnelling Mode when connection is completed, and Data State is entered */ + /* TODO: */ t += 3; + locations[0] = NULL; + locations[1] = NULL; + locations[2] = NULL; + if (!parse_n_out(s, &t, locations, maxes, 3, "+ES:", "(0-7),(0-4),(0-9)")) + return NULL; + return t; +} +/*- End of function --------------------------------------------------------*/ + +static const char *at_cmd_plus_ESA(at_state_t *s, const char *t) +{ + static const int maxes[8] = + { + 2, 1, 1, 1, 2, 1, 255, 255 + }; + int *locations[8]; + int i; + + /* V.80 8.2 - Synchronous access mode configuration */ + /* TODO: */ + t += 4; + for (i = 0; i < 8; i++) + locations[i] = NULL; + if (!parse_n_out(s, &t, locations, maxes, 8, "+ESA:", "(0-2),(0-1),(0-1),(0-1),(0-2),(0-1),(0-255),(0-255)")) + return NULL; return t; } /*- End of function --------------------------------------------------------*/ @@ -3800,18 +3925,66 @@ static const char *at_cmd_plus_GSN(at_state_t *s, const char *t) static const char *at_cmd_plus_IBC(at_state_t *s, const char *t) { - /* TIA-617 8.3 - Control of in-band control */ + static const int maxes[13] = + { + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 + }; + int *locations[13]; + int i; + + /* V.80 7.9 - Control of in-band control */ /* TODO: */ t += 4; + /* 0: In-band control service disabled + 1: In-band control service enabled, 7-bit codes allowed, and top bit insignificant + 2; In-band control service enabled, 7-bit codes allowed, and 8-bit codes available + + Circuits 105, 106, 107, 108, 109, 110, 125, 132, 133, 135, 142 in that order. For each one: + 0: disabled + 1: enabled + + DCE line connect status reports: + 0: disabled + 1: enabled */ + for (i = 0; i < 13; i++) + locations[i] = NULL; + if (!parse_n_out(s, &t, locations, maxes, 13, "+IBC:", "(0-2),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0.1),(0,1)")) + return NULL; return t; } /*- End of function --------------------------------------------------------*/ static const char *at_cmd_plus_IBM(at_state_t *s, const char *t) { - /* TIA-617 8.4 - In-Band MARK idle reporting control */ + static const int maxes[3] = + { + 7, 255, 255 + }; + int *locations[3]; + + /* V.80 7.10 - In-band MARK idle reporting control */ /* TODO: */ t += 4; + /* Report control + 0: No reports + 1: Report only once when expires + 2: Report each time expires + 3: Report once when expires, and then each time expires + 4: Report only when the Mark-ldle Period ends; T3 = the entire interval + 5: Report the first time when is exceeded, and then once more when the mark idle period ends + 6: Report each time when is exceeded, and then once more when the mark idle period ends; + T3 = entire interval -- N*T2 + 7: report the first time when is exceeded, and then each time is exceeded, and then once + more when the mark idle period ends; T3 = entire mark idle period -- N*T2 - T1 + + T1 in units of 10ms + + T2 in units of 10ms */ + locations[0] = NULL; + locations[1] = NULL; + locations[2] = NULL; + if (!parse_n_out(s, &t, locations, maxes, 3, "+IBM:", "(0-7),(0-255),(0-255)")) + return NULL; return t; } /*- End of function --------------------------------------------------------*/ @@ -3821,19 +3994,19 @@ static const char *at_cmd_plus_ICF(at_state_t *s, const char *t) /* V.250 6.2.11 - DTE-DCE character framing */ t += 4; /* Character format - 0 auto detect - 1 8 data 2 stop - 2 8 data 1 parity 1 stop - 3 8 data 1 stop - 4 7 data 2 stop - 5 7 data 1 parity 1 stop - 6 7 data 1 stop + 0: auto detect + 1: 8 data 2 stop + 2: 8 data 1 parity 1 stop + 3: 8 data 1 stop + 4: 7 data 2 stop + 5: 7 data 1 parity 1 stop + 6: 7 data 1 stop - parity - 0 Odd - 1 Even - 2 Mark - 3 Space */ + Parity + 0: Odd + 1: Even + 2: Mark + 3: Space */ if (!parse_2_out(s, &t, &s->dte_char_format, 6, &s->dte_parity, 3, "+ICF:", "(0-6),(0-3)")) return NULL; return t; @@ -3909,6 +4082,15 @@ static const char *at_cmd_plus_IRTS(at_state_t *s, const char *t) } /*- End of function --------------------------------------------------------*/ +static const char *at_cmd_plus_ITF(at_state_t *s, const char *t) +{ + /* V.80 8.4 - Transmit flow control thresholds */ + /* TODO: */ + t += 5; + return t; +} +/*- End of function --------------------------------------------------------*/ + static const char *at_cmd_plus_MA(at_state_t *s, const char *t) { /* V.250 6.4.2 - Modulation automode control */ diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index 5858292af9..1256eef5d6 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -23,7 +23,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: fax.c,v 1.91 2009/04/12 03:29:58 steveu Exp $ + * $Id: fax.c,v 1.92 2009/04/23 15:48:21 steveu Exp $ */ /*! \file */ @@ -575,7 +575,7 @@ SPAN_DECLARE(fax_state_t *) fax_init(fax_state_t *s, int calling_party) (void *) s, fax_send_hdlc, (void *) s); - t30_set_supported_modems(&s->t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29); + t30_set_supported_modems(&s->t30, T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17); t30_restart(&s->t30); #if defined(LOG_FAX_AUDIO) { diff --git a/libs/spandsp/src/g722.c b/libs/spandsp/src/g722.c index 9a5d49b6c4..1bc84be738 100644 --- a/libs/spandsp/src/g722.c +++ b/libs/spandsp/src/g722.c @@ -28,7 +28,7 @@ * Computer Science, Speech Group * Chengxiang Lu and Alex Hauptmann * - * $Id: g722.c,v 1.9 2009/02/21 04:27:46 steveu Exp $ + * $Id: g722.c,v 1.10 2009/04/22 12:57:40 steveu Exp $ */ /*! \file */ @@ -415,7 +415,8 @@ SPAN_DECLARE(int) g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8 { if (s->eight_k) { - amp[outlen++] = (int16_t) rlow; + /* We shift by 1 to allow for the 15 bit input to the G.722 algorithm. */ + amp[outlen++] = (int16_t) (rlow << 1); } else { @@ -424,8 +425,10 @@ SPAN_DECLARE(int) g722_decode(g722_decode_state_t *s, int16_t amp[], const uint8 s->y[s->ptr] = (int16_t) (rlow - rhigh); if (++s->ptr >= 12) s->ptr = 0; - amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr) >> 12); - amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr) >> 12); + /* We shift by 12 to allow for the QMF filters (DC gain = 4096), less 1 + to allow for the 15 bit input to the G.722 algorithm. */ + amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr) >> 11); + amp[outlen++] = (int16_t) (vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr) >> 11); } } } @@ -511,7 +514,8 @@ SPAN_DECLARE(int) g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const { if (s->eight_k) { - xlow = amp[j++]; + /* We shift by 1 to allow for the 15 bit input to the G.722 algorithm. */ + xlow = amp[j++] >> 1; } else { @@ -522,8 +526,11 @@ SPAN_DECLARE(int) g722_encode(g722_encode_state_t *s, uint8_t g722_data[], const s->ptr = 0; sumodd = vec_circular_dot_prodi16(s->x, qmf_coeffs_fwd, 12, s->ptr); sumeven = vec_circular_dot_prodi16(s->y, qmf_coeffs_rev, 12, s->ptr); - xlow = (int16_t) ((sumeven + sumodd) >> 13); - xhigh = (int16_t) ((sumeven - sumodd) >> 13); + /* We shift by 12 to allow for the QMF filters (DC gain = 4096), plus 1 + to allow for us summing two filters, plus 1 to allow for the 15 bit + input to the G.722 algorithm. */ + xlow = (int16_t) ((sumeven + sumodd) >> 14); + xhigh = (int16_t) ((sumeven - sumodd) >> 14); } } /* Block 1L, SUBTRA */ diff --git a/libs/spandsp/src/libspandsp.2008.sln b/libs/spandsp/src/libspandsp.2008.sln index 257ab1c335..8080dbc12b 100644 --- a/libs/spandsp/src/libspandsp.2008.sln +++ b/libs/spandsp/src/libspandsp.2008.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 +# Visual C++ Express 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_at_dictionary", "msvc\make_at_dictionary.2008.vcproj", "{DEE932AB-5911-4700-9EEB-8C7090A0A330}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_modem_filter", "msvc\make_modem_filter.2008.vcproj", "{329A6FA0-0FCC-4435-A950-E670AEFA9838}" @@ -19,6 +19,41 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtiff", "libtiff.2008.vcp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download TIFF", "msvc\Download_TIFF.2008.vcproj", "{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t38_core_tests", "..\tests\msvc\t38_core_tests.vcproj", "{A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}" + ProjectSection(ProjectDependencies) = postProject + {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "t38_non_ecm_buffer_tests", "..\tests\msvc\t38_non_ecm_buffer_tests.vcproj", "{80A3D9D9-3846-4DA5-8676-F940D725EA62}" + ProjectSection(ProjectDependencies) = postProject + {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vector_int_tests", "..\tests\msvc\vector_int_tests.vcproj", "{80A60464-29E8-4EE8-BAFA-8708B7C08CC3}" + ProjectSection(ProjectDependencies) = postProject + {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vector_float_tests", "..\tests\msvc\vector_float_tests.vcproj", "{EA745FF7-9E4B-4C13-BA19-2EE8165A6245}" + ProjectSection(ProjectDependencies) = postProject + {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "complex_tests", "..\tests\msvc\complex_tests.vcproj", "{A349379F-0FEA-49C8-9535-05F39663337B}" + ProjectSection(ProjectDependencies) = postProject + {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "complex_vector_float_tests", "..\tests\msvc\complex_vector_float_tests.vcproj", "{2B0D705C-1CF2-401C-BFBC-A43FB806908C}" + ProjectSection(ProjectDependencies) = postProject + {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "complex_vector_int_tests", "..\tests\msvc\complex_vector_int_tests.vcproj", "{C2E8B4D1-A398-4D57-94F8-B61F20C7D514}" + ProjectSection(ProjectDependencies) = postProject + {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} = {1CBB0077-18C5-455F-801C-0A0CE7B0BBF5} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All|Win32 = All|Win32 @@ -76,6 +111,69 @@ Global {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.ActiveCfg = All|Win32 {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.Build.0 = All|Win32 {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|x64.ActiveCfg = All|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.All|Win32.ActiveCfg = Release|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.All|Win32.Build.0 = Release|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.All|x64.ActiveCfg = Release|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Debug|Win32.ActiveCfg = Debug|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Debug|Win32.Build.0 = Debug|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Debug|x64.ActiveCfg = Debug|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Release|Win32.ActiveCfg = Release|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Release|Win32.Build.0 = Release|Win32 + {A34A9D0E-A7E2-4A04-B044-7BB2FE709EF3}.Release|x64.ActiveCfg = Release|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.All|Win32.ActiveCfg = Release|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.All|Win32.Build.0 = Release|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.All|x64.ActiveCfg = Release|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Debug|Win32.ActiveCfg = Debug|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Debug|Win32.Build.0 = Debug|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Debug|x64.ActiveCfg = Debug|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Release|Win32.ActiveCfg = Release|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Release|Win32.Build.0 = Release|Win32 + {80A3D9D9-3846-4DA5-8676-F940D725EA62}.Release|x64.ActiveCfg = Release|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.All|Win32.ActiveCfg = Release|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.All|Win32.Build.0 = Release|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.All|x64.ActiveCfg = Release|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Debug|Win32.ActiveCfg = Debug|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Debug|Win32.Build.0 = Debug|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Debug|x64.ActiveCfg = Debug|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Release|Win32.ActiveCfg = Release|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Release|Win32.Build.0 = Release|Win32 + {80A60464-29E8-4EE8-BAFA-8708B7C08CC3}.Release|x64.ActiveCfg = Release|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.All|Win32.ActiveCfg = Release|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.All|Win32.Build.0 = Release|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.All|x64.ActiveCfg = Release|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Debug|Win32.ActiveCfg = Debug|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Debug|Win32.Build.0 = Debug|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Debug|x64.ActiveCfg = Debug|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Release|Win32.ActiveCfg = Release|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Release|Win32.Build.0 = Release|Win32 + {EA745FF7-9E4B-4C13-BA19-2EE8165A6245}.Release|x64.ActiveCfg = Release|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.All|Win32.ActiveCfg = Release|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.All|Win32.Build.0 = Release|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.All|x64.ActiveCfg = Release|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.Debug|Win32.ActiveCfg = Debug|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.Debug|Win32.Build.0 = Debug|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.Debug|x64.ActiveCfg = Debug|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.Release|Win32.ActiveCfg = Release|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.Release|Win32.Build.0 = Release|Win32 + {A349379F-0FEA-49C8-9535-05F39663337B}.Release|x64.ActiveCfg = Release|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.All|Win32.ActiveCfg = Release|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.All|Win32.Build.0 = Release|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.All|x64.ActiveCfg = Release|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Debug|Win32.ActiveCfg = Debug|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Debug|Win32.Build.0 = Debug|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Debug|x64.ActiveCfg = Debug|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Release|Win32.ActiveCfg = Release|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Release|Win32.Build.0 = Release|Win32 + {2B0D705C-1CF2-401C-BFBC-A43FB806908C}.Release|x64.ActiveCfg = Release|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.All|Win32.ActiveCfg = Release|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.All|Win32.Build.0 = Release|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.All|x64.ActiveCfg = Release|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Debug|Win32.ActiveCfg = Debug|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Debug|Win32.Build.0 = Debug|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Debug|x64.ActiveCfg = Debug|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Release|Win32.ActiveCfg = Release|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Release|Win32.Build.0 = Release|Win32 + {C2E8B4D1-A398-4D57-94F8-B61F20C7D514}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/libs/spandsp/src/make_at_dictionary.c b/libs/spandsp/src/make_at_dictionary.c index fcd1253167..6c6f1edc1e 100644 --- a/libs/spandsp/src/make_at_dictionary.c +++ b/libs/spandsp/src/make_at_dictionary.c @@ -23,7 +23,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: make_at_dictionary.c,v 1.2 2009/02/10 17:16:57 steveu Exp $ + * $Id: make_at_dictionary.c,v 1.4 2009/04/24 22:35:25 steveu Exp $ */ #if defined(HAVE_CONFIG_H) @@ -228,6 +228,7 @@ const char *wordlist[] = "+EFRAM", /* V.250 6.5.8 - Frame length */ "+ER", /* V.250 6.5.5 - Error control reporting */ "+ES", /* V.250 6.5.1 - Error control selection */ + "+ESA", /* V.80 8.2 - Synchronous access mode configuration */ "+ESR", /* V.250 6.5.3 - Selective repeat */ "+ETBM", /* V.250 6.5.6 - Call termination buffer management */ "+EWIND", /* V.250 6.5.7 - Window size */ @@ -289,8 +290,8 @@ const char *wordlist[] = "+GMR", /* V.250 6.1.6 - Request revision identification */ "+GOI", /* V.250 6.1.8 - Request global object identification */ "+GSN", /* V.250 6.1.7 - Request product serial number identification */ - "+IBC", /* TIA-617 8.3 - Control of in-band control */ - "+IBM", /* TIA-617 8.4 - In-Band MARK idle reporting control */ + "+IBC", /* V.80 7.9 - Control of in-band control */ + "+IBM", /* V.80 7.10 - In-band MARK idle reporting control */ "+ICF", /* V.250 6.2.11 - DTE-DCE character framing */ "+ICLOK", /* V.250 6.2.14 - Select sync transmit clock source */ "+IDSR", /* V.250 6.2.16 - Select data set ready option */ @@ -299,6 +300,7 @@ const char *wordlist[] = "+ILSD", /* V.250 6.2.15 - Select long space disconnect option */ "+IPR", /* V.250 6.2.10 - Fixed DTE rate */ "+IRTS", /* V.250 6.2.17 - Select synchronous mode RTS option */ + "+ITF", /* V.80 8.4 - Transmit flow control thresholds */ "+MA", /* V.250 6.4.2 - Modulation automode control */ "+MR", /* V.250 6.4.3 - Modulation reporting control */ "+MS", /* V.250 6.4.1 - Modulation selection */ diff --git a/libs/spandsp/src/spandsp/async.h b/libs/spandsp/src/spandsp/async.h index 4584e13181..50eb6e4455 100644 --- a/libs/spandsp/src/spandsp/async.h +++ b/libs/spandsp/src/spandsp/async.h @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: async.h,v 1.24 2009/02/12 12:38:39 steveu Exp $ + * $Id: async.h,v 1.25 2009/04/23 14:12:34 steveu Exp $ */ /*! \file */ @@ -78,7 +78,11 @@ enum /*! \brief A modem has completed its task, and shut down. */ SIG_STATUS_SHUTDOWN_COMPLETE = -10, /*! \brief Regular octet report for things like HDLC to the MTP standards. */ - SIG_STATUS_OCTET_REPORT = -11 + SIG_STATUS_OCTET_REPORT = -11, + /*! \brief Notification that a modem has detected signal quality degradation. */ + SIG_STATUS_POOR_SIGNAL_QUALITY = -12, + /*! \brief Notification that a modem retrain has occurred. */ + SIG_STATUS_MODEM_RETRAIN_OCCURRED = -13 }; /*! Message put function for data pumps */ diff --git a/libs/spandsp/src/spandsp/fax_modems.h b/libs/spandsp/src/spandsp/fax_modems.h index 86c5d5d294..ad48b8f240 100644 --- a/libs/spandsp/src/spandsp/fax_modems.h +++ b/libs/spandsp/src/spandsp/fax_modems.h @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: fax_modems.h,v 1.10 2009/02/14 15:21:14 steveu Exp $ + * $Id: fax_modems.h,v 1.11 2009/04/26 12:55:23 steveu Exp $ */ /*! \file */ @@ -63,6 +63,10 @@ extern "C" SPAN_DECLARE(int) fax_modems_v17_v21_rx(void *user_data, const int16_t amp[], int len); SPAN_DECLARE(int) fax_modems_v27ter_v21_rx(void *user_data, const int16_t amp[], int len); SPAN_DECLARE(int) fax_modems_v29_v21_rx(void *user_data, const int16_t amp[], int len); +SPAN_DECLARE(int) fax_modems_v17_v21_rx_fillin(void *user_data, int len); +SPAN_DECLARE(int) fax_modems_v27ter_v21_rx_fillin(void *user_data, int len); +SPAN_DECLARE(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len); +SPAN_DECLARE(void) fax_modems_start_rx_modem(fax_modems_state_t *s, int which); SPAN_DECLARE(void) fax_modems_set_tep_mode(fax_modems_state_t *s, int use_tep); diff --git a/libs/spandsp/src/spandsp/private/v22bis.h b/libs/spandsp/src/spandsp/private/v22bis.h index ea18035d0a..da22616ad1 100644 --- a/libs/spandsp/src/spandsp/private/v22bis.h +++ b/libs/spandsp/src/spandsp/private/v22bis.h @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v22bis.h,v 1.4 2009/04/17 14:37:53 steveu Exp $ + * $Id: v22bis.h,v 1.9 2009/04/26 09:50:28 steveu Exp $ */ #if !defined(_SPANDSP_PRIVATE_V22BIS_H_) @@ -34,22 +34,26 @@ */ struct v22bis_state_s { - /*! \brief The bit rate of the modem. Valid values are 1200 and 2400. */ + /*! \brief The maximum permitted bit rate of the modem. Valid values are 1200 and 2400. */ int bit_rate; /*! \brief TRUE is this is the calling side modem. */ int caller; - /*! \brief The callback function used to put each bit received. */ - put_bit_func_t put_bit; /*! \brief The callback function used to get the next bit to be transmitted. */ get_bit_func_t get_bit; - /*! \brief A user specified opaque pointer passed to the callback routines. */ - void *user_data; + /*! \brief A user specified opaque pointer passed to the get_bit callback routine. */ + void *get_bit_user_data; + /*! \brief The callback function used to put each bit received. */ + put_bit_func_t put_bit; + /*! \brief A user specified opaque pointer passed to the put_bit callback routine. */ + void *put_bit_user_data; /*! \brief The callback function used to report modem status changes. */ modem_rx_status_func_t status_handler; /*! \brief A user specified opaque pointer passed to the status function. */ void *status_user_data; - /* RECEIVE SECTION */ + int negotiated_bit_rate; + + /* Receive section */ struct { /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ @@ -84,8 +88,6 @@ struct v22bis_state_s /*! \brief The integral part of the carrier tracking filter. */ float carrier_track_i; - int scrambled_ones_to_date; - /*! \brief A callback function which may be enabled to report every symbol's constellation position. */ qam_report_handler_t qam_report; @@ -132,12 +134,11 @@ struct v22bis_state_s int sixteen_way_decisions; - int detected_unscrambled_ones; - int detected_unscrambled_zeros; - int detected_2400bps_markers; + int pattern_repeats; + int last_raw_bits; } rx; - /* TRANSMIT SECTION */ + /* Transmit section */ struct { /*! \brief The gain factor needed to achieve the specified output power. */ @@ -181,5 +182,22 @@ struct v22bis_state_s logging_state_t logging; }; +#if defined(__cplusplus) +extern "C" +{ +#endif + +/*! Reinitialise an existing V.22bis modem receive context. + \brief Reinitialise an existing V.22bis modem receive context. + \param s The modem context. + \return 0 for OK, -1 for bad parameter */ +int v22bis_rx_restart(v22bis_state_t *s); + +void v22bis_report_status_change(v22bis_state_t *s, int status); + +#if defined(__cplusplus) +} +#endif + #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/spandsp/v22bis.h b/libs/spandsp/src/spandsp/v22bis.h index 19fc787b77..0ec9666100 100644 --- a/libs/spandsp/src/spandsp/v22bis.h +++ b/libs/spandsp/src/spandsp/v22bis.h @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v22bis.h,v 1.39 2009/04/17 14:37:53 steveu Exp $ + * $Id: v22bis.h,v 1.41 2009/04/25 10:18:50 steveu Exp $ */ /*! \file */ @@ -81,13 +81,6 @@ extern "C" { #endif -/*! Reinitialise an existing V.22bis modem receive context. - \brief Reinitialise an existing V.22bis modem receive context. - \param s The modem context. - \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400. - \return 0 for OK, -1 for bad parameter */ -SPAN_DECLARE(int) v22bis_rx_restart(v22bis_state_t *s, int bit_rate); - /*! Process a block of received V.22bis modem audio samples. \brief Process a block of received V.22bis modem audio samples. \param s The modem context. @@ -108,7 +101,7 @@ SPAN_DECLARE(int) v22bis_rx_fillin(v22bis_state_t *s, int len); \brief Get a snapshot of the current equalizer coefficients. \param coeffs The vector of complex coefficients. \return The number of coefficients in the vector. */ -SPAN_DECLARE(int) v22bis_equalizer_state(v22bis_state_t *s, complexf_t **coeffs); +SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexf_t **coeffs); /*! Get the current received carrier frequency. \param s The modem context. @@ -118,7 +111,7 @@ SPAN_DECLARE(float) v22bis_rx_carrier_frequency(v22bis_state_t *s); /*! Get the current symbol timing correction since startup. \param s The modem context. \return The correction. */ -SPAN_DECLARE(float) v22bis_symbol_timing_correction(v22bis_state_t *s); +SPAN_DECLARE(float) v22bis_rx_symbol_timing_correction(v22bis_state_t *s); /*! Get a current received signal power. \param s The modem context. @@ -134,7 +127,7 @@ SPAN_DECLARE(void) v22bis_rx_signal_cutoff(v22bis_state_t *s, float cutoff); \param s The modem context. \param handler The handler routine. \param user_data An opaque pointer passed to the handler routine. */ -SPAN_DECLARE(void) v22bis_set_qam_report_handler(v22bis_state_t *s, qam_report_handler_t handler, void *user_data); +SPAN_DECLARE(void) v22bis_rx_set_qam_report_handler(v22bis_state_t *s, qam_report_handler_t handler, void *user_data); /*! Generate a block of V.22bis modem audio samples. \brief Generate a block of V.22bis modem audio samples. @@ -157,6 +150,18 @@ SPAN_DECLARE(void) v22bis_tx_power(v22bis_state_t *s, float power); \return 0 for OK, -1 for bad parameter. */ SPAN_DECLARE(int) v22bis_restart(v22bis_state_t *s, int bit_rate); +/*! Request a retrain for a V.22bis modem context. A rate change may also be resquested. + \brief Request a retrain for a V.22bis modem context. + \param s The modem context. + \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400. + \return 0 for OK, -1 for bad parameter. */ +SPAN_DECLARE(int) v22bis_request_retrain(v22bis_state_t *s, int bit_rate); + +/*! Report the current operating bit rate of a V.22bis modem context. + \brief Report the current operating bit rate of a V.22bis modem context + \param s The modem context. */ +SPAN_DECLARE(int) v22bis_current_bit_rate(v22bis_state_t *s); + /*! Initialise a V.22bis modem context. This must be called before the first use of the context, to initialise its contents. \brief Initialise a V.22bis modem context. @@ -173,8 +178,9 @@ SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s, int guard, int caller, get_bit_func_t get_bit, + void *get_bit_user_data, put_bit_func_t put_bit, - void *user_data); + void *put_bit_user_data); /*! Release a V.22bis modem receive context. \brief Release a V.22bis modem receive context. diff --git a/libs/spandsp/src/spandsp/version.h b/libs/spandsp/src/spandsp/version.h index 9fb4a038ea..aeefbf54ba 100644 --- a/libs/spandsp/src/spandsp/version.h +++ b/libs/spandsp/src/spandsp/version.h @@ -30,9 +30,9 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20090420 -#define SPANDSP_RELEASE_TIME 163808 -#define SPANDSP_RELEASE_DATETIME_STRING "20090420 163808" +#define SPANDSP_RELEASE_DATE 20090427 +#define SPANDSP_RELEASE_TIME 151958 +#define SPANDSP_RELEASE_DATETIME_STRING "20090427 151958" #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index b673bb8b62..c702e9ba79 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t30.c,v 1.290 2009/04/16 12:11:54 steveu Exp $ + * $Id: t30.c,v 1.291 2009/04/23 15:40:32 steveu Exp $ */ /*! \file */ @@ -5914,7 +5914,7 @@ SPAN_DECLARE(t30_state_t *) t30_init(t30_state_t *s, s->send_hdlc_user_data = send_hdlc_user_data; /* Default to the basic modems. */ - s->supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29; + s->supported_modems = T30_SUPPORT_V27TER | T30_SUPPORT_V29 | T30_SUPPORT_V17; s->supported_compressions = T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION; s->supported_resolutions = T30_SUPPORT_STANDARD_RESOLUTION | T30_SUPPORT_FINE_RESOLUTION | T30_SUPPORT_SUPERFINE_RESOLUTION | T30_SUPPORT_R8_RESOLUTION; diff --git a/libs/spandsp/src/v17rx.c b/libs/spandsp/src/v17rx.c index d706da13c4..7b02958075 100644 --- a/libs/spandsp/src/v17rx.c +++ b/libs/spandsp/src/v17rx.c @@ -23,7 +23,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v17rx.c,v 1.145 2009/04/20 16:36:36 steveu Exp $ + * $Id: v17rx.c,v 1.146 2009/04/21 13:59:07 steveu Exp $ */ /*! \file */ @@ -1323,6 +1323,16 @@ SPAN_DECLARE(int) v17_rx_restart(v17_rx_state_t *s, int bit_rate, int short_trai SPAN_DECLARE(v17_rx_state_t *) v17_rx_init(v17_rx_state_t *s, int bit_rate, put_bit_func_t put_bit, void *user_data) { + switch (bit_rate) + { + case 14400: + case 12000: + case 9600: + case 7200: + break; + default: + return NULL; + } if (s == NULL) { if ((s = (v17_rx_state_t *) malloc(sizeof(*s))) == NULL) diff --git a/libs/spandsp/src/v17tx.c b/libs/spandsp/src/v17tx.c index c4034c3f02..560591806a 100644 --- a/libs/spandsp/src/v17tx.c +++ b/libs/spandsp/src/v17tx.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v17tx.c,v 1.72 2009/04/12 04:20:01 steveu Exp $ + * $Id: v17tx.c,v 1.73 2009/04/21 13:59:07 steveu Exp $ */ /*! \file */ @@ -400,6 +400,16 @@ SPAN_DECLARE(int) v17_tx_restart(v17_tx_state_t *s, int bit_rate, int tep, int s SPAN_DECLARE(v17_tx_state_t *) v17_tx_init(v17_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data) { + switch (bit_rate) + { + case 14400: + case 12000: + case 9600: + case 7200: + break; + default: + return NULL; + } if (s == NULL) { if ((s = (v17_tx_state_t *) malloc(sizeof(*s))) == NULL) diff --git a/libs/spandsp/src/v18.c b/libs/spandsp/src/v18.c index d6f420124e..4e27144051 100644 --- a/libs/spandsp/src/v18.c +++ b/libs/spandsp/src/v18.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v18.c,v 1.6 2009/04/20 16:36:36 steveu Exp $ + * $Id: v18.c,v 1.7 2009/04/26 07:00:38 steveu Exp $ */ /*! \file */ @@ -113,12 +113,21 @@ static const struct dtmf_to_ascii_s dtmf_to_ascii[] = {"##8", 'W'}, {"##9", 'Z'}, {"##0", ' '}, +#if defined(WIN32) + {"#*1", 'X'}, // (Note 1) 111 1011 + {"#*2", 'X'}, // (Note 1) 111 1100 + {"#*3", 'X'}, // (Note 1) 111 1101 + {"#*4", 'X'}, // (Note 1) 101 1011 + {"#*5", 'X'}, // (Note 1) 101 1100 + {"#*6", 'X'}, // (Note 1) 101 1101 +#else {"#*1", 'æ'}, // (Note 1) 111 1011 {"#*2", 'ø'}, // (Note 1) 111 1100 {"#*3", 'å'}, // (Note 1) 111 1101 {"#*4", 'Æ'}, // (Note 1) 101 1011 {"#*5", 'Ø'}, // (Note 1) 101 1100 {"#*6", 'Å'}, // (Note 1) 101 1101 +#endif {"#0", '?'}, {"#1", 'c'}, {"#2", 'f'}, diff --git a/libs/spandsp/src/v22bis_rx.c b/libs/spandsp/src/v22bis_rx.c index 1f3e96cc01..6158026a0f 100644 --- a/libs/spandsp/src/v22bis_rx.c +++ b/libs/spandsp/src/v22bis_rx.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v22bis_rx.c,v 1.56 2009/04/20 12:26:38 steveu Exp $ + * $Id: v22bis_rx.c,v 1.66 2009/04/27 15:18:52 steveu Exp $ */ /*! \file */ @@ -47,11 +47,12 @@ #include "spandsp/telephony.h" #include "spandsp/logging.h" +#include "spandsp/complex.h" #include "spandsp/vector_float.h" +#include "spandsp/complex_vector_float.h" #include "spandsp/async.h" #include "spandsp/power_meter.h" #include "spandsp/arctan2.h" -#include "spandsp/complex.h" #include "spandsp/dds.h" #include "spandsp/complex_filters.h" @@ -108,10 +109,10 @@ enum V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION, V22BIS_RX_TRAINING_STAGE_LOG_PHASE, V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES, + V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES_SUSTAINING, V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200, V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200_SUSTAINING, - V22BIS_RX_TRAINING_STAGE_WAIT_FOR_START_1, - V22BIS_RX_TRAINING_STAGE_WAIT_FOR_START_2, + V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400, V22BIS_RX_TRAINING_STAGE_PARKED }; @@ -158,7 +159,7 @@ SPAN_DECLARE(float) v22bis_rx_carrier_frequency(v22bis_state_t *s) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(float) v22bis_symbol_timing_correction(v22bis_state_t *s) +SPAN_DECLARE(float) v22bis_rx_symbol_timing_correction(v22bis_state_t *s) { return (float) s->rx.total_baud_timing_correction/((float) PULSESHAPER_COEFF_SETS*40.0f/(3.0f*2.0f)); } @@ -177,16 +178,16 @@ SPAN_DECLARE(void) v22bis_rx_signal_cutoff(v22bis_state_t *s, float cutoff) } /*- End of function --------------------------------------------------------*/ -static void report_status_change(v22bis_state_t *s, int status) +void v22bis_report_status_change(v22bis_state_t *s, int status) { if (s->status_handler) s->status_handler(s->status_user_data, status); else if (s->put_bit) - s->put_bit(s->user_data, status); + s->put_bit(s->put_bit_user_data, status); } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v22bis_equalizer_state(v22bis_state_t *s, complexf_t **coeffs) +SPAN_DECLARE(int) v22bis_rx_equalizer_state(v22bis_state_t *s, complexf_t **coeffs) { *coeffs = s->rx.eq_coeff; return 2*V22BIS_EQUALIZER_LEN + 1; @@ -195,31 +196,20 @@ SPAN_DECLARE(int) v22bis_equalizer_state(v22bis_state_t *s, complexf_t **coeffs) static void equalizer_reset(v22bis_state_t *s) { - int i; - /* Start with an equalizer based on everything being perfect */ - for (i = 0; i < 2*V22BIS_EQUALIZER_LEN + 1; i++) - s->rx.eq_coeff[i] = complex_setf(0.0f, 0.0f); +#if defined(SPANDSP_USE_FIXED_POINTx) + cvec_zeroi16(s->rx.eq_coeff, 2*V22BIS_EQUALIZER_LEN + 1); + s->rx.eq_coeff[V22BIS_EQUALIZER_LEN] = complex_seti16(3*FP_FACTOR, 0*FP_FACTOR); + cvec_zeroi16(s->rx.eq_buf, V22BIS_EQUALIZER_MASK + 1); + s->rx.eq_delta = 32768.0f*EQUALIZER_DELTA/(2*V22BIS_EQUALIZER_LEN + 1); +#else + cvec_zerof(s->rx.eq_coeff, 2*V22BIS_EQUALIZER_LEN + 1); s->rx.eq_coeff[V22BIS_EQUALIZER_LEN] = complex_setf(3.0f, 0.0f); - for (i = 0; i <= V22BIS_EQUALIZER_MASK; i++) - s->rx.eq_buf[i] = complex_setf(0.0f, 0.0f); - - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN - 6].re = -0.02f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN - 5].re = 0.035f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN - 4].re = 0.08f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN - 3].re = -0.30f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN - 2].re = -0.37f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN - 1].re = 0.09f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN].re = 3.19f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN + 1].re = 0.09f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN + 2].re = -0.37f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN + 3].re = -0.30f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN + 5].re = 0.035f; - s->rx.eq_coeff[V22BIS_EQUALIZER_LEN + 6].re = -0.02f; - + cvec_zerof(s->rx.eq_buf, V22BIS_EQUALIZER_MASK + 1); + s->rx.eq_delta = EQUALIZER_DELTA/(2*V22BIS_EQUALIZER_LEN + 1); +#endif s->rx.eq_put_step = 20 - 1; s->rx.eq_step = 0; - s->rx.eq_delta = EQUALIZER_DELTA/(2*V22BIS_EQUALIZER_LEN + 1); } /*- End of function --------------------------------------------------------*/ @@ -291,7 +281,9 @@ static __inline__ int descramble(v22bis_state_t *s, int bit) bit &= 1; /* Descramble the bit */ - out_bit = (bit ^ (s->rx.scramble_reg >> 14) ^ (s->rx.scramble_reg >> 17)) & 1; + out_bit = (bit ^ (s->rx.scramble_reg >> 13) ^ (s->rx.scramble_reg >> 16)) & 1; + s->rx.scramble_reg = (s->rx.scramble_reg << 1) | bit; + if (s->rx.scrambler_pattern_count >= 64) { out_bit ^= 1; @@ -301,7 +293,6 @@ static __inline__ int descramble(v22bis_state_t *s, int bit) s->rx.scrambler_pattern_count++; else s->rx.scrambler_pattern_count = 0; - s->rx.scramble_reg = (s->rx.scramble_reg << 1) | bit; return out_bit; } /*- End of function --------------------------------------------------------*/ @@ -312,7 +303,7 @@ static __inline__ void put_bit(v22bis_state_t *s, int bit) /* Descramble the bit */ out_bit = descramble(s, bit); - s->put_bit(s->user_data, out_bit); + s->put_bit(s->put_bit_user_data, out_bit); } /*- End of function --------------------------------------------------------*/ @@ -321,16 +312,16 @@ static void decode_baud(v22bis_state_t *s, int nearest) int raw_bits; raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3]; + s->rx.constellation_state = nearest; /* The first two bits are the quadrant */ put_bit(s, raw_bits >> 1); put_bit(s, raw_bits); - if (s->bit_rate == 2400) + if (s->rx.sixteen_way_decisions) { /* The other two bits are the position within the quadrant */ put_bit(s, nearest >> 1); put_bit(s, nearest); } - s->rx.constellation_state = nearest; } /*- End of function --------------------------------------------------------*/ @@ -340,16 +331,16 @@ static int decode_baudx(v22bis_state_t *s, int nearest) int out_bits; raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3]; + s->rx.constellation_state = nearest; /* The first two bits are the quadrant */ out_bits = descramble(s, raw_bits >> 1); out_bits = (out_bits << 1) | descramble(s, raw_bits); - if (s->bit_rate == 2400) + if (s->rx.sixteen_way_decisions) { /* The other two bits are the position within the quadrant */ out_bits = (out_bits << 1) | descramble(s, nearest >> 1); out_bits = (out_bits << 1) | descramble(s, nearest); } - s->rx.constellation_state = nearest; return out_bits; } /*- End of function --------------------------------------------------------*/ @@ -443,7 +434,7 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) when the true symbol boundary is close to a sample boundary. */ s->rx.eq_put_step += (s->rx.gardner_integrate/16); s->rx.total_baud_timing_correction += (s->rx.gardner_integrate/16); -//span_log(&s->logging, SPAN_LOG_FLOW, "Gardner kick %d [total %d]\n", s->rx.gardner_integrate, s->rx.total_baud_timing_correction); + //span_log(&s->logging, SPAN_LOG_FLOW, "Gardner kick %d [total %d]\n", s->rx.gardner_integrate, s->rx.total_baud_timing_correction); if (s->rx.qam_report) s->rx.qam_report(s->rx.qam_user_data, NULL, NULL, s->rx.gardner_integrate); s->rx.gardner_integrate = 0; @@ -451,7 +442,6 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) z = equalizer_get(s); -//span_log(&s->logging, SPAN_LOG_FLOW, "VVV %p %d\n", s->user_data, s->rx.training); if (s->rx.sixteen_way_decisions) { re = (int) (z.re + 3.0f); @@ -468,20 +458,20 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) } else { - zz = complex_setf(3.0f/sqrtf(10.0f), -1.0f/sqrtf(10.0f)); + zz = complex_setf(3.0f/3.162278f, -1.0f/3.162278f); zz = complex_mulf(&z, &zz); nearest = (find_quadrant(&zz) << 2) | 0x01; - printf("Trackit rx %p %15.5f %15.5f %15.5f %15.5f %d\n", s, z.re, z.im, zz.re, zz.im, nearest); } + raw_bits = 0; switch (s->rx.training) { case V22BIS_RX_TRAINING_STAGE_NORMAL_OPERATION: /* Normal operation. */ - track_carrier(s, &z, &v22bis_constellation[nearest]); - tune_equalizer(s, &z, &v22bis_constellation[nearest]); + target = &v22bis_constellation[nearest]; + track_carrier(s, &z, target); + tune_equalizer(s, &z, target); decode_baud(s, nearest); - target = &v22bis_constellation[s->rx.constellation_state]; break; case V22BIS_RX_TRAINING_STAGE_SYMBOL_ACQUISITION: /* Allow time for the Gardner algorithm to settle the symbol timing. */ @@ -494,13 +484,13 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) but since we might be off in the opposite direction from the source, the total error could be higher. */ s->rx.gardner_step = 4; - s->rx.detected_unscrambled_zeros = 0; - s->rx.detected_unscrambled_ones = 0; - s->rx.detected_2400bps_markers = 0; + s->rx.pattern_repeats = 0; if (s->caller) s->rx.training = V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES; else s->rx.training = V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200; + /* Be pessimistic and see what the handshake brings */ + s->negotiated_bit_rate = 1200; break; } /* Once we have pulled in the symbol timing in a coarse way, use finer @@ -511,29 +501,25 @@ static void process_half_baud(v22bis_state_t *s, const complexf_t *sample) case V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES: /* Calling modem only */ /* The calling modem should initially receive unscrambled ones at 1200bps */ - track_carrier(s, &z, &v22bis_constellation[nearest]); - target = &z; + target = &v22bis_constellation[nearest]; + track_carrier(s, &z, target); raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3]; s->rx.constellation_state = nearest; - switch (raw_bits) - { - case 0: - s->rx.detected_unscrambled_zeros++; - break; - case 3: - s->rx.detected_unscrambled_ones++; - break; - default: - s->rx.detected_2400bps_markers++; - break; - } -span_log(&s->logging, SPAN_LOG_FLOW, "TWIDDLING THUMBS - %d %d\n", s->rx.training_count, s->rx.detected_2400bps_markers); + if (raw_bits != s->rx.last_raw_bits) + s->rx.pattern_repeats = 0; + else + s->rx.pattern_repeats++; if (++s->rx.training_count == ms_to_symbols(155 + 456)) { - if (s->rx.detected_unscrambled_ones >= ms_to_symbols(456) - || - s->rx.detected_unscrambled_zeros >= ms_to_symbols(456)) + /* After the first 155ms things should have been steady, so check if the last 456ms was + steady at 11 or 00. */ + if (raw_bits == s->rx.last_raw_bits + && + (raw_bits == 0x3 || raw_bits == 0x0) + && + s->rx.pattern_repeats >= ms_to_symbols(456)) { + /* It looks like the answering machine is sending us a clean unscrambled 11 or 00 */ if (s->bit_rate == 2400) { /* Try to establish at 2400bps */ @@ -544,127 +530,147 @@ span_log(&s->logging, SPAN_LOG_FLOW, "TWIDDLING THUMBS - %d %d\n", s->rx.trainin else { /* Only try to establish at 1200bps */ - span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S11 (Caller)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; + span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S11 (1200) (Caller)\n"); + s->tx.training = V22BIS_TX_TRAINING_STAGE_S11; s->tx.training_count = 0; } } -span_log(&s->logging, SPAN_LOG_FLOW, "unscrambled ones = %d, unscrambled zeros = %d, 2400 markers = %d\n", s->rx.detected_unscrambled_ones, s->rx.detected_unscrambled_zeros, s->rx.detected_2400bps_markers); + s->rx.pattern_repeats = 0; + s->rx.training_count = 0; + s->rx.training = V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES_SUSTAINING; + } + break; + case V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES_SUSTAINING: + /* Calling modem only */ + /* Wait for the end of the unscrambled ones at 1200bps */ + target = &v22bis_constellation[nearest]; + track_carrier(s, &z, target); + raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3]; + s->rx.constellation_state = nearest; + if (raw_bits != s->rx.last_raw_bits) + { + /* This looks like the end of the sustained initial unscrambled 11 or 00 */ + s->tx.training_count = 0; + s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; s->rx.training_count = 0; s->rx.training = V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200; - s->rx.detected_unscrambled_zeros = 0; - s->rx.detected_unscrambled_ones = 0; - s->rx.detected_2400bps_markers = 0; - s->rx.scrambled_ones_to_date = 0; + s->rx.pattern_repeats = 0; } break; case V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200: - track_carrier(s, &z, &v22bis_constellation[nearest]); - tune_equalizer(s, &z, &v22bis_constellation[nearest]); - target = &z; + target = &v22bis_constellation[nearest]; + track_carrier(s, &z, target); + tune_equalizer(s, &z, target); raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3]; - switch (raw_bits) - { - case 0: - s->rx.detected_unscrambled_zeros++; - break; - case 3: - s->rx.detected_unscrambled_ones++; - break; - default: - s->rx.detected_2400bps_markers++; - break; - } bitstream = decode_baudx(s, nearest); - s->rx.scrambled_ones_to_date += ones[bitstream]; -span_log(&s->logging, SPAN_LOG_FLOW, "S11 0x%02x 0x%02x 0x%X %d %d %d %d %d %d\n", raw_bits, nearest, bitstream, s->rx.scrambled_ones_to_date, s->rx.detected_unscrambled_ones, s->rx.detected_unscrambled_zeros, s->rx.detected_2400bps_markers, s->rx.training_count, s->rx.detected_2400bps_markers); - if (s->rx.detected_2400bps_markers && ++s->rx.training_count > ms_to_symbols(270)) + s->rx.training_count++; +//span_log(&s->logging, SPAN_LOG_FLOW, "S11 0x%02x 0x%02x 0x%X %d %d %d %d %d\n", raw_bits, nearest, bitstream, s->rx.scrambled_ones_to_date, 0, 0, 0, s->rx.training_count); + if (s->negotiated_bit_rate == 1200) { - if (!s->caller) + /* Search for the S1 signal */ + if ((s->rx.last_raw_bits ^ raw_bits) == 0x3) { - if (s->bit_rate == 2400 && s->rx.detected_2400bps_markers > 20) + s->rx.pattern_repeats++; + } + else + { + if (s->rx.pattern_repeats >= 15 && (s->rx.last_raw_bits == 0x3 || s->rx.last_raw_bits == 0x0)) { - /* Try to establish at 2400bps */ - span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting U0011 (S1) (Answerer)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_U0011; + /* We should get a full run of 00 11 (about 60 bauds) at the calling modem, but only about 20 + at the answering modem, as the first 40 are TED settling time. */ + span_log(&s->logging, SPAN_LOG_FLOW, "+++ S1 detected at %d\n", s->rx.pattern_repeats); + if (s->bit_rate == 2400) + { + if (!s->caller) + { + /* Accept establishment at 2400bps */ + span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting U0011 (S1) (Answerer)\n"); + s->tx.training = V22BIS_TX_TRAINING_STAGE_U0011; + s->tx.training_count = 0; + } + s->negotiated_bit_rate = 2400; + } + } + s->rx.pattern_repeats = 0; + } + if (s->rx.training_count >= ms_to_symbols(270)) + { + /* If we haven't seen the S1 signal by now, we are committed to be in 1200bps mode */ + if (s->caller) + { + span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (1200)\n"); + /* The transmit side needs to sustain the scrambled ones for a timed period */ s->tx.training_count = 0; + s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; + /* Normal reception starts immediately */ + s->rx.training = V22BIS_RX_TRAINING_STAGE_NORMAL_OPERATION; + s->rx.carrier_track_i = 8000.0f; } else { - /* We are going to work at 1200bps. */ - span_log(&s->logging, SPAN_LOG_FLOW, "+++ [1200] starting S11 (Answerer)\n"); - s->bit_rate = 1200; - s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; + span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S11 (1200) (Answerer)\n"); + /* The transmit side needs to sustain the scrambled ones for a timed period */ s->tx.training_count = 0; + s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; + /* The receive side needs to wait a timed period, receiving scrambled ones, + before entering normal operation. */ + s->rx.training = V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200_SUSTAINING; } } - s->rx.training = V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200_SUSTAINING; } - break; - case V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200_SUSTAINING: - track_carrier(s, &z, &v22bis_constellation[nearest]); - tune_equalizer(s, &z, &v22bis_constellation[nearest]); - target = &z; - raw_bits = phase_steps[((nearest >> 2) - (s->rx.constellation_state >> 2)) & 3]; - switch (raw_bits) - { - case 0: - s->rx.detected_unscrambled_zeros++; - break; - case 3: - s->rx.detected_unscrambled_ones++; - break; - default: - s->rx.detected_2400bps_markers++; - break; - } - bitstream = decode_baudx(s, nearest); - s->rx.scrambled_ones_to_date += ones[bitstream]; -span_log(&s->logging, SPAN_LOG_FLOW, "S11 0x%02x 0x%02x 0x%X %d %d %d %d %d sustain\n", raw_bits, nearest, bitstream, s->rx.scrambled_ones_to_date, s->rx.detected_unscrambled_ones, s->rx.detected_unscrambled_zeros, s->rx.detected_2400bps_markers, s->rx.training_count); - if (s->rx.detected_2400bps_markers == 20) - { - /* It looks like we have the S1 (Unscrambled 00 11) section, so 2400bps - operation is possible. */ - s->rx.detected_2400bps_markers++; - if (s->bit_rate == 2400) - { - /* We are allowed to use 2400bps, and the far end is requesting 2400bps. Result: we are going to - work at 2400bps */ - span_log(&s->logging, SPAN_LOG_FLOW, "+++ [2400] starting U0011 (S1)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_U0011; - s->tx.training_count = 0; - } - } - if (++s->rx.training_count > ms_to_symbols(270 + 765)) + else { if (s->caller) { - if (s->bit_rate == 2400) + if (s->rx.training_count >= ms_to_symbols(100 + 450)) { - /* We've continued for a further 756+-10ms. This should have given the other - side enough time to train its equaliser. */ - span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S1111 (B)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_S1111; - s->tx.training_count = 0; - } - else - { - span_log(&s->logging, SPAN_LOG_FLOW, "+++ Tx normal operation (1200)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_NORMAL_OPERATION; - s->tx.training_count = 0; - s->tx.current_get_bit = s->get_bit; + span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting 16 way decisions (caller)\n"); + s->rx.sixteen_way_decisions = TRUE; + s->rx.training = V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400; + s->rx.pattern_repeats = 0; + s->rx.carrier_track_i = 8000.0f; } } - if (s->bit_rate == 2400) - span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (2400)\n"); else - span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (1200)\n"); + { + if (s->rx.training_count >= ms_to_symbols(450)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting 16 way decisions (answerer)\n"); + s->rx.sixteen_way_decisions = TRUE; + s->rx.training = V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400; + s->rx.pattern_repeats = 0; + } + } + } + break; + case V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200_SUSTAINING: + target = &v22bis_constellation[nearest]; + track_carrier(s, &z, target); + tune_equalizer(s, &z, target); + bitstream = decode_baudx(s, nearest); + if (++s->rx.training_count > ms_to_symbols(270 + 765)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (1200)\n"); s->rx.training = V22BIS_RX_TRAINING_STAGE_NORMAL_OPERATION; } - if (s->bit_rate == 2400 && s->rx.training_count == ms_to_symbols(450)) + break; + case V22BIS_RX_TRAINING_STAGE_WAIT_FOR_SCRAMBLED_ONES_AT_2400: + target = &v22bis_constellation[nearest]; + track_carrier(s, &z, target); + tune_equalizer(s, &z, target); + bitstream = decode_baudx(s, nearest); + /* We need 32 sustained 1's to switch into normal operation. */ + if (bitstream == 0xF) { - span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting 16 way decisions\n"); - s->rx.sixteen_way_decisions = TRUE; + if (++s->rx.pattern_repeats >= 9) + { + span_log(&s->logging, SPAN_LOG_FLOW, "+++ Rx normal operation (2400)\n"); + s->rx.training = V22BIS_RX_TRAINING_STAGE_NORMAL_OPERATION; + } + } + else + { + s->rx.pattern_repeats = 0; } break; case V22BIS_RX_TRAINING_STAGE_PARKED: @@ -674,6 +680,7 @@ span_log(&s->logging, SPAN_LOG_FLOW, "S11 0x%02x 0x%02x 0x%X %d %d %d %d %d sust target = &z; break; } + s->rx.last_raw_bits = raw_bits; if (s->rx.qam_report) s->rx.qam_report(s->rx.qam_user_data, &z, target, s->rx.constellation_state); } @@ -721,8 +728,8 @@ SPAN_DECLARE(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int len) /* Look for power below the carrier off point */ if (power < s->rx.carrier_off_power) { - v22bis_rx_restart(s, s->bit_rate); - report_status_change(s, SIG_STATUS_CARRIER_DOWN); + v22bis_restart(s, s->bit_rate); + v22bis_report_status_change(s, SIG_STATUS_CARRIER_DOWN); continue; } } @@ -732,7 +739,7 @@ SPAN_DECLARE(int) v22bis_rx(v22bis_state_t *s, const int16_t amp[], int len) if (power < s->rx.carrier_on_power) continue; s->rx.signal_present = TRUE; - report_status_change(s, SIG_STATUS_CARRIER_UP); + v22bis_report_status_change(s, SIG_STATUS_CARRIER_UP); } if (s->rx.training != V22BIS_RX_TRAINING_STAGE_PARKED) { @@ -813,11 +820,8 @@ SPAN_DECLARE(int) v22bis_rx_fillin(v22bis_state_t *s, int len) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) v22bis_rx_restart(v22bis_state_t *s, int bit_rate) +int v22bis_rx_restart(v22bis_state_t *s) { - /* If bit_rate is 2400, the real bit rate is negotiated. If bit_rate - is 1200, the real bit rate is forced to 1200. */ - s->bit_rate = bit_rate; vec_zerof(s->rx.rrc_filter, sizeof(s->rx.rrc_filter)/sizeof(s->rx.rrc_filter[0])); s->rx.rrc_filter_step = 0; s->rx.scramble_reg = 0; @@ -837,19 +841,24 @@ SPAN_DECLARE(int) v22bis_rx_restart(v22bis_state_t *s, int bit_rate) equalizer_reset(s); - s->rx.detected_unscrambled_ones = 0; - s->rx.detected_unscrambled_zeros = 0; - s->rx.detected_2400bps_markers = 0; + s->rx.pattern_repeats = 0; + s->rx.last_raw_bits = 0; s->rx.gardner_integrate = 0; s->rx.gardner_step = 256; s->rx.baud_phase = 0; - s->rx.carrier_track_i = 8000.0f; + s->rx.training_error = 0.0f; + s->rx.total_baud_timing_correction = 0; + /* We want the carrier to pull in faster on the answerer side, as it has very little time to adapt. */ + s->rx.carrier_track_i = (s->caller) ? 8000.0f : 40000.0f; s->rx.carrier_track_p = 8000000.0f; + + s->negotiated_bit_rate = 1200; + return 0; } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) v22bis_set_qam_report_handler(v22bis_state_t *s, qam_report_handler_t handler, void *user_data) +SPAN_DECLARE(void) v22bis_rx_set_qam_report_handler(v22bis_state_t *s, qam_report_handler_t handler, void *user_data) { s->rx.qam_report = handler; s->rx.qam_user_data = user_data; diff --git a/libs/spandsp/src/v22bis_tx.c b/libs/spandsp/src/v22bis_tx.c index 63a0547b2d..96fb35e310 100644 --- a/libs/spandsp/src/v22bis_tx.c +++ b/libs/spandsp/src/v22bis_tx.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v22bis_tx.c,v 1.56 2009/04/17 14:37:52 steveu Exp $ + * $Id: v22bis_tx.c,v 1.61 2009/04/25 10:18:50 steveu Exp $ */ /*! \file */ @@ -294,12 +294,13 @@ static __inline__ int scramble(v22bis_state_t *s, int bit) bit ^= 1; s->tx.scrambler_pattern_count = 0; } - out_bit = (bit ^ (s->tx.scramble_reg >> 14) ^ (s->tx.scramble_reg >> 17)) & 1; + out_bit = (bit ^ (s->tx.scramble_reg >> 13) ^ (s->tx.scramble_reg >> 16)) & 1; + s->tx.scramble_reg = (s->tx.scramble_reg << 1) | out_bit; + if (out_bit == 1) s->tx.scrambler_pattern_count++; else s->tx.scrambler_pattern_count = 0; - s->tx.scramble_reg = (s->tx.scramble_reg << 1) | out_bit; return out_bit; } /*- End of function --------------------------------------------------------*/ @@ -308,7 +309,7 @@ static __inline__ int get_scrambled_bit(v22bis_state_t *s) { int bit; - if ((bit = s->tx.current_get_bit(s->user_data)) == SIG_STATUS_END_OF_DATA) + if ((bit = s->tx.current_get_bit(s->get_bit_user_data)) == SIG_STATUS_END_OF_DATA) { /* Fill out this symbol with ones, and prepare to send the rest of the shutdown sequence. */ @@ -334,8 +335,8 @@ static complexf_t training_get(v22bis_state_t *s) { /* Initial 75ms of silence is over */ span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting U11 1200\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_U11; s->tx.training_count = 0; + s->tx.training = V22BIS_TX_TRAINING_STAGE_U11; } /* Fall through */ case V22BIS_TX_TRAINING_STAGE_INITIAL_SILENCE: @@ -353,37 +354,40 @@ static complexf_t training_get(v22bis_state_t *s) /* Continuous unscrambled double dibit 00 11 at 1200bps. This is termed the S1 segment in the V.22bis spec. It is only sent to request or accept 2400bps mode, and lasts 100+-3ms. After this timed burst, we unconditionally change to sending scrambled ones at 1200bps. */ - s->tx.constellation_state = (s->tx.constellation_state + phase_steps[(s->tx.training_count & 1) ? 3 : 0]) & 3; + s->tx.constellation_state = (s->tx.constellation_state + phase_steps[3*(s->tx.training_count & 1)]) & 3; z = v22bis_constellation[(s->tx.constellation_state << 2) | 0x01]; if (++s->tx.training_count >= ms_to_symbols(100)) { span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S11 after U0011\n"); if (s->caller) + { + s->tx.training_count = 0; s->tx.training = V22BIS_TX_TRAINING_STAGE_S11; + } else + { + s->tx.training_count = ms_to_symbols(756 - (600 - 100)); s->tx.training = V22BIS_TX_TRAINING_STAGE_TIMED_S11; - s->tx.training_count = 0; + } } break; case V22BIS_TX_TRAINING_STAGE_TIMED_S11: /* A timed period of scrambled ones at 1200bps. */ - if (!s->caller) + if (++s->tx.training_count >= ms_to_symbols(756)) { - if (++s->tx.training_count >= ms_to_symbols(756)) + if (s->negotiated_bit_rate == 2400) { - if (s->bit_rate == 2400) - { - span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S1111 (C)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_S1111; - s->tx.training_count = 0; - } - else - { - span_log(&s->logging, SPAN_LOG_FLOW, "+++ Tx normal operation (1200)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_NORMAL_OPERATION; - s->tx.training_count = 0; - s->tx.current_get_bit = s->get_bit; - } + span_log(&s->logging, SPAN_LOG_FLOW, "+++ starting S1111 (C)\n"); + s->tx.training_count = 0; + s->tx.training = V22BIS_TX_TRAINING_STAGE_S1111; + } + else + { + span_log(&s->logging, SPAN_LOG_FLOW, "+++ Tx normal operation (1200)\n"); + s->tx.training_count = 0; + s->tx.training = V22BIS_TX_TRAINING_STAGE_NORMAL_OPERATION; + v22bis_report_status_change(s, SIG_STATUS_TRAINING_SUCCEEDED); + s->tx.current_get_bit = s->get_bit; } } /* Fall through */ @@ -406,8 +410,9 @@ static complexf_t training_get(v22bis_state_t *s) { /* We have completed training. Now handle some real work. */ span_log(&s->logging, SPAN_LOG_FLOW, "+++ Tx normal operation (2400)\n"); - s->tx.training = V22BIS_TX_TRAINING_STAGE_NORMAL_OPERATION; s->tx.training_count = 0; + s->tx.training = V22BIS_TX_TRAINING_STAGE_NORMAL_OPERATION; + v22bis_report_status_change(s, SIG_STATUS_TRAINING_SUCCEEDED); s->tx.current_get_bit = s->get_bit; } break; @@ -442,7 +447,7 @@ static complexf_t getbaud(v22bis_state_t *s) bits = get_scrambled_bit(s); bits = (bits << 1) | get_scrambled_bit(s); s->tx.constellation_state = (s->tx.constellation_state + phase_steps[bits]) & 3; - if (s->bit_rate == 1200) + if (s->negotiated_bit_rate == 1200) { bits = 0x01; } @@ -525,9 +530,8 @@ SPAN_DECLARE(void) v22bis_tx_power(v22bis_state_t *s, float power) } /*- End of function --------------------------------------------------------*/ -static int v22bis_tx_restart(v22bis_state_t *s, int bit_rate) +static int v22bis_tx_restart(v22bis_state_t *s) { - s->bit_rate = bit_rate; cvec_zerof(s->tx.rrc_filter, sizeof(s->tx.rrc_filter)/sizeof(s->tx.rrc_filter[0])); s->tx.rrc_filter_step = 0; s->tx.scramble_reg = 0; @@ -550,14 +554,14 @@ static int v22bis_tx_restart(v22bis_state_t *s, int bit_rate) SPAN_DECLARE(void) v22bis_set_get_bit(v22bis_state_t *s, get_bit_func_t get_bit, void *user_data) { s->get_bit = get_bit; - s->user_data = user_data; + s->get_bit_user_data = user_data; } /*- End of function --------------------------------------------------------*/ SPAN_DECLARE(void) v22bis_set_put_bit(v22bis_state_t *s, put_bit_func_t put_bit, void *user_data) { s->put_bit = put_bit; - s->user_data = user_data; + s->put_bit_user_data = user_data; } /*- End of function --------------------------------------------------------*/ @@ -576,11 +580,40 @@ SPAN_DECLARE(logging_state_t *) v22bis_get_logging_state(v22bis_state_t *s) SPAN_DECLARE(int) v22bis_restart(v22bis_state_t *s, int bit_rate) { - if (bit_rate != 2400 && bit_rate != 1200) + switch (bit_rate) + { + case 2400: + case 1200: + break; + default: return -1; - if (v22bis_tx_restart(s, bit_rate)) + } + s->bit_rate = bit_rate; + s->negotiated_bit_rate = 1200; + if (v22bis_tx_restart(s)) return -1; - return v22bis_rx_restart(s, bit_rate); + return v22bis_rx_restart(s); +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) v22bis_request_retrain(v22bis_state_t *s, int bit_rate) +{ + switch (bit_rate) + { + case 2400: + case 1200: + break; + default: + return -1; + } + /* TODO: Implement retrain and bit rate change */ + return -1; +} +/*- End of function --------------------------------------------------------*/ + +SPAN_DECLARE(int) v22bis_current_bit_rate(v22bis_state_t *s) +{ + return s->negotiated_bit_rate; } /*- End of function --------------------------------------------------------*/ @@ -589,9 +622,18 @@ SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s, int guard, int caller, get_bit_func_t get_bit, + void *get_bit_user_data, put_bit_func_t put_bit, - void *user_data) + void *put_bit_user_data) { + switch (bit_rate) + { + case 2400: + case 1200: + break; + default: + return NULL; + } if (s == NULL) { if ((s = (v22bis_state_t *) malloc(sizeof(*s))) == NULL) @@ -604,8 +646,9 @@ SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s, s->caller = caller; s->get_bit = get_bit; + s->get_bit_user_data = get_bit_user_data; s->put_bit = put_bit; - s->user_data = user_data; + s->put_bit_user_data = put_bit_user_data; if (s->caller) { diff --git a/libs/spandsp/src/v27ter_rx.c b/libs/spandsp/src/v27ter_rx.c index 1d39d812cb..25f959b019 100644 --- a/libs/spandsp/src/v27ter_rx.c +++ b/libs/spandsp/src/v27ter_rx.c @@ -23,7 +23,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v27ter_rx.c,v 1.125 2009/04/20 16:36:36 steveu Exp $ + * $Id: v27ter_rx.c,v 1.126 2009/04/21 13:59:07 steveu Exp $ */ /*! \file */ @@ -1145,6 +1145,14 @@ SPAN_DECLARE(int) v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_ SPAN_DECLARE(v27ter_rx_state_t *) v27ter_rx_init(v27ter_rx_state_t *s, int bit_rate, put_bit_func_t put_bit, void *user_data) { + switch (bit_rate) + { + case 4800: + case 2400: + break; + default: + return NULL; + } if (s == NULL) { if ((s = (v27ter_rx_state_t *) malloc(sizeof(*s))) == NULL) diff --git a/libs/spandsp/src/v27ter_tx.c b/libs/spandsp/src/v27ter_tx.c index b3c5afc7f2..cca8a8b854 100644 --- a/libs/spandsp/src/v27ter_tx.c +++ b/libs/spandsp/src/v27ter_tx.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v27ter_tx.c,v 1.74 2009/04/12 04:20:01 steveu Exp $ + * $Id: v27ter_tx.c,v 1.75 2009/04/21 13:59:07 steveu Exp $ */ /*! \file */ @@ -412,6 +412,14 @@ SPAN_DECLARE(int) v27ter_tx_restart(v27ter_tx_state_t *s, int bit_rate, int tep) SPAN_DECLARE(v27ter_tx_state_t *) v27ter_tx_init(v27ter_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data) { + switch (bit_rate) + { + case 4800: + case 2400: + break; + default: + return NULL; + } if (s == NULL) { if ((s = (v27ter_tx_state_t *) malloc(sizeof(*s))) == NULL) diff --git a/libs/spandsp/src/v29rx.c b/libs/spandsp/src/v29rx.c index 9b5f98fe1d..0b4944add3 100644 --- a/libs/spandsp/src/v29rx.c +++ b/libs/spandsp/src/v29rx.c @@ -23,7 +23,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v29rx.c,v 1.163 2009/04/20 16:36:36 steveu Exp $ + * $Id: v29rx.c,v 1.164 2009/04/21 13:59:07 steveu Exp $ */ /*! \file */ @@ -1156,14 +1156,22 @@ SPAN_DECLARE(int) v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(v29_rx_state_t *) v29_rx_init(v29_rx_state_t *s, int rate, put_bit_func_t put_bit, void *user_data) +SPAN_DECLARE(v29_rx_state_t *) v29_rx_init(v29_rx_state_t *s, int bit_rate, put_bit_func_t put_bit, void *user_data) { + switch (bit_rate) + { + case 9600: + case 7200: + case 4800: + break; + default: + return NULL; + } if (s == NULL) { if ((s = (v29_rx_state_t *) malloc(sizeof(*s))) == NULL) return NULL; } - memset(s, 0, sizeof(*s)); span_log_init(&s->logging, SPAN_LOG_NONE, NULL); span_log_set_protocol(&s->logging, "V.29 RX"); @@ -1176,7 +1184,7 @@ SPAN_DECLARE(v29_rx_state_t *) v29_rx_init(v29_rx_state_t *s, int rate, put_bit_ /* The thresholds should be on at -26dBm0 and off at -31dBm0 */ v29_rx_signal_cutoff(s, -28.5f); - v29_rx_restart(s, rate, FALSE); + v29_rx_restart(s, bit_rate, FALSE); return s; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v29tx.c b/libs/spandsp/src/v29tx.c index 1347a99a7c..ff1a2f9e8d 100644 --- a/libs/spandsp/src/v29tx.c +++ b/libs/spandsp/src/v29tx.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v29tx.c,v 1.87 2009/04/12 04:20:01 steveu Exp $ + * $Id: v29tx.c,v 1.88 2009/04/21 13:59:07 steveu Exp $ */ /*! \file */ @@ -368,6 +368,15 @@ SPAN_DECLARE(int) v29_tx_restart(v29_tx_state_t *s, int bit_rate, int tep) SPAN_DECLARE(v29_tx_state_t *) v29_tx_init(v29_tx_state_t *s, int bit_rate, int tep, get_bit_func_t get_bit, void *user_data) { + switch (bit_rate) + { + case 9600: + case 7200: + case 4800: + break; + default: + return NULL; + } if (s == NULL) { if ((s = (v29_tx_state_t *) malloc(sizeof(*s))) == NULL) diff --git a/libs/spandsp/tests/Makefile.am b/libs/spandsp/tests/Makefile.am index 373e0b4096..1b2d7174a0 100644 --- a/libs/spandsp/tests/Makefile.am +++ b/libs/spandsp/tests/Makefile.am @@ -16,7 +16,7 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## -## $Id: Makefile.am,v 1.112 2009/04/01 13:22:40 steveu Exp $ +## $Id: Makefile.am,v 1.114 2009/04/26 08:25:37 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS) @@ -25,7 +25,26 @@ LIBS += $(TESTLIBS) noinst_DATA = sound_c1_8k.wav sound_c3_8k.wav -EXTRA_DIST = regression_tests.sh v42bis_tests.sh fax_tests.sh tsb85_tests.sh +EXTRA_DIST = regression_tests.sh \ + v42bis_tests.sh \ + fax_tests.sh \ + tsb85_tests.sh \ + msvc/adsi_tests.vcproj \ + msvc/complex_tests.vcproj \ + msvc/complex_vector_float_tests.vcproj \ + msvc/complex_vector_int_tests.vcproj \ + msvc/dtmf_rx_tests.vcproj \ + msvc/dtmf_tx_tests.vcproj \ + msvc/queue_tests.vcproj \ + msvc/t38_core_tests.vcproj \ + msvc/t38_non_ecm_buffer_tests.vcproj \ + msvc/t38_terminal_tests.vcproj \ + msvc/v22bis_tests.vcproj \ + msvc/v29_tests.vcproj \ + msvc/v8_tests.vcproj \ + msvc/v80_tests.vcproj \ + msvc/vector_float_tests.vcproj \ + msvc/vector_int_tests.vcproj MAINTAINERCLEANFILES = Makefile.in diff --git a/libs/spandsp/tests/adsi_tests.c b/libs/spandsp/tests/adsi_tests.c index eff107332d..bfa93f17c2 100644 --- a/libs/spandsp/tests/adsi_tests.c +++ b/libs/spandsp/tests/adsi_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: adsi_tests.c,v 1.55 2009/04/11 15:16:14 steveu Exp $ + * $Id: adsi_tests.c,v 1.56 2009/04/26 07:24:35 steveu Exp $ */ /*! \page adsi_tests_page ADSI tests @@ -47,7 +47,6 @@ tests, these tests do not include line modelling. #include #include #include -#include #include #include diff --git a/libs/spandsp/tests/at_interpreter_tests.c b/libs/spandsp/tests/at_interpreter_tests.c index 224018395e..99e9fd926a 100644 --- a/libs/spandsp/tests/at_interpreter_tests.c +++ b/libs/spandsp/tests/at_interpreter_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: at_interpreter_tests.c,v 1.20 2008/11/30 05:43:37 steveu Exp $ + * $Id: at_interpreter_tests.c,v 1.22 2009/04/24 22:35:25 steveu Exp $ */ /*! \file */ @@ -221,9 +221,14 @@ static const struct command_response_s general_test_seq[] = {"AT+EB=?\r", "\r\n+EB:\r\n\r\nOK\r\n"}, /* V.250 6.5.2 - Break handling in error control operation */ {"AT+EFCS=?\r", "\r\n+EFCS:(0-2)\r\n\r\nOK\r\n"}, /* V.250 6.5.4 - 32-bit frame check sequence */ {"AT+EFCS?\r", "\r\n+EFCS:0\r\n\r\nOK\r\n"}, - {"AT+EFRAM=?\r", "\r\n+EFRAM:(1-65535),(1-65535)\r\n\r\nOK\r\n"}, /* V.250 6.5.8 - Frame length */ + {"AT+EFRAM=?\r", "\r\n+EFRAM:(1-65535),(1-65535)\r\n\r\nOK\r\n"}, + /* V.250 6.5.8 - Frame length */ {"AT+ER=?\r", "\r\n+ER:(0,1)\r\n\r\nOK\r\n"}, /* V.250 6.5.5 - Error control reporting */ - {"AT+ES\r", "\r\nOK\r\n"}, /* V.250 6.5.1 - Error control selection */ + {"AT+ES=?\r", "\r\n+ES:(0-7),(0-4),(0-9)\r\n\r\nOK\r\n"}, /* V.250 6.5.1 - Error control selection */ + {"AT+ES?\r", "\r\n+ES:0,0,0\r\n\r\nOK\r\n"}, + {"AT+ESA=?\r", "\r\n+ESA:(0-2),(0-1),(0-1),(0-1),(0-2),(0-1),(0-255),(0-255)\r\n\r\nOK\r\n"}, + /* V.80 8.2 - Synchronous access mode configuration */ + {"AT+ESA?\r", "\r\n+ESA:0,0,0,0,0,0,0,0\r\n\r\nOK\r\n"}, {"AT+ESR\r", "\r\nOK\r\n"}, /* V.250 6.5.3 - Selective repeat */ {"AT+ETBM=?\r", "\r\n+ETBM:(0-2),(0-2),(0-30)\r\n\r\nOK\r\n"}, /* T.31 8.5.1 - Adaptive reception control */ {"AT+ETBM?\r", "\r\n+ETBM:0,0\r\n\r\nOK\r\n"}, @@ -264,6 +269,11 @@ static const struct command_response_s general_test_seq[] = {"AT+GMR?\r", "\r\n" VERSION "\r\n\r\nOK\r\n"}, /* V.250 6.1.6 - Request revision identification */ {"AT+GOI\r", "\r\nOK\r\n"}, /* V.250 6.1.8 - Request global object identification */ {"AT+GSN?\r", "\r\n42\r\n\r\nOK\r\n"}, /* V.250 6.1.7 - Request product serial number identification */ + {"AT+IBC=?\r", "\r\n+IBC:(0-2),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0,1),(0.1),(0,1)\r\n\r\nOK\r\n"}, + /* V.80 7.9 - Control of in-band control */ + {"AT+IBC?\r", "\r\n+IBC:0,0,0,0,0,0,0,0,0,0,0,0,0\r\n\r\nOK\r\n"}, + {"AT+IBM=?\r", "\r\n+IBM:(0-7),(0-255),(0-255)\r\n\r\nOK\r\n"}, /* V.80 7.10 - In-band MARK idle reporting control */ + {"AT+IBM?\r", "\r\n+IBM:0,0,0\r\n\r\nOK\r\n"}, {"AT+ICF?\r", "\r\n+ICF:0,0\r\n\r\nOK\r\n"}, /* V.250 6.2.11 - DTE-DCE character framing */ {"AT+ICLOK?\r", "\r\n+ICLOK:0\r\n\r\nOK\r\n"}, /* V.250 6.2.14 - Select sync transmit clock source */ {"AT+IDSR?\r", "\r\n+IDSR:0\r\n\r\nOK\r\n"}, /* V.250 6.2.16 - Select data set ready option */ diff --git a/libs/spandsp/tests/complex_vector_float_tests.c b/libs/spandsp/tests/complex_vector_float_tests.c index 0684f52d3e..05449caca3 100644 --- a/libs/spandsp/tests/complex_vector_float_tests.c +++ b/libs/spandsp/tests/complex_vector_float_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: complex_vector_float_tests.c,v 1.2 2008/10/09 13:25:19 steveu Exp $ + * $Id: complex_vector_float_tests.c,v 1.3 2009/04/26 07:00:39 steveu Exp $ */ #if defined(HAVE_CONFIG_H) @@ -33,7 +33,6 @@ #include #include #include -#include #include "spandsp.h" diff --git a/libs/spandsp/tests/complex_vector_int_tests.c b/libs/spandsp/tests/complex_vector_int_tests.c index 8ee5b090da..5da6a36cee 100644 --- a/libs/spandsp/tests/complex_vector_int_tests.c +++ b/libs/spandsp/tests/complex_vector_int_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: complex_vector_int_tests.c,v 1.1 2008/09/18 12:05:35 steveu Exp $ + * $Id: complex_vector_int_tests.c,v 1.2 2009/04/26 07:00:39 steveu Exp $ */ #if defined(HAVE_CONFIG_H) @@ -33,7 +33,6 @@ #include #include #include -#include #include "spandsp.h" diff --git a/libs/spandsp/tests/fax_utils.c b/libs/spandsp/tests/fax_utils.c index 6219035364..79b3cfe719 100644 --- a/libs/spandsp/tests/fax_utils.c +++ b/libs/spandsp/tests/fax_utils.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: fax_utils.c,v 1.1 2009/02/20 12:34:20 steveu Exp $ + * $Id: fax_utils.c,v 1.2 2009/04/25 14:17:47 steveu Exp $ */ #if defined(HAVE_CONFIG_H) @@ -31,10 +31,8 @@ #include #include -#include #include #include -#include //#if defined(WITH_SPANDSP_INTERNALS) #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES diff --git a/libs/spandsp/tests/g711_tests.c b/libs/spandsp/tests/g711_tests.c index 668ff2a478..73b1ab7ec9 100644 --- a/libs/spandsp/tests/g711_tests.c +++ b/libs/spandsp/tests/g711_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: g711_tests.c,v 1.15 2008/11/30 10:17:31 steveu Exp $ + * $Id: g711_tests.c,v 1.16 2009/04/22 12:57:40 steveu Exp $ */ /*! \page g711_tests_page A-law and u-law conversion tests @@ -38,6 +38,7 @@ #include #include #include +#include #include #include @@ -48,7 +49,11 @@ #include "spandsp.h" #include "spandsp-sim.h" -#define OUT_FILE_NAME "g711.wav" +#define BLOCK_LEN 160 + +#define IN_FILE_NAME "../test-data/local/short_nb_voice.wav" +#define ENCODED_FILE_NAME "g711.g711" +#define OUT_FILE_NAME "post_g711.wav" int16_t amp[65536]; uint8_t ulaw_data[65536]; @@ -57,7 +62,7 @@ uint8_t alaw_data[65536]; const uint8_t alaw_1khz_sine[] = {0x34, 0x21, 0x21, 0x34, 0xB4, 0xA1, 0xA1, 0xB4}; const uint8_t ulaw_1khz_sine[] = {0x1E, 0x0B, 0x0B, 0x1E, 0x9E, 0x8B, 0x8B, 0x9E}; -int main(int argc, char *argv[]) +static void compliance_tests(int log_audio) { AFfilehandle outhandle; power_meter_t power_meter; @@ -73,14 +78,18 @@ int main(int argc, char *argv[]) float worst_ulaw; float tmp; int len; - g711_state_t *encode; + g711_state_t *enc_state; g711_state_t *transcode; - g711_state_t *decode; - - if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE) + g711_state_t *dec_state; + + outhandle = AF_NULL_FILEHANDLE; + if (log_audio) { - fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME); - exit(2); + if ((outhandle = afOpenFile_telephony_write(OUT_FILE_NAME, 1)) == AF_NULL_FILEHANDLE) + { + fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME); + exit(2); + } } printf("Conversion accuracy tests.\n"); @@ -116,14 +125,17 @@ int main(int argc, char *argv[]) } amp[i] = post; } - outframes = afWriteFrames(outhandle, - AF_DEFAULT_TRACK, - amp, - 65536); - if (outframes != 65536) + if (log_audio) { - fprintf(stderr, " Error writing wave file\n"); - exit(2); + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + 65536); + if (outframes != 65536) + { + fprintf(stderr, " Error writing wave file\n"); + exit(2); + } } for (i = 0; i < 65536; i++) { @@ -151,14 +163,17 @@ int main(int argc, char *argv[]) } amp[i] = post; } - outframes = afWriteFrames(outhandle, - AF_DEFAULT_TRACK, - amp, - 65536); - if (outframes != 65536) + if (log_audio) { - fprintf(stderr, " Error writing wave file\n"); - exit(2); + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + 65536); + if (outframes != 65536) + { + fprintf(stderr, " Error writing wave file\n"); + exit(2); + } } } printf("Worst A-law error (ignoring small values) %f%%\n", worst_alaw*100.0); @@ -207,14 +222,17 @@ int main(int argc, char *argv[]) power_meter_update(&power_meter, amp[i]); } printf("Reference u-law 1kHz tone is %fdBm0\n", power_meter_current_dbm0(&power_meter)); - outframes = afWriteFrames(outhandle, - AF_DEFAULT_TRACK, - amp, - 8000); - if (outframes != 8000) + if (log_audio) { - fprintf(stderr, " Error writing wave file\n"); - exit(2); + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + 8000); + if (outframes != 8000) + { + fprintf(stderr, " Error writing wave file\n"); + exit(2); + } } if (0.1f < fabs(power_meter_current_dbm0(&power_meter))) { @@ -228,14 +246,17 @@ int main(int argc, char *argv[]) power_meter_update(&power_meter, amp[i]); } printf("Reference A-law 1kHz tone is %fdBm0\n", power_meter_current_dbm0(&power_meter)); - outframes = afWriteFrames(outhandle, - AF_DEFAULT_TRACK, - amp, - 8000); - if (outframes != 8000) + if (log_audio) { - fprintf(stderr, " Error writing wave file\n"); - exit(2); + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + 8000); + if (outframes != 8000) + { + fprintf(stderr, " Error writing wave file\n"); + exit(2); + } } if (0.1f < fabs(power_meter_current_dbm0(&power_meter))) { @@ -272,16 +293,16 @@ int main(int argc, char *argv[]) } } - encode = g711_init(NULL, G711_ALAW); + enc_state = g711_init(NULL, G711_ALAW); transcode = g711_init(NULL, G711_ALAW); - decode = g711_init(NULL, G711_ULAW); + dec_state = g711_init(NULL, G711_ULAW); len = 65536; for (i = 0; i < len; i++) amp[i] = i - 32768; - len = g711_encode(encode, alaw_data, amp, len); + len = g711_encode(enc_state, alaw_data, amp, len); len = g711_transcode(transcode, ulaw_data, alaw_data, len); - len = g711_decode(decode, amp, ulaw_data, len); + len = g711_decode(dec_state, amp, ulaw_data, len); if (len != 65536) { printf("Block coding gave the wrong length - %d instead of %d\n", len, 65536); @@ -311,17 +332,204 @@ int main(int argc, char *argv[]) } } } - g711_release(encode); + g711_release(enc_state); g711_release(transcode); - g711_release(decode); + g711_release(dec_state); - if (afCloseFile(outhandle)) + if (log_audio) { - fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME); - exit(2); + if (afCloseFile(outhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME); + exit(2); + } } printf("Tests passed.\n"); +} +/*- End of function --------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + AFfilehandle inhandle; + AFfilehandle outhandle; + int outframes; + int opt; + int samples; + int len2; + int len3; + int basic_tests; + int law; + int encode; + int decode; + int file; + const char *in_file; + const char *out_file; + g711_state_t *enc_state; + g711_state_t *dec_state; + int16_t indata[BLOCK_LEN]; + int16_t outdata[BLOCK_LEN]; + uint8_t g711data[BLOCK_LEN]; + + basic_tests = TRUE; + law = G711_ALAW; + encode = FALSE; + decode = FALSE; + in_file = NULL; + out_file = NULL; + while ((opt = getopt(argc, argv, "ad:e:l:u")) != -1) + { + switch (opt) + { + case 'a': + law = G711_ALAW; + basic_tests = FALSE; + break; + case 'd': + in_file = optarg; + basic_tests = FALSE; + decode = TRUE; + break; + case 'e': + in_file = optarg; + basic_tests = FALSE; + encode = TRUE; + break; + case 'l': + out_file = optarg; + break; + case 'u': + law = G711_ULAW; + basic_tests = FALSE; + break; + default: + //usage(); + exit(2); + } + } + + if (basic_tests) + { + compliance_tests(TRUE); + } + else + { + if (!decode && !encode) + { + decode = + encode = TRUE; + } + if (in_file == NULL) + { + in_file = (encode) ? IN_FILE_NAME : ENCODED_FILE_NAME; + } + if (out_file == NULL) + { + out_file = (decode) ? OUT_FILE_NAME : ENCODED_FILE_NAME; + } + inhandle = AF_NULL_FILEHANDLE; + outhandle = AF_NULL_FILEHANDLE; + file = -1; + enc_state = NULL; + dec_state = NULL; + if (encode) + { + if ((inhandle = afOpenFile_telephony_read(in_file, 1)) == AF_NULL_FILEHANDLE) + { + fprintf(stderr, " Cannot open wave file '%s'\n", in_file); + exit(2); + } + enc_state = g711_init(NULL, law); + } + else + { + if ((file = open(in_file, O_RDONLY)) < 0) + { + fprintf(stderr, " Failed to open '%s'\n", in_file); + exit(2); + } + } + if (decode) + { + if ((outhandle = afOpenFile_telephony_write(out_file, 1)) == AF_NULL_FILEHANDLE) + { + fprintf(stderr, " Cannot create wave file '%s'\n", out_file); + exit(2); + } + dec_state = g711_init(NULL, law); + } + else + { + if ((file = open(out_file, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) + { + fprintf(stderr, " Failed to open '%s'\n", out_file); + exit(2); + } + } + for (;;) + { + if (encode) + { + samples = afReadFrames(inhandle, + AF_DEFAULT_TRACK, + indata, + BLOCK_LEN); + if (samples <= 0) + break; + len2 = g711_encode(enc_state, g711data, indata, samples); + } + else + { + len2 = read(file, g711data, BLOCK_LEN); + if (len2 <= 0) + break; + } + if (decode) + { + len3 = g711_decode(dec_state, outdata, g711data, len2); + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + outdata, + len3); + if (outframes != len3) + { + fprintf(stderr, " Error writing wave file\n"); + exit(2); + } + } + else + { + len3 = write(file, g711data, len2); + if (len3 <= 0) + break; + } + } + if (encode) + { + if (afCloseFile(inhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME); + exit(2); + } + } + else + { + close(file); + } + if (decode) + { + if (afCloseFile(outhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME); + exit(2); + } + } + else + { + close(file); + } + printf("'%s' translated to '%s' using %s.\n", in_file, out_file, (law == G711_ALAW) ? "A-law" : "u-law"); + } return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/g722_tests.c b/libs/spandsp/tests/g722_tests.c index 2299be837e..558a3956b8 100644 --- a/libs/spandsp/tests/g722_tests.c +++ b/libs/spandsp/tests/g722_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: g722_tests.c,v 1.29 2009/01/12 17:20:59 steveu Exp $ + * $Id: g722_tests.c,v 1.30 2009/04/22 12:57:40 steveu Exp $ */ /*! \file */ @@ -87,6 +87,7 @@ and the resulting audio stored in post_g722.wav. #define EIGHTK_IN_FILE_NAME "../test-data/local/short_nb_voice.wav" #define IN_FILE_NAME "../test-data/local/short_wb_voice.wav" +#define ENCODED_FILE_NAME "g722.g722" #define OUT_FILE_NAME "post_g722.wav" #if 0 @@ -217,91 +218,91 @@ static int get_test_vector(const char *file, uint16_t buf[], int max_len) } /*- End of function --------------------------------------------------------*/ -int main(int argc, char *argv[]) +static void itu_compliance_tests(void) { g722_encode_state_t enc_state; g722_decode_state_t dec_state; - int len; - int len_comp; - int len_comp_upper; - int len_data; - int len2; - int len3; int i; int j; int k; - int file; - AFfilehandle inhandle; - AFfilehandle outhandle; - AFfilesetup filesetup; - int outframes; - int samples; + int len_comp; + int len_comp_upper; + int len_data; + int len; + int len2; int mode; - int opt; - int itutests; - int bit_rate; - int eight_k_in; - int eight_k_out; - float x; - int16_t indata[BLOCK_LEN]; - int16_t outdata[BLOCK_LEN]; - uint8_t adpcmdata[BLOCK_LEN]; + int file; - bit_rate = 64000; - eight_k_in = FALSE; - eight_k_out = FALSE; - itutests = TRUE; - while ((opt = getopt(argc, argv, "b:i:o:")) != -1) +#if 1 + /* ITU G.722 encode tests, using configuration 1. The QMF is bypassed */ + for (file = 0; encode_test_files[file]; file += 2) { - switch (opt) + printf("Testing %s -> %s\n", encode_test_files[file], encode_test_files[file + 1]); + + /* Get the input data */ + len_data = get_test_vector(encode_test_files[file], (uint16_t *) itu_data, MAX_TEST_VECTOR_LEN); + + /* Get the reference output data */ + len_comp = get_test_vector(encode_test_files[file + 1], itu_ref, MAX_TEST_VECTOR_LEN); + + /* Process the input data */ + /* Skip the reset stuff at each end of the data */ + for (i = 0; i < len_data; i++) { - case 'b': - bit_rate = atoi(optarg); - if (bit_rate != 48000 && bit_rate != 56000 && bit_rate != 64000) + if ((itu_data[i] & 1) == 0) + break; + } + for (j = i; j < len_data; j++) + { + if ((itu_data[j] & 1)) + break; + } + len = j - i; + g722_encode_init(&enc_state, 64000, 0); + enc_state.itu_test_mode = TRUE; + len2 = g722_encode(&enc_state, compressed, itu_data + i, len); + + /* Check the result against the ITU's reference output data */ + j = 0; + for (k = 0; k < len2; k++) + { + if ((compressed[k] & 0xFF) != ((itu_ref[k + i] >> 8) & 0xFF)) { - fprintf(stderr, "Invalid bit rate selected. Only 48000, 56000 and 64000 are valid.\n"); - exit(2); + printf(">>> %6d %4x %4x\n", k, compressed[k] & 0xFF, itu_ref[k + i] & 0xFFFF); + j++; } - itutests = FALSE; - break; - case 'i': - i = atoi(optarg); - if (i != 8000 && i != 16000) - { - fprintf(stderr, "Invalid incoming sample rate. Only 8000 and 16000 are valid.\n"); - exit(2); - } - eight_k_in = (i == 8000); - break; - case 'o': - i = atoi(optarg); - if (i != 8000 && i != 16000) - { - fprintf(stderr, "Invalid incoming sample rate. Only 8000 and 16000 are valid.\n"); - exit(2); - } - eight_k_out = (i == 8000); - break; - default: - //usage(); + } + printf("%d bad samples, out of %d/%d samples\n", j, len, len_data); + if (j) + { + printf("Test failed\n"); exit(2); } + printf("Test passed\n"); } - - if (itutests) - { +#endif #if 1 - /* ITU G.722 encode tests, using configuration 1. The QMF is bypassed */ - for (file = 0; encode_test_files[file]; file += 2) + /* ITU G.722 decode tests, using configuration 2. The QMF is bypassed */ + /* Run each of the tests for each of the modes - 48kbps, 56kbps and 64kbps. */ + for (mode = 1; mode <= 3; mode++) + { + for (file = 0; decode_test_files[file]; file += 5) { - printf("Testing %s -> %s\n", encode_test_files[file], encode_test_files[file + 1]); - + printf("Testing mode %d, %s -> %s + %s\n", + mode, + decode_test_files[file], + decode_test_files[file + mode], + decode_test_files[file + 4]); + /* Get the input data */ - len_data = get_test_vector(encode_test_files[file], (uint16_t *) itu_data, MAX_TEST_VECTOR_LEN); - - /* Get the reference output data */ - len_comp = get_test_vector(encode_test_files[file + 1], itu_ref, MAX_TEST_VECTOR_LEN); - + len_data = get_test_vector(decode_test_files[file], (uint16_t *) itu_data, MAX_TEST_VECTOR_LEN); + + /* Get the lower reference output data */ + len_comp = get_test_vector(decode_test_files[file + mode], itu_ref, MAX_TEST_VECTOR_LEN); + + /* Get the upper reference output data */ + len_comp_upper = get_test_vector(decode_test_files[file + 4], itu_ref_upper, MAX_TEST_VECTOR_LEN); + /* Process the input data */ /* Skip the reset stuff at each end of the data */ for (i = 0; i < len_data; i++) @@ -315,17 +316,22 @@ int main(int argc, char *argv[]) break; } len = j - i; - g722_encode_init(&enc_state, 64000, 0); - enc_state.itu_test_mode = TRUE; - len2 = g722_encode(&enc_state, compressed, itu_data + i, len); + for (k = 0; k < len; k++) + compressed[k] = itu_data[k + i] >> ((mode == 3) ? 10 : (mode == 2) ? 9 : 8); + + g722_decode_init(&dec_state, (mode == 3) ? 48000 : (mode == 2) ? 56000 : 64000, 0); + dec_state.itu_test_mode = TRUE; + len2 = g722_decode(&dec_state, decompressed, compressed, len); /* Check the result against the ITU's reference output data */ j = 0; - for (k = 0; k < len2; k++) + for (k = 0; k < len2; k += 2) { - if ((compressed[k] & 0xFF) != ((itu_ref[k + i] >> 8) & 0xFF)) + if ((decompressed[k] & 0xFFFF) != (itu_ref[(k >> 1) + i] & 0xFFFF) + || + (decompressed[k + 1] & 0xFFFF) != (itu_ref_upper[(k >> 1) + i] & 0xFFFF)) { - printf(">>> %6d %4x %4x\n", k, compressed[k] & 0xFF, itu_ref[k + i] & 0xFFFF); + printf(">>> %6d %4x %4x %4x %4x\n", k >> 1, decompressed[k] & 0xFFFF, decompressed[k + 1] & 0xFFFF, itu_ref[(k >> 1) + i] & 0xFFFF, itu_ref_upper[(k >> 1) + i] & 0xFFFF); j++; } } @@ -337,180 +343,305 @@ int main(int argc, char *argv[]) } printf("Test passed\n"); } + } #endif -#if 1 - /* ITU G.722 decode tests, using configuration 2. The QMF is bypassed */ - /* Run each of the tests for each of the modes - 48kbps, 56kbps and 64kbps. */ - for (mode = 1; mode <= 3; mode++) - { - for (file = 0; decode_test_files[file]; file += 5) - { - printf("Testing mode %d, %s -> %s + %s\n", - mode, - decode_test_files[file], - decode_test_files[file + mode], - decode_test_files[file + 4]); + printf("Tests passed.\n"); +} +/*- End of function --------------------------------------------------------*/ - /* Get the input data */ - len_data = get_test_vector(decode_test_files[file], (uint16_t *) itu_data, MAX_TEST_VECTOR_LEN); - - /* Get the lower reference output data */ - len_comp = get_test_vector(decode_test_files[file + mode], itu_ref, MAX_TEST_VECTOR_LEN); - - /* Get the upper reference output data */ - len_comp_upper = get_test_vector(decode_test_files[file + 4], itu_ref_upper, MAX_TEST_VECTOR_LEN); - - /* Process the input data */ - /* Skip the reset stuff at each end of the data */ - for (i = 0; i < len_data; i++) - { - if ((itu_data[i] & 1) == 0) - break; - } - for (j = i; j < len_data; j++) - { - if ((itu_data[j] & 1)) - break; - } - len = j - i; - for (k = 0; k < len; k++) - compressed[k] = itu_data[k + i] >> ((mode == 3) ? 10 : (mode == 2) ? 9 : 8); - - g722_decode_init(&dec_state, (mode == 3) ? 48000 : (mode == 2) ? 56000 : 64000, 0); - dec_state.itu_test_mode = TRUE; - len2 = g722_decode(&dec_state, decompressed, compressed, len); - - /* Check the result against the ITU's reference output data */ - j = 0; - for (k = 0; k < len2; k += 2) - { - if ((decompressed[k] & 0xFFFF) != (itu_ref[(k >> 1) + i] & 0xFFFF) - || - (decompressed[k + 1] & 0xFFFF) != (itu_ref_upper[(k >> 1) + i] & 0xFFFF)) - { - printf(">>> %6d %4x %4x %4x %4x\n", k >> 1, decompressed[k] & 0xFFFF, decompressed[k + 1] & 0xFFFF, itu_ref[(k >> 1) + i] & 0xFFFF, itu_ref_upper[(k >> 1) + i] & 0xFFFF); - j++; - } - } - printf("%d bad samples, out of %d/%d samples\n", j, len, len_data); - if (j) - { - printf("Test failed\n"); - exit(2); - } - printf("Test passed\n"); +int main(int argc, char *argv[]) +{ + g722_encode_state_t enc_state; + g722_decode_state_t dec_state; + int len2; + int len3; + int i; + int file; + AFfilehandle inhandle; + AFfilehandle outhandle; + AFfilesetup filesetup; + int outframes; + int samples; + int opt; + int itutests; + int bit_rate; + int eight_k_in; + int eight_k_out; + int encode; + int decode; + int tone_test; + float x; + const char *in_file; + const char *out_file; + int16_t indata[BLOCK_LEN]; + int16_t outdata[BLOCK_LEN]; + uint8_t adpcmdata[BLOCK_LEN]; + float tone_level; + uint32_t tone_phase; + int32_t tone_phase_rate; + + bit_rate = 64000; + eight_k_in = FALSE; + eight_k_out = FALSE; + itutests = TRUE; + encode = FALSE; + decode = FALSE; + tone_test = FALSE; + in_file = NULL; + out_file = NULL; + while ((opt = getopt(argc, argv, "b:d:e:i:l:o:t")) != -1) + { + switch (opt) + { + case 'b': + bit_rate = atoi(optarg); + if (bit_rate != 48000 && bit_rate != 56000 && bit_rate != 64000) + { + fprintf(stderr, "Invalid bit rate selected. Only 48000, 56000 and 64000 are valid.\n"); + exit(2); } + itutests = FALSE; + break; + case 'd': + in_file = optarg; + decode = TRUE; + itutests = FALSE; + break; + case 'e': + in_file = optarg; + encode = TRUE; + itutests = FALSE; + break; + case 'i': + i = atoi(optarg); + if (i != 8000 && i != 16000) + { + fprintf(stderr, "Invalid incoming sample rate. Only 8000 and 16000 are valid.\n"); + exit(2); + } + eight_k_in = (i == 8000); + if (eight_k_in) + in_file = EIGHTK_IN_FILE_NAME; + break; + case 'l': + out_file = optarg; + break; + case 'o': + i = atoi(optarg); + if (i != 8000 && i != 16000) + { + fprintf(stderr, "Invalid outgoing sample rate. Only 8000 and 16000 are valid.\n"); + exit(2); + } + eight_k_out = (i == 8000); + break; + case 't': + tone_test = TRUE; + itutests = FALSE; + break; + default: + //usage(); + exit(2); } -#endif - printf("Tests passed.\n"); + } + + if (itutests) + { + itu_compliance_tests(); } else { - if (eight_k_in) + tone_level = dds_scaling_dbm0f(2.5f); + tone_phase = 0; + tone_phase_rate = dds_phase_ratef(1500.0f/2.0f); + if (!decode && !encode) { - if ((inhandle = afOpenFile(EIGHTK_IN_FILE_NAME, "r", NULL)) == AF_NULL_FILEHANDLE) + decode = + encode = TRUE; + } + if (in_file == NULL) + { + if (encode) { - fprintf(stderr, " Cannot open wave file '%s'\n", EIGHTK_IN_FILE_NAME); - exit(2); + if (eight_k_in) + in_file = EIGHTK_IN_FILE_NAME; + else + in_file = IN_FILE_NAME; } - if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0) + else { - fprintf(stderr, " Unexpected frame size in wave file '%s'\n", EIGHTK_IN_FILE_NAME); - exit(2); + in_file = ENCODED_FILE_NAME; } - if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE) + } + if (out_file == NULL) + { + out_file = (decode) ? OUT_FILE_NAME : ENCODED_FILE_NAME; + } + inhandle = AF_NULL_FILEHANDLE; + outhandle = AF_NULL_FILEHANDLE; + file = -1; + if (encode) + { + if (eight_k_in) { - fprintf(stderr, " Unexpected sample rate %f in wave file '%s'\n", x, EIGHTK_IN_FILE_NAME); - exit(2); + if ((inhandle = afOpenFile(in_file, "r", NULL)) == AF_NULL_FILEHANDLE) + { + fprintf(stderr, " Cannot open wave file '%s'\n", in_file); + exit(2); + } + if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0) + { + fprintf(stderr, " Unexpected frame size in wave file '%s'\n", in_file); + exit(2); + } + if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) SAMPLE_RATE) + { + fprintf(stderr, " Unexpected sample rate %f in wave file '%s'\n", x, in_file); + exit(2); + } + if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0) + { + fprintf(stderr, " Unexpected number of channels in wave file '%s'\n", in_file); + exit(2); + } } - if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0) + else { - fprintf(stderr, " Unexpected number of channels in wave file '%s'\n", EIGHTK_IN_FILE_NAME); - exit(2); + if ((inhandle = afOpenFile(in_file, "r", NULL)) == AF_NULL_FILEHANDLE) + { + fprintf(stderr, " Cannot open wave file '%s'\n", in_file); + exit(2); + } + if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0) + { + fprintf(stderr, " Unexpected frame size in wave file '%s'\n", in_file); + exit(2); + } + if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) G722_SAMPLE_RATE) + { + fprintf(stderr, " Unexpected sample rate %f in wave file '%s'\n", x, in_file); + exit(2); + } + if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0) + { + fprintf(stderr, " Unexpected number of channels in wave file '%s'\n", in_file); + exit(2); + } } + if (eight_k_in) + g722_encode_init(&enc_state, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000); + else + g722_encode_init(&enc_state, bit_rate, G722_PACKED); } else { - if ((inhandle = afOpenFile(IN_FILE_NAME, "r", NULL)) == AF_NULL_FILEHANDLE) + if ((file = open(in_file, O_RDONLY)) < 0) { - fprintf(stderr, " Cannot open wave file '%s'\n", IN_FILE_NAME); - exit(2); - } - if ((x = afGetFrameSize(inhandle, AF_DEFAULT_TRACK, 1)) != 2.0) - { - fprintf(stderr, " Unexpected frame size in wave file '%s'\n", IN_FILE_NAME); - exit(2); - } - if ((x = afGetRate(inhandle, AF_DEFAULT_TRACK)) != (float) G722_SAMPLE_RATE) - { - fprintf(stderr, " Unexpected sample rate %f in wave file '%s'\n", x, IN_FILE_NAME); - exit(2); - } - if ((x = afGetChannels(inhandle, AF_DEFAULT_TRACK)) != 1.0) - { - fprintf(stderr, " Unexpected number of channels in wave file '%s'\n", IN_FILE_NAME); + fprintf(stderr, " Failed to open '%s'\n", in_file); exit(2); } } - - if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP) + if (decode) { - fprintf(stderr, " Failed to create file setup\n"); - exit(2); + if ((filesetup = afNewFileSetup()) == AF_NULL_FILESETUP) + { + fprintf(stderr, " Failed to create file setup\n"); + exit(2); + } + afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); + if (eight_k_out) + afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE); + else + afInitRate(filesetup, AF_DEFAULT_TRACK, (float) G722_SAMPLE_RATE); + afInitFileFormat(filesetup, AF_FILE_WAVE); + afInitChannels(filesetup, AF_DEFAULT_TRACK, 1); + if ((outhandle = afOpenFile(out_file, "w", filesetup)) == AF_NULL_FILEHANDLE) + { + fprintf(stderr, " Cannot create wave file '%s'\n", out_file); + exit(2); + } + afFreeFileSetup(filesetup); + if (eight_k_out) + g722_decode_init(&dec_state, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000); + else + g722_decode_init(&dec_state, bit_rate, G722_PACKED); } - afInitSampleFormat(filesetup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16); - if (eight_k_out) - afInitRate(filesetup, AF_DEFAULT_TRACK, (float) SAMPLE_RATE); else - afInitRate(filesetup, AF_DEFAULT_TRACK, (float) G722_SAMPLE_RATE); - afInitFileFormat(filesetup, AF_FILE_WAVE); - afInitChannels(filesetup, AF_DEFAULT_TRACK, 1); - if ((outhandle = afOpenFile(OUT_FILE_NAME, "w", filesetup)) == AF_NULL_FILEHANDLE) { - fprintf(stderr, " Cannot create wave file '%s'\n", OUT_FILE_NAME); - exit(2); + if ((file = open(out_file, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0) + { + fprintf(stderr, " Failed to open '%s'\n", out_file); + exit(2); + } } - if (eight_k_in) - g722_encode_init(&enc_state, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000); - else - g722_encode_init(&enc_state, bit_rate, G722_PACKED); - if (eight_k_out) - g722_decode_init(&dec_state, bit_rate, G722_PACKED | G722_SAMPLE_RATE_8000); - else - g722_decode_init(&dec_state, bit_rate, G722_PACKED); for (;;) { - samples = afReadFrames(inhandle, - AF_DEFAULT_TRACK, - indata, - BLOCK_LEN); - if (samples <= 0) - break; - len2 = g722_encode(&enc_state, adpcmdata, indata, samples); - len3 = g722_decode(&dec_state, outdata, adpcmdata, len2); - outframes = afWriteFrames(outhandle, - AF_DEFAULT_TRACK, - outdata, - len3); - if (outframes != len3) + if (encode) { - fprintf(stderr, " Error writing wave file\n"); + samples = afReadFrames(inhandle, + AF_DEFAULT_TRACK, + indata, + BLOCK_LEN); + if (samples <= 0) + break; + if (tone_test) + { + for (i = 0; i < samples; i++) + indata[i] = dds_modf(&tone_phase, tone_phase_rate, tone_level, 0); + } + len2 = g722_encode(&enc_state, adpcmdata, indata, samples); + } + else + { + len2 = read(file, adpcmdata, BLOCK_LEN); + if (len2 <= 0) + break; + } + if (decode) + { + len3 = g722_decode(&dec_state, outdata, adpcmdata, len2); + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + outdata, + len3); + if (outframes != len3) + { + fprintf(stderr, " Error writing wave file\n"); + exit(2); + } + } + else + { + len3 = write(file, adpcmdata, len2); + if (len3 <= 0) + break; + } + } + if (encode) + { + if (afCloseFile(inhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME); exit(2); } } - if (afCloseFile(inhandle)) + else { - fprintf(stderr, " Cannot close wave file '%s'\n", IN_FILE_NAME); - exit(2); + close(file); } - if (afCloseFile(outhandle)) + if (decode) { - fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME); - exit(2); + if (afCloseFile(outhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", OUT_FILE_NAME); + exit(2); + } } - afFreeFileSetup(filesetup); - - printf("'%s' transcoded to '%s' at %dbps.\n", IN_FILE_NAME, OUT_FILE_NAME, bit_rate); + else + { + close(file); + } + printf("'%s' translated to '%s' at %dbps.\n", in_file, out_file, bit_rate); } return 0; } diff --git a/libs/spandsp/tests/g726_tests.c b/libs/spandsp/tests/g726_tests.c index ebaa5a1d8c..9fd9c6a0d3 100644 --- a/libs/spandsp/tests/g726_tests.c +++ b/libs/spandsp/tests/g726_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: g726_tests.c,v 1.31 2009/01/12 17:20:59 steveu Exp $ + * $Id: g726_tests.c,v 1.32 2009/04/22 12:57:40 steveu Exp $ */ /*! \file */ @@ -1077,7 +1077,7 @@ static int get_test_vector(const char *file, uint8_t buf[], int max_len) } /*- End of function --------------------------------------------------------*/ -int main(int argc, char *argv[]) +static void itu_compliance_tests(void) { g726_state_t enc_state; g726_state_t dec_state; @@ -1085,27 +1085,157 @@ int main(int argc, char *argv[]) int len3; int i; int test; - int opt; int bits_per_code; + int bad_samples; + int conditioning_samples; + int samples; + int conditioning_adpcm; + int adpcm; + + len2 = 0; + conditioning_samples = 0; + for (test = 0; itu_test_sets[test].rate; test++) + { + printf("Test %2d: '%s' + '%s'\n" + " -> '%s' + '%s'\n" + " -> '%s' [%d, %d, %d]\n", + test, + itu_test_sets[test].conditioning_pcm_file, + itu_test_sets[test].pcm_file, + itu_test_sets[test].conditioning_adpcm_file, + itu_test_sets[test].adpcm_file, + itu_test_sets[test].output_file, + itu_test_sets[test].rate, + itu_test_sets[test].compression_law, + itu_test_sets[test].decompression_law); + switch (itu_test_sets[test].rate) + { + case 16000: + bits_per_code = 2; + break; + case 24000: + bits_per_code = 3; + break; + case 32000: + default: + bits_per_code = 4; + break; + case 40000: + bits_per_code = 5; + break; + } + if (itu_test_sets[test].compression_law != G726_ENCODING_NONE) + { + /* Test the encode side */ + g726_init(&enc_state, itu_test_sets[test].rate, itu_test_sets[test].compression_law, G726_PACKING_NONE); + if (itu_test_sets[test].conditioning_pcm_file[0]) + { + conditioning_samples = get_test_vector(itu_test_sets[test].conditioning_pcm_file, xlaw, MAX_TEST_VECTOR_LEN); + printf("Test %d: Homing %d samples at %dbps\n", test, conditioning_samples, itu_test_sets[test].rate); + } + else + { + conditioning_samples = 0; + } + samples = get_test_vector(itu_test_sets[test].pcm_file, xlaw + conditioning_samples, MAX_TEST_VECTOR_LEN); + memcpy(itudata, xlaw, samples + conditioning_samples); + printf("Test %d: Compressing %d samples at %dbps\n", test, samples, itu_test_sets[test].rate); + len2 = g726_encode(&enc_state, adpcmdata, itudata, conditioning_samples + samples); + } + /* Test the decode side */ + g726_init(&dec_state, itu_test_sets[test].rate, itu_test_sets[test].decompression_law, G726_PACKING_NONE); + if (itu_test_sets[test].conditioning_adpcm_file[0]) + { + conditioning_adpcm = get_test_vector(itu_test_sets[test].conditioning_adpcm_file, unpacked, MAX_TEST_VECTOR_LEN); + printf("Test %d: Homing %d octets at %dbps\n", test, conditioning_adpcm, itu_test_sets[test].rate); + } + else + { + conditioning_adpcm = 0; + } + adpcm = get_test_vector(itu_test_sets[test].adpcm_file, unpacked + conditioning_adpcm, MAX_TEST_VECTOR_LEN); + if (itu_test_sets[test].compression_law != G726_ENCODING_NONE) + { + /* Test our compressed version against the reference compressed version */ + printf("Test %d: Compressed data check - %d/%d octets\n", test, conditioning_adpcm + adpcm, len2); + if (conditioning_adpcm + adpcm == len2) + { + for (bad_samples = 0, i = conditioning_samples; i < len2; i++) + { + if (adpcmdata[i] != unpacked[i]) + { + bad_samples++; + printf("Test %d: Compressed mismatch %d %x %x\n", test, i, adpcmdata[i], unpacked[i]); + } + } + if (bad_samples > 0) + { + printf("Test failed\n"); + exit(2); + } + printf("Test passed\n"); + } + else + { + printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, conditioning_adpcm + adpcm, len2); + exit(2); + } + } + + len3 = g726_decode(&dec_state, outdata, unpacked, conditioning_adpcm + adpcm); + + /* Get the output reference data */ + samples = get_test_vector(itu_test_sets[test].output_file, xlaw, MAX_TEST_VECTOR_LEN); + memcpy(itu_ref, xlaw, samples); + /* Test our decompressed version against the reference decompressed version */ + printf("Test %d: Decompressed data check - %d/%d samples\n", test, samples, len3 - conditioning_adpcm); + if (samples == len3 - conditioning_adpcm) + { + for (bad_samples = 0, i = 0; i < len3; i++) + { + if (itu_ref[i] != ((uint8_t *) outdata)[i + conditioning_adpcm]) + { + bad_samples++; + printf("Test %d: Decompressed mismatch %d %x %x\n", test, i, itu_ref[i], ((uint8_t *) outdata)[i + conditioning_adpcm]); + } + } + if (bad_samples > 0) + { + printf("Test failed\n"); + exit(2); + } + printf("Test passed\n"); + } + else + { + printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, samples, len3 - conditioning_adpcm); + exit(2); + } + } + + printf("Tests passed.\n"); +} +/*- End of function --------------------------------------------------------*/ + +int main(int argc, char *argv[]) +{ + g726_state_t enc_state; + g726_state_t dec_state; + int opt; int itutests; int bit_rate; - int bad_samples; AFfilehandle inhandle; AFfilehandle outhandle; int16_t amp[1024]; int frames; int outframes; - int conditioning_samples; - int samples; - int conditioning_adpcm; int adpcm; int packing; - i = 1; bit_rate = 32000; itutests = TRUE; packing = G726_PACKING_NONE; - while ((opt = getopt(argc, argv, "b:lr")) != -1) + while ((opt = getopt(argc, argv, "b:LR")) != -1) { switch (opt) { @@ -1118,10 +1248,10 @@ int main(int argc, char *argv[]) } itutests = FALSE; break; - case 'l': + case 'L': packing = G726_PACKING_LEFT; break; - case 'r': + case 'R': packing = G726_PACKING_RIGHT; break; default: @@ -1130,130 +1260,9 @@ int main(int argc, char *argv[]) } } - len2 = 0; - conditioning_samples = 0; if (itutests) { - for (test = 0; itu_test_sets[test].rate; test++) - { - printf("Test %2d: '%s' + '%s'\n" - " -> '%s' + '%s'\n" - " -> '%s' [%d, %d, %d]\n", - test, - itu_test_sets[test].conditioning_pcm_file, - itu_test_sets[test].pcm_file, - itu_test_sets[test].conditioning_adpcm_file, - itu_test_sets[test].adpcm_file, - itu_test_sets[test].output_file, - itu_test_sets[test].rate, - itu_test_sets[test].compression_law, - itu_test_sets[test].decompression_law); - switch (itu_test_sets[test].rate) - { - case 16000: - bits_per_code = 2; - break; - case 24000: - bits_per_code = 3; - break; - case 32000: - default: - bits_per_code = 4; - break; - case 40000: - bits_per_code = 5; - break; - } - if (itu_test_sets[test].compression_law != G726_ENCODING_NONE) - { - /* Test the encode side */ - g726_init(&enc_state, itu_test_sets[test].rate, itu_test_sets[test].compression_law, G726_PACKING_NONE); - if (itu_test_sets[test].conditioning_pcm_file[0]) - { - conditioning_samples = get_test_vector(itu_test_sets[test].conditioning_pcm_file, xlaw, MAX_TEST_VECTOR_LEN); - printf("Test %d: Homing %d samples at %dbps\n", test, conditioning_samples, itu_test_sets[test].rate); - } - else - { - conditioning_samples = 0; - } - samples = get_test_vector(itu_test_sets[test].pcm_file, xlaw + conditioning_samples, MAX_TEST_VECTOR_LEN); - memcpy(itudata, xlaw, samples + conditioning_samples); - printf("Test %d: Compressing %d samples at %dbps\n", test, samples, itu_test_sets[test].rate); - len2 = g726_encode(&enc_state, adpcmdata, itudata, conditioning_samples + samples); - } - /* Test the decode side */ - g726_init(&dec_state, itu_test_sets[test].rate, itu_test_sets[test].decompression_law, G726_PACKING_NONE); - if (itu_test_sets[test].conditioning_adpcm_file[0]) - { - conditioning_adpcm = get_test_vector(itu_test_sets[test].conditioning_adpcm_file, unpacked, MAX_TEST_VECTOR_LEN); - printf("Test %d: Homing %d octets at %dbps\n", test, conditioning_adpcm, itu_test_sets[test].rate); - } - else - { - conditioning_adpcm = 0; - } - adpcm = get_test_vector(itu_test_sets[test].adpcm_file, unpacked + conditioning_adpcm, MAX_TEST_VECTOR_LEN); - if (itu_test_sets[test].compression_law != G726_ENCODING_NONE) - { - /* Test our compressed version against the reference compressed version */ - printf("Test %d: Compressed data check - %d/%d octets\n", test, conditioning_adpcm + adpcm, len2); - if (conditioning_adpcm + adpcm == len2) - { - for (bad_samples = 0, i = conditioning_samples; i < len2; i++) - { - if (adpcmdata[i] != unpacked[i]) - { - bad_samples++; - printf("Test %d: Compressed mismatch %d %x %x\n", test, i, adpcmdata[i], unpacked[i]); - } - } - if (bad_samples > 0) - { - printf("Test failed\n"); - exit(2); - } - printf("Test passed\n"); - } - else - { - printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, conditioning_adpcm + adpcm, len2); - exit(2); - } - } - - len3 = g726_decode(&dec_state, outdata, unpacked, conditioning_adpcm + adpcm); - - /* Get the output reference data */ - samples = get_test_vector(itu_test_sets[test].output_file, xlaw, MAX_TEST_VECTOR_LEN); - memcpy(itu_ref, xlaw, samples); - /* Test our decompressed version against the reference decompressed version */ - printf("Test %d: Decompressed data check - %d/%d samples\n", test, samples, len3 - conditioning_adpcm); - if (samples == len3 - conditioning_adpcm) - { - for (bad_samples = 0, i = 0; i < len3; i++) - { - if (itu_ref[i] != ((uint8_t *) outdata)[i + conditioning_adpcm]) - { - bad_samples++; - printf("Test %d: Decompressed mismatch %d %x %x\n", test, i, itu_ref[i], ((uint8_t *) outdata)[i + conditioning_adpcm]); - } - } - if (bad_samples > 0) - { - printf("Test failed\n"); - exit(2); - } - printf("Test passed\n"); - } - else - { - printf("Test %d: Length mismatch - ref = %d, processed = %d\n", test, samples, len3 - conditioning_adpcm); - exit(2); - } - } - - printf("Tests passed.\n"); + itu_compliance_tests(); } else { @@ -1269,8 +1278,6 @@ int main(int argc, char *argv[]) } printf("ADPCM packing is %d\n", packing); - //g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, G726_PACKING_LEFT); - //g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, G726_PACKING_RIGHT); g726_init(&enc_state, bit_rate, G726_ENCODING_LINEAR, packing); g726_init(&dec_state, bit_rate, G726_ENCODING_LINEAR, packing); diff --git a/libs/spandsp/tests/gsm0610_tests.c b/libs/spandsp/tests/gsm0610_tests.c index 8c7405cf8d..02a63c508e 100644 --- a/libs/spandsp/tests/gsm0610_tests.c +++ b/libs/spandsp/tests/gsm0610_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: gsm0610_tests.c,v 1.23 2009/01/12 17:20:59 steveu Exp $ + * $Id: gsm0610_tests.c,v 1.24 2009/04/22 12:57:40 steveu Exp $ */ /*! \file */ @@ -516,6 +516,30 @@ static int perform_pack_unpack_test(void) } /*- End of function --------------------------------------------------------*/ +static void etsi_compliance_tests(void) +{ + perform_linear_test(TRUE, 1, "Seq01"); + perform_linear_test(TRUE, 1, "Seq02"); + perform_linear_test(TRUE, 1, "Seq03"); + perform_linear_test(TRUE, 1, "Seq04"); + perform_linear_test(FALSE, 1, "Seq05"); + perform_law_test(TRUE, 'a', "Seq01"); + perform_law_test(TRUE, 'a', "Seq02"); + perform_law_test(TRUE, 'a', "Seq03"); + perform_law_test(TRUE, 'a', "Seq04"); + perform_law_test(FALSE, 'a', "Seq05"); + perform_law_test(TRUE, 'u', "Seq01"); + perform_law_test(TRUE, 'u', "Seq02"); + perform_law_test(TRUE, 'u', "Seq03"); + perform_law_test(TRUE, 'u', "Seq04"); + perform_law_test(FALSE, 'u', "Seq05"); + /* This is not actually an ETSI test */ + perform_pack_unpack_test(); + + printf("Tests passed.\n"); +} +/*- End of function --------------------------------------------------------*/ + int main(int argc, char *argv[]) { AFfilehandle inhandle; @@ -552,25 +576,7 @@ int main(int argc, char *argv[]) if (etsitests) { - perform_linear_test(TRUE, 1, "Seq01"); - perform_linear_test(TRUE, 1, "Seq02"); - perform_linear_test(TRUE, 1, "Seq03"); - perform_linear_test(TRUE, 1, "Seq04"); - perform_linear_test(FALSE, 1, "Seq05"); - perform_law_test(TRUE, 'a', "Seq01"); - perform_law_test(TRUE, 'a', "Seq02"); - perform_law_test(TRUE, 'a', "Seq03"); - perform_law_test(TRUE, 'a', "Seq04"); - perform_law_test(FALSE, 'a', "Seq05"); - perform_law_test(TRUE, 'u', "Seq01"); - perform_law_test(TRUE, 'u', "Seq02"); - perform_law_test(TRUE, 'u', "Seq03"); - perform_law_test(TRUE, 'u', "Seq04"); - perform_law_test(FALSE, 'u', "Seq05"); - /* This is not actually an ETSI test */ - perform_pack_unpack_test(); - - printf("Tests passed.\n"); + etsi_compliance_tests(); } else { diff --git a/libs/spandsp/tests/msvc/adsi_tests.vcproj b/libs/spandsp/tests/msvc/adsi_tests.vcproj new file mode 100644 index 0000000000..c9f443cea2 --- /dev/null +++ b/libs/spandsp/tests/msvc/adsi_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/complex_tests.vcproj b/libs/spandsp/tests/msvc/complex_tests.vcproj new file mode 100644 index 0000000000..406d6d3805 --- /dev/null +++ b/libs/spandsp/tests/msvc/complex_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/complex_vector_float_tests.vcproj b/libs/spandsp/tests/msvc/complex_vector_float_tests.vcproj new file mode 100644 index 0000000000..887fcd48df --- /dev/null +++ b/libs/spandsp/tests/msvc/complex_vector_float_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/complex_vector_int_tests.vcproj b/libs/spandsp/tests/msvc/complex_vector_int_tests.vcproj new file mode 100644 index 0000000000..35017c4a63 --- /dev/null +++ b/libs/spandsp/tests/msvc/complex_vector_int_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/dtmf_rx_tests.vcproj b/libs/spandsp/tests/msvc/dtmf_rx_tests.vcproj new file mode 100644 index 0000000000..0cda11eb2b --- /dev/null +++ b/libs/spandsp/tests/msvc/dtmf_rx_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/dtmf_tx_tests.vcproj b/libs/spandsp/tests/msvc/dtmf_tx_tests.vcproj new file mode 100644 index 0000000000..2d548b3993 --- /dev/null +++ b/libs/spandsp/tests/msvc/dtmf_tx_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/queue_tests.vcproj b/libs/spandsp/tests/msvc/queue_tests.vcproj new file mode 100644 index 0000000000..05b49b0879 --- /dev/null +++ b/libs/spandsp/tests/msvc/queue_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/t38_core_tests.vcproj b/libs/spandsp/tests/msvc/t38_core_tests.vcproj new file mode 100644 index 0000000000..0c30685503 --- /dev/null +++ b/libs/spandsp/tests/msvc/t38_core_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/t38_non_ecm_buffer_tests.vcproj b/libs/spandsp/tests/msvc/t38_non_ecm_buffer_tests.vcproj new file mode 100644 index 0000000000..6feea6c1c1 --- /dev/null +++ b/libs/spandsp/tests/msvc/t38_non_ecm_buffer_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/t38_terminal_tests.vcproj b/libs/spandsp/tests/msvc/t38_terminal_tests.vcproj new file mode 100644 index 0000000000..20977a3abd --- /dev/null +++ b/libs/spandsp/tests/msvc/t38_terminal_tests.vcproj @@ -0,0 +1,202 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/v22bis_tests.vcproj b/libs/spandsp/tests/msvc/v22bis_tests.vcproj new file mode 100644 index 0000000000..eff603b122 --- /dev/null +++ b/libs/spandsp/tests/msvc/v22bis_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/v29_tests.vcproj b/libs/spandsp/tests/msvc/v29_tests.vcproj new file mode 100644 index 0000000000..9daf6d0e61 --- /dev/null +++ b/libs/spandsp/tests/msvc/v29_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/v80_tests.vcproj b/libs/spandsp/tests/msvc/v80_tests.vcproj new file mode 100644 index 0000000000..0afc6a3178 --- /dev/null +++ b/libs/spandsp/tests/msvc/v80_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/v8_tests.vcproj b/libs/spandsp/tests/msvc/v8_tests.vcproj new file mode 100644 index 0000000000..1aa9813330 --- /dev/null +++ b/libs/spandsp/tests/msvc/v8_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/vector_float_tests.vcproj b/libs/spandsp/tests/msvc/vector_float_tests.vcproj new file mode 100644 index 0000000000..d6bf25a70d --- /dev/null +++ b/libs/spandsp/tests/msvc/vector_float_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/msvc/vector_int_tests.vcproj b/libs/spandsp/tests/msvc/vector_int_tests.vcproj new file mode 100644 index 0000000000..d254722fe4 --- /dev/null +++ b/libs/spandsp/tests/msvc/vector_int_tests.vcproj @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/libs/spandsp/tests/t38_core_tests.c b/libs/spandsp/tests/t38_core_tests.c index 4f8073c926..307855dc4a 100644 --- a/libs/spandsp/tests/t38_core_tests.c +++ b/libs/spandsp/tests/t38_core_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_core_tests.c,v 1.14 2008/11/30 13:44:35 steveu Exp $ + * $Id: t38_core_tests.c,v 1.15 2009/04/25 14:17:47 steveu Exp $ */ /*! \file */ @@ -42,16 +42,6 @@ These tests exercise the T.38 core ASN.1 processing code. #include #include #include -#include -#include -#include -#if !defined(__USE_MISC) -#define __USE_MISC -#endif -#include -#include -#include -#include //#if defined(WITH_SPANDSP_INTERNALS) #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES diff --git a/libs/spandsp/tests/t38_gateway_tests.c b/libs/spandsp/tests/t38_gateway_tests.c index 4f62168b69..ae6ab82233 100644 --- a/libs/spandsp/tests/t38_gateway_tests.c +++ b/libs/spandsp/tests/t38_gateway_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_gateway_tests.c,v 1.80 2009/02/20 12:34:20 steveu Exp $ + * $Id: t38_gateway_tests.c,v 1.81 2009/04/25 14:27:18 steveu Exp $ */ /*! \file */ @@ -48,20 +48,13 @@ These tests exercise the path #include #include #include -#include #include #include #include -#include -#include -#include -#if !defined(__USE_MISC) -#define __USE_MISC -#endif -#include -#include -#include #include +#if !defined(_WIN32) +#include +#endif //#if defined(WITH_SPANDSP_INTERNALS) #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES diff --git a/libs/spandsp/tests/t38_gateway_to_terminal_tests.c b/libs/spandsp/tests/t38_gateway_to_terminal_tests.c index cedaed446d..6e904b92c8 100644 --- a/libs/spandsp/tests/t38_gateway_to_terminal_tests.c +++ b/libs/spandsp/tests/t38_gateway_to_terminal_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_gateway_to_terminal_tests.c,v 1.64 2009/02/20 12:34:20 steveu Exp $ + * $Id: t38_gateway_to_terminal_tests.c,v 1.65 2009/04/25 14:27:18 steveu Exp $ */ /*! \file */ @@ -48,20 +48,13 @@ These tests exercise the path #include #include #include -#include #include #include #include -#include -#include -#include -#if !defined(__USE_MISC) -#define __USE_MISC -#endif -#include -#include -#include #include +#if !defined(_WIN32) +#include +#endif //#if defined(WITH_SPANDSP_INTERNALS) #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES diff --git a/libs/spandsp/tests/t38_non_ecm_buffer_tests.c b/libs/spandsp/tests/t38_non_ecm_buffer_tests.c index fb1909de11..a35cde7bb4 100644 --- a/libs/spandsp/tests/t38_non_ecm_buffer_tests.c +++ b/libs/spandsp/tests/t38_non_ecm_buffer_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_non_ecm_buffer_tests.c,v 1.4 2008/11/30 13:44:35 steveu Exp $ + * $Id: t38_non_ecm_buffer_tests.c,v 1.5 2009/04/25 14:17:47 steveu Exp $ */ /*! \file */ @@ -40,20 +40,9 @@ module, used for T.38 gateways. #include #include #include -#include #include #include #include -#include -#include -#include -#if !defined(__USE_MISC) -#define __USE_MISC -#endif -#include -#include -#include -#include //#if defined(WITH_SPANDSP_INTERNALS) #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES diff --git a/libs/spandsp/tests/t38_terminal_tests.c b/libs/spandsp/tests/t38_terminal_tests.c index e6735d3e01..7d2c204b53 100644 --- a/libs/spandsp/tests/t38_terminal_tests.c +++ b/libs/spandsp/tests/t38_terminal_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_terminal_tests.c,v 1.65 2009/02/20 12:34:20 steveu Exp $ + * $Id: t38_terminal_tests.c,v 1.67 2009/04/25 14:34:45 steveu Exp $ */ /*! \file */ @@ -34,7 +34,6 @@ These tests exercise the path T.38 termination <-> T.38 termination */ -/* Enable the following definition to enable direct probing into the FAX structures */ //#define WITH_SPANDSP_INTERNALS #if defined(HAVE_CONFIG_H) @@ -48,20 +47,12 @@ These tests exercise the path #include #include #include -#include #include #include #include -#include -#include -#include -#if !defined(__USE_MISC) -#define __USE_MISC +#if !defined(_WIN32) +#include #endif -#include -#include -#include -#include //#if defined(WITH_SPANDSP_INTERNALS) #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES diff --git a/libs/spandsp/tests/t38_terminal_to_gateway_tests.c b/libs/spandsp/tests/t38_terminal_to_gateway_tests.c index 438121483b..92a4bca819 100644 --- a/libs/spandsp/tests/t38_terminal_to_gateway_tests.c +++ b/libs/spandsp/tests/t38_terminal_to_gateway_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t38_terminal_to_gateway_tests.c,v 1.63 2009/02/20 12:34:20 steveu Exp $ + * $Id: t38_terminal_to_gateway_tests.c,v 1.64 2009/04/25 14:27:19 steveu Exp $ */ /*! \file */ @@ -48,20 +48,13 @@ These tests exercise the path #include #include #include -#include #include #include #include -#include -#include -#include -#if !defined(__USE_MISC) -#define __USE_MISC -#endif -#include -#include -#include #include +#if !defined(_WIN32) +#include +#endif //#if defined(WITH_SPANDSP_INTERNALS) #define SPANDSP_EXPOSE_INTERNAL_STRUCTURES diff --git a/libs/spandsp/tests/v17_tests.c b/libs/spandsp/tests/v17_tests.c index 893f8b702e..b30888ced1 100644 --- a/libs/spandsp/tests/v17_tests.c +++ b/libs/spandsp/tests/v17_tests.c @@ -23,7 +23,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v17_tests.c,v 1.101 2009/03/15 09:09:21 steveu Exp $ + * $Id: v17_tests.c,v 1.102 2009/04/25 16:30:52 steveu Exp $ */ /*! \page v17_tests_page V.17 modem tests @@ -483,6 +483,14 @@ int main(int argc, char *argv[]) if (use_gui) qam_wait_to_end(qam_monitor); #endif + if (decode_test_file) + { + if (afCloseFile(inhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file); + exit(2); + } + } if (log_audio) { if (afCloseFile(outhandle)) diff --git a/libs/spandsp/tests/v22bis_tests.c b/libs/spandsp/tests/v22bis_tests.c index 1f926716b6..b1469b5809 100644 --- a/libs/spandsp/tests/v22bis_tests.c +++ b/libs/spandsp/tests/v22bis_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v22bis_tests.c,v 1.58 2009/04/17 14:37:53 steveu Exp $ + * $Id: v22bis_tests.c,v 1.61 2009/04/25 16:30:52 steveu Exp $ */ /*! \page v22bis_tests_page V.22bis modem tests @@ -62,13 +62,13 @@ display of modem status is maintained. #define BLOCK_LEN 160 -#define IN_FILE_NAME "v22bis_samp.wav" #define OUT_FILE_NAME "v22bis.wav" -int rx_bits = 0; - +char *decode_test_file = NULL; int use_gui = FALSE; +int rx_bits = 0; + both_ways_line_model_state_t *model; typedef struct @@ -115,6 +115,7 @@ static void v22bis_putbit(void *user_data, int bit) endpoint_t *s; int i; int len; + int bit_rate; complexf_t *coeffs; s = (endpoint_t *) user_data; @@ -125,7 +126,9 @@ static void v22bis_putbit(void *user_data, int bit) switch (bit) { case SIG_STATUS_TRAINING_SUCCEEDED: - len = v22bis_equalizer_state(s->v22bis, &coeffs); + bit_rate = v22bis_current_bit_rate(s->v22bis); + printf("Negotiated bit rate: %d\n", bit_rate); + len = v22bis_rx_equalizer_state(s->v22bis, &coeffs); printf("Equalizer:\n"); for (i = 0; i < len; i++) printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); @@ -134,8 +137,10 @@ static void v22bis_putbit(void *user_data, int bit) return; } - //printf("Rx bit %p - %d\n", user_data, bit); - bert_put_bit(&s->bert_rx, bit); + if (decode_test_file) + printf("Rx bit %p-%d - %d\n", user_data, rx_bits++, bit); + else + bert_put_bit(&s->bert_rx, bit); } /*- End of function --------------------------------------------------------*/ @@ -166,7 +171,7 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex { qam_monitor_update_constel(s->qam_monitor, constel); qam_monitor_update_carrier_tracking(s->qam_monitor, v22bis_rx_carrier_frequency(s->v22bis)); - qam_monitor_update_symbol_tracking(s->qam_monitor, v22bis_symbol_timing_correction(s->v22bis)); + qam_monitor_update_symbol_tracking(s->qam_monitor, v22bis_rx_symbol_timing_correction(s->v22bis)); } #endif fpower = (constel->re - target->re)*(constel->re - target->re) @@ -188,7 +193,7 @@ static void qam_report(void *user_data, const complexf_t *constel, const complex else { printf("Gardner step %d\n", symbol); - len = v22bis_equalizer_state(s->v22bis, &coeffs); + len = v22bis_rx_equalizer_state(s->v22bis, &coeffs); printf("Equalizer A:\n"); for (i = 0; i < len; i++) printf("%3d (%15.5f, %15.5f) -> %15.5f\n", i, coeffs[i].re, coeffs[i].im, powerf(&coeffs[i])); @@ -205,9 +210,11 @@ int main(int argc, char *argv[]) int16_t amp[2][BLOCK_LEN]; int16_t model_amp[2][BLOCK_LEN]; int16_t out_amp[2*BLOCK_LEN]; + AFfilehandle inhandle; AFfilehandle outhandle; int outframes; int samples; + int samples2; int i; int j; int test_bps; @@ -222,11 +229,12 @@ int main(int argc, char *argv[]) channel_codec = MUNGE_CODEC_NONE; test_bps = 2400; line_model_no = 0; + decode_test_file = NULL; noise_level = -70; signal_level = -13; bits_per_test = 50000; log_audio = FALSE; - while ((opt = getopt(argc, argv, "b:B:c:glm:n:s:")) != -1) + while ((opt = getopt(argc, argv, "b:B:c:d:glm:n:s:")) != -1) { switch (opt) { @@ -244,6 +252,9 @@ int main(int argc, char *argv[]) case 'c': channel_codec = atoi(optarg); break; + case 'd': + decode_test_file = optarg; + break; case 'g': #if defined(ENABLE_GUI) use_gui = TRUE; @@ -270,6 +281,17 @@ int main(int argc, char *argv[]) break; } } + inhandle = AF_NULL_FILEHANDLE; + if (decode_test_file) + { + /* We will decode the audio from a wave file. */ + if ((inhandle = afOpenFile_telephony_read(decode_test_file, 1)) == AF_NULL_FILEHANDLE) + { + fprintf(stderr, " Cannot open wave file '%s'\n", decode_test_file); + exit(2); + } + } + outhandle = AF_NULL_FILEHANDLE; if (log_audio) { @@ -283,11 +305,11 @@ int main(int argc, char *argv[]) for (i = 0; i < 2; i++) { - endpoint[i].v22bis = v22bis_init(NULL, test_bps, V22BIS_GUARD_TONE_1800HZ, (i == 0), v22bis_getbit, v22bis_putbit, &endpoint[i]); + endpoint[i].v22bis = v22bis_init(NULL, test_bps, V22BIS_GUARD_TONE_1800HZ, (i == 0), v22bis_getbit, &endpoint[i], v22bis_putbit, &endpoint[i]); v22bis_tx_power(endpoint[i].v22bis, signal_level); /* Move the carrier off a bit */ endpoint[i].v22bis->tx.carrier_phase_rate = dds_phase_ratef((i == 0) ? 1207.0f : 2407.0f); - v22bis_set_qam_report_handler(endpoint[i].v22bis, qam_report, (void *) &endpoint[i]); + v22bis_rx_set_qam_report_handler(endpoint[i].v22bis, qam_report, (void *) &endpoint[i]); span_log_set_level(&endpoint[i].v22bis->logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW); span_log_set_tag(&endpoint[i].v22bis->logging, (i == 0) ? "caller" : "answerer"); endpoint[i].smooth_power = 0.0f; @@ -334,7 +356,7 @@ int main(int argc, char *argv[]) } } -#if 0 +#if 1 both_ways_line_model(model, model_amp[0], amp[0], @@ -345,6 +367,15 @@ int main(int argc, char *argv[]) vec_copyi16(model_amp[0], amp[0], samples); vec_copyi16(model_amp[1], amp[1], samples); #endif + if (decode_test_file) + { + samples2 = afReadFrames(inhandle, + AF_DEFAULT_TRACK, + model_amp[0], + samples); + if (samples2 != samples) + break; + } for (i = 0; i < 2; i++) { span_log_bump_samples(&endpoint[i].v22bis->logging, samples); @@ -368,6 +399,18 @@ int main(int argc, char *argv[]) } } } +#if defined(ENABLE_GUI) + if (use_gui) + qam_wait_to_end(endpoint[0].qam_monitor); +#endif + if (decode_test_file) + { + if (afCloseFile(inhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file); + exit(2); + } + } if (log_audio) { if (afCloseFile(outhandle) != 0) diff --git a/libs/spandsp/tests/v27ter_tests.c b/libs/spandsp/tests/v27ter_tests.c index d921b0dd49..2855fc753e 100644 --- a/libs/spandsp/tests/v27ter_tests.c +++ b/libs/spandsp/tests/v27ter_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v27ter_tests.c,v 1.103 2009/03/15 09:09:21 steveu Exp $ + * $Id: v27ter_tests.c,v 1.104 2009/04/25 16:30:52 steveu Exp $ */ /*! \page v27ter_tests_page V.27ter modem tests @@ -471,6 +471,14 @@ int main(int argc, char *argv[]) if (use_gui) qam_wait_to_end(qam_monitor); #endif + if (decode_test_file) + { + if (afCloseFile(inhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file); + exit(2); + } + } if (log_audio) { if (afCloseFile(outhandle)) diff --git a/libs/spandsp/tests/v29_tests.c b/libs/spandsp/tests/v29_tests.c index 918a6c5958..0f7f3e7ec0 100644 --- a/libs/spandsp/tests/v29_tests.c +++ b/libs/spandsp/tests/v29_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v29_tests.c,v 1.117 2009/03/15 09:09:21 steveu Exp $ + * $Id: v29_tests.c,v 1.118 2009/04/25 16:30:52 steveu Exp $ */ /*! \page v29_tests_page V.29 modem tests @@ -500,6 +500,14 @@ int main(int argc, char *argv[]) if (use_gui) qam_wait_to_end(qam_monitor); #endif + if (decode_test_file) + { + if (afCloseFile(inhandle)) + { + fprintf(stderr, " Cannot close wave file '%s'\n", decode_test_file); + exit(2); + } + } if (log_audio) { if (afCloseFile(outhandle)) diff --git a/libs/spandsp/tests/v8_tests.c b/libs/spandsp/tests/v8_tests.c index fe2d0c5872..7d8d7f1c12 100644 --- a/libs/spandsp/tests/v8_tests.c +++ b/libs/spandsp/tests/v8_tests.c @@ -22,14 +22,14 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: v8_tests.c,v 1.31 2008/11/30 10:17:31 steveu Exp $ + * $Id: v8_tests.c,v 1.32 2009/04/24 22:35:25 steveu Exp $ */ /*! \page v8_tests_page V.8 tests \section v8_tests_page_sec_1 What does it do? */ -/* Enable the following definition to enable direct probing into the FAX structures */ +/* Enable the following definition to enable direct probing into the internal structures */ //#define WITH_SPANDSP_INTERNALS #if defined(HAVE_CONFIG_H) diff --git a/libs/spandsp/tests/vector_float_tests.c b/libs/spandsp/tests/vector_float_tests.c index 2e17a04880..ec578bef41 100644 --- a/libs/spandsp/tests/vector_float_tests.c +++ b/libs/spandsp/tests/vector_float_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: vector_float_tests.c,v 1.12 2008/10/09 13:25:19 steveu Exp $ + * $Id: vector_float_tests.c,v 1.13 2009/04/26 07:00:39 steveu Exp $ */ #if defined(HAVE_CONFIG_H) @@ -33,7 +33,6 @@ #include #include #include -#include #include "spandsp.h" diff --git a/libs/spandsp/tests/vector_int_tests.c b/libs/spandsp/tests/vector_int_tests.c index 67ad5e0628..f8c147e955 100644 --- a/libs/spandsp/tests/vector_int_tests.c +++ b/libs/spandsp/tests/vector_int_tests.c @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: vector_int_tests.c,v 1.10 2008/09/18 12:05:35 steveu Exp $ + * $Id: vector_int_tests.c,v 1.11 2009/04/26 07:00:39 steveu Exp $ */ #if defined(HAVE_CONFIG_H) @@ -33,7 +33,6 @@ #include #include #include -#include #include "spandsp.h"