From 70c1c03c93f172ea18e33350897d58e3a82028d0 Mon Sep 17 00:00:00 2001 From: Steve Underwood Date: Tue, 6 Dec 2011 22:45:24 +0800 Subject: [PATCH] Addition of logging capability to the DTMF detector in spandsp, to aid debugging poor detection. Fixes to how timezones are handled for FAX page headers. Various cleanups of the spandsp headers. --- libs/spandsp/config/ax_c99_features.m4 | 24 +-- .../config/ax_check_export_capability.m4 | 8 +- libs/spandsp/src/Makefile.am | 20 +-- libs/spandsp/src/bell_r2_mf.c | 4 +- libs/spandsp/src/dds_int.c | 4 - libs/spandsp/src/dtmf.c | 72 +++++--- libs/spandsp/src/fax.c | 22 ++- libs/spandsp/src/image_translate.c | 21 ++- libs/spandsp/src/plc.c | 2 + libs/spandsp/src/spandsp.h.in | 3 +- libs/spandsp/src/spandsp/dtmf.h | 5 + libs/spandsp/src/spandsp/expose.h | 2 +- libs/spandsp/src/spandsp/private/dtmf.h | 6 + libs/spandsp/src/spandsp/private/fax.h | 2 +- libs/spandsp/src/spandsp/private/t30.h | 5 + libs/spandsp/src/spandsp/private/t31.h | 2 +- .../src/spandsp/private/t38_terminal.h | 2 +- libs/spandsp/src/spandsp/private/t4_tx.h | 4 +- libs/spandsp/src/spandsp/private/v17rx.h | 161 +++++++++--------- libs/spandsp/src/spandsp/private/v17tx.h | 23 +-- libs/spandsp/src/spandsp/private/v22bis.h | 69 ++++++-- libs/spandsp/src/spandsp/private/v27ter_rx.h | 93 +++++----- libs/spandsp/src/spandsp/private/v27ter_tx.h | 14 +- libs/spandsp/src/spandsp/t4_tx.h | 4 +- libs/spandsp/src/spandsp/v22bis.h | 2 - libs/spandsp/src/t30.c | 8 +- libs/spandsp/src/t30_api.c | 25 ++- libs/spandsp/src/t30_logging.c | 6 +- libs/spandsp/src/t31.c | 1 + libs/spandsp/src/t38_gateway.c | 6 +- libs/spandsp/src/t38_terminal.c | 6 +- libs/spandsp/src/t4_rx.c | 1 + libs/spandsp/src/t4_tx.c | 4 +- libs/spandsp/src/v17rx.c | 22 +-- libs/spandsp/src/v27ter_rx.c | 54 +++--- libs/spandsp/src/v27ter_tx.c | 16 +- libs/spandsp/src/v42.c | 2 +- libs/spandsp/tests/dtmf_rx_tests.c | 28 ++- 38 files changed, 455 insertions(+), 298 deletions(-) diff --git a/libs/spandsp/config/ax_c99_features.m4 b/libs/spandsp/config/ax_c99_features.m4 index 6f9644884a..52ab00b543 100644 --- a/libs/spandsp/config/ax_c99_features.m4 +++ b/libs/spandsp/config/ax_c99_features.m4 @@ -47,8 +47,8 @@ AC_DEFUN([AX_C99_FUNC_LRINT], [AC_CACHE_CHECK(for lrint, ac_cv_c99_lrint, [ -lrint_save_CFLAGS=$CFLAGS -CFLAGS="-lm" +lrint_save_LIBS=$LIBS +LIBS="-lm" AC_TRY_LINK([ #define _ISOC9X_SOURCE 1 #define _ISOC99_SOURCE 1 @@ -58,7 +58,7 @@ AC_TRY_LINK([ #include ], if (!lrint(3.14159)) lrint(2.7183);, ac_cv_c99_lrint=yes, ac_cv_c99_lrint=no) -CFLAGS=$lrint_save_CFLAGS +LIBS=$lrint_save_LIBS ]) @@ -84,8 +84,8 @@ AC_DEFUN([AX_C99_FUNC_LRINTF], [AC_CACHE_CHECK(for lrintf, ac_cv_c99_lrintf, [ -lrintf_save_CFLAGS=$CFLAGS -CFLAGS="-lm" +lrintf_save_LIBS=$LIBS +LIBS="-lm" AC_TRY_LINK([ #define _ISOC9X_SOURCE 1 #define _ISOC99_SOURCE 1 @@ -95,7 +95,7 @@ AC_TRY_LINK([ #include ], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no) -CFLAGS=$lrintf_save_CFLAGS +LIBS=$lrintf_save_LIBS ]) @@ -121,8 +121,8 @@ AC_DEFUN([AX_C99_FUNC_LLRINT], [AC_CACHE_CHECK(for llrint, ac_cv_c99_llrint, [ -llrint_save_CFLAGS=$CFLAGS -CFLAGS="-lm" +llrint_save_LIBS=$LIBS +LIBS="-lm" AC_TRY_LINK([ #define ISOC9X_SOURCE 1 #define _ISOC99_SOURCE 1 @@ -132,7 +132,7 @@ AC_TRY_LINK([ #include ], long long int x ; x = llrint(3.14159) ;, ac_cv_c99_llrint=yes, ac_cv_c99_llrint=no) -CFLAGS=$llrint_save_CFLAGS +LIBS=$llrint_save_LIBS ]) @@ -159,8 +159,8 @@ AC_DEFUN([AX_C99_FUNC_LLRINTF], [AC_CACHE_CHECK(for llrintf, ac_cv_c99_llrintf, [ -llrintf_save_CFLAGS=$CFLAGS -CFLAGS="-lm" +llrintf_save_LIBS=$LIBS +LIBS="-lm" AC_TRY_LINK([ #define _ISOC9X_SOURCE 1 #define _ISOC99_SOURCE 1 @@ -170,7 +170,7 @@ AC_TRY_LINK([ #include ], long long int x ; x = llrintf(3.14159) ;, ac_cv_c99_llrintf=yes, ac_cv_c99_llrintf=no) -CFLAGS=$llrintf_save_CFLAGS +LIBS=$llrintf_save_LIBS ]) diff --git a/libs/spandsp/config/ax_check_export_capability.m4 b/libs/spandsp/config/ax_check_export_capability.m4 index 37585393c2..952bb32139 100644 --- a/libs/spandsp/config/ax_check_export_capability.m4 +++ b/libs/spandsp/config/ax_check_export_capability.m4 @@ -28,8 +28,8 @@ gnu) )], [AC_MSG_RESULT([yes]) - COMP_VENDOR_CFLAGS="-fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 $COMP_VENDOR_CFLAGS" - COMP_VENDOR_CXXFLAGS="-fvisibility=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 $COMP_VENDOR_CXXFLAGS" + COMP_VENDOR_CFLAGS="-fvisibility=hidden -DHAVE_VISIBILITY=1 $COMP_VENDOR_CFLAGS" + COMP_VENDOR_CXXFLAGS="-fvisibility=hidden -DHAVE_VISIBILITY=1 $COMP_VENDOR_CXXFLAGS" ac_cv_symbol_export_capability="yes"], [AC_MSG_RESULT([no])] @@ -47,8 +47,8 @@ sun) )], [AC_MSG_RESULT([yes]) - COMP_VENDOR_CFLAGS="-xldscope=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 $COMP_VENDOR_CFLAGS" - COMP_VENDOR_CXXFLAGS="-xldscope=hidden -DSWITCH_API_VISIBILITY=1 -DHAVE_VISIBILITY=1 $COMP_VENDOR_CXXFLAGS" + COMP_VENDOR_CFLAGS="-xldscope=hidden -DHAVE_VISIBILITY=1 $COMP_VENDOR_CFLAGS" + COMP_VENDOR_CXXFLAGS="-xldscope=hidden -DHAVE_VISIBILITY=1 $COMP_VENDOR_CXXFLAGS" ac_cv_symbol_export_capability="yes"], [AC_MSG_RESULT([no])] diff --git a/libs/spandsp/src/Makefile.am b/libs/spandsp/src/Makefile.am index 5c1f216586..96924bfe4c 100644 --- a/libs/spandsp/src/Makefile.am +++ b/libs/spandsp/src/Makefile.am @@ -319,16 +319,16 @@ nobase_include_HEADERS = spandsp/adsi.h \ nodist_include_HEADERS = spandsp.h -noinst_HEADERS = faxfont.h \ - filter_tools.h \ - gsm0610_local.h \ - lpc10_encdecs.h \ - mmx_sse_decs.h \ - t30_local.h \ - t4_t6_decode_states.h \ - v17_v32bis_rx_constellation_maps.h \ - v17_v32bis_tx_constellation_maps.h \ - v29tx_constellation_maps.h +noinst_HEADERS = faxfont.h \ + filter_tools.h \ + gsm0610_local.h \ + lpc10_encdecs.h \ + mmx_sse_decs.h \ + t30_local.h \ + t4_t6_decode_states.h \ + v17_v32bis_rx_constellation_maps.h \ + v17_v32bis_tx_constellation_maps.h \ + v29tx_constellation_maps.h make_at_dictionary$(EXEEXT): $(top_srcdir)/src/make_at_dictionary.c $(CC_FOR_BUILD) -o make_at_dictionary$(EXEEXT) $(top_srcdir)/src/make_at_dictionary.c -DHAVE_CONFIG_H -I$(top_builddir)/src diff --git a/libs/spandsp/src/bell_r2_mf.c b/libs/spandsp/src/bell_r2_mf.c index e61b782dc5..1487a821f5 100644 --- a/libs/spandsp/src/bell_r2_mf.c +++ b/libs/spandsp/src/bell_r2_mf.c @@ -43,6 +43,7 @@ #include "floating_fudge.h" #include "spandsp/telephony.h" +#include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/queue.h" #include "spandsp/dc_restore.h" @@ -54,6 +55,7 @@ #include "spandsp/dtmf.h" #include "spandsp/bell_r2_mf.h" +#include "spandsp/private/logging.h" #include "spandsp/private/queue.h" #include "spandsp/private/tone_generate.h" #include "spandsp/private/bell_r2_mf.h" @@ -786,7 +788,7 @@ SPAN_DECLARE(int) r2_mf_rx(r2_mf_rx_state_t *s, const int16_t amp[], int samples } if (s->current_digit != hit_digit && s->callback) { - i = (hit_digit) ? -99 : -10; + i = (hit_digit) ? -10 : -99; s->callback(s->callback_data, hit_digit, i, 0); } s->current_digit = hit_digit; diff --git a/libs/spandsp/src/dds_int.c b/libs/spandsp/src/dds_int.c index 73eecb4077..df7a0a38cb 100644 --- a/libs/spandsp/src/dds_int.c +++ b/libs/spandsp/src/dds_int.c @@ -42,10 +42,6 @@ #include "spandsp/complex.h" #include "spandsp/dds.h" -#if !defined(M_PI) -# define M_PI 3.14159265358979323846 /* pi */ -#endif - /* In a A-law or u-law channel, a 128 step sine table is adequate to keep the spectral mess due to the DDS at a similar level to the spectral mess due to the A-law or u-law compression. */ diff --git a/libs/spandsp/src/dtmf.c b/libs/spandsp/src/dtmf.c index b07f8ec120..18a8b18420 100644 --- a/libs/spandsp/src/dtmf.c +++ b/libs/spandsp/src/dtmf.c @@ -29,8 +29,8 @@ #include "config.h" #endif -#include #include +#include #if defined(HAVE_TGMATH_H) #include #endif @@ -38,12 +38,12 @@ #include #endif #include "floating_fudge.h" +#include #include -#include -#include -#include +#include #include "spandsp/telephony.h" +#include "spandsp/logging.h" #include "spandsp/fast_convert.h" #include "spandsp/queue.h" #include "spandsp/complex.h" @@ -53,6 +53,7 @@ #include "spandsp/super_tone_rx.h" #include "spandsp/dtmf.h" +#include "spandsp/private/logging.h" #include "spandsp/private/queue.h" #include "spandsp/private/tone_generate.h" #include "spandsp/private/dtmf.h" @@ -165,6 +166,8 @@ SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples) goertzel_samplex(&s->row_out[3], xamp); goertzel_samplex(&s->col_out[3], xamp); } + if (s->duration < INT_MAX - (limit - sample)) + s->duration += (limit - sample); s->current_sample += (limit - sample); if (s->current_sample < DTMF_SAMPLES_PER_BLOCK) continue; @@ -188,29 +191,45 @@ SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples) /* Basic signal level test and the twist test */ if (row_energy[best_row] >= s->threshold && - col_energy[best_col] >= s->threshold - && - col_energy[best_col] < row_energy[best_row]*s->reverse_twist - && - col_energy[best_col]*s->normal_twist > row_energy[best_row]) + col_energy[best_col] >= s->threshold) { - /* Relative peak test ... */ - for (i = 0; i < 4; i++) + if (col_energy[best_col] < row_energy[best_row]*s->reverse_twist + && + col_energy[best_col]*s->normal_twist > row_energy[best_row]) { - if ((i != best_col && col_energy[i]*DTMF_RELATIVE_PEAK_COL > col_energy[best_col]) - || - (i != best_row && row_energy[i]*DTMF_RELATIVE_PEAK_ROW > row_energy[best_row])) + /* Relative peak test ... */ + for (i = 0; i < 4; i++) { - break; + if ((i != best_col && col_energy[i]*DTMF_RELATIVE_PEAK_COL > col_energy[best_col]) + || + (i != best_row && row_energy[i]*DTMF_RELATIVE_PEAK_ROW > row_energy[best_row])) + { + break; + } + } + /* ... and fraction of total energy test */ + if (i >= 4 + && + (row_energy[best_row] + col_energy[best_col]) > DTMF_TO_TOTAL_ENERGY*s->energy) + { + /* Got a hit */ + hit = dtmf_positions[(best_row << 2) + best_col]; } } - /* ... and fraction of total energy test */ - if (i >= 4 - && - (row_energy[best_row] + col_energy[best_col]) > DTMF_TO_TOTAL_ENERGY*s->energy) + if (span_log_test(&s->logging, SPAN_LOG_FLOW)) { - /* Got a hit */ - hit = dtmf_positions[(best_row << 2) + best_col]; + /* Log information about the quality of the signal, to aid analysis of detection problems */ + /* Logging at this point filters the total no-hoper frames out of the log, and leaves + anything which might feasibly be a DTMF digit. The log will then contain a list of the + total, row and coloumn power levels for detailed analysis of detection problems. */ + span_log(&s->logging, + SPAN_LOG_FLOW, + "Potentially '%c' - total %.2fdB, row %.2fdB, col %.2fdB - %s\n", + dtmf_positions[(best_row << 2) + best_col], + log10f(s->energy)*10.0f - DTMF_POWER_OFFSET + DBM0_MAX_POWER, + log10f(row_energy[best_row]/DTMF_TO_TOTAL_ENERGY)*10.0f - DTMF_POWER_OFFSET + DBM0_MAX_POWER, + log10f(col_energy[best_col]/DTMF_TO_TOTAL_ENERGY)*10.0f - DTMF_POWER_OFFSET + DBM0_MAX_POWER, + (hit) ? "hit" : "miss"); } } /* The logic in the next test should ensure the following for different successive hit patterns: @@ -251,7 +270,8 @@ SPAN_DECLARE(int) dtmf_rx(dtmf_rx_state_t *s, const int16_t amp[], int samples) if (s->in_digit || hit) { i = (s->in_digit && !hit) ? -99 : lfastrintf(log10f(s->energy)*10.0f - DTMF_POWER_OFFSET + DBM0_MAX_POWER); - s->realtime_callback(s->realtime_callback_data, hit, i, 0); + s->realtime_callback(s->realtime_callback_data, hit, i, s->duration); + s->duration = 0; } } else @@ -357,6 +377,12 @@ SPAN_DECLARE(void) dtmf_rx_parms(dtmf_rx_state_t *s, } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(logging_state_t *) dtmf_rx_get_logging_state(dtmf_rx_state_t *s) +{ + return &s->logging; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s, digits_rx_callback_t callback, void *user_data) @@ -369,6 +395,8 @@ SPAN_DECLARE(dtmf_rx_state_t *) dtmf_rx_init(dtmf_rx_state_t *s, if ((s = (dtmf_rx_state_t *) malloc(sizeof (*s))) == NULL) return NULL; } + span_log_init(&s->logging, SPAN_LOG_NONE, NULL); + span_log_set_protocol(&s->logging, "DTMF"); s->digits_callback = callback; s->digits_callback_data = user_data; s->realtime_callback = NULL; diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index ae10069e82..422315f2d0 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -71,12 +71,21 @@ #include "spandsp/v27ter_rx.h" #include "spandsp/v17tx.h" #include "spandsp/v17rx.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" +#endif +#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" #endif +#if defined(SPANDSP_SUPPORT_T42) +#include "spandsp/t42.h" +#endif +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/t43.h" +#endif #include "spandsp/t4_t6_decode.h" #include "spandsp/t4_t6_encode.h" @@ -102,10 +111,19 @@ #include "spandsp/private/v29rx.h" #include "spandsp/private/hdlc.h" #include "spandsp/private/fax_modems.h" -#if defined(SPANDSP_SUPPORT_T85) +#include "spandsp/private/timezone.h" +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" +#endif +#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" #endif +#if defined(SPANDSP_SUPPORT_T42) +#include "spandsp/private/t42.h" +#endif +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/private/t43.h" +#endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" #include "spandsp/private/t4_rx.h" diff --git a/libs/spandsp/src/image_translate.c b/libs/spandsp/src/image_translate.c index 3a3b86ff9d..beba3dab07 100644 --- a/libs/spandsp/src/image_translate.c +++ b/libs/spandsp/src/image_translate.c @@ -54,21 +54,38 @@ #include "spandsp/fast_convert.h" #include "spandsp/logging.h" #include "spandsp/saturated.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" +#endif +#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/t85.h" #endif +#if defined(SPANDSP_SUPPORT_T42) +#include "spandsp/t42.h" +#endif +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/t43.h" +#endif #include "spandsp/t4_t6_decode.h" #include "spandsp/t4_t6_encode.h" #include "spandsp/image_translate.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" +#endif +#if defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t85.h" #endif +#if defined(SPANDSP_SUPPORT_T42) +#include "spandsp/private/t42.h" +#endif +#if defined(SPANDSP_SUPPORT_T43) +#include "spandsp/private/t43.h" +#endif #include "spandsp/private/t4_t6_decode.h" #include "spandsp/private/t4_t6_encode.h" #include "spandsp/private/t4_rx.h" diff --git a/libs/spandsp/src/plc.c b/libs/spandsp/src/plc.c index 3d07417f68..fb1cea78be 100644 --- a/libs/spandsp/src/plc.c +++ b/libs/spandsp/src/plc.c @@ -165,8 +165,10 @@ SPAN_DECLARE(int) plc_fillin(plc_state_t *s, int16_t amp[], int len) float old_weight; float new_weight; float gain; + int16_t *orig_amp; int orig_len; + orig_amp = amp; orig_len = len; if (s->missing_samples == 0) { diff --git a/libs/spandsp/src/spandsp.h.in b/libs/spandsp/src/spandsp.h.in index eaed548c97..acb8a18ed5 100644 --- a/libs/spandsp/src/spandsp.h.in +++ b/libs/spandsp/src/spandsp.h.in @@ -52,6 +52,7 @@ #include #include #include +#include #include #include #include @@ -97,6 +98,7 @@ #include /*#include */ #include +#include #include #include #include @@ -126,7 +128,6 @@ #include #include #include -#include #endif diff --git a/libs/spandsp/src/spandsp/dtmf.h b/libs/spandsp/src/spandsp/dtmf.h index 60b2f65183..bca36cf015 100644 --- a/libs/spandsp/src/spandsp/dtmf.h +++ b/libs/spandsp/src/spandsp/dtmf.h @@ -186,6 +186,11 @@ SPAN_DECLARE(int) dtmf_rx_status(dtmf_rx_state_t *s); \return The number of digits actually returned. */ SPAN_DECLARE(size_t) dtmf_rx_get(dtmf_rx_state_t *s, char *digits, int max); +/*! \brief Get the logging context associated with a DTMF receiver context. + \param s The DTMF receiver context. + \return A pointer to the logging context */ +SPAN_DECLARE(logging_state_t *) dtmf_rx_get_logging_state(dtmf_rx_state_t *s); + /*! \brief Initialise a DTMF receiver context. \param s The DTMF receiver context. \param callback An optional callback routine, used to report received digits. If diff --git a/libs/spandsp/src/spandsp/expose.h b/libs/spandsp/src/spandsp/expose.h index ca2274d9f7..6989a3faae 100644 --- a/libs/spandsp/src/spandsp/expose.h +++ b/libs/spandsp/src/spandsp/expose.h @@ -72,6 +72,7 @@ /*#include */ #include #include +#include #include #include #include @@ -88,7 +89,6 @@ #include #include #include -#include #include #include #include diff --git a/libs/spandsp/src/spandsp/private/dtmf.h b/libs/spandsp/src/spandsp/private/dtmf.h index eeacff16d3..dc9c17bffc 100644 --- a/libs/spandsp/src/spandsp/private/dtmf.h +++ b/libs/spandsp/src/spandsp/private/dtmf.h @@ -96,6 +96,9 @@ struct dtmf_rx_state_s uint8_t in_digit; /*! The current sample number within a processing block. */ int current_sample; + + /*! Tone state duration */ + int duration; /*! The number of digits which have been lost due to buffer overflows. */ int lost_digits; @@ -103,6 +106,9 @@ struct dtmf_rx_state_s int current_digits; /*! The received digits buffer. This is a NULL terminated string. */ char digits[MAX_DTMF_DIGITS + 1]; + + /*! \brief Error and flow logging control */ + logging_state_t logging; }; #endif diff --git a/libs/spandsp/src/spandsp/private/fax.h b/libs/spandsp/src/spandsp/private/fax.h index c75f4fa01e..9e99a10751 100644 --- a/libs/spandsp/src/spandsp/private/fax.h +++ b/libs/spandsp/src/spandsp/private/fax.h @@ -40,7 +40,7 @@ struct fax_state_s /*! \brief The analogue modem front-end */ fax_modems_state_t modems; /*! \brief V.8 */ - //v8_state_t v8; + v8_state_t v8; /*! \brief Error and flow logging control */ logging_state_t logging; diff --git a/libs/spandsp/src/spandsp/private/t30.h b/libs/spandsp/src/spandsp/private/t30.h index b8a2e8be1c..8cd890b9e0 100644 --- a/libs/spandsp/src/spandsp/private/t30.h +++ b/libs/spandsp/src/spandsp/private/t30.h @@ -73,6 +73,11 @@ struct t30_state_s page image. FALSE for FAX page headers to add to the overall length of the page. */ int header_overlays_image; + /*! \brief Use private timezone if TRUE */ + int use_own_tz; + /*! \brief Optional per instance time zone for the FAX page header timestamp. */ + tz_t tz; + /*! \brief TRUE if remote T.30 procedural interrupts are allowed. */ int remote_interrupts_allowed; diff --git a/libs/spandsp/src/spandsp/private/t31.h b/libs/spandsp/src/spandsp/private/t31.h index a2d8f97199..ee481c5151 100644 --- a/libs/spandsp/src/spandsp/private/t31.h +++ b/libs/spandsp/src/spandsp/private/t31.h @@ -33,7 +33,7 @@ typedef struct { fax_modems_state_t modems; - //v8_state_t v8; + v8_state_t v8; /*! The transmit signal handler to be used when the current one has finished sending. */ span_tx_handler_t *next_tx_handler; diff --git a/libs/spandsp/src/spandsp/private/t38_terminal.h b/libs/spandsp/src/spandsp/private/t38_terminal.h index 6681f9321c..a78ec685f7 100644 --- a/libs/spandsp/src/spandsp/private/t38_terminal.h +++ b/libs/spandsp/src/spandsp/private/t38_terminal.h @@ -96,7 +96,7 @@ typedef struct /*! \brief The value for samples at the next transmission point. */ int32_t next_tx_samples; /*! \brief The current transmit timeout. */ - //int32_t timeout_tx_samples; + int32_t timeout_tx_samples; /*! \brief The current receive timeout. */ int32_t timeout_rx_samples; } t38_terminal_front_end_state_t; diff --git a/libs/spandsp/src/spandsp/private/t4_tx.h b/libs/spandsp/src/spandsp/private/t4_tx.h index a30f7ba7aa..9153b47e8b 100644 --- a/libs/spandsp/src/spandsp/private/t4_tx.h +++ b/libs/spandsp/src/spandsp/private/t4_tx.h @@ -49,8 +49,8 @@ struct t4_state_s /*! \brief The text which will be used in FAX page header. No text results in no header line. */ const char *header_info; - /*! \brief Optional per instance time zone for the FAX pager header timestamp. */ - struct tz_s *tz; + /*! \brief Optional per instance time zone for the FAX page header timestamp. */ + tz_t *tz; /*! \brief The size of the compressed image on the line side, in bits. */ int line_image_size; diff --git a/libs/spandsp/src/spandsp/private/v17rx.h b/libs/spandsp/src/spandsp/private/v17rx.h index 9bf9149dbc..8da0967a4a 100644 --- a/libs/spandsp/src/spandsp/private/v17rx.h +++ b/libs/spandsp/src/spandsp/private/v17rx.h @@ -72,77 +72,6 @@ struct v17_rx_state_s routine. */ void *qam_user_data; - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ -#if defined(SPANDSP_USE_FIXED_POINT) - int16_t rrc_filter[V17_RX_FILTER_STEPS]; -#else - float rrc_filter[V17_RX_FILTER_STEPS]; -#endif - /*! \brief Current offset into the RRC pulse shaping filter buffer. */ - int rrc_filter_step; - - /*! \brief The state of the differential decoder */ - int diff; - /*! \brief The register for the data scrambler. */ - uint32_t scramble_reg; - /*! \brief Scrambler tap */ - int scrambler_tap; - - /*! \brief TRUE if the short training sequence is to be used. */ - int short_train; - /*! \brief The section of the training data we are currently in. */ - int training_stage; - /*! \brief A count of how far through the current training step we are. */ - int training_count; - /*! \brief A measure of how much mismatch there is between the real constellation, - and the decoded symbol positions. */ - float training_error; - /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ - int16_t last_sample; - /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.17 signal. */ - int signal_present; - /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ - int carrier_drop_pending; - /*! \brief A count of the current consecutive samples below the carrier off threshold. */ - int low_samples; - /*! \brief A highest magnitude sample seen. */ - int16_t high_sample; - - /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ - uint32_t carrier_phase; - /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ - int32_t carrier_phase_rate; - /*! \brief The carrier update rate saved for reuse when using short training. */ - int32_t carrier_phase_rate_save; -#if defined(SPANDSP_USE_FIXED_POINTx) - /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; - /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; -#else - /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; - /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; -#endif - - /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ - power_meter_t power; - /*! \brief The power meter level at which carrier on is declared. */ - int32_t carrier_on_power; - /*! \brief The power meter level at which carrier off is declared. */ - int32_t carrier_off_power; - - /*! \brief Current read offset into the equalizer buffer. */ - int eq_step; - /*! \brief Current write offset into the equalizer buffer. */ - int eq_put_step; - /*! \brief Symbol count to the next equalizer update. */ - int eq_skip; - - /*! \brief The current half of the baud. */ - int baud_half; - #if defined(SPANDSP_USE_FIXED_POINTx) /*! \brief The scaling factor accessed by the AGC algorithm. */ float agc_scaling; @@ -166,6 +95,20 @@ struct v17_rx_state_s int32_t symbol_sync_dc_filter[2]; /*! Baud phase for symbol sync. */ int32_t baud_phase; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; + + /*! \brief The proportional part of the carrier tracking filter. */ + float carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + float carrier_track_i; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + int16_t rrc_filter[V17_RX_FILTER_STEPS]; + + /*! \brief A pointer to the current constellation. */ + const complexi16_t *constellation; #else /*! \brief The scaling factor accessed by the AGC algorithm. */ float agc_scaling; @@ -189,7 +132,71 @@ struct v17_rx_state_s float symbol_sync_dc_filter[2]; /*! Baud phase for symbol sync. */ float baud_phase; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; + + /*! \brief The proportional part of the carrier tracking filter. */ + float carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + float carrier_track_i; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + float rrc_filter[V17_RX_FILTER_STEPS]; + + /*! \brief A pointer to the current constellation. */ + const complexf_t *constellation; #endif + /*! \brief Current offset into the RRC pulse shaping filter buffer. */ + int rrc_filter_step; + + /*! \brief The state of the differential decoder */ + int diff; + /*! \brief The register for the data scrambler. */ + uint32_t scramble_reg; + /*! \brief Scrambler tap */ + int scrambler_tap; + + /*! \brief TRUE if the short training sequence is to be used. */ + int short_train; + /*! \brief The section of the training data we are currently in. */ + int training_stage; + /*! \brief A count of how far through the current training step we are. */ + int training_count; + /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ + int16_t last_sample; + /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.17 signal. */ + int signal_present; + /*! \brief Whether or not a carrier drop was detected and the signal delivery is pending. */ + int carrier_drop_pending; + /*! \brief A count of the current consecutive samples below the carrier off threshold. */ + int low_samples; + /*! \brief A highest magnitude sample seen. */ + int16_t high_sample; + + /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ + uint32_t carrier_phase; + /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ + int32_t carrier_phase_rate; + /*! \brief The carrier update rate saved for reuse when using short training. */ + int32_t carrier_phase_rate_save; + + /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ + power_meter_t power; + /*! \brief The power meter level at which carrier on is declared. */ + int32_t carrier_on_power; + /*! \brief The power meter level at which carrier off is declared. */ + int32_t carrier_off_power; + + /*! \brief Current read offset into the equalizer buffer. */ + int eq_step; + /*! \brief Current write offset into the equalizer buffer. */ + int eq_put_step; + /*! \brief Symbol count to the next equalizer update. */ + int eq_skip; + + /*! \brief The current half of the baud. */ + int baud_half; /*! \brief The total symbol timing correction since the carrier came up. This is only for performance analysis purposes. */ @@ -199,12 +206,7 @@ struct v17_rx_state_s int32_t start_angles[2]; /*! \brief History list of phase angles for the coarse carrier aquisition step. */ int32_t angles[16]; - /*! \brief A pointer to the current constellation. */ -#if defined(SPANDSP_USE_FIXED_POINTx) - const complexi16_t *constellation; -#else - const complexf_t *constellation; -#endif + /*! \brief A pointer to the current space map. There is a space map for each trellis state. */ int space_map; @@ -217,13 +219,16 @@ struct v17_rx_state_s int full_path_to_past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; /*! \brief The trellis. */ int past_state_locations[V17_TRELLIS_STORAGE_DEPTH][8]; +#if defined(SPANDSP_USE_FIXED_POINTx) /*! \brief Euclidean distances (actually the squares of the distances) from the last states of the trellis. */ -#if defined(SPANDSP_USE_FIXED_POINTx) uint32_t distances[8]; #else + /*! \brief Euclidean distances (actually the squares of the distances) + from the last states of the trellis. */ float distances[8]; #endif + /*! \brief Error and flow logging control */ logging_state_t logging; }; diff --git a/libs/spandsp/src/spandsp/private/v17tx.h b/libs/spandsp/src/spandsp/private/v17tx.h index badbd799b0..f6c9d21343 100644 --- a/libs/spandsp/src/spandsp/private/v17tx.h +++ b/libs/spandsp/src/spandsp/private/v17tx.h @@ -49,23 +49,24 @@ struct v17_tx_state_s /*! \brief A user specified opaque pointer passed to the status function. */ void *status_user_data; +#if defined(SPANDSP_USE_FIXED_POINT) /*! \brief The gain factor needed to achieve the specified output power. */ -#if defined(SPANDSP_USE_FIXED_POINT) - int32_t gain; -#else - float gain; -#endif - - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ -#if defined(SPANDSP_USE_FIXED_POINT) + int16_t gain; + /*! \brief A pointer to the constellation currently in use. */ + const complexi16_t *constellation; /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ int16_t rrc_filter_re[V17_TX_FILTER_STEPS]; int16_t rrc_filter_im[V17_TX_FILTER_STEPS]; #else + /*! \brief The gain factor needed to achieve the specified output power. */ + float gain; + /*! \brief A pointer to the constellation currently in use. */ + const complexf_t *constellation; /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ float rrc_filter_re[V17_TX_FILTER_STEPS]; float rrc_filter_im[V17_TX_FILTER_STEPS]; #endif + /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; @@ -94,12 +95,6 @@ struct v17_tx_state_s /*! \brief The current fractional phase of the baud timing. */ int baud_phase; - /*! \brief A pointer to the constellation currently in use. */ -#if defined(SPANDSP_USE_FIXED_POINT) - const complexi16_t *constellation; -#else - const complexf_t *constellation; -#endif /*! \brief The current number of data bits per symbol. This does not include the redundant bit. */ int bits_per_symbol; diff --git a/libs/spandsp/src/spandsp/private/v22bis.h b/libs/spandsp/src/spandsp/private/v22bis.h index d81bd039c5..67962e0daf 100644 --- a/libs/spandsp/src/spandsp/private/v22bis.h +++ b/libs/spandsp/src/spandsp/private/v22bis.h @@ -27,15 +27,15 @@ #define _SPANDSP_PRIVATE_V22BIS_H_ /*! The number of steps to the left and to the right of the target position in the equalizer buffer. */ -#define V22BIS_EQUALIZER_LEN 7 +#define V22BIS_EQUALIZER_LEN 7 /*! One less than a power of 2 >= (2*V22BIS_EQUALIZER_LEN + 1) */ -#define V22BIS_EQUALIZER_MASK 15 +#define V22BIS_EQUALIZER_MASK 15 /*! The number of taps in the transmit pulse shaping filter */ -#define V22BIS_TX_FILTER_STEPS 9 +#define V22BIS_TX_FILTER_STEPS 9 /*! The number of taps in the receive pulse shaping/bandpass filter */ -#define V22BIS_RX_FILTER_STEPS 27 +#define V22BIS_RX_FILTER_STEPS 27 /*! Segments of the training sequence on the receive side */ enum @@ -65,6 +65,12 @@ enum V22BIS_TX_TRAINING_STAGE_PARKED }; +#if defined(SPANDSP_USE_FIXED_POINT) +extern const complexi16_t v22bis_constellation[16]; +#else +extern const complexf_t v22bis_constellation[16]; +#endif + /*! V.22bis modem descriptor. This defines the working state for a single instance of a V.22bis modem. @@ -93,10 +99,15 @@ struct v22bis_state_s /* Receive section */ struct { - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ #if defined(SPANDSP_USE_FIXED_POINTx) + /*! \brief The scaling factor accessed by the AGC algorithm. */ + float agc_scaling; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ int16_t rrc_filter[V22BIS_RX_FILTER_STEPS]; #else + /*! \brief The scaling factor accessed by the AGC algorithm. */ + float agc_scaling; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ float rrc_filter[V22BIS_RX_FILTER_STEPS]; #endif /*! \brief Current offset into the RRC pulse shaping filter buffer. */ @@ -116,19 +127,29 @@ struct v22bis_state_s /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.22bis signal. */ int signal_present; - /*! \brief A measure of how much mismatch there is between the real constellation, - and the decoded symbol positions. */ - float training_error; - /*! \brief The current phase of the carrier (i.e. the DDS parameter). */ uint32_t carrier_phase; /*! \brief The update rate for the phase of the carrier (i.e. the DDS increment). */ int32_t carrier_phase_rate; + +#if defined(SPANDSP_USE_FIXED_POINTx) + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; /*! \brief The proportional part of the carrier tracking filter. */ float carrier_track_p; /*! \brief The integral part of the carrier tracking filter. */ float carrier_track_i; - +#else + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; + /*! \brief The proportional part of the carrier tracking filter. */ + float carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + float carrier_track_i; +#endif + /*! \brief A callback function which may be enabled to report every symbol's constellation position. */ qam_report_handler_t qam_report; @@ -142,20 +163,22 @@ struct v22bis_state_s int32_t carrier_on_power; /*! \brief The power meter level at which carrier off is declared. */ int32_t carrier_off_power; - /*! \brief The scaling factor accessed by the AGC algorithm. */ - float agc_scaling; - + int constellation_state; +#if defined(SPANDSP_USE_FIXED_POINTx) /*! \brief The current delta factor for updating the equalizer coefficients. */ float eq_delta; -#if defined(SPANDSP_USE_FIXED_POINTx) /*! \brief The adaptive equalizer coefficients. */ complexi_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1]; /*! \brief The equalizer signal buffer. */ complexi_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; #else + /*! \brief The current delta factor for updating the equalizer coefficients. */ + float eq_delta; + /*! \brief The adaptive equalizer coefficients. */ complexf_t eq_coeff[2*V22BIS_EQUALIZER_LEN + 1]; + /*! \brief The equalizer signal buffer. */ complexf_t eq_buf[V22BIS_EQUALIZER_MASK + 1]; #endif /*! \brief Current offset into the equalizer buffer. */ @@ -182,16 +205,27 @@ struct v22bis_state_s /* Transmit section */ struct { +#if defined(SPANDSP_USE_FIXED_POINTx) + /*! \brief The guard tone level. */ + float guard_level; /*! \brief The gain factor needed to achieve the specified output power. */ float gain; - - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ complexf_t rrc_filter[2*V22BIS_TX_FILTER_STEPS]; +#else + /*! \brief The guard tone level. */ + float guard_level; + /*! \brief The gain factor needed to achieve the specified output power. */ + float gain; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + complexf_t rrc_filter[2*V22BIS_TX_FILTER_STEPS]; +#endif + /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; /*! \brief The register for the data scrambler. */ - unsigned int scramble_reg; + uint32_t scramble_reg; /*! \brief A counter for the number of consecutive bits of repeating pattern through the scrambler. */ int scrambler_pattern_count; @@ -208,7 +242,6 @@ struct v22bis_state_s uint32_t guard_phase; /*! \brief The update rate for the phase of the guard tone (i.e. the DDS increment). */ int32_t guard_phase_rate; - float guard_level; /*! \brief The current fractional phase of the baud timing. */ int baud_phase; /*! \brief The code number for the current position in the constellation. */ diff --git a/libs/spandsp/src/spandsp/private/v27ter_rx.h b/libs/spandsp/src/spandsp/private/v27ter_rx.h index 8ae99b4f81..4a991ba3f5 100644 --- a/libs/spandsp/src/spandsp/private/v27ter_rx.h +++ b/libs/spandsp/src/spandsp/private/v27ter_rx.h @@ -69,17 +69,62 @@ struct v27ter_rx_state_s routine. */ void *qam_user_data; - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ #if defined(SPANDSP_USE_FIXED_POINT) + /*! \brief The scaling factor accessed by the AGC algorithm. */ + int16_t agc_scaling; + /*! \brief The previous value of agc_scaling, needed to reuse old training. */ + int16_t agc_scaling_save; + + /*! \brief The current delta factor for updating the equalizer coefficients. */ + float eq_delta; + /*! \brief The adaptive equalizer coefficients. */ + /*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_LEN]; + /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ + /*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN]; + /*! \brief The equalizer signal buffer. */ + /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_LEN]; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; + + /*! \brief The proportional part of the carrier tracking filter. */ + float carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + float carrier_track_i; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ int16_t rrc_filter[V27TER_RX_FILTER_STEPS]; #else + /*! \brief The scaling factor accessed by the AGC algorithm. */ + float agc_scaling; + /*! \brief The previous value of agc_scaling, needed to reuse old training. */ + float agc_scaling_save; + + /*! \brief The current delta factor for updating the equalizer coefficients. */ + float eq_delta; + /*! \brief The adaptive equalizer coefficients. */ + complexf_t eq_coeff[V27TER_EQUALIZER_LEN]; + /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ + complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN]; + /*! \brief The equalizer signal buffer. */ + complexf_t eq_buf[V27TER_EQUALIZER_LEN]; + + /*! \brief A measure of how much mismatch there is between the real constellation, + and the decoded symbol positions. */ + float training_error; + + /*! \brief The proportional part of the carrier tracking filter. */ + float carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + float carrier_track_i; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ float rrc_filter[V27TER_RX_FILTER_STEPS]; #endif /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; /*! \brief The register for the training and data scrambler. */ - unsigned int scramble_reg; + uint32_t scramble_reg; /*! \brief A counter for the number of consecutive bits of repeating pattern through the scrambler. */ int scrambler_pattern_count; @@ -91,9 +136,6 @@ struct v27ter_rx_state_s int training_stage; /*! \brief A count of how far through the current training step we are. */ int training_count; - /*! \brief A measure of how much mismatch there is between the real constellation, - and the decoded symbol positions. */ - float training_error; /*! \brief The value of the last signal sample, using the a simple HPF for signal power estimation. */ int16_t last_sample; /*! \brief >0 if a signal above the minimum is present. It may or may not be a V.27ter signal. */ @@ -115,17 +157,6 @@ struct v27ter_rx_state_s int32_t carrier_phase_rate; /*! \brief The carrier update rate saved for reuse when using short training. */ int32_t carrier_phase_rate_save; -#if defined(SPANDSP_USE_FIXED_POINTx) - /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; - /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; -#else - /*! \brief The proportional part of the carrier tracking filter. */ - float carrier_track_p; - /*! \brief The integral part of the carrier tracking filter. */ - float carrier_track_i; -#endif /*! \brief A power meter, to measure the HPF'ed signal power in the channel. */ power_meter_t power; @@ -144,36 +175,6 @@ struct v27ter_rx_state_s /*! \brief The current half of the baud. */ int baud_half; -#if defined(SPANDSP_USE_FIXED_POINT) - /*! \brief The scaling factor accessed by the AGC algorithm. */ - int16_t agc_scaling; - /*! \brief The previous value of agc_scaling, needed to reuse old training. */ - int16_t agc_scaling_save; - - /*! \brief The current delta factor for updating the equalizer coefficients. */ - float eq_delta; - /*! \brief The adaptive equalizer coefficients. */ - /*complexi16_t*/ complexf_t eq_coeff[V27TER_EQUALIZER_LEN]; - /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ - /*complexi16_t*/ complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN]; - /*! \brief The equalizer signal buffer. */ - /*complexi16_t*/ complexf_t eq_buf[V27TER_EQUALIZER_LEN]; -#else - /*! \brief The scaling factor accessed by the AGC algorithm. */ - float agc_scaling; - /*! \brief The previous value of agc_scaling, needed to reuse old training. */ - float agc_scaling_save; - - /*! \brief The current delta factor for updating the equalizer coefficients. */ - float eq_delta; - /*! \brief The adaptive equalizer coefficients. */ - complexf_t eq_coeff[V27TER_EQUALIZER_LEN]; - /*! \brief A saved set of adaptive equalizer coefficients for use after restarts. */ - complexf_t eq_coeff_save[V27TER_EQUALIZER_LEN]; - /*! \brief The equalizer signal buffer. */ - complexf_t eq_buf[V27TER_EQUALIZER_LEN]; -#endif - /*! \brief Integration variable for damping the Gardner algorithm tests. */ int gardner_integrate; /*! \brief Current step size of Gardner algorithm integration. */ diff --git a/libs/spandsp/src/spandsp/private/v27ter_tx.h b/libs/spandsp/src/spandsp/private/v27ter_tx.h index f9781aeb0f..18e27e1277 100644 --- a/libs/spandsp/src/spandsp/private/v27ter_tx.h +++ b/libs/spandsp/src/spandsp/private/v27ter_tx.h @@ -49,26 +49,24 @@ struct v27ter_tx_state_s #if defined(SPANDSP_USE_FIXED_POINT) /*! \brief The gain factor needed to achieve the specified output power at 2400bps. */ - int32_t gain_2400; + int16_t gain_2400; /*! \brief The gain factor needed to achieve the specified output power at 4800bps. */ - int32_t gain_4800; + int16_t gain_4800; + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ + complexi16_t rrc_filter[2*V27TER_TX_FILTER_STEPS]; #else /*! \brief The gain factor needed to achieve the specified output power at 2400bps. */ float gain_2400; /*! \brief The gain factor needed to achieve the specified output power at 4800bps. */ float gain_4800; -#endif - /*! \brief The route raised cosine (RRC) pulse shaping filter buffer. */ -#if defined(SPANDSP_USE_FIXED_POINT) - complexi16_t rrc_filter[2*V27TER_TX_FILTER_STEPS]; -#else + /*! \brief The root raised cosine (RRC) pulse shaping filter buffer. */ complexf_t rrc_filter[2*V27TER_TX_FILTER_STEPS]; #endif /*! \brief Current offset into the RRC pulse shaping filter buffer. */ int rrc_filter_step; /*! \brief The register for the training and data scrambler. */ - unsigned int scramble_reg; + uint32_t scramble_reg; /*! \brief A counter for the number of consecutive bits of repeating pattern through the scrambler. */ int scrambler_pattern_count; diff --git a/libs/spandsp/src/spandsp/t4_tx.h b/libs/spandsp/src/spandsp/t4_tx.h index 6ee4135b4b..3985e28f63 100644 --- a/libs/spandsp/src/spandsp/t4_tx.h +++ b/libs/spandsp/src/spandsp/t4_tx.h @@ -141,8 +141,8 @@ SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info); the current time zone of the program's environment is used. \brief Set the header timezone. \param s The T.4 context. - \param info A POSIX timezone description string. */ -SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, const char *tzstring); + \param tz A time zone descriptor. */ +SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, tz_t *tz); /*! Set page header extends or overlays the image mode. \brief Set page header overlay mode. diff --git a/libs/spandsp/src/spandsp/v22bis.h b/libs/spandsp/src/spandsp/v22bis.h index 073fb7135a..a203c72795 100644 --- a/libs/spandsp/src/spandsp/v22bis.h +++ b/libs/spandsp/src/spandsp/v22bis.h @@ -61,8 +61,6 @@ enum */ typedef struct v22bis_state_s v22bis_state_t; -extern const complexf_t v22bis_constellation[16]; - #if defined(__cplusplus) extern "C" { diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index eb3eca248a..c301ceb0d4 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -58,9 +58,10 @@ #include "spandsp/v29tx.h" #include "spandsp/v27ter_rx.h" #include "spandsp/v27ter_tx.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) @@ -81,7 +82,8 @@ #include "spandsp/t30_logging.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#include "spandsp/private/timezone.h" +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) @@ -1975,6 +1977,8 @@ static int start_sending_document(t30_state_t *s) t4_tx_set_tx_encoding(&s->t4.tx, s->line_encoding); t4_tx_set_local_ident(&s->t4.tx, s->tx_info.ident); t4_tx_set_header_info(&s->t4.tx, s->header_info); + if (s->use_own_tz) + t4_tx_set_header_tz(&s->t4.tx, &s->tz); s->x_resolution = t4_tx_get_x_resolution(&s->t4.tx); s->y_resolution = t4_tx_get_y_resolution(&s->t4.tx); diff --git a/libs/spandsp/src/t30_api.c b/libs/spandsp/src/t30_api.c index b7a571989d..707f5fe44e 100644 --- a/libs/spandsp/src/t30_api.c +++ b/libs/spandsp/src/t30_api.c @@ -58,9 +58,10 @@ #include "spandsp/v29tx.h" #include "spandsp/v27ter_rx.h" #include "spandsp/v27ter_tx.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) @@ -81,7 +82,8 @@ #include "spandsp/t30_logging.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#include "spandsp/private/timezone.h" +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) @@ -585,13 +587,6 @@ SPAN_DECLARE(int) t30_set_tx_page_header_info(t30_state_t *s, const char *info) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(int) t30_set_tx_page_header_tz(t30_state_t *s, const char *tzstring) -{ - t4_tx_set_header_tz(&s->t4.tx, tzstring); - return 0; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE(size_t) t30_get_tx_page_header_info(t30_state_t *s, char *info) { if (info) @@ -600,6 +595,18 @@ SPAN_DECLARE(size_t) t30_get_tx_page_header_info(t30_state_t *s, char *info) } /*- End of function --------------------------------------------------------*/ +SPAN_DECLARE(int) t30_set_tx_page_header_tz(t30_state_t *s, const char *tzstring) +{ + if (tz_init(&s->tz, tzstring)) + { + s->use_own_tz = TRUE; + t4_tx_set_header_tz(&s->t4.tx, &s->tz); + return 0; + } + return -1; +} +/*- End of function --------------------------------------------------------*/ + SPAN_DECLARE(const char *) t30_get_rx_country(t30_state_t *s) { return s->country; diff --git a/libs/spandsp/src/t30_logging.c b/libs/spandsp/src/t30_logging.c index 700c0db18d..52ab767dfc 100644 --- a/libs/spandsp/src/t30_logging.c +++ b/libs/spandsp/src/t30_logging.c @@ -58,9 +58,10 @@ #include "spandsp/v29tx.h" #include "spandsp/v27ter_rx.h" #include "spandsp/v27ter_tx.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) @@ -80,7 +81,8 @@ #include "spandsp/t30_logging.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#include "spandsp/private/timezone.h" +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 5a23de1d2f..6839b0efcc 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -77,6 +77,7 @@ #if defined(SPANDSP_SUPPORT_V34) #include "spandsp/v34.h" #endif +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" #include "spandsp/t30.h" diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index 11760f9743..0626ac4086 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -71,9 +71,10 @@ #include "spandsp/v17rx.h" #include "spandsp/super_tone_rx.h" #include "spandsp/modem_connect_tones.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) @@ -108,7 +109,8 @@ #include "spandsp/private/modem_connect_tones.h" #include "spandsp/private/hdlc.h" #include "spandsp/private/fax_modems.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#include "spandsp/private/timezone.h" +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) diff --git a/libs/spandsp/src/t38_terminal.c b/libs/spandsp/src/t38_terminal.c index 64b30f4805..836210ca9f 100644 --- a/libs/spandsp/src/t38_terminal.c +++ b/libs/spandsp/src/t38_terminal.c @@ -61,9 +61,10 @@ #include "spandsp/v27ter_rx.h" #include "spandsp/v17tx.h" #include "spandsp/v17rx.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) @@ -86,7 +87,8 @@ #include "spandsp/t38_terminal.h" #include "spandsp/private/logging.h" -#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) | defined(SPANDSP_SUPPORT_T85) +#include "spandsp/private/timezone.h" +#if defined(SPANDSP_SUPPORT_T42) || defined(SPANDSP_SUPPORT_T43) || defined(SPANDSP_SUPPORT_T85) #include "spandsp/private/t81_t82_arith_coding.h" #endif #if defined(SPANDSP_SUPPORT_T85) diff --git a/libs/spandsp/src/t4_rx.c b/libs/spandsp/src/t4_rx.c index 131bfc0179..bc3389d7b4 100644 --- a/libs/spandsp/src/t4_rx.c +++ b/libs/spandsp/src/t4_rx.c @@ -82,6 +82,7 @@ #include "spandsp/logging.h" #include "spandsp/bit_operations.h" #include "spandsp/async.h" +#include "spandsp/timezone.h" #include "spandsp/t4_rx.h" #include "spandsp/t4_tx.h" #if defined(SPANDSP_SUPPORT_T85) diff --git a/libs/spandsp/src/t4_tx.c b/libs/spandsp/src/t4_tx.c index b2842a46d7..5d150348ba 100644 --- a/libs/spandsp/src/t4_tx.c +++ b/libs/spandsp/src/t4_tx.c @@ -1521,9 +1521,9 @@ SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, const char *tzstring) +SPAN_DECLARE(void) t4_tx_set_header_tz(t4_state_t *s, tz_t *tz) { - s->tz = tz_init(s->tz, tzstring); + s->tz = tz; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/v17rx.c b/libs/spandsp/src/v17rx.c index 89b7dc4c9a..62256eb3b4 100644 --- a/libs/spandsp/src/v17rx.c +++ b/libs/spandsp/src/v17rx.c @@ -126,13 +126,13 @@ enum #define ALPHA 0.99f #if defined(SPANDSP_USE_FIXED_POINTx) -#define SYNC_LOW_BAND_EDGE_COEFF_0 ((int)(FP_FACTOR*(2.0f*ALPHA*COS_LOW_BAND_EDGE))) -#define SYNC_LOW_BAND_EDGE_COEFF_1 ((int)(FP_FACTOR*(-ALPHA*ALPHA))) -#define SYNC_LOW_BAND_EDGE_COEFF_2 ((int)(FP_FACTOR*(-ALPHA*SIN_LOW_BAND_EDGE))) -#define SYNC_HIGH_BAND_EDGE_COEFF_0 ((int)(FP_FACTOR*(2.0f*ALPHA*COS_HIGH_BAND_EDGE))) -#define SYNC_HIGH_BAND_EDGE_COEFF_1 ((int)(FP_FACTOR*(-ALPHA*ALPHA))) -#define SYNC_HIGH_BAND_EDGE_COEFF_2 ((int)(FP_FACTOR*(-ALPHA*SIN_HIGH_BAND_EDGE))) -#define SYNC_MIXED_EDGES_COEFF_3 ((int)(FP_FACTOR*(-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE)))) +#define SYNC_LOW_BAND_EDGE_COEFF_0 FP_Q_6_10(2.0f*ALPHA*COS_LOW_BAND_EDGE) +#define SYNC_LOW_BAND_EDGE_COEFF_1 FP_Q_6_10(-ALPHA*ALPHA) +#define SYNC_LOW_BAND_EDGE_COEFF_2 FP_Q_6_10(-ALPHA*SIN_LOW_BAND_EDGE) +#define SYNC_HIGH_BAND_EDGE_COEFF_0 FP_Q_6_10(2.0f*ALPHA*COS_HIGH_BAND_EDGE) +#define SYNC_HIGH_BAND_EDGE_COEFF_1 FP_Q_6_10(-ALPHA*ALPHA) +#define SYNC_HIGH_BAND_EDGE_COEFF_2 FP_Q_6_10(-ALPHA*SIN_HIGH_BAND_EDGE) +#define SYNC_MIXED_EDGES_COEFF_3 FP_Q_6_10(-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE)) #else #define SYNC_LOW_BAND_EDGE_COEFF_0 (2.0f*ALPHA*COS_LOW_BAND_EDGE) #define SYNC_LOW_BAND_EDGE_COEFF_1 (-ALPHA*ALPHA) @@ -146,10 +146,10 @@ enum #if defined(SPANDSP_USE_FIXED_POINTx) static const int constellation_spacing[4] = { - ((int)(FP_FACTOR*1.414f), - ((int)(FP_FACTOR*2.0f)}, - ((int)(FP_FACTOR*2.828f)}, - ((int)(FP_FACTOR*4.0f)}, + FP_Q_6_10(1.414f), + FP_Q_6_10(2.0f), + FP_Q_6_10(2.828f), + FP_Q_6_10(4.0f) }; #else static const float constellation_spacing[4] = diff --git a/libs/spandsp/src/v27ter_rx.c b/libs/spandsp/src/v27ter_rx.c index 22ce185408..5ae87dc44d 100644 --- a/libs/spandsp/src/v27ter_rx.c +++ b/libs/spandsp/src/v27ter_rx.c @@ -44,6 +44,9 @@ #include "spandsp/telephony.h" #include "spandsp/logging.h" +#include "spandsp/fast_convert.h" +#include "spandsp/math_fixed.h" +#include "spandsp/saturated.h" #include "spandsp/complex.h" #include "spandsp/vector_float.h" #include "spandsp/complex_vector_float.h" @@ -62,9 +65,11 @@ #include "spandsp/private/v27ter_rx.h" #if defined(SPANDSP_USE_FIXED_POINT) +#define FP_SCALE FP_Q_6_10 #include "v27ter_rx_4800_fixed_rrc.h" #include "v27ter_rx_2400_fixed_rrc.h" #else +#define FP_SCALE(x) (x) #include "v27ter_rx_4800_floating_rrc.h" #include "v27ter_rx_2400_floating_rrc.h" #endif @@ -110,29 +115,19 @@ enum #if defined(SPANDSP_USE_FIXED_POINTx) static const complexi16_t v27ter_constellation[8] = -{ - {((int)(FP_FACTOR* 1.414f), ((int)(FP_FACTOR* 0.0f)}, /* 0deg */ - {((int)(FP_FACTOR* 1.0f), ((int)(FP_FACTOR* 1.0f)}, /* 45deg */ - {((int)(FP_FACTOR* 0.0f), ((int)(FP_FACTOR* 1.414f)}, /* 90deg */ - {((int)(FP_FACTOR*-1.0f), ((int)(FP_FACTOR* 1.0f)}, /* 135deg */ - {((int)(FP_FACTOR*-1.414f), ((int)(FP_FACTOR* 0.0f)}, /* 180deg */ - {((int)(FP_FACTOR*-1.0f), ((int)(FP_FACTOR*-1.0f)}, /* 225deg */ - {((int)(FP_FACTOR* 0.0f), ((int)(FP_FACTOR*-1.414f)}, /* 270deg */ - {((int)(FP_FACTOR* 1.0f), ((int)(FP_FACTOR*-1.0f)} /* 315deg */ -}; #else static const complexf_t v27ter_constellation[8] = -{ - { 1.414f, 0.0f}, /* 0deg */ - { 1.0f, 1.0f}, /* 45deg */ - { 0.0f, 1.414f}, /* 90deg */ - {-1.0f, 1.0f}, /* 135deg */ - {-1.414f, 0.0f}, /* 180deg */ - {-1.0f, -1.0f}, /* 225deg */ - { 0.0f, -1.414f}, /* 270deg */ - { 1.0f, -1.0f} /* 315deg */ -}; #endif +{ + {FP_SCALE( 1.414f), FP_SCALE( 0.0f)}, /* 0deg */ + {FP_SCALE( 1.0f), FP_SCALE( 1.0f)}, /* 45deg */ + {FP_SCALE( 0.0f), FP_SCALE( 1.414f)}, /* 90deg */ + {FP_SCALE(-1.0f), FP_SCALE( 1.0f)}, /* 135deg */ + {FP_SCALE(-1.414f), FP_SCALE( 0.0f)}, /* 180deg */ + {FP_SCALE(-1.0f), FP_SCALE(-1.0f)}, /* 225deg */ + {FP_SCALE( 0.0f), FP_SCALE(-1.414f)}, /* 270deg */ + {FP_SCALE( 1.0f), FP_SCALE(-1.0f)} /* 315deg */ +}; SPAN_DECLARE(float) v27ter_rx_carrier_frequency(v27ter_rx_state_t *s) { @@ -198,14 +193,14 @@ static void equalizer_restore(v27ter_rx_state_t *s) #if defined(SPANDSP_USE_FIXED_POINTx) cvec_copyi16(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_LEN); cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_LEN); - s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN); + s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN; #else cvec_copyf(s->eq_coeff, s->eq_coeff_save, V27TER_EQUALIZER_LEN); cvec_zerof(s->eq_buf, V27TER_EQUALIZER_LEN); s->eq_delta = EQUALIZER_DELTA/V27TER_EQUALIZER_LEN; #endif - s->eq_put_step = (s->bit_rate == 4800) ? RX_PULSESHAPER_4800_COEFF_SETS*5/2 : RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2); + s->eq_put_step = (s->bit_rate == 4800) ? (RX_PULSESHAPER_4800_COEFF_SETS*5/2 - 1) : (RX_PULSESHAPER_2400_COEFF_SETS*20/(3*2) - 1); s->eq_step = 0; } /*- End of function --------------------------------------------------------*/ @@ -214,13 +209,17 @@ static void equalizer_reset(v27ter_rx_state_t *s) { /* Start with an equalizer based on everything being perfect. */ #if defined(SPANDSP_USE_FIXED_POINTx) + static const complexi16_t x = {FP_SCALE(1.414f), FP_SCALE(0.0f)}; + cvec_zeroi16(s->eq_coeff, V27TER_EQUALIZER_LEN); - s->eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1] = complex_seti16(1.414f*FP_FACTOR, 0); + s->eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1] = x; cvec_zeroi16(s->eq_buf, V27TER_EQUALIZER_LEN); - s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN); + s->eq_delta = 32768.0f*EQUALIZER_DELTA/V27TER_EQUALIZER_LEN; #else + static const complexf_t x = {1.414f, 0.0f}; + cvec_zerof(s->eq_coeff, V27TER_EQUALIZER_LEN); - s->eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1] = complex_setf(1.414f, 0.0f); + s->eq_coeff[V27TER_EQUALIZER_PRE_LEN + 1] = x; cvec_zerof(s->eq_buf, V27TER_EQUALIZER_LEN); s->eq_delta = EQUALIZER_DELTA/V27TER_EQUALIZER_LEN; #endif @@ -324,8 +323,13 @@ static __inline__ int find_octant(complexf_t *z) if (abs_im > abs_re*0.4142136f && abs_im < abs_re*2.4142136f) { /* Split the space along the two axes. */ +#if defined(SPANDSP_USE_FIXED_POINTx) + b1 = (z->re < 0); + b2 = (z->im < 0); +#else b1 = (z->re < 0.0f); b2 = (z->im < 0.0f); +#endif bits = (b2 << 2) | ((b1 ^ b2) << 1) | 1; } else diff --git a/libs/spandsp/src/v27ter_tx.c b/libs/spandsp/src/v27ter_tx.c index bff8bb7071..f2673444ee 100644 --- a/libs/spandsp/src/v27ter_tx.c +++ b/libs/spandsp/src/v27ter_tx.c @@ -151,14 +151,14 @@ static complexf_t getbaud(v27ter_tx_state_t *s) #if defined(SPANDSP_USE_FIXED_POINT) static const complexi16_t constellation[8] = { - { 1414, 0000}, /* 0deg */ - { 1000, 1000}, /* 45deg */ - { 0000, 1414}, /* 90deg */ - {-1000, 1000}, /* 135deg */ - {-1414, 0000}, /* 180deg */ - {-1000, -1000}, /* 225deg */ - { 0000, -1414}, /* 270deg */ - { 1000, -1000} /* 315deg */ + {FP_Q_6_10( 1.414f), FP_Q_6_10( 0.0f)}, /* 0deg */ + {FP_Q_6_10( 1.0f), FP_Q_6_10( 1.0f)}, /* 45deg */ + {FP_Q_6_10( 0.0f), FP_Q_6_10( 1.414f)}, /* 90deg */ + {FP_Q_6_10(-1.0f), FP_Q_6_10( 1.0f)}, /* 135deg */ + {FP_Q_6_10(-1.414f), FP_Q_6_10( 0.0f)}, /* 180deg */ + {FP_Q_6_10(-1.0f), FP_Q_6_10(-1.0f)}, /* 225deg */ + {FP_Q_6_10( 0.0f), FP_Q_6_10(-1.414f)}, /* 270deg */ + {FP_Q_6_10( 1.0f), FP_Q_6_10(-1.0f)} /* 315deg */ }; static const complexi16_t zero = {0, 0}; #else diff --git a/libs/spandsp/src/v42.c b/libs/spandsp/src/v42.c index 729ab40cfe..7aea3f2116 100644 --- a/libs/spandsp/src/v42.c +++ b/libs/spandsp/src/v42.c @@ -1183,7 +1183,7 @@ static void reset_lapm(v42_state_t *ss) } /*- End of function --------------------------------------------------------*/ -SPAN_DECLARE(void) v42_stop(v42_state_t *ss) +void v42_stop(v42_state_t *ss) { lapm_state_t *s; diff --git a/libs/spandsp/tests/dtmf_rx_tests.c b/libs/spandsp/tests/dtmf_rx_tests.c index 01d96ea54e..e160bbf4ef 100644 --- a/libs/spandsp/tests/dtmf_rx_tests.c +++ b/libs/spandsp/tests/dtmf_rx_tests.c @@ -256,6 +256,7 @@ static void digit_status(void *data, int signal, int level, int delay) static int last_step = 0; static int first = TRUE; + //printf("Digit status %d %d %d\n", signal, level, delay); callback_hit = TRUE; len = step - last_step; if (data == (void *) 0x12345678) @@ -321,10 +322,14 @@ static void mitel_cm7291_side_1_tests(void) float rcfo; dtmf_rx_state_t *dtmf_state; awgn_state_t noise_source; + logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + logging = dtmf_rx_get_logging_state(dtmf_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "DTMF-rx"); /* Test 1: Mitel's test 1 isn't really a test. Its a calibration step, which has no meaning here. */ @@ -627,10 +632,14 @@ static void mitel_cm7291_side_2_and_bellcore_tests(void) SNDFILE *inhandle; int frames; dtmf_rx_state_t *dtmf_state; + logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + logging = dtmf_rx_get_logging_state(dtmf_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "DTMF-rx"); /* The remainder of the Mitel tape is the talk-off test */ /* Here we use the Bellcore test tapes (much tougher), in six @@ -694,10 +703,14 @@ static void dial_tone_tolerance_tests(void) dtmf_rx_state_t *dtmf_state; tone_gen_descriptor_t dial_tone_desc; tone_gen_state_t dial_tone; + logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + logging = dtmf_rx_get_logging_state(dtmf_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "DTMF-rx"); /* Test dial tone tolerance */ printf("Test: Dial tone tolerance.\n"); @@ -742,6 +755,7 @@ static void callback_function_tests(void) int len; int sample; dtmf_rx_state_t *dtmf_state; + logging_state_t *logging; /* Test the callback mode for delivering detected digits */ printf("Test: Callback digit delivery mode.\n"); @@ -751,6 +765,9 @@ static void callback_function_tests(void) dtmf_state = dtmf_rx_init(NULL, digit_delivery, (void *) 0x12345678); if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + logging = dtmf_rx_get_logging_state(dtmf_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "DTMF-rx"); my_dtmf_gen_init(0.0f, DEFAULT_DTMF_TX_LEVEL, 0.0f, DEFAULT_DTMF_TX_LEVEL, DEFAULT_DTMF_TX_ON_TIME, DEFAULT_DTMF_TX_OFF_TIME); for (i = 1; i < 10; i++) @@ -778,6 +795,9 @@ static void callback_function_tests(void) dtmf_rx_set_realtime_callback(dtmf_state, digit_status, (void *) 0x12345678); if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + logging = dtmf_rx_get_logging_state(dtmf_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "DTMF-rx"); my_dtmf_gen_init(0.0f, DEFAULT_DTMF_TX_LEVEL, 0.0f, DEFAULT_DTMF_TX_LEVEL, DEFAULT_DTMF_TX_ON_TIME, DEFAULT_DTMF_TX_OFF_TIME); step = 0; @@ -813,19 +833,23 @@ static void decode_test(const char *test_file) int actual; int samples; int total; + logging_state_t *logging; dtmf_state = dtmf_rx_init(NULL, NULL, NULL); if (use_dialtone_filter || max_forward_twist >= 0 || max_reverse_twist >= 0) dtmf_rx_parms(dtmf_state, use_dialtone_filter, max_forward_twist, max_reverse_twist, -99); + logging = dtmf_rx_get_logging_state(dtmf_state); + span_log_set_level(logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); + span_log_set_tag(logging, "DTMF-rx"); /* We will decode the audio from a file. */ - + if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL) { fprintf(stderr, " Cannot open audio file '%s'\n", decode_test_file); exit(2); } - + total = 0; while ((samples = sf_readf_short(inhandle, amp, SAMPLES_PER_CHUNK)) > 0) {