From e503aa41d7c053d5c39591ae648e80d80c1556c0 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 1 Oct 2008 03:54:17 +0000 Subject: [PATCH] update to snapshot spandsp-20080913.tar.gz git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9768 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/spandsp/.update | 2 +- libs/spandsp/config-h.in | 3 - libs/spandsp/configure.ac | 4 +- libs/spandsp/spandsp/tsb85.xml | 82 +++++++++----------------- libs/spandsp/src/spandsp/v27ter_rx.h | 23 ++++++-- libs/spandsp/src/spandsp/v29rx.h | 23 ++++++-- libs/spandsp/src/spandsp/version.h | 4 +- libs/spandsp/src/v27ter_rx.c | 21 +++++-- libs/spandsp/src/v29rx.c | 66 ++++++++++++++++----- libs/spandsp/tests/fax_tester.c | 12 +++- libs/spandsp/tests/fax_tester.h | 4 +- libs/spandsp/tests/t31_tests.c | 6 +- libs/spandsp/tests/tsb85_tests.c | 88 ++++++++++++++++++++-------- 13 files changed, 211 insertions(+), 127 deletions(-) diff --git a/libs/spandsp/.update b/libs/spandsp/.update index 697eb52e85..f493a4799a 100644 --- a/libs/spandsp/.update +++ b/libs/spandsp/.update @@ -1 +1 @@ -Tue Sep 30 23:52:21 EDT 2008 +Tue Sep 30 23:53:44 EDT 2008 diff --git a/libs/spandsp/config-h.in b/libs/spandsp/config-h.in index 3266538bbb..0732e147fd 100644 --- a/libs/spandsp/config-h.in +++ b/libs/spandsp/config-h.in @@ -212,9 +212,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TIFFIO_H -/* Define to 1 if you have the header file. */ -#undef HAVE_UNICALL_H - /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H diff --git a/libs/spandsp/configure.ac b/libs/spandsp/configure.ac index c25f60d33d..6665f8a4f0 100644 --- a/libs/spandsp/configure.ac +++ b/libs/spandsp/configure.ac @@ -16,7 +16,7 @@ # License along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# $Id: configure.ac,v 1.56 2008/07/10 12:44:54 steveu Exp $ +# $Id: configure.ac,v 1.57 2008/09/12 14:41:55 steveu Exp $ # @start 1 @@ -180,7 +180,6 @@ AC_CHECK_HEADERS([audiofile.h]) AC_CHECK_HEADERS([fftw3.h], , [AC_CHECK_HEADERS([fftw.h])]) AC_CHECK_HEADERS([tiffio.h]) AC_CHECK_HEADERS([pthread.h]) -AC_CHECK_HEADERS([unicall.h]) if test "${build}" == "${host}" then AC_CHECK_HEADERS([X11/X.h]) @@ -273,7 +272,6 @@ if test -n "$enable_tests" ; then AC_CHECK_LIB([fftw3], [fftw_plan_dft_1d], TESTLIBS="$TESTLIBS -lfftw3", [AC_CHECK_LIB([fftw], [fftw_create_plan], TESTLIBS="$TESTLIBS -lfftw")]) AC_CHECK_LIB([pthread], [pthread_attr_init], TESTLIBS="$TESTLIBS -lpthread") AC_CHECK_LIB([dl], [dlopen], TESTLIBS="$TESTLIBS -ldl") - AC_CHECK_LIB([unicall], [uc_start], TESTLIBS="$TESTLIBS -lunicall",, -ltiff -ldl) AC_CHECK_LIB([Xft], [XftFontOpen], TESTLIBS="$TESTLIBS -lXft",, $TESTLIBS) AC_CHECK_LIB([Xext], [XextCreateExtension], TESTLIBS="$TESTLIBS -lXext",, $TESTLIBS) AC_CHECK_LIB([X11], [XOpenDisplay], TESTLIBS="$TESTLIBS -lX11",, $TESTLIBS) diff --git a/libs/spandsp/spandsp/tsb85.xml b/libs/spandsp/spandsp/tsb85.xml index 77c7cc3665..b04f47a6a1 100644 --- a/libs/spandsp/spandsp/tsb85.xml +++ b/libs/spandsp/spandsp/tsb85.xml @@ -1,7 +1,10 @@ - + + + + @@ -1330,25 +1333,26 @@ + - + - + - + - + @@ -1356,19 +1360,19 @@ - + - + - + - + @@ -1378,6 +1382,7 @@ + @@ -1411,39 +1416,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1629,7 +1601,7 @@ - + @@ -1651,7 +1623,7 @@ - + @@ -1673,7 +1645,7 @@ - + @@ -1695,7 +1667,7 @@ - + @@ -1759,7 +1731,7 @@ - + @@ -1781,7 +1753,7 @@ - + @@ -1794,7 +1766,7 @@ - + @@ -1803,7 +1775,7 @@ - + @@ -1816,7 +1788,7 @@ - + @@ -1825,7 +1797,7 @@ - + @@ -1838,7 +1810,7 @@ - + @@ -1847,7 +1819,7 @@ - + @@ -1860,7 +1832,7 @@ - + diff --git a/libs/spandsp/src/spandsp/v27ter_rx.h b/libs/spandsp/src/spandsp/v27ter_rx.h index acd64fd452..0a516396be 100644 --- a/libs/spandsp/src/spandsp/v27ter_rx.h +++ b/libs/spandsp/src/spandsp/v27ter_rx.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: v27ter_rx.h,v 1.48 2008/09/08 12:54:32 steveu Exp $ + * $Id: v27ter_rx.h,v 1.49 2008/09/13 14:59:31 steveu Exp $ */ /*! \file */ @@ -128,10 +128,17 @@ typedef struct 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; @@ -139,10 +146,6 @@ typedef struct 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; - /*! \brief The previous value of agc_scaling, needed to reuse old training. */ - float agc_scaling_save; /*! \brief The position of the current symbol in the constellation, used for differential decoding. */ @@ -159,6 +162,11 @@ typedef struct int baud_half; #if defined(SPANDSP_USE_FIXED_POINTx) + /*! \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. */ @@ -168,6 +176,11 @@ typedef struct /*! \brief The equalizer signal buffer. */ complexi16_t eq_buf[V27TER_EQUALIZER_MASK + 1]; #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. */ diff --git a/libs/spandsp/src/spandsp/v29rx.h b/libs/spandsp/src/spandsp/v29rx.h index ac85d7bebc..ab8bbe4207 100644 --- a/libs/spandsp/src/spandsp/v29rx.h +++ b/libs/spandsp/src/spandsp/v29rx.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: v29rx.h,v 1.59 2008/09/08 12:45:02 steveu Exp $ + * $Id: v29rx.h,v 1.60 2008/09/13 14:10:31 steveu Exp $ */ /*! \file */ @@ -196,10 +196,17 @@ typedef struct 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_POINT) + /*! \brief The proportional part of the carrier tracking filter. */ + int32_t carrier_track_p; + /*! \brief The integral part of the carrier tracking filter. */ + int32_t 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; @@ -207,10 +214,6 @@ typedef struct 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; - /*! \brief The previous value of agc_scaling, needed to reuse old training. */ - float agc_scaling_save; /*! \brief The position of the current symbol in the constellation, used for differential decoding. */ @@ -227,6 +230,11 @@ typedef struct int baud_half; #if defined(SPANDSP_USE_FIXED_POINT) + /*! \brief The scaling factor accessed by the AGC algorithm. */ + int32_t agc_scaling; + /*! \brief The previous value of agc_scaling, needed to reuse old training. */ + int32_t agc_scaling_save; + /*! \brief The current delta factor for updating the equalizer coefficients. */ int16_t eq_delta; /*! \brief The adaptive equalizer coefficients. */ @@ -245,6 +253,11 @@ typedef struct /*! Baud phase for symbol sync. */ int32_t baud_phase; #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. */ diff --git a/libs/spandsp/src/spandsp/version.h b/libs/spandsp/src/spandsp/version.h index 12c67f9940..2b7aea9dea 100644 --- a/libs/spandsp/src/spandsp/version.h +++ b/libs/spandsp/src/spandsp/version.h @@ -30,8 +30,8 @@ /* The date and time of the version are in UTC form. */ -#define SPANDSP_RELEASE_DATE 20080911 -#define SPANDSP_RELEASE_TIME 151652 +#define SPANDSP_RELEASE_DATE 20080913 +#define SPANDSP_RELEASE_TIME 155039 #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/v27ter_rx.c b/libs/spandsp/src/v27ter_rx.c index 5d6961d58e..d196cc5b1e 100644 --- a/libs/spandsp/src/v27ter_rx.c +++ b/libs/spandsp/src/v27ter_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: v27ter_rx.c,v 1.101 2008/09/08 13:13:29 steveu Exp $ + * $Id: v27ter_rx.c,v 1.102 2008/09/13 14:59:30 steveu Exp $ */ /*! \file */ @@ -323,16 +323,17 @@ static __inline__ void track_carrier(v27ter_rx_state_t *s, const complexf_t *z, /* For small errors the imaginary part of the difference between the actual and the target positions is proportional to the phase error, for any particular target. However, the different amplitudes of the various target positions scale things. */ + error = z->im*target->re - z->re*target->im; + #if defined(SPANDSP_USE_FIXED_POINTx) - error = z->im*target->re - z->re*target->im; error /= (float) FP_FACTOR; + s->carrier_phase_rate += (int32_t) (s->carrier_track_i*error); + s->carrier_phase += (int32_t) (s->carrier_track_p*error); #else - error = z->im*target->re - z->re*target->im; -#endif - s->carrier_phase_rate += (int32_t) (s->carrier_track_i*error); s->carrier_phase += (int32_t) (s->carrier_track_p*error); //span_log(&s->logging, SPAN_LOG_FLOW, "Im = %15.5f f = %15.5f\n", error, dds_frequencyf(s->carrier_phase_rate)); +#endif } /*- End of function --------------------------------------------------------*/ @@ -676,8 +677,13 @@ static __inline__ void process_half_baud(v27ter_rx_state_t *s, const complexf_t s->constellation_state = (s->bit_rate == 4800) ? 4 : 2; s->training_count = 0; s->training_stage = TRAINING_STAGE_TEST_ONES; +#if defined(SPANDSP_USE_FIXED_POINTx) + s->carrier_track_i = 400; + s->carrier_track_p = 1000000; +#else s->carrier_track_i = 400.0f; s->carrier_track_p = 1000000.0f; +#endif } break; case TRAINING_STAGE_TEST_ONES: @@ -1076,8 +1082,13 @@ int v27ter_rx_restart(v27ter_rx_state_t *s, int bit_rate, int old_train) #endif s->carrier_phase = 0; +#if defined(SPANDSP_USE_FIXED_POINTx) + s->carrier_track_i = 200000; + s->carrier_track_p = 10000000; +#else s->carrier_track_i = 200000.0f; s->carrier_track_p = 10000000.0f; +#endif power_meter_init(&(s->power), 4); s->constellation_state = 0; diff --git a/libs/spandsp/src/v29rx.c b/libs/spandsp/src/v29rx.c index 298546d718..8abd49c3ed 100644 --- a/libs/spandsp/src/v29rx.c +++ b/libs/spandsp/src/v29rx.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: v29rx.c,v 1.135 2008/09/09 16:13:12 steveu Exp $ + * $Id: v29rx.c,v 1.138 2008/09/13 15:48:04 steveu Exp $ */ /*! \file */ @@ -362,7 +362,11 @@ static __inline__ void track_carrier(v29_rx_state_t *s, const complexi16_t *z, c static __inline__ void track_carrier(v29_rx_state_t *s, const complexf_t *z, const complexf_t *target) #endif { +#if defined(SPANDSP_USE_FIXED_POINT) + int32_t error; +#else float error; +#endif /* The initial coarse carrier frequency and phase estimation should have got us in the right ballpark. Now we need to fine tune fairly quickly, @@ -377,19 +381,19 @@ static __inline__ void track_carrier(v29_rx_state_t *s, const complexf_t *z, con different amplitudes of the various target positions scale things. This isn't all bad, as the angular error for the larger amplitude constellation points is probably a more reliable indicator, and we are weighting it as such. */ -#if defined(SPANDSP_USE_FIXED_POINT) error = z->im*target->re - z->re*target->im; - error /= (float) FP_FACTOR; -#else - error = z->im*target->re - z->re*target->im; -#endif /* Use a proportional-integral approach to tracking the carrier. The PI parameters are coarser at first, until we get precisely on target. Then, the filter will be damped more to keep us on target. */ +#if defined(SPANDSP_USE_FIXED_POINT) + s->carrier_phase_rate += ((s->carrier_track_i*error) >> FP_SHIFT_FACTOR); + s->carrier_phase += ((s->carrier_track_p*error) >> FP_SHIFT_FACTOR); +#else s->carrier_phase_rate += (int32_t) (s->carrier_track_i*error); s->carrier_phase += (int32_t) (s->carrier_track_p*error); //span_log(&s->logging, SPAN_LOG_FLOW, "Im = %15.5f f = %15.5f\n", error, dds_frequencyf(s->carrier_phase_rate)); +#endif } /*- End of function --------------------------------------------------------*/ @@ -521,7 +525,7 @@ static __inline__ void symbol_sync(v29_rx_state_t *s) s->symbol_sync_dc_filter[0] = v; /* A little integration will now filter away much of the noise */ s->baud_phase -= p; - if (abs(s->baud_phase) > 50*FP_FACTOR) + if (abs(s->baud_phase) > 100*FP_FACTOR) { if (s->baud_phase > 0) i = (s->baud_phase > 1000*FP_FACTOR) ? 5 : 1; @@ -543,7 +547,7 @@ static __inline__ void symbol_sync(v29_rx_state_t *s) s->symbol_sync_dc_filter[0] = v; /* A little integration will now filter away much of the noise */ s->baud_phase -= p; - if (fabsf(s->baud_phase) > 50.0f) + if (fabsf(s->baud_phase) > 100.0f) { if (s->baud_phase > 0.0f) i = (s->baud_phase > 1000.0f) ? 5 : 1; @@ -620,8 +624,13 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) s->training_stage = TRAINING_STAGE_LOG_PHASE; s->angles[0] = s->start_angles[0] = arctan2(z.im, z.re); +#if defined(SPANDSP_USE_FIXED_POINT) + if (s->agc_scaling_save == 0) + s->agc_scaling_save = s->agc_scaling; +#else if (s->agc_scaling_save == 0.0f) s->agc_scaling_save = s->agc_scaling; +#endif } break; case TRAINING_STAGE_LOG_PHASE: @@ -664,7 +673,11 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) { span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (sequence failed)\n"); /* Park this modem */ +#if defined(SPANDSP_USE_FIXED_POINT) + s->agc_scaling_save = 0; +#else s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); break; @@ -700,7 +713,11 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) of a real training sequence. */ span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (sequence failed)\n"); /* Park this modem */ +#if defined(SPANDSP_USE_FIXED_POINT) + s->agc_scaling_save = 0; +#else s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); } @@ -717,8 +734,13 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) { s->training_stage = TRAINING_STAGE_TRAIN_ON_CDCD_AND_TEST; s->training_error = 0.0f; +#if defined(SPANDSP_USE_FIXED_POINT) + s->carrier_track_i = 200; + s->carrier_track_p = 1000000; +#else s->carrier_track_i = 200.0f; s->carrier_track_p = 1000000.0f; +#endif } break; case TRAINING_STAGE_TRAIN_ON_CDCD_AND_TEST: @@ -755,7 +777,11 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) { span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (convergence failed)\n"); /* Park this modem */ +#if defined(SPANDSP_USE_FIXED_POINT) + s->agc_scaling_save = 0; +#else s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); } @@ -799,7 +825,11 @@ static void process_half_baud(v29_rx_state_t *s, complexf_t *sample) /* Training has failed */ span_log(&s->logging, SPAN_LOG_FLOW, "Training failed (constellation mismatch %f)\n", s->training_error); /* Park this modem */ +#if defined(SPANDSP_USE_FIXED_POINT) + s->agc_scaling_save = 0; +#else s->agc_scaling_save = 0.0f; +#endif s->training_stage = TRAINING_STAGE_PARKED; report_status_change(s, SIG_STATUS_TRAINING_FAILED); } @@ -839,7 +869,6 @@ int v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) complexi16_t zz; complexi16_t sample; int32_t v; - float y; #else complexf_t z; complexf_t zz; @@ -930,8 +959,7 @@ int v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) v = (int32_t) rx_pulseshaper[step][0].re*(int32_t) s->rrc_filter[s->rrc_filter_step]; for (j = 1; j < V29_RX_FILTER_STEPS; j++) v += (int32_t) rx_pulseshaper[step][j].re*(int32_t) s->rrc_filter[j + s->rrc_filter_step]; - y = v*s->agc_scaling; - sample.re = y; + sample.re = (v*s->agc_scaling) >> 15; #else v = rx_pulseshaper[step][0].re*s->rrc_filter[s->rrc_filter_step]; for (j = 1; j < V29_RX_FILTER_STEPS; j++) @@ -965,8 +993,8 @@ int v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) { /* Only AGC until we have locked down the setting. */ #if defined(SPANDSP_USE_FIXED_POINT) - if (s->agc_scaling_save == 0.0f) - s->agc_scaling = (float) FP_FACTOR*(1.0f/RX_PULSESHAPER_GAIN)*5.0f*0.25f/sqrtf(power); + if (s->agc_scaling_save == 0) + s->agc_scaling = (float) FP_FACTOR*32768.0f*(1.0f/RX_PULSESHAPER_GAIN)*5.0f*0.25f/sqrtf(power); #else if (s->agc_scaling_save == 0.0f) s->agc_scaling = (1.0f/RX_PULSESHAPER_GAIN)*5.0f*0.25f/sqrtf(power); @@ -983,7 +1011,7 @@ int v29_rx(v29_rx_state_t *s, const int16_t amp[], int len) v = (int32_t) rx_pulseshaper[step][0].im*(int32_t) s->rrc_filter[s->rrc_filter_step]; for (j = 1; j < V29_RX_FILTER_STEPS; j++) v += (int32_t) rx_pulseshaper[step][j].im*(int32_t) s->rrc_filter[j + s->rrc_filter_step]; - sample.im = v*s->agc_scaling; + sample.im = (v*s->agc_scaling) >> 15; z = dds_lookup_complexi16(s->carrier_phase); zz.re = ((int32_t) sample.re*(int32_t) z.re - (int32_t) sample.im*(int32_t) z.im) >> 15; zz.im = ((int32_t) -sample.re*(int32_t) z.im - (int32_t) sample.im*(int32_t) z.re) >> 15; @@ -1070,16 +1098,22 @@ int v29_rx_restart(v29_rx_state_t *s, int bit_rate, int old_train) else { s->carrier_phase_rate = dds_phase_ratef(CARRIER_NOMINAL_FREQ); - s->agc_scaling_save = 0.0f; #if defined(SPANDSP_USE_FIXED_POINT) - s->agc_scaling = (float) FP_FACTOR*0.0017f/RX_PULSESHAPER_GAIN; + s->agc_scaling_save = 0; + s->agc_scaling = (float) FP_FACTOR*32768.0f*0.0017f/RX_PULSESHAPER_GAIN; #else + s->agc_scaling_save = 0.0f; s->agc_scaling = 0.0017f/RX_PULSESHAPER_GAIN; #endif equalizer_reset(s); } +#if defined(SPANDSP_USE_FIXED_POINT) + s->carrier_track_i = 8000; + s->carrier_track_p = 8000000; +#else s->carrier_track_i = 8000.0f; s->carrier_track_p = 8000000.0f; +#endif s->last_sample = 0; s->eq_skip = 0; diff --git a/libs/spandsp/tests/fax_tester.c b/libs/spandsp/tests/fax_tester.c index 4f54f80e54..0bb78f9805 100644 --- a/libs/spandsp/tests/fax_tester.c +++ b/libs/spandsp/tests/fax_tester.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: fax_tester.c,v 1.16 2008/09/09 14:05:55 steveu Exp $ + * $Id: fax_tester.c,v 1.17 2008/09/12 14:41:55 steveu Exp $ */ /*! \file */ @@ -217,10 +217,16 @@ void faxtester_set_non_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf } /*- End of function --------------------------------------------------------*/ -void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len, int frame_size, int crc_hit) +void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len, int block, int frame_size, int crc_hit) { + int start; + + start = 256*frame_size*block; + if (len > start + 256*frame_size) + len = start + 256*frame_size; + s->ecm_frame_size = frame_size; - s->image_ptr = 0; + s->image_ptr = start; s->image_bit_ptr = 8; s->image_len = len; s->image_buffer = buf; diff --git a/libs/spandsp/tests/fax_tester.h b/libs/spandsp/tests/fax_tester.h index ee51e42a33..39bc2d88d5 100644 --- a/libs/spandsp/tests/fax_tester.h +++ b/libs/spandsp/tests/fax_tester.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_tester.h,v 1.8 2008/08/13 00:11:30 steveu Exp $ + * $Id: fax_tester.h,v 1.9 2008/09/12 14:41:55 steveu Exp $ */ /*! \file */ @@ -179,7 +179,7 @@ void faxtester_set_timeout(faxtester_state_t *s, int timeout); void faxtester_set_non_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len); -void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len, int frame_size, int crc_hit); +void faxtester_set_ecm_image_buffer(faxtester_state_t *s, const uint8_t *buf, int len, int block, int frame_size, int crc_hit); /*! Initialise a FAX context. \brief Initialise a FAX context. diff --git a/libs/spandsp/tests/t31_tests.c b/libs/spandsp/tests/t31_tests.c index e9a49cbe1b..1a59d71f85 100644 --- a/libs/spandsp/tests/t31_tests.c +++ b/libs/spandsp/tests/t31_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: t31_tests.c,v 1.62 2008/08/29 09:28:13 steveu Exp $ + * $Id: t31_tests.c,v 1.63 2008/09/13 14:32:53 steveu Exp $ */ /*! \file */ @@ -35,6 +35,10 @@ #include "config.h" #endif +#if defined(HAVE_FL_FL_H) && defined(HAVE_FL_FL_CARTESIAN_H) && defined(HAVE_FL_FL_AUDIO_METER_H) +#define ENABLE_GUI +#endif + #include #include #include diff --git a/libs/spandsp/tests/tsb85_tests.c b/libs/spandsp/tests/tsb85_tests.c index 29509bb296..2ad8ce84b7 100644 --- a/libs/spandsp/tests/tsb85_tests.c +++ b/libs/spandsp/tests/tsb85_tests.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: tsb85_tests.c,v 1.23 2008/09/10 16:55:15 steveu Exp $ + * $Id: tsb85_tests.c,v 1.24 2008/09/12 14:41:55 steveu Exp $ */ /*! \file */ @@ -84,6 +84,8 @@ uint8_t image[1000000]; uint8_t awaited[1000]; int awaited_len = 0; +char image_path[1024]; + t30_exchanged_info_t expected_rx_info; char next_tx_file[1000]; @@ -629,15 +631,18 @@ static int next_step(faxtester_state_t *s) xmlChar *timeout; xmlChar *min_bits; xmlChar *frame_size; + xmlChar *block; xmlChar *compression; uint8_t buf[1000]; uint8_t mask[1000]; + char path[1024]; int i; int j; int hdlc; int short_train; int min_row_bits; int ecm_frame_size; + int ecm_block; int compression_type; int timer; int len; @@ -678,6 +683,7 @@ static int next_step(faxtester_state_t *s) timeout = xmlGetProp(s->cur, (const xmlChar *) "timeout"); min_bits = xmlGetProp(s->cur, (const xmlChar *) "min_bits"); frame_size = xmlGetProp(s->cur, (const xmlChar *) "frame_size"); + block = xmlGetProp(s->cur, (const xmlChar *) "block"); compression = xmlGetProp(s->cur, (const xmlChar *) "compression"); s->cur = s->cur->next; @@ -878,7 +884,7 @@ static int next_step(faxtester_state_t *s) } else if (strcasecmp((const char *) tag, "TXFILE") == 0) { - strcpy(next_tx_file, (const char *) value); + sprintf(next_tx_file, "%s/%s", image_path, (const char *) value); printf("Push '%s'\n", next_tx_file); } return 0; @@ -893,7 +899,10 @@ printf("Push '%s'\n", next_tx_file); /* Avoid libtiff 3.8.2 and earlier bug on complex 2D lines. */ t30_set_rx_encoding(t30, T4_COMPRESSION_ITU_T4_1D); if (value) - t30_set_tx_file(t30, (const char *) value, -1, -1); + { + sprintf(path, "%s/%s", image_path, (const char *) value); + t30_set_tx_file(t30, path, -1, -1); + } return 0; } else if (strcasecmp((const char *) type, "ANSWER") == 0) @@ -905,7 +914,10 @@ printf("Push '%s'\n", next_tx_file); /* Avoid libtiff 3.8.2 and earlier bug on complex 2D lines. */ t30_set_rx_encoding(t30, T4_COMPRESSION_ITU_T4_1D); if (value) - t30_set_tx_file(t30, (const char *) value, -1, -1); + { + sprintf(path, "%s/%s", image_path, (const char *) value); + t30_set_tx_file(t30, path, -1, -1); + } return 0; } else if (strcasecmp((const char *) type, "CNG") == 0) @@ -966,11 +978,9 @@ printf("Push '%s'\n", next_tx_file); else if (strcasecmp((const char *) type, "MSG") == 0) { /* A non-ECM page */ - if (min_bits) - min_row_bits = atoi((const char *) min_bits); - else - min_row_bits = 0; - if (t4_tx_init(&t4_state, (const char *) value, -1, -1) == NULL) + min_row_bits = (min_bits) ? atoi((const char *) min_bits) : 0; + sprintf(path, "%s/%s", image_path, (const char *) value); + if (t4_tx_init(&t4_state, path, -1, -1) == NULL) { span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n"); exit(2); @@ -1003,22 +1013,12 @@ printf("Push '%s'\n", next_tx_file); } else if (strcasecmp((const char *) type, "PP") == 0) { - if (min_bits) - min_row_bits = atoi((const char *) min_bits); - else - min_row_bits = 0; - /*endif*/ - if (frame_size) - ecm_frame_size = atoi((const char *) frame_size); - else - ecm_frame_size = 64; - /*endif*/ - if (crc_error) - i = atoi((const char *) crc_error); - else - i = -1; - /*endif*/ - if (t4_tx_init(&t4_state, (const char *) value, -1, -1) == NULL) + min_row_bits = (min_bits) ? atoi((const char *) min_bits) : 0; + ecm_block = (block) ? atoi((const char *) block) : 0; + ecm_frame_size = (frame_size) ? atoi((const char *) frame_size) : 64; + i = (crc_error) ? atoi((const char *) crc_error) : -1; + sprintf(path, "%s/%s", image_path, (const char *) value); + if (t4_tx_init(&t4_state, path, -1, -1) == NULL) { span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n"); exit(2); @@ -1049,7 +1049,7 @@ printf("Push '%s'\n", next_tx_file); /*endif*/ t4_tx_end(&t4_state); span_log(&s->logging, SPAN_LOG_FLOW, "ECM image is %d bytes\n", len); - faxtester_set_ecm_image_buffer(s, image, len, ecm_frame_size, i); + faxtester_set_ecm_image_buffer(s, image, len, ecm_block, ecm_frame_size, i); } else { @@ -1149,6 +1149,36 @@ static void exchange(faxtester_state_t *s) } /*- End of function --------------------------------------------------------*/ +static int parse_config(faxtester_state_t *s, xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur) +{ + xmlChar *x; + xmlChar *y; + + while (cur) + { + if (xmlStrcmp(cur->name, (const xmlChar *) "path") == 0) + { + if ((x = xmlGetProp(cur, (const xmlChar *) "type")) + && + (y = xmlGetProp(cur, (const xmlChar *) "value"))) + { + if (strcasecmp((const char *) x, "IMAGE") == 0) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Found '%s' '%s'\n", (char *) x, (char *) y); + strcpy(image_path, (const char *) y); + } + /*endif*/ + } + /*endif*/ + } + /*endif*/ + cur = cur->next; + } + /*endwhile*/ + return -1; +} +/*- End of function --------------------------------------------------------*/ + static int parse_test_group(faxtester_state_t *s, xmlDocPtr doc, xmlNsPtr ns, xmlNodePtr cur, const char *test) { xmlChar *x; @@ -1225,6 +1255,11 @@ static int get_test_set(faxtester_state_t *s, const char *test_file, const char /*endif*/ while (cur) { + if (xmlStrcmp(cur->name, (const xmlChar *) "config") == 0) + { + parse_config(s, doc, ns, cur->xmlChildrenNode); + } + /*endif*/ if (xmlStrcmp(cur->name, (const xmlChar *) "test-group") == 0) { if (parse_test_group(s, doc, ns, cur->xmlChildrenNode, test) == 0) @@ -1254,6 +1289,7 @@ int main(int argc, char *argv[]) if (argc > 1) test_name = argv[1]; + strcpy(image_path, "."); faxtester_init(&state, TRUE); memset(&expected_rx_info, 0, sizeof(expected_rx_info)); span_log_set_level(&state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);