From 1d99b900fdd170631d4fb208d322dd00f0579e7f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 1 Oct 2008 03:52:36 +0000 Subject: [PATCH] update to snapshot spandsp-20080911.tar.gz git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9767 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- libs/spandsp/.update | 2 +- libs/spandsp/spandsp/tones.dtd | 2 - libs/spandsp/spandsp/tsb85.xml | 2135 +++++++++++------ libs/spandsp/src/dds_int.c | 24 +- libs/spandsp/src/spandsp/dds.h | 12 +- libs/spandsp/src/spandsp/tone_generate.h | 6 +- libs/spandsp/src/spandsp/version.h | 4 +- libs/spandsp/src/t30.c | 339 +-- libs/spandsp/src/tone_generate.c | 39 +- libs/spandsp/test-data/etsi/fax/Makefile.am | 36 +- .../etsi/fax/generate_etsi_300_242_pages.c | 100 +- libs/spandsp/tests/tone_generate_tests.c | 116 +- libs/spandsp/tests/tsb85_tests.c | 160 +- libs/spandsp/tests/tsb85_tests.sh | 76 +- 14 files changed, 2064 insertions(+), 987 deletions(-) diff --git a/libs/spandsp/.update b/libs/spandsp/.update index 2827df6d63..697eb52e85 100644 --- a/libs/spandsp/.update +++ b/libs/spandsp/.update @@ -1 +1 @@ -Wed Sep 3 14:32:49 CDT 2008 +Tue Sep 30 23:52:21 EDT 2008 diff --git a/libs/spandsp/spandsp/tones.dtd b/libs/spandsp/spandsp/tones.dtd index 023f8d0783..6f0fe46ba6 100644 --- a/libs/spandsp/spandsp/tones.dtd +++ b/libs/spandsp/spandsp/tones.dtd @@ -35,7 +35,6 @@ diff --git a/libs/spandsp/spandsp/tsb85.xml b/libs/spandsp/spandsp/tsb85.xml index 30783fd17a..77c7cc3665 100644 --- a/libs/spandsp/spandsp/tsb85.xml +++ b/libs/spandsp/spandsp/tsb85.xml @@ -1,7 +1,7 @@ - + @@ -11,19 +11,15 @@ - - - - - - - - - + + + @@ -31,14 +27,17 @@ - - + + + + + + + + + - - - - @@ -59,7 +58,7 @@ - + @@ -71,7 +70,7 @@ - + @@ -92,6 +91,7 @@ + @@ -111,7 +111,7 @@ - + @@ -123,7 +123,7 @@ - + @@ -140,6 +140,7 @@ + @@ -159,7 +160,7 @@ - + @@ -171,7 +172,7 @@ - + @@ -195,6 +196,7 @@ + @@ -214,7 +216,7 @@ - @@ -228,7 +230,7 @@ - + @@ -268,7 +271,7 @@ - + @@ -296,6 +299,7 @@ + @@ -318,7 +322,7 @@ - + @@ -328,7 +332,7 @@ - + @@ -343,6 +347,7 @@ + @@ -365,7 +370,7 @@ - + @@ -375,7 +380,7 @@ - + @@ -390,6 +395,7 @@ + @@ -421,7 +427,7 @@ - + @@ -436,6 +442,7 @@ + @@ -471,7 +478,7 @@ - + @@ -486,7 +493,8 @@ - + + @@ -503,7 +511,7 @@ - + @@ -512,7 +520,7 @@ - + @@ -529,7 +537,7 @@ - + @@ -544,6 +552,7 @@ + @@ -567,7 +576,7 @@ - + @@ -582,6 +591,7 @@ + @@ -623,7 +633,7 @@ - + @@ -638,6 +648,7 @@ + @@ -675,7 +686,7 @@ - + @@ -690,6 +701,7 @@ + @@ -727,7 +739,7 @@ - + @@ -742,6 +754,7 @@ + @@ -768,7 +781,7 @@ - + @@ -783,7 +796,7 @@ - + @@ -797,6 +810,7 @@ + @@ -836,7 +850,7 @@ - + @@ -851,6 +865,7 @@ + @@ -870,7 +885,7 @@ - + @@ -911,7 +926,7 @@ - + @@ -939,7 +954,7 @@ - + @@ -984,7 +999,7 @@ - + @@ -1025,7 +1040,7 @@ - + @@ -1053,7 +1068,7 @@ - + @@ -1088,6 +1103,7 @@ + @@ -1107,7 +1123,7 @@ - + @@ -1117,7 +1133,7 @@ - + @@ -1132,6 +1148,7 @@ + @@ -1151,7 +1168,7 @@ - + @@ -1161,7 +1178,7 @@ - + @@ -1176,6 +1193,7 @@ + @@ -1195,7 +1213,7 @@ - + @@ -1212,6 +1230,7 @@ + @@ -1232,7 +1251,7 @@ - + @@ -1244,7 +1263,7 @@ - + @@ -1266,7 +1285,7 @@ - + @@ -1292,6 +1311,7 @@ + @@ -1312,7 +1332,7 @@ - + @@ -1324,7 +1344,7 @@ - + @@ -1336,7 +1356,7 @@ - + @@ -1348,7 +1368,7 @@ - + @@ -1360,7 +1380,7 @@ - + @@ -1372,7 +1392,7 @@ - + @@ -1393,7 +1413,7 @@ - + @@ -1405,7 +1425,7 @@ - + @@ -1430,6 +1450,7 @@ + @@ -1448,7 +1469,7 @@ - + @@ -1470,7 +1491,7 @@ - + @@ -1492,7 +1513,7 @@ - + @@ -1514,7 +1535,7 @@ - + @@ -1544,7 +1565,7 @@ - + @@ -1570,6 +1591,7 @@ + @@ -1590,7 +1612,7 @@ - + @@ -1612,7 +1634,7 @@ - + @@ -1634,7 +1656,7 @@ - + @@ -1656,7 +1678,7 @@ - + @@ -1686,7 +1708,7 @@ - + @@ -1712,6 +1734,7 @@ + @@ -1732,7 +1755,7 @@ - + @@ -1754,7 +1777,7 @@ - + @@ -1776,7 +1799,7 @@ - + @@ -1798,7 +1821,7 @@ - + @@ -1820,7 +1843,7 @@ - + @@ -1854,6 +1877,7 @@ + @@ -1874,7 +1898,7 @@ - + @@ -1896,7 +1920,7 @@ - + @@ -1918,7 +1942,7 @@ - + @@ -1940,7 +1964,7 @@ - + @@ -1970,7 +1994,7 @@ - + @@ -1996,6 +2020,7 @@ + @@ -2015,7 +2040,7 @@ - + @@ -2037,7 +2062,7 @@ - + @@ -2059,7 +2084,7 @@ - + @@ -2081,7 +2106,7 @@ - + @@ -2115,6 +2140,7 @@ + @@ -2135,7 +2161,7 @@ - + @@ -2157,7 +2183,7 @@ - + @@ -2183,6 +2209,7 @@ + @@ -2193,7 +2220,7 @@ - + @@ -2203,11 +2230,11 @@ - + - + @@ -2215,11 +2242,11 @@ - + - + @@ -2231,6 +2258,7 @@ + @@ -2241,7 +2269,7 @@ - + @@ -2251,11 +2279,11 @@ - + - + @@ -2269,6 +2297,7 @@ + @@ -2278,6 +2307,7 @@ + @@ -2290,6 +2320,7 @@ + @@ -2298,7 +2329,7 @@ - + @@ -2308,15 +2339,21 @@ - + + + + + + + @@ -2341,6 +2378,7 @@ + @@ -2358,7 +2396,7 @@ - + @@ -2367,7 +2405,7 @@ - + @@ -2376,6 +2414,7 @@ + @@ -2393,7 +2432,7 @@ - + @@ -2408,6 +2447,7 @@ + @@ -2425,7 +2465,7 @@ - + @@ -2440,6 +2480,7 @@ + @@ -2457,7 +2498,7 @@ - + @@ -2472,6 +2513,7 @@ + @@ -2527,7 +2569,7 @@ - + @@ -2538,7 +2580,7 @@ - + @@ -2578,7 +2620,7 @@ - + @@ -2611,7 +2653,7 @@ - + @@ -2657,7 +2699,7 @@ - + @@ -2692,7 +2734,7 @@ - + @@ -2717,7 +2759,13 @@ - + + + + + + + @@ -2725,7 +2773,7 @@ - + @@ -2772,8 +2820,8 @@ - - + + @@ -2787,7 +2835,7 @@ - + @@ -2797,7 +2845,7 @@ - + @@ -2824,8 +2872,11 @@ + - + + + @@ -2834,39 +2885,41 @@ - + - + - + - + + - + - + + - + - + @@ -2877,7 +2930,7 @@ - + @@ -2886,8 +2939,8 @@ - - + + @@ -2895,17 +2948,20 @@ - + - + - + + + @@ -2915,8 +2971,8 @@ - - + + @@ -2925,17 +2981,18 @@ - + - + - + + @@ -2945,7 +3002,7 @@ - + @@ -2954,27 +3011,28 @@ - + - + - + + - + - + @@ -2983,28 +3041,29 @@ - + - + - + + - + - - + + @@ -3012,17 +3071,19 @@ - + - + - + + @@ -3032,7 +3093,7 @@ - + @@ -3041,17 +3102,18 @@ - + - + - + + @@ -3061,10 +3123,11 @@ - + - + + @@ -3074,7 +3137,7 @@ - + @@ -3083,7 +3146,7 @@ - + @@ -3091,17 +3154,18 @@ - + - + - + + @@ -3111,7 +3175,7 @@ - + @@ -3119,7 +3183,7 @@ - + @@ -3128,17 +3192,18 @@ - + - + - + + @@ -3148,21 +3213,23 @@ - + + - + + - + @@ -3171,17 +3238,18 @@ - + - + - + + @@ -3191,30 +3259,31 @@ - - - - - - + + + + + + - - + + - + - + + @@ -3224,34 +3293,43 @@ - - + + - - + + + + + + + + + + - - + + - + - + + @@ -3261,54 +3339,57 @@ - - + + - - + + - - + + - + - + + - + - - + + + + - - + + @@ -3317,10 +3398,10 @@ - + - + @@ -3329,27 +3410,65 @@ - + - + - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -3358,62 +3477,28 @@ - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - + - + + - + - + @@ -3421,22 +3506,24 @@ + + - + - + - + @@ -3445,10 +3532,10 @@ - + - + @@ -3457,17 +3544,18 @@ - + - + - + + @@ -3477,7 +3565,7 @@ - + @@ -3486,9 +3574,9 @@ - - - + + + @@ -3496,17 +3584,18 @@ - + - + - + + @@ -3516,7 +3605,7 @@ - + @@ -3525,21 +3614,21 @@ - + - + - + @@ -3547,17 +3636,18 @@ - + - + - + + @@ -3567,8 +3657,8 @@ - - + + @@ -3576,21 +3666,21 @@ - + - + - + - + - + @@ -3598,17 +3688,18 @@ - + - + - + - + + @@ -3618,7 +3709,7 @@ - + @@ -3627,19 +3718,20 @@ - - - + + + - + - + + @@ -3649,7 +3741,7 @@ - + @@ -3658,31 +3750,32 @@ - + - + - + - + - + + @@ -3692,8 +3785,8 @@ - - + + @@ -3701,31 +3794,32 @@ - + - + - + - + - + + @@ -3735,7 +3829,7 @@ - + @@ -3743,12 +3837,14 @@ + + - + - + @@ -3756,7 +3852,7 @@ - + @@ -3765,17 +3861,18 @@ - + - + - + + @@ -3785,7 +3882,7 @@ - + @@ -3794,33 +3891,34 @@ - + - + - - + + - - + + - + - + + @@ -3830,7 +3928,7 @@ - + @@ -3839,22 +3937,18 @@ - + - + - - - - - - + - + + @@ -3864,28 +3958,30 @@ - - + + - - + + + + - + - + - + @@ -3894,62 +3990,73 @@ - + - + - + + - + - - + + - - + + - + - - + + - - + + + - + + + + + + + + + - + + @@ -3959,8 +4066,8 @@ - - + + @@ -3968,19 +4075,20 @@ - + - + - + - + + @@ -3990,7 +4098,7 @@ - + @@ -3998,8 +4106,8 @@ - - + + @@ -4007,36 +4115,37 @@ - + - + - + + - + - - + + - - + + @@ -4044,17 +4153,18 @@ - + - + - + + @@ -4064,34 +4174,35 @@ - - + + - - + + - - + + - + - + + @@ -4101,42 +4212,43 @@ - - + + - - + + - - + + - - + + - + - + + @@ -4146,34 +4258,35 @@ - - + + - - + + - - + + - + - + + @@ -4183,34 +4296,35 @@ - - + + - - + + - - + + - + - + + @@ -4220,212 +4334,634 @@ - - + + - - + + - - + + - - + + - - + + - + - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + + - + - - + + - - + + - - + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - + - + + @@ -4435,28 +4971,29 @@ - - + + - - + + - + - + + @@ -4466,42 +5003,43 @@ - - + + - - + + - - + + - - + + - + - + + @@ -4511,102 +5049,258 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - + + - + - - + + - - + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -4616,8 +5310,8 @@ - - + + @@ -4625,43 +5319,87 @@ - - + + - + - - + + - + - - + + - + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4669,11 +5407,12 @@ - + - + + @@ -4683,7 +5422,7 @@ - + @@ -4692,43 +5431,43 @@ - - + + - + - - + + - + - - + + - + - - + + - + - + @@ -4736,66 +5475,73 @@ - - + + - + - + + - + - - + + - - + + - + - + + + - + - + + + @@ -4808,18 +5554,19 @@ - + + - + - - + + @@ -4827,26 +5574,29 @@ - + + - + - - + + - - + + + + @@ -4854,7 +5604,8 @@ - + + @@ -4864,8 +5615,8 @@ - - + + @@ -4873,15 +5624,16 @@ - + - + - + + @@ -4891,7 +5643,7 @@ - + @@ -4900,59 +5652,70 @@ - + - + - + + - + - - - - - - - + + + + + + + + + + - + + - + - - + + - - - - - + + + + + + + + + + - + + @@ -4962,7 +5725,7 @@ - + @@ -4971,13 +5734,17 @@ - - - - + + + + + + + - + + @@ -4987,7 +5754,7 @@ - + @@ -4996,23 +5763,43 @@ - - - - + + + + + + + - + + - + - + + + + + + + + + + + + + + + + + @@ -5020,143 +5807,141 @@ - - + + - - - - - - - - - + - + + - + - - + + - - + + - - + + - + - + + - + - - + + - - + + - - + + - + - + + - + - - + + - - + + + + - + - + - + - + + @@ -5166,7 +5951,7 @@ - + @@ -5175,31 +5960,32 @@ - + - + - + - + - + + @@ -5209,52 +5995,47 @@ - - + + - - + + - + - + - + - + - - - - - @@ -5262,12 +6043,18 @@ - + + + + + + + - + @@ -5279,7 +6066,7 @@ - + @@ -5322,7 +6109,7 @@ - + @@ -5358,7 +6145,7 @@ - + @@ -5391,7 +6178,7 @@ - + @@ -5438,7 +6225,7 @@ - + @@ -5484,7 +6271,7 @@ - + @@ -5524,7 +6311,7 @@ - + @@ -5561,7 +6348,7 @@ - + @@ -5601,7 +6388,7 @@ - + @@ -5677,7 +6464,7 @@ - + @@ -5720,7 +6507,7 @@ - + @@ -5767,7 +6554,7 @@ - + @@ -5809,7 +6596,7 @@ - + @@ -5828,7 +6615,7 @@ - + @@ -5869,7 +6656,7 @@ - + @@ -5888,7 +6675,7 @@ - + diff --git a/libs/spandsp/src/dds_int.c b/libs/spandsp/src/dds_int.c index e8a907ae1b..7573587ec4 100644 --- a/libs/spandsp/src/dds_int.c +++ b/libs/spandsp/src/dds_int.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: dds_int.c,v 1.10 2008/09/01 16:07:33 steveu Exp $ + * $Id: dds_int.c,v 1.11 2008/09/11 15:13:42 steveu Exp $ */ /*! \file */ @@ -252,11 +252,11 @@ int16_t dds(uint32_t *phase_acc, int32_t phase_rate) } /*- End of function --------------------------------------------------------*/ -int16_t dds_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase) +int16_t dds_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase) { int16_t amp; - amp = (int16_t) ((dds_lookup(*phase_acc + phase)*scale) >> 15); + amp = (int16_t) (((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15); *phase_acc += phase_rate; return amp; } @@ -278,12 +278,12 @@ complexi_t dds_complexi(uint32_t *phase_acc, int32_t phase_rate) } /*- End of function --------------------------------------------------------*/ -complexi_t dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase) +complexi_t dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase) { complexi_t amp; - amp = complex_seti((dds_lookup(*phase_acc + phase + (1 << 30))*scale) >> 15, - (dds_lookup(*phase_acc + phase)*scale) >> 15); + amp = complex_seti(((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*(int32_t) scale) >> 15, + ((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15); *phase_acc += phase_rate; return amp; } @@ -305,12 +305,12 @@ complexi16_t dds_complexi16(uint32_t *phase_acc, int32_t phase_rate) } /*- End of function --------------------------------------------------------*/ -complexi16_t dds_complexi16_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase) +complexi16_t dds_complexi16_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase) { complexi16_t amp; - amp = complex_seti16((dds_lookup(*phase_acc + phase + (1 << 30))*scale) >> 15, - (dds_lookup(*phase_acc + phase)*scale) >> 15); + amp = complex_seti16(((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*(int32_t) scale) >> 15, + ((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15); *phase_acc += phase_rate; return amp; } @@ -332,12 +332,12 @@ complexi32_t dds_complexi32(uint32_t *phase_acc, int32_t phase_rate) } /*- End of function --------------------------------------------------------*/ -complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase) +complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase) { complexi32_t amp; - amp = complex_seti32((dds_lookup(*phase_acc + phase + (1 << 30))*scale) >> 15, - (dds_lookup(*phase_acc + phase)*scale) >> 15); + amp = complex_seti32(((int32_t) dds_lookup(*phase_acc + phase + (1 << 30))*(int32_t) scale) >> 15, + ((int32_t) dds_lookup(*phase_acc + phase)*(int32_t) scale) >> 15); *phase_acc += phase_rate; return amp; } diff --git a/libs/spandsp/src/spandsp/dds.h b/libs/spandsp/src/spandsp/dds.h index 6dfd999143..af09c510d3 100644 --- a/libs/spandsp/src/spandsp/dds.h +++ b/libs/spandsp/src/spandsp/dds.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: dds.h,v 1.20 2008/09/04 14:40:05 steveu Exp $ + * $Id: dds.h,v 1.21 2008/09/11 15:13:42 steveu Exp $ */ /*! \file */ @@ -98,7 +98,7 @@ int16_t dds_lookup(uint32_t phase); \param phase The phase offset. \return The signal amplitude, between -32767 and 32767. */ -int16_t dds_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase); +int16_t dds_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); /*! \brief Lookup the complex integer value of a specified phase. \param phase The phase accumulator value to be looked up. @@ -120,7 +120,7 @@ complexi_t dds_complexi(uint32_t *phase_acc, int32_t phase_rate); \param phase The phase offset. \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). */ -complexi_t dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase); +complexi_t dds_complexi_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); /*! \brief Generate a complex 16 bit integer tone sample. \param phase_acc A pointer to a phase accumulator value. @@ -143,7 +143,7 @@ complexi16_t dds_complexi16(uint32_t *phase_acc, int32_t phase_rate); \param phase The phase offset. \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). */ -complexi16_t dds_complexi16_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase); +complexi16_t dds_complexi16_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); /*! \brief Generate a complex 32 bit integer tone sample, with modulation. \param phase_acc A pointer to a phase accumulator value. @@ -152,7 +152,7 @@ complexi16_t dds_complexi16_mod(uint32_t *phase_acc, int32_t phase_rate, int sca \param phase The phase offset. \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). */ -complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase); +complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); /*! \brief Generate a complex 32 bit integer tone sample. \param phase_acc A pointer to a phase accumulator value. @@ -175,7 +175,7 @@ complexi32_t dds_complexi32(uint32_t *phase_acc, int32_t phase_rate); \param phase The phase offset. \return The complex signal amplitude, between (-32767, -32767) and (32767, 32767). */ -complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int scale, int32_t phase); +complexi32_t dds_complexi32_mod(uint32_t *phase_acc, int32_t phase_rate, int16_t scale, int32_t phase); /*! \brief Find the phase rate equivalent to a frequency, in Hz. \param frequency The frequency, in Hz. diff --git a/libs/spandsp/src/spandsp/tone_generate.h b/libs/spandsp/src/spandsp/tone_generate.h index 0b31ddaede..6dc705b441 100644 --- a/libs/spandsp/src/spandsp/tone_generate.h +++ b/libs/spandsp/src/spandsp/tone_generate.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: tone_generate.h,v 1.33 2008/04/17 14:27:01 steveu Exp $ + * $Id: tone_generate.h,v 1.34 2008/09/11 15:13:42 steveu Exp $ */ /*! \file */ @@ -48,7 +48,11 @@ conditions in which we will use it. typedef struct { int32_t phase_rate; +#if defined(SPANDSP_USE_FIXED_POINT) + int16_t gain; +#else float gain; +#endif } tone_gen_tone_descriptor_t; /*! diff --git a/libs/spandsp/src/spandsp/version.h b/libs/spandsp/src/spandsp/version.h index ddd8f81175..12c67f9940 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 20080909 -#define SPANDSP_RELEASE_TIME 162813 +#define SPANDSP_RELEASE_DATE 20080911 +#define SPANDSP_RELEASE_TIME 151652 #endif /*- End of file ------------------------------------------------------------*/ diff --git a/libs/spandsp/src/t30.c b/libs/spandsp/src/t30.c index c74d6ff0a2..3ac1b70914 100644 --- a/libs/spandsp/src/t30.c +++ b/libs/spandsp/src/t30.c @@ -22,7 +22,7 @@ * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: t30.c,v 1.264 2008/09/09 15:30:43 steveu Exp $ + * $Id: t30.c,v 1.266 2008/09/11 15:13:42 steveu Exp $ */ /*! \file */ @@ -682,6 +682,15 @@ static int send_next_ecm_frame(t30_state_t *s) } /*- End of function --------------------------------------------------------*/ +static int send_rr(t30_state_t *s) +{ + if (s->current_status != T30_ERR_TX_T5EXP) + send_simple_frame(s, T30_RR); + else + send_dcn(s); +} +/*- End of function --------------------------------------------------------*/ + static int send_first_ecm_frame(t30_state_t *s) { s->ecm_current_tx_frame = 0; @@ -1517,6 +1526,26 @@ static void send_dcn(t30_state_t *s) } /*- End of function --------------------------------------------------------*/ +static void return_to_phase_b(t30_state_t *s, int with_fallback) +{ + /* This is what we do after things like T30_EOM is exchanged. */ + if (step_fallback_entry(s) < 0) + { + /* We have fallen back as far as we can go. Give up. */ + s->current_fallback = 0; + s->current_status = T30_ERR_CANNOT_TRAIN; + send_dcn(s); + } + else + { + if (s->calling_party) + set_state(s, T30_STATE_T); + else + set_state(s, T30_STATE_R); + } +} +/*- End of function --------------------------------------------------------*/ + static int send_dis_or_dtc_sequence(t30_state_t *s, int start) { /* (NSF) (CSI) DIS */ @@ -2668,12 +2697,14 @@ static void process_state_d_post_tcf(t30_state_t *s, const uint8_t *msg, int len break; case T30_DIS: /* It appears they didn't see what we sent - retry the TCF */ - if (++s->retries > MAX_MESSAGE_TRIES) + if (++s->retries >= MAX_MESSAGE_TRIES) { + span_log(&s->logging, SPAN_LOG_FLOW, "Too many retries. Giving up.\n"); s->current_status = T30_ERR_RETRYDCN; send_dcn(s); break; } + span_log(&s->logging, SPAN_LOG_FLOW, "Retry number %d\n", s->retries); queue_phase(s, T30_PHASE_B_TX); /* TODO: should we reassess the new DIS message, and possibly adjust the DCS we use? */ send_dcs_sequence(s, TRUE); @@ -2759,7 +2790,10 @@ static void process_state_f_ftt(t30_state_t *s, const uint8_t *msg, int len) static void process_state_f_doc_non_ecm(t30_state_t *s, const uint8_t *msg, int len) { /* If we are getting HDLC messages, and we have not moved to the _POST_DOC_NON_ECM - state, it looks like we didn't see the image data carrier properly. */ + state, it looks like either: + - we didn't see the image data carrier properly, or + - they didn't see our T30_CFR, and are repeating the DCS/TCF sequence. + - they didn't see out T30_MCF, and are repeating the end of page message. */ switch (msg[2] & 0xFE) { case T30_DIS: @@ -3319,12 +3353,12 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) s->phase_d_handler(s, s->phase_d_user_data, T30_MCF); t4_tx_end(&(s->t4)); s->operation_in_progress = OPERATION_IN_PROGRESS_NONE; - set_state(s, T30_STATE_R); if (span_log_test(&s->logging, SPAN_LOG_FLOW)) { t4_get_transfer_statistics(&s->t4, &stats); span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred); } + return_to_phase_b(s, FALSE); break; case T30_EOP: case T30_PRI_EOP: @@ -3349,8 +3383,14 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) case T30_MPS: case T30_PRI_MPS: s->retries = 0; + t4_tx_end_page(&(s->t4)); if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, T30_RTP); + if (tx_start_page(s)) + { + /* TODO: recover */ + break; + } /* Send fresh training, and then the next page */ if (step_fallback_entry(s) < 0) { @@ -3367,24 +3407,20 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) case T30_PRI_EOM: case T30_EOS: s->retries = 0; + t4_tx_end_page(&(s->t4)); if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, T30_RTP); - if (step_fallback_entry(s) < 0) - { - /* We have fallen back as far as we can go. Give up. */ - s->current_fallback = 0; - s->current_status = T30_ERR_CANNOT_TRAIN; - send_dcn(s); - break; - } + t4_tx_end(&(s->t4)); /* TODO: should go back to T, and resend */ - set_state(s, T30_STATE_R); + return_to_phase_b(s, TRUE); break; case T30_EOP: case T30_PRI_EOP: s->retries = 0; + t4_tx_end_page(&(s->t4)); if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, T30_RTP); + t4_tx_end(&(s->t4)); s->current_status = T30_ERR_TX_INVALRSP; send_dcn(s); break; @@ -3410,11 +3446,17 @@ static void process_state_ii_q(t30_state_t *s, const uint8_t *msg, int len) queue_phase(s, T30_PHASE_B_TX); restart_sending_document(s); break; - case T30_EOP: - case T30_PRI_EOP: case T30_EOM: case T30_PRI_EOM: case T30_EOS: + s->retries = 0; + if (s->phase_d_handler) + s->phase_d_handler(s, s->phase_d_user_data, T30_RTN); + s->current_status = T30_ERR_TX_INVALRSP; + return_to_phase_b(s, TRUE); + break; + case T30_EOP: + case T30_PRI_EOP: s->retries = 0; if (s->phase_d_handler) s->phase_d_handler(s, s->phase_d_user_data, T30_RTN); @@ -3639,12 +3681,12 @@ static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int le s->phase_d_handler(s, s->phase_d_user_data, T30_MCF); t4_tx_end(&(s->t4)); s->operation_in_progress = OPERATION_IN_PROGRESS_NONE; - set_state(s, T30_STATE_R); if (span_log_test(&s->logging, SPAN_LOG_FLOW)) { t4_get_transfer_statistics(&s->t4, &stats); span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred); } + return_to_phase_b(s, FALSE); break; case T30_EOP: case T30_PRI_EOP: @@ -3672,7 +3714,7 @@ static void process_state_iv_pps_null(t30_state_t *s, const uint8_t *msg, int le s->timer_t5 = ms_to_samples(DEFAULT_TIMER_T5); queue_phase(s, T30_PHASE_D_TX); set_state(s, T30_STATE_IV_PPS_RNR); - send_simple_frame(s, T30_RR); + send_rr(s); break; case T30_DCN: s->current_status = T30_ERR_TX_BADPG; @@ -3714,7 +3756,6 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len) } else { - span_log(&s->logging, SPAN_LOG_FLOW, "Moving on to the next page\n"); switch (s->next_tx_step) { @@ -3745,12 +3786,12 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len) s->phase_d_handler(s, s->phase_d_user_data, T30_MCF); t4_tx_end(&(s->t4)); s->operation_in_progress = OPERATION_IN_PROGRESS_NONE; - set_state(s, T30_STATE_R); if (span_log_test(&s->logging, SPAN_LOG_FLOW)) { t4_get_transfer_statistics(&s->t4, &stats); span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred); } + return_to_phase_b(s, FALSE); break; case T30_EOP: case T30_PRI_EOP: @@ -3775,7 +3816,7 @@ static void process_state_iv_pps_q(t30_state_t *s, const uint8_t *msg, int len) s->timer_t5 = ms_to_samples(DEFAULT_TIMER_T5); queue_phase(s, T30_PHASE_D_TX); set_state(s, T30_STATE_IV_PPS_RNR); - send_simple_frame(s, T30_RR); + send_rr(s); break; case T30_PIP: s->retries = 0; @@ -3866,12 +3907,12 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len s->phase_d_handler(s, s->phase_d_user_data, T30_MCF); t4_tx_end(&(s->t4)); s->operation_in_progress = OPERATION_IN_PROGRESS_NONE; - set_state(s, T30_STATE_R); if (span_log_test(&s->logging, SPAN_LOG_FLOW)) { t4_get_transfer_statistics(&s->t4, &stats); span_log(&s->logging, SPAN_LOG_FLOW, "Success - delivered %d pages\n", stats.pages_transferred); } + return_to_phase_b(s, FALSE); break; case T30_EOP: case T30_PRI_EOP: @@ -3896,7 +3937,7 @@ static void process_state_iv_pps_rnr(t30_state_t *s, const uint8_t *msg, int len s->timer_t5 = ms_to_samples(DEFAULT_TIMER_T5); queue_phase(s, T30_PHASE_D_TX); set_state(s, T30_STATE_IV_PPS_RNR); - send_simple_frame(s, T30_RR); + send_rr(s); break; case T30_PIP: s->retries = 0; @@ -3968,7 +4009,7 @@ static void process_state_iv_eor(t30_state_t *s, const uint8_t *msg, int len) s->timer_t5 = ms_to_samples(DEFAULT_TIMER_T5); queue_phase(s, T30_PHASE_D_TX); set_state(s, T30_STATE_IV_EOR_RNR); - send_simple_frame(s, T30_RR); + send_rr(s); break; case T30_PIN: s->retries = 0; @@ -4006,7 +4047,7 @@ static void process_state_iv_eor_rnr(t30_state_t *s, const uint8_t *msg, int len s->timer_t5 = ms_to_samples(DEFAULT_TIMER_T5); queue_phase(s, T30_PHASE_D_TX); set_state(s, T30_STATE_IV_EOR_RNR); - send_simple_frame(s, T30_RR); + send_rr(s); break; case T30_PIN: s->retries = 0; @@ -4341,98 +4382,109 @@ static void queue_phase(t30_state_t *s, int phase) static void set_phase(t30_state_t *s, int phase) { - if (phase != s->phase) + //if (phase = s->phase) + // return; + span_log(&s->logging, SPAN_LOG_FLOW, "Changing from phase %s to %s\n", phase_names[s->phase], phase_names[phase]); + /* We may be killing a receiver before it has declared the end of the + signal. Force the signal present indicator to off, because the + receiver will never be able to. */ + if (s->phase != T30_PHASE_A_CED && s->phase != T30_PHASE_A_CNG) + s->rx_signal_present = FALSE; + s->rx_trained = FALSE; + s->rx_frame_received = FALSE; + s->phase = phase; + switch (phase) { - span_log(&s->logging, SPAN_LOG_FLOW, "Changing from phase %s to %s\n", phase_names[s->phase], phase_names[phase]); - /* We may be killing a receiver before it has declared the end of the - signal. Force the signal present indicator to off, because the - receiver will never be able to. */ - if (s->phase != T30_PHASE_A_CED && s->phase != T30_PHASE_A_CNG) - s->rx_signal_present = FALSE; - s->rx_trained = FALSE; - s->rx_frame_received = FALSE; - s->phase = phase; - switch (phase) + case T30_PHASE_A_CED: + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CED, 0, FALSE, FALSE); + break; + case T30_PHASE_A_CNG: + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CNG, 0, FALSE, FALSE); + break; + case T30_PHASE_B_RX: + case T30_PHASE_D_RX: + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + break; + case T30_PHASE_B_TX: + case T30_PHASE_D_TX: + if (!s->far_end_detected && s->timer_t0_t1 > 0) { - case T30_PHASE_A_CED: - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CED, 0, FALSE, FALSE); - break; - case T30_PHASE_A_CNG: - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_CNG, 0, FALSE, FALSE); - break; - case T30_PHASE_B_RX: - case T30_PHASE_D_RX: - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - break; - case T30_PHASE_B_TX: - case T30_PHASE_D_TX: - if (!s->far_end_detected && s->timer_t0_t1 > 0) - { - s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T1); - s->far_end_detected = TRUE; - } - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); - break; - case T30_PHASE_C_NON_ECM_RX: - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, FALSE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - break; - case T30_PHASE_C_NON_ECM_TX: - /* Pause before switching from anything to phase C */ - /* Always prime the training count for 1.5s of data at the current rate. Its harmless if - we prime it and are not doing TCF. */ - s->tcf_test_bits = (3*fallback_sequence[s->current_fallback].bit_rate)/2; - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, FALSE); - break; - case T30_PHASE_C_ECM_RX: - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, TRUE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - break; - case T30_PHASE_C_ECM_TX: - /* Pause before switching from anything to phase C */ - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, TRUE); - break; - case T30_PHASE_E: - /* Send a little silence before ending things, to ensure the - buffers are all flushed through, and the far end has seen - the last message we sent. */ - s->tcf_test_bits = 0; - s->tcf_current_zeros = 0; - s->tcf_most_zeros = 0; - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_PAUSE, 0, FINAL_FLUSH_TIME, FALSE); - break; - case T30_PHASE_CALL_FINISHED: - if (s->set_rx_type_handler) - s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_DONE, 0, FALSE, FALSE); - if (s->set_tx_type_handler) - s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_DONE, 0, FALSE, FALSE); - break; + s->timer_t0_t1 = ms_to_samples(DEFAULT_TIMER_T1); + s->far_end_detected = TRUE; } + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_V21, 300, FALSE, TRUE); + break; + case T30_PHASE_C_NON_ECM_RX: + if (s->set_rx_type_handler) + { + /* Momentarily stop the receive modem, so the next change is forced to happen. If we don't do this + an HDLC message on the slow modem, which has disabled the fast modem, will prevent the same + fast modem from restarting. */ + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, FALSE); + } + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + break; + case T30_PHASE_C_NON_ECM_TX: + /* Pause before switching from anything to phase C */ + /* Always prime the training count for 1.5s of data at the current rate. Its harmless if + we prime it and are not doing TCF. */ + s->tcf_test_bits = (3*fallback_sequence[s->current_fallback].bit_rate)/2; + if (s->set_rx_type_handler) + { + /* Momentarily stop the receive modem, so the next change is forced to happen. If we don't do this + an HDLC message on the slow modem, which has disabled the fast modem, will prevent the same + fast modem from restarting. */ + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + } + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, FALSE); + break; + case T30_PHASE_C_ECM_RX: + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, TRUE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + break; + case T30_PHASE_C_ECM_TX: + /* Pause before switching from anything to phase C */ + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, fallback_sequence[s->current_fallback].modem_type, fallback_sequence[s->current_fallback].bit_rate, s->short_train, TRUE); + break; + case T30_PHASE_E: + /* Send a little silence before ending things, to ensure the + buffers are all flushed through, and the far end has seen + the last message we sent. */ + s->tcf_test_bits = 0; + s->tcf_current_zeros = 0; + s->tcf_most_zeros = 0; + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_NONE, 0, FALSE, FALSE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_PAUSE, 0, FINAL_FLUSH_TIME, FALSE); + break; + case T30_PHASE_CALL_FINISHED: + if (s->set_rx_type_handler) + s->set_rx_type_handler(s->set_rx_type_user_data, T30_MODEM_DONE, 0, FALSE, FALSE); + if (s->set_tx_type_handler) + s->set_tx_type_handler(s->set_tx_type_user_data, T30_MODEM_DONE, 0, FALSE, FALSE); + break; } } /*- End of function --------------------------------------------------------*/ @@ -4451,6 +4503,30 @@ static void set_state(t30_state_t *s, int state) static void repeat_last_command(t30_state_t *s) { s->step = 0; + if (++s->retries >= MAX_MESSAGE_TRIES) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Too many retries. Giving up.\n"); + switch (s->state) + { + case T30_STATE_D_POST_TCF: + /* Received no response to DCS or TCF */ + s->current_status = T30_ERR_TX_PHBDEAD; + break; + case T30_STATE_II_Q: + case T30_STATE_IV_PPS_NULL: + case T30_STATE_IV_PPS_Q: + /* No response after sending a page */ + s->current_status = T30_ERR_TX_PHDDEAD; + break; + default: + /* Disconnected after permitted retries */ + s->current_status = T30_ERR_RETRYDCN; + break; + } + send_dcn(s); + return; + } + span_log(&s->logging, SPAN_LOG_FLOW, "Retry number %d\n", s->retries); switch (s->state) { case T30_STATE_R: @@ -4482,7 +4558,7 @@ static void repeat_last_command(t30_state_t *s) case T30_STATE_IV_PPS_RNR: case T30_STATE_IV_EOR_RNR: queue_phase(s, T30_PHASE_D_TX); - send_simple_frame(s, T30_RNR); + send_rr(s); break; case T30_STATE_D: queue_phase(s, T30_PHASE_B_TX); @@ -4693,28 +4769,6 @@ static void timer_t4_expired(t30_state_t *s) /* There was no response (or only a corrupt response) to a command, within the T4 timeout period. */ span_log(&s->logging, SPAN_LOG_FLOW, "T4 expired in phase %s, state %d\n", phase_names[s->phase], s->state); - if (++s->retries > MAX_MESSAGE_TRIES) - { - switch (s->state) - { - case T30_STATE_D_POST_TCF: - /* Received no response to DCS or TCF */ - s->current_status = T30_ERR_TX_PHBDEAD; - break; - case T30_STATE_II_Q: - case T30_STATE_IV_PPS_NULL: - case T30_STATE_IV_PPS_Q: - /* No response after sending a page */ - s->current_status = T30_ERR_TX_PHDDEAD; - break; - default: - /* Disconnected after permitted retries */ - s->current_status = T30_ERR_RETRYDCN; - break; - } - send_dcn(s); - return; - } /* Of course, things might just be a little late, especially if there are T.38 links in the path. There is no point in simply timing out, and resending, if we are currently receiving something from the far end - its a half-duplex @@ -4746,7 +4800,6 @@ static void timer_t5_expired(t30_state_t *s) /* Give up waiting for the receiver to become ready in error correction mode */ span_log(&s->logging, SPAN_LOG_FLOW, "T5 expired in phase %s, state %d\n", phase_names[s->phase], s->state); s->current_status = T30_ERR_TX_T5EXP; - send_dcn(s); } /*- End of function --------------------------------------------------------*/ @@ -5605,8 +5658,7 @@ void t30_timer_update(t30_state_t *s, int samples) { if (s->timer_t0_t1 > 0) { - s->timer_t0_t1 -= samples; - if (s->timer_t0_t1 <= 0) + if ((s->timer_t0_t1 -= samples) <= 0) { if (s->far_end_detected) timer_t1_expired(s); @@ -5616,14 +5668,12 @@ void t30_timer_update(t30_state_t *s, int samples) } if (s->timer_t3 > 0) { - s->timer_t3 -= samples; - if (s->timer_t3 <= 0) + if ((s->timer_t3 -= samples) <= 0) timer_t3_expired(s); } if (s->timer_t2_t4 > 0) { - s->timer_t2_t4 -= samples; - if (s->timer_t2_t4 <= 0) + if ((s->timer_t2_t4 -= samples) <= 0) { switch (s->timer_t2_t4_is) { @@ -5650,8 +5700,7 @@ void t30_timer_update(t30_state_t *s, int samples) } if (s->timer_t5 > 0) { - s->timer_t5 -= samples; - if (s->timer_t5 <= 0) + if ((s->timer_t5 -= samples) <= 0) timer_t5_expired(s); } } diff --git a/libs/spandsp/src/tone_generate.c b/libs/spandsp/src/tone_generate.c index 1f9fed7a41..30e309cfc8 100644 --- a/libs/spandsp/src/tone_generate.c +++ b/libs/spandsp/src/tone_generate.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: tone_generate.c,v 1.43 2008/07/02 14:48:26 steveu Exp $ + * $Id: tone_generate.c,v 1.46 2008/09/11 15:13:42 steveu Exp $ */ /*! \file */ @@ -72,15 +72,27 @@ void make_tone_gen_descriptor(tone_gen_descriptor_t *s, memset(s, 0, sizeof(*s)); if (f1) { +#if defined(SPANDSP_USE_FIXED_POINT) + s->tone[0].phase_rate = dds_phase_rate((float) f1); + if (f2 < 0) + s->tone[0].phase_rate = -s->tone[0].phase_rate; + s->tone[0].gain = dds_scaling_dbm0((float) l1); +#else s->tone[0].phase_rate = dds_phase_ratef((float) f1); if (f2 < 0) s->tone[0].phase_rate = -s->tone[0].phase_rate; s->tone[0].gain = dds_scaling_dbm0f((float) l1); +#endif } if (f2) { +#if defined(SPANDSP_USE_FIXED_POINT) + s->tone[1].phase_rate = dds_phase_rate((float) abs(f2)); + s->tone[1].gain = (f2 < 0) ? (float) 32767.0f*l2/100.0f : dds_scaling_dbm0((float) l2); +#else s->tone[1].phase_rate = dds_phase_ratef((float) abs(f2)); s->tone[1].gain = (f2 < 0) ? (float) l2/100.0f : dds_scaling_dbm0f((float) l2); +#endif } s->duration[0] = d1*SAMPLE_RATE/1000; @@ -118,7 +130,11 @@ int tone_gen(tone_gen_state_t *s, int16_t amp[], int max_samples) { int samples; int limit; +#if defined(SPANDSP_USE_FIXED_POINT) + int16_t xamp; +#else float xamp; +#endif int i; if (s->current_section < 0) @@ -141,30 +157,49 @@ int tone_gen(tone_gen_state_t *s, int16_t amp[], int max_samples) { if (s->tone[0].phase_rate < 0) { + /* Modulated tone */ for ( ; samples < limit; samples++) { - /* There must be two, and only two tones */ + /* There must be two, and only two, tones */ +#if defined(SPANDSP_USE_FIXED_POINT) + xamp = ((int32_t) dds_mod(&s->phase[0], -s->tone[0].phase_rate, s->tone[0].gain, 0) + *(32767 + (int32_t) dds_mod(&s->phase[1], s->tone[1].phase_rate, s->tone[1].gain, 0))) >> 15; + amp[samples] = xamp; +#else xamp = dds_modf(&s->phase[0], -s->tone[0].phase_rate, s->tone[0].gain, 0) *(1.0f + dds_modf(&s->phase[1], s->tone[1].phase_rate, s->tone[1].gain, 0)); amp[samples] = (int16_t) lrintf(xamp); +#endif } } else { for ( ; samples < limit; samples++) { +#if defined(SPANDSP_USE_FIXED_POINT) + xamp = 0; +#else xamp = 0.0f; +#endif for (i = 0; i < 4; i++) { if (s->tone[i].phase_rate == 0) break; +#if defined(SPANDSP_USE_FIXED_POINT) + xamp += dds_mod(&s->phase[i], s->tone[i].phase_rate, s->tone[i].gain, 0); +#else xamp += dds_modf(&s->phase[i], s->tone[i].phase_rate, s->tone[i].gain, 0); +#endif } /* Saturation of the answer is the right thing at this point. However, we are normally generating well controlled tones, that cannot clip. So, the overhead of doing saturation is a waste of valuable time. */ +#if defined(SPANDSP_USE_FIXED_POINT) + amp[samples] = xamp; +#else amp[samples] = (int16_t) lrintf(xamp); +#endif } } } diff --git a/libs/spandsp/test-data/etsi/fax/Makefile.am b/libs/spandsp/test-data/etsi/fax/Makefile.am index 33b2240346..7ab1609f40 100644 --- a/libs/spandsp/test-data/etsi/fax/Makefile.am +++ b/libs/spandsp/test-data/etsi/fax/Makefile.am @@ -16,7 +16,7 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## -## $Id: Makefile.am,v 1.1 2008/07/10 12:44:54 steveu Exp $ +## $Id: Makefile.am,v 1.2 2008/09/10 16:55:15 steveu Exp $ AM_CFLAGS = $(COMP_VENDOR_CFLAGS) @@ -25,13 +25,17 @@ FAX2TIFF = fax2tiff EXTRA_DIST = -nobase_data_DATA = etsi_300_242_white.tif \ - etsi_300_242_stairstep.tif \ - etsi_300_242_diago1.tif \ - etsi_300_242_diago2.tif \ - etsi_300_242_impress.tif \ - etsi_300_242_error.tif - +nobase_data_DATA = etsi_300_242_a4_diago1.tif \ + etsi_300_242_a4_diago2.tif \ + etsi_300_242_a4_duration1.tif \ + etsi_300_242_a4_duration2.tif \ + etsi_300_242_a4_error.tif \ + etsi_300_242_a4_impress.tif \ + etsi_300_242_a4_impress_white.tif \ + etsi_300_242_a4_stairstep.tif \ + etsi_300_242_a4_white.tif \ + etsi_300_242_a4_white_2p.tif + noinst_PROGRAMS = generate_etsi_300_242_pages generate_etsi_300_242_pages_SOURCES = generate_etsi_300_242_pages.c @@ -46,10 +50,14 @@ clean: .pbm.g3: ${PBM2G3} $*.pbm >$*.g3 -etsi_300_242_white.tif \ -etsi_300_242_stairstep.tif \ -etsi_300_242_diago1.tif \ -etsi_300_242_diago2.tif \ -etsi_300_242_impress.tif \ -etsi_300_242_error.tif: generate_etsi_300_242_pages$(EXEEXT) +etsi_300_242_a4_diago1.tif \ +etsi_300_242_a4_diago2.tif \ +etsi_300_242_a4_duration1.tif \ +etsi_300_242_a4_duration2.tif \ +etsi_300_242_a4_error.tif \ +etsi_300_242_a4_impress.tif \ +etsi_300_242_a4_impress_white.tif \ +etsi_300_242_a4_stairstep.tif \ +etsi_300_242_a4_white.tif \ +etsi_300_242_a4_white_2p.tif: generate_etsi_300_242_pages$(EXEEXT) ./generate_etsi_300_242_pages$(EXEEXT) diff --git a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c index 4b0f88c7de..72a800f7f5 100644 --- a/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.c +++ b/libs/spandsp/test-data/etsi/fax/generate_etsi_300_242_pages.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: generate_etsi_300_242_pages.c,v 1.1 2008/07/10 12:44:54 steveu Exp $ + * $Id: generate_etsi_300_242_pages.c,v 1.2 2008/09/10 16:55:15 steveu Exp $ */ /*! \file */ @@ -61,7 +61,7 @@ struct } sequence[] = { { - "etsi_300_242_white.tif", + "etsi_300_242_a4_diago1.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -70,7 +70,7 @@ struct 0 }, { - "etsi_300_242_stairstep.tif", + "etsi_300_242_a4_diago2.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -79,7 +79,7 @@ struct 1 }, { - "etsi_300_242_diago1.tif", + "etsi_300_242_a4_duration1.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -88,7 +88,7 @@ struct 2 }, { - "etsi_300_242_diago2.tif", + "etsi_300_242_a4_duration2.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -97,7 +97,7 @@ struct 3 }, { - "etsi_300_242_impress.tif", + "etsi_300_242_a4_error.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -106,7 +106,7 @@ struct 4 }, { - "etsi_300_242_duration1.tif", + "etsi_300_242_a4_impress.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -115,7 +115,7 @@ struct 5 }, { - "etsi_300_242_duration2.tif", + "etsi_300_242_a4_stairstep.tif", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -124,7 +124,43 @@ struct 6 }, { - "etsi_300_242_error.tif", + "etsi_300_242_a4_white.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A4, + 1100, + COMPRESSION_CCITT_T4, + 7 + }, + { + "etsi_300_242_a4_white_2p.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A4, + 1100, + COMPRESSION_CCITT_T4, + 7 + }, + { /* Second page of the above file */ + "", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A4, + 1100, + COMPRESSION_CCITT_T4, + 7 + }, + { + "etsi_300_242_a4_impress_white.tif", + T4_X_RESOLUTION_R8, + T4_Y_RESOLUTION_STANDARD, + T4_WIDTH_R8_A4, + 1100, + COMPRESSION_CCITT_T4, + 5 + }, + { /* Second page of the above file */ + "", T4_X_RESOLUTION_R8, T4_Y_RESOLUTION_STANDARD, T4_WIDTH_R8_A4, @@ -512,11 +548,16 @@ int main(int argc, char *argv[]) int i; int image_length; + tiff_file = NULL; for (i = 0; sequence[i].name; i++) { - if ((tiff_file = TIFFOpen(sequence[i].name, "w")) == NULL) - exit(2); - + if (sequence[i].name[0]) + { + if (tiff_file) + TIFFClose(tiff_file); + if ((tiff_file = TIFFOpen(sequence[i].name, "w")) == NULL) + exit(2); + } /* Prepare the directory entry fully before writing the image, or libtiff complains */ TIFFSetField(tiff_file, TIFFTAG_COMPRESSION, sequence[i].compression); if (sequence[i].compression == COMPRESSION_CCITT_T4) @@ -565,37 +606,37 @@ int main(int argc, char *argv[]) switch (sequence[i].type) { case 0: - /* A white A4 page */ - image_length = create_white_page(tiff_file); - break; - case 1: - /* A stairstep of 64 pixel dashes */ - image_length = create_stairstep_page(tiff_file); - break; - case 2: /* The DIAGO1 page */ image_length = create_diago1_page(tiff_file); break; - case 3: + case 1: /* The DIAGO2 page */ image_length = create_diago2_page(tiff_file); break; - case 4: - /* The IMPRESS page */ - image_length = create_impress_page(tiff_file); - break; - case 5: + case 2: /* The DURATION1 page */ image_length = create_duration1_page(tiff_file); break; - case 6: + case 3: /* The DURATION2 page */ image_length = create_duration2_page(tiff_file); break; - case 7: + case 4: /* The ERROR page */ image_length = create_error_page(tiff_file); break; + case 5: + /* The IMPRESS page */ + image_length = create_impress_page(tiff_file); + break; + case 6: + /* A stairstep of 64 pixel dashes */ + image_length = create_stairstep_page(tiff_file); + break; + case 7: + /* A white A4 page */ + image_length = create_white_page(tiff_file); + break; } /* ....then the directory entry, and libtiff is happy. */ TIFFSetField(tiff_file, TIFFTAG_IMAGELENGTH, image_length); @@ -603,8 +644,9 @@ int main(int argc, char *argv[]) TIFFSetField(tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN); TIFFWriteDirectory(tiff_file); - TIFFClose(tiff_file); } + if (tiff_file) + TIFFClose(tiff_file); return 0; } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/tests/tone_generate_tests.c b/libs/spandsp/tests/tone_generate_tests.c index 6d56418a55..3a1e7c93d6 100644 --- a/libs/spandsp/tests/tone_generate_tests.c +++ b/libs/spandsp/tests/tone_generate_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: tone_generate_tests.c,v 1.19 2008/08/16 15:24:16 steveu Exp $ + * $Id: tone_generate_tests.c,v 1.20 2008/09/11 15:13:42 steveu Exp $ */ /*! \page tone_generate_tests_page Tone generation tests @@ -60,7 +60,8 @@ int main(int argc, char *argv[]) fprintf(stderr, " Cannot open wave file '%s'\n", OUTPUT_FILE_NAME); exit(2); } - + + /* Try a tone pair */ make_tone_gen_descriptor(&tone_desc, 440, -10, @@ -85,15 +86,16 @@ int main(int argc, char *argv[]) len); } + /* Try a different tone pair */ make_tone_gen_descriptor(&tone_desc, 350, -10, 440, -15, - 100, - 200, - 300, 400, + 300, + 200, + 100, TRUE); tone_gen_init(&tone_state, &tone_desc); @@ -108,7 +110,8 @@ int main(int argc, char *argv[]) amp, len); } - + + /* Try a different tone pair */ make_tone_gen_descriptor(&tone_desc, 400, -10, @@ -121,6 +124,106 @@ int main(int argc, char *argv[]) TRUE); tone_gen_init(&tone_state, &tone_desc); + for (i = 0; i < 1000; i++) + { + len = tone_gen(&tone_state, amp, 160); + printf("Generated %d samples\n", len); + if (len <= 0) + break; + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + len); + } + + /* Try a single tone */ + make_tone_gen_descriptor(&tone_desc, + 400, + -10, + 0, + 0, + 100, + 200, + 300, + 400, + TRUE); + tone_gen_init(&tone_state, &tone_desc); + + for (i = 0; i < 1000; i++) + { + len = tone_gen(&tone_state, amp, 160); + printf("Generated %d samples\n", len); + if (len <= 0) + break; + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + len); + } + + /* Try a single non-repeating tone */ + make_tone_gen_descriptor(&tone_desc, + 820, + -10, + 0, + 0, + 2000, + 0, + 0, + 0, + FALSE); + tone_gen_init(&tone_state, &tone_desc); + + for (i = 0; i < 1000; i++) + { + len = tone_gen(&tone_state, amp, 160); + printf("Generated %d samples\n", len); + if (len <= 0) + break; + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + len); + } + + /* Try a single non-repeating tone at 0dBm0 */ + make_tone_gen_descriptor(&tone_desc, + 820, + 0, + 0, + 0, + 2000, + 0, + 0, + 0, + FALSE); + tone_gen_init(&tone_state, &tone_desc); + + for (i = 0; i < 1000; i++) + { + len = tone_gen(&tone_state, amp, 160); + printf("Generated %d samples\n", len); + if (len <= 0) + break; + outframes = afWriteFrames(outhandle, + AF_DEFAULT_TRACK, + amp, + len); + } + + /* Try an AM modulated tone at a modest modulation level (25%) */ + make_tone_gen_descriptor(&tone_desc, + 425, + -10, + -50, + 25, + 100, + 200, + 300, + 400, + TRUE); + tone_gen_init(&tone_state, &tone_desc); + for (i = 0; i < 1000; i++) { len = tone_gen(&tone_state, amp, 160); @@ -133,6 +236,7 @@ int main(int argc, char *argv[]) len); } + /* Try an AM modulated tone at maximum modulation level (100%) */ make_tone_gen_descriptor(&tone_desc, 425, -10, diff --git a/libs/spandsp/tests/tsb85_tests.c b/libs/spandsp/tests/tsb85_tests.c index dc45572818..29509bb296 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.22 2008/09/09 15:30:43 steveu Exp $ + * $Id: tsb85_tests.c,v 1.23 2008/09/10 16:55:15 steveu Exp $ */ /*! \file */ @@ -86,6 +86,8 @@ int awaited_len = 0; t30_exchanged_info_t expected_rx_info; +char next_tx_file[1000]; + static int next_step(faxtester_state_t *s); static int phase_b_handler(t30_state_t *s, void *user_data, int result) @@ -317,6 +319,12 @@ static int document_handler(t30_state_t *s, void *user_data, int event) i = (intptr_t) user_data; fprintf(stderr, "%d: Document handler on channel %d - event %d\n", i, i, event); + if (next_tx_file[0]) + { + t30_set_tx_file(s, next_tx_file, -1, -1); + next_tx_file[0] = '\0'; + return TRUE; + } return FALSE; } /*- End of function --------------------------------------------------------*/ @@ -329,7 +337,9 @@ static void faxtester_real_time_frame_handler(faxtester_state_t *s, { if (msg == NULL) { - next_step(s); + while (next_step(s) == 0) + ; + /*endwhile*/ } else { @@ -352,14 +362,20 @@ static void faxtester_real_time_frame_handler(faxtester_state_t *s, } } if (msg[1] == awaited[1]) - next_step(s); + { + while (next_step(s) == 0) + ; + /*endwhile*/ + } } } /*- End of function --------------------------------------------------------*/ static void faxtester_front_end_step_complete_handler(faxtester_state_t *s, void *user_data) { - next_step(s); + while (next_step(s) == 0) + ; + /*endwhile*/ } /*- End of function --------------------------------------------------------*/ @@ -611,7 +627,9 @@ static int next_step(faxtester_state_t *s) xmlChar *crc_error; xmlChar *pattern; xmlChar *timeout; - xmlChar *min_time; + xmlChar *min_bits; + xmlChar *frame_size; + xmlChar *compression; uint8_t buf[1000]; uint8_t mask[1000]; int i; @@ -619,8 +637,8 @@ static int next_step(faxtester_state_t *s) int hdlc; int short_train; int min_row_bits; - int compression; - int compression_step; + int ecm_frame_size; + int compression_type; int timer; int len; t4_state_t t4_state; @@ -658,7 +676,9 @@ static int next_step(faxtester_state_t *s) crc_error = xmlGetProp(s->cur, (const xmlChar *) "crc_error"); pattern = xmlGetProp(s->cur, (const xmlChar *) "pattern"); timeout = xmlGetProp(s->cur, (const xmlChar *) "timeout"); - min_time = xmlGetProp(s->cur, (const xmlChar *) "min_time"); + min_bits = xmlGetProp(s->cur, (const xmlChar *) "min_bits"); + frame_size = xmlGetProp(s->cur, (const xmlChar *) "frame_size"); + compression = xmlGetProp(s->cur, (const xmlChar *) "compression"); s->cur = s->cur->next; @@ -857,15 +877,21 @@ static int next_step(faxtester_state_t *s) t30_set_rx_file(t30, output_tiff_file_name, -1); } else if (strcasecmp((const char *) tag, "TXFILE") == 0) - t30_set_tx_file(t30, (const char *) value, -1, -1); + { + strcpy(next_tx_file, (const char *) value); +printf("Push '%s'\n", next_tx_file); + } return 0; } else if (strcasecmp((const char *) type, "CALL") == 0) { fax_init(&fax, FALSE); fax_prepare(); + next_tx_file[0] = '\0'; t30 = fax_get_t30_state(&fax); t30_set_rx_file(t30, output_tiff_file_name, -1); + /* 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); return 0; @@ -874,7 +900,10 @@ static int next_step(faxtester_state_t *s) { fax_init(&fax, TRUE); fax_prepare(); + next_tx_file[0] = '\0'; t30 = fax_get_t30_state(&fax); + /* 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); return 0; @@ -937,8 +966,10 @@ static int next_step(faxtester_state_t *s) else if (strcasecmp((const char *) type, "MSG") == 0) { /* A non-ECM page */ - min_row_bits = 0; - compression_step = 0; + 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) { span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n"); @@ -946,19 +977,15 @@ static int next_step(faxtester_state_t *s) } t4_tx_set_min_row_bits(&t4_state, min_row_bits); t4_tx_set_header_info(&t4_state, NULL); - switch (compression_step) + compression_type = T4_COMPRESSION_ITU_T4_1D; + if (compression) { - case 0: - compression = T4_COMPRESSION_ITU_T4_1D; - break; - case 1: - compression = T4_COMPRESSION_ITU_T4_2D; - break; - case 2: - compression = T4_COMPRESSION_ITU_T6; - break; + if (strcasecmp((const char *) compression, "T.4 2D") == 0) + compression_type = T4_COMPRESSION_ITU_T4_2D; + else if (strcasecmp((const char *) compression, "T.6") == 0) + compression_type = T4_COMPRESSION_ITU_T6; } - t4_tx_set_tx_encoding(&t4_state, compression); + t4_tx_set_tx_encoding(&t4_state, compression_type); if (t4_tx_start_page(&t4_state)) { span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n"); @@ -971,51 +998,58 @@ static int next_step(faxtester_state_t *s) corrupt_image(s, image, len, (const char *) bad_rows); } t4_tx_end(&t4_state); + span_log(&s->logging, SPAN_LOG_FLOW, "Non-ECM image is %d bytes\n", len); faxtester_set_non_ecm_image_buffer(s, image, len); } else if (strcasecmp((const char *) type, "PP") == 0) { - compression_step = 0; - if (t4_tx_init(&t4_state, (const char *) value, -1, -1) == NULL) - { - span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n"); - exit(2); - } - t4_tx_set_min_row_bits(&t4_state, 0); - t4_tx_set_header_info(&t4_state, NULL); - switch (compression_step) - { - case 0: - compression = T4_COMPRESSION_ITU_T4_1D; - break; - case 1: - compression = T4_COMPRESSION_ITU_T4_2D; - break; - case 2: - compression = T4_COMPRESSION_ITU_T6; - break; - } - t4_tx_set_tx_encoding(&t4_state, compression); - if (t4_tx_start_page(&t4_state)) - { - span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n"); - exit(2); - } + if (min_bits) + min_row_bits = atoi((const char *) min_bits); + else + min_row_bits = 0; /*endif*/ - len = t4_tx_get_chunk(&t4_state, image, sizeof(image)); - if (bad_rows) - { - span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n"); - corrupt_image(s, image, len, (const char *) bad_rows); - } + if (frame_size) + ecm_frame_size = atoi((const char *) frame_size); + else + ecm_frame_size = 64; /*endif*/ - t4_tx_end(&t4_state); if (crc_error) i = atoi((const char *) crc_error); else i = -1; /*endif*/ - faxtester_set_ecm_image_buffer(s, image, len, 64, i); + if (t4_tx_init(&t4_state, (const char *) value, -1, -1) == NULL) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Failed to init T.4 send\n"); + exit(2); + } + t4_tx_set_min_row_bits(&t4_state, min_row_bits); + t4_tx_set_header_info(&t4_state, NULL); + compression_type = T4_COMPRESSION_ITU_T4_1D; + if (compression) + { + if (strcasecmp((const char *) compression, "T.4 2D") == 0) + compression_type = T4_COMPRESSION_ITU_T4_2D; + else if (strcasecmp((const char *) compression, "T.6") == 0) + compression_type = T4_COMPRESSION_ITU_T6; + } + t4_tx_set_tx_encoding(&t4_state, compression_type); + if (t4_tx_start_page(&t4_state)) + { + span_log(&s->logging, SPAN_LOG_FLOW, "Failed to start T.4 send\n"); + exit(2); + } + /*endif*/ + len = t4_tx_get_chunk(&t4_state, image, sizeof(image)); + if (bad_rows) + { + span_log(&s->logging, SPAN_LOG_FLOW, "We need to corrupt the image\n"); + corrupt_image(s, image, len, (const char *) bad_rows); + } + /*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); } else { @@ -1061,6 +1095,7 @@ static void exchange(faxtester_state_t *s) fax_init(&fax, FALSE); fax_prepare(); + next_tx_file[0] = '\0'; while (next_step(s) == 0) ; @@ -1147,39 +1182,36 @@ static int get_test_set(faxtester_state_t *s, const char *test_file, const char xmlDocPtr doc; xmlNsPtr ns; xmlNodePtr cur; -#if 1 xmlValidCtxt valid; -#endif ns = NULL; xmlKeepBlanksDefault(0); xmlCleanupParser(); if ((doc = xmlParseFile(test_file)) == NULL) { - span_log(&s->logging, SPAN_LOG_FLOW, "No document\n"); + fprintf(stderr, "No document\n"); exit(2); } /*endif*/ xmlXIncludeProcess(doc); -#if 1 if (!xmlValidateDocument(&valid, doc)) { - span_log(&s->logging, SPAN_LOG_FLOW, "Invalid document\n"); + fprintf(stderr, "Invalid document\n"); exit(2); } /*endif*/ -#endif + /* Check the document is of the right kind */ if ((cur = xmlDocGetRootElement(doc)) == NULL) { - span_log(&s->logging, SPAN_LOG_FLOW, "Empty document\n"); + fprintf(stderr, "Empty document\n"); xmlFreeDoc(doc); exit(2); } /*endif*/ if (xmlStrcmp(cur->name, (const xmlChar *) "fax-tests")) { - span_log(&s->logging, SPAN_LOG_FLOW, "Document of the wrong type, root node != fax-tests"); + fprintf(stderr, "Document of the wrong type, root node != fax-tests"); xmlFreeDoc(doc); exit(2); } diff --git a/libs/spandsp/tests/tsb85_tests.sh b/libs/spandsp/tests/tsb85_tests.sh index 52fd4f9eb1..9f17beaa3e 100755 --- a/libs/spandsp/tests/tsb85_tests.sh +++ b/libs/spandsp/tests/tsb85_tests.sh @@ -15,7 +15,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.sh,v 1.4 2008/09/09 15:30:43 steveu Exp $ +# $Id: tsb85_tests.sh,v 1.6 2008/09/11 15:13:42 steveu Exp $ # run_tsb85_test() @@ -35,6 +35,12 @@ for TEST in MRGN01 MRGN02 MRGN03 MRGN04 MRGN05 MRGN06a MRGN06b MRGN07 MRGN08 ; d run_tsb85_test done +#MRGN14 fails because ??? +#MRGN16 fails because we don't adequately distinguish between receiving a +#bad image signal and receiving none at all. +#MRGN17 fails because we don't adequately distinguish between receiving a +#bad HDLC message and receiving none at all. + #for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN14 MRGN15 MRGN16 MRGN17 ; do for TEST in MRGN09 MRGN10 MRGN11 MRGN12 MRGN13 MRGN15 ; do run_tsb85_test @@ -48,50 +54,62 @@ for TEST in OREN01 OREN02 OREN03 OREN04 OREN05 OREN06 OREN07 OREN08 OREN09 OREN1 run_tsb85_test done +# MRGX05 is failing because we don't distinguish MPS immediately after MCF from MPS after +# a corrupt image signal. + #for TEST in MRGX01 MRGX02 MRGX03 MRGX04 MRGX05 MRGX06 MRGX07 MRGX08 ; do -for TEST in MRGX02 MRGX04 MRGX06 MRGX07 MRGX08 ; do +for TEST in MRGX01 MRGX02 MRGX03 MRGX04 MRGX06 MRGX07 MRGX08 ; do run_tsb85_test done -#for TEST in MRGX09 MRGX10 MRGX11 MRGX12 MRGX13 MRGX14 MRGX15 ; do -for TEST in MRGX09 MRGX11 ; do +for TEST in MRGX09 MRGX10 MRGX11 MRGX12 MRGX13 MRGX14 MRGX15 ; do run_tsb85_test done -#for TEST in MTGP01 MTGP02 OTGP03 ; do -# run_tsb85_test -#done +for TEST in MTGP01 MTGP02 OTGP03 ; do + run_tsb85_test +done -#for TEST in MTGN01 MTGN02 MTGN03 MTGN04 MTGN05 MTGN06 MTGN07 MTGN08 MTGN09 MTGN10 ; do -# run_tsb85_test -#done +for TEST in MTGN01 MTGN02 MTGN03 MTGN04 MTGN05 MTGN06 MTGN07 MTGN08 MTGN09 MTGN10 ; do + run_tsb85_test +done -#for TEST in MTGN11 MTGN12 MTGN13 MTGN14 MTGN15 MTGN16 MTGN17 MTGN18 MTGN19 MTGN20 ; do -# run_tsb85_test -#done +for TEST in MTGN11 MTGN12 MTGN13 MTGN14 MTGN15 MTGN16 MTGN17 MTGN18 MTGN19 MTGN20 ; do + run_tsb85_test +done -#for TEST in MTGN21 MTGN22 MTGN23 MTGN24 MTGN25 MTGN26 MTGN27 MTGN28 ; do -# run_tsb85_test -#done +for TEST in MTGN21 MTGN22 MTGN23 MTGN24 MTGN25 MTGN26 MTGN27 MTGN28 ; do + run_tsb85_test +done -#for TEST in OTGC01 OTGC02 OTGC03 OTGC04 OTGC05 OTGC06 OTGC07 OTGC08 OTGC09 OTGC10 OTGC11 ; do -# run_tsb85_test -#done +for TEST in OTGC01 OTGC02 OTGC03 OTGC04 OTGC05 OTGC06 OTGC07 OTGC08 ; do + run_tsb85_test +done -#for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06 ; do -# run_tsb85_test -#done +for TEST in OTGC09-01 OTGC09-02 OTGC09-03 OTGC09-04 OTGC09-05 OTGC09-06 OTGC09-07 OTGC09-08 OTGC09-09 OTGC09-10 OTGC09-11 OTGC09-12 ; do + run_tsb85_test +done + +for TEST in OTGC10 OTGC11 ; do + run_tsb85_test +done + +for TEST in OTEN01 OTEN02 OTEN03 OTEN04 OTEN05 OTEN06 ; do + run_tsb85_test +done + +#MTGX02 fails because ????? #for TEST in MTGX01 MTGX02 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 ; do -# run_tsb85_test -#done +for TEST in MTGX01 MTGX03 MTGX04 MTGX05 MTGX06 MTGX07 MTGX08 ; do + run_tsb85_test +done -#for TEST in MTGX09 MTGX10 MTGX11 MTGX12 MTGX13 MTGX14 MTGX15 MTGX16 ; do -# run_tsb85_test -#done +for TEST in MTGX09 MTGX10 MTGX11 MTGX12 MTGX13 MTGX14 MTGX15 MTGX16 ; do + run_tsb85_test +done -#for TEST in MTGX17 MTGX18 MTGX19 MTGX20 MTGX21 MTGX22 MTGX23 ; do -for TEST in MTGX18 MTGX19 MTGX20 MTGX21 MTGX22 MTGX23 ; do +for TEST in MTGX17 MTGX18 MTGX19 MTGX20 MTGX21 MTGX22 MTGX23 ; do run_tsb85_test done