<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16035] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16035">16035</a></dd>
<dt>Author</dt> <dd>mikej</dd>
<dt>Date</dt> <dd>2009-12-22 19:38:36 -0600 (Tue, 22 Dec 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>update to <a href="http://jira.freeswitch.org/browse/spandsp-20091222">spandsp-20091222</a> snapshot</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibsspandspspandspsimspandspline_modelh">freeswitch/trunk/libs/spandsp/spandsp-sim/spandsp/line_model.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcMakefileam">freeswitch/trunk/libs/spandsp/src/Makefile.am</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcadsic">freeswitch/trunk/libs/spandsp/src/adsi.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcat_interpreterc">freeswitch/trunk/libs/spandsp/src/at_interpreter.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcfaxc">freeswitch/trunk/libs/spandsp/src/fax.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcfax_modemsc">freeswitch/trunk/libs/spandsp/src/fax_modems.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcfskc">freeswitch/trunk/libs/spandsp/src/fsk.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcgsm0610_rpec">freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrclibspandsp2005vcproj">freeswitch/trunk/libs/spandsp/src/libspandsp.2005.vcproj</a></li>
<li><a href="#freeswitchtrunklibsspandspsrclibspandsp2008vcproj">freeswitch/trunk/libs/spandsp/src/libspandsp.2008.vcproj</a></li>
<li><a href="#freeswitchtrunklibsspandspsrclibspandspdsp">freeswitch/trunk/libs/spandsp/src/libspandsp.dsp</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcmake_at_dictionaryc">freeswitch/trunk/libs/spandsp/src/make_at_dictionary.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcmodem_connect_tonesc">freeswitch/trunk/libs/spandsp/src/modem_connect_tones.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcmsvcspandsph">freeswitch/trunk/libs/spandsp/src/msvc/spandsp.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspexposeh">freeswitch/trunk/libs/spandsp/src/spandsp/expose.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspfskh">freeswitch/trunk/libs/spandsp/src/spandsp/fsk.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatemodem_connect_tonesh">freeswitch/trunk/libs/spandsp/src/spandsp/private/modem_connect_tones.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatet30h">freeswitch/trunk/libs/spandsp/src/spandsp/private/t30.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatet38_gatewayh">freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_gateway.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatet38_non_ecm_bufferh">freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatev18h">freeswitch/trunk/libs/spandsp/src/spandsp/private/v18.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatev22bish">freeswitch/trunk/libs/spandsp/src/spandsp/private/v22bis.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatev42h">freeswitch/trunk/libs/spandsp/src/spandsp/private/v42.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatev8h">freeswitch/trunk/libs/spandsp/src/spandsp/private/v8.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspt30h">freeswitch/trunk/libs/spandsp/src/spandsp/t30.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspt30_fcfh">freeswitch/trunk/libs/spandsp/src/spandsp/t30_fcf.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspt38_non_ecm_bufferh">freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandsptelephonyh">freeswitch/trunk/libs/spandsp/src/spandsp/telephony.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspv18h">freeswitch/trunk/libs/spandsp/src/spandsp/v18.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspv22bish">freeswitch/trunk/libs/spandsp/src/spandsp/v22bis.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspv42h">freeswitch/trunk/libs/spandsp/src/spandsp/v42.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspv8h">freeswitch/trunk/libs/spandsp/src/spandsp/v8.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspversionh">freeswitch/trunk/libs/spandsp/src/spandsp/version.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspversionhin">freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandsphin">freeswitch/trunk/libs/spandsp/src/spandsp.h.in</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcsuper_tone_rxc">freeswitch/trunk/libs/spandsp/src/super_tone_rx.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct30c">freeswitch/trunk/libs/spandsp/src/t30.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct30_apic">freeswitch/trunk/libs/spandsp/src/t30_api.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct30_loggingc">freeswitch/trunk/libs/spandsp/src/t30_logging.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct31c">freeswitch/trunk/libs/spandsp/src/t31.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct38_corec">freeswitch/trunk/libs/spandsp/src/t38_core.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct38_gatewayc">freeswitch/trunk/libs/spandsp/src/t38_gateway.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct38_non_ecm_bufferc">freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct38_terminalc">freeswitch/trunk/libs/spandsp/src/t38_terminal.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcv17rxc">freeswitch/trunk/libs/spandsp/src/v17rx.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcv18c">freeswitch/trunk/libs/spandsp/src/v18.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcv22bis_rxc">freeswitch/trunk/libs/spandsp/src/v22bis_rx.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcv22bis_txc">freeswitch/trunk/libs/spandsp/src/v22bis_tx.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcv29rxc">freeswitch/trunk/libs/spandsp/src/v29rx.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcv42c">freeswitch/trunk/libs/spandsp/src/v42.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcv8c">freeswitch/trunk/libs/spandsp/src/v8.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsat_interpreter_testsc">freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsfax_decodec">freeswitch/trunk/libs/spandsp/tests/fax_decode.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsfax_testerc">freeswitch/trunk/libs/spandsp/tests/fax_tester.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsfax_testssh">freeswitch/trunk/libs/spandsp/tests/fax_tests.sh</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsfax_utilsc">freeswitch/trunk/libs/spandsp/tests/fax_utils.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsfsk_testsc">freeswitch/trunk/libs/spandsp/tests/fsk_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsmodem_connect_tones_testsc">freeswitch/trunk/libs/spandsp/tests/modem_connect_tones_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestst38_gateway_testsc">freeswitch/trunk/libs/spandsp/tests/t38_gateway_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestst38_gateway_to_terminal_testsc">freeswitch/trunk/libs/spandsp/tests/t38_gateway_to_terminal_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestst38_non_ecm_buffer_testsc">freeswitch/trunk/libs/spandsp/tests/t38_non_ecm_buffer_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestst38_terminal_testsc">freeswitch/trunk/libs/spandsp/tests/t38_terminal_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestst38_terminal_to_gateway_testsc">freeswitch/trunk/libs/spandsp/tests/t38_terminal_to_gateway_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandsptestst4_testsc">freeswitch/trunk/libs/spandsp/tests/t4_tests.c</a></li>
<li><a href="#freeswitchtrunklibsspandspteststsb85_testssh">freeswitch/trunk/libs/spandsp/tests/tsb85_tests.sh</a></li>
<li><a href="#freeswitchtrunklibsspandsptestsv8_testsc">freeswitch/trunk/libs/spandsp/tests/v8_tests.c</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatet30_dis_dtc_dcs_bitsh">freeswitch/trunk/libs/spandsp/src/spandsp/private/t30_dis_dtc_dcs_bits.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatet4_rxh">freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_rx.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspprivatet4_txh">freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_tx.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspt4_rxh">freeswitch/trunk/libs/spandsp/src/spandsp/t4_rx.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrcspandspt4_txh">freeswitch/trunk/libs/spandsp/src/spandsp/t4_tx.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct4_rxc">freeswitch/trunk/libs/spandsp/src/t4_rx.c</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct4_t6_decode_statesh">freeswitch/trunk/libs/spandsp/src/t4_t6_decode_states.h</a></li>
<li><a href="#freeswitchtrunklibsspandspsrct4_txc">freeswitch/trunk/libs/spandsp/src/t4_tx.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunklibsspandspspandspsimspandspline_modelh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/spandsp-sim/spandsp/line_model.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/spandsp-sim/spandsp/line_model.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/spandsp-sim/spandsp/line_model.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: line_model.h,v 1.7 2009/09/23 16:02:59 steveu Exp $
</del><ins>+ * $Id: line_model.h,v 1.7.4.1 2009/12/19 10:16:44 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -70,7 +70,7 @@
</span><span class="cx">     codec_munge_state_t *munge;
</span><span class="cx"> 
</span><span class="cx">     /*! The coefficients for the near end analogue section simulation filter */
</span><del>-    float *near_filter;
</del><ins>+    const float *near_filter;
</ins><span class="cx">     /*! The number of coefficients for the near end analogue section simulation filter */
</span><span class="cx">     int near_filter_len;
</span><span class="cx">     /*! Last transmitted samples (ring buffer, used by the line filter) */
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx">     int16_t bulk_delay_buf[8000];
</span><span class="cx"> 
</span><span class="cx">     /*! The coefficients for the far end analogue section simulation filter */
</span><del>-    float *far_filter;
</del><ins>+    const float *far_filter;
</ins><span class="cx">     /*! The number of coefficients for the far end analogue section simulation filter */
</span><span class="cx">     int far_filter_len;
</span><span class="cx">     /*! Last transmitted samples (ring buffer, used by the line filter) */
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcMakefileam"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/Makefile.am (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/Makefile.am        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/Makefile.am        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -16,13 +16,37 @@
</span><span class="cx"> ## License along with this program; if not, write to the Free Software
</span><span class="cx"> ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx"> ##
</span><del>-## $Id: Makefile.am,v 1.137 2009/09/22 14:52:31 steveu Exp $
</del><ins>+## $Id: Makefile.am,v 1.138.4.3 2009/12/19 10:30:10 steveu Exp $
</ins><span class="cx"> 
</span><span class="cx"> AM_CFLAGS = $(COMP_VENDOR_CFLAGS)
</span><span class="cx"> AM_LDFLAGS = $(COMP_VENDOR_LDFLAGS)
</span><span class="cx"> 
</span><span class="cx"> MAINTAINERCLEANFILES = Makefile.in
</span><span class="cx"> 
</span><ins>+DISTCLEANFILES = $(srcdir)/at_interpreter_dictionary.h \
+                 $(srcdir)/v17_v32bis_rx_fixed_rrc.h \
+                 $(srcdir)/v17_v32bis_rx_floating_rrc.h \
+                 $(srcdir)/v17_v32bis_tx_fixed_rrc.h \
+                 $(srcdir)/v17_v32bis_tx_floating_rrc.h \
+                 $(srcdir)/v22bis_rx_1200_fixed_rrc.h \
+                 $(srcdir)/v22bis_rx_2400_fixed_rrc.h \
+                 $(srcdir)/v22bis_rx_1200_floating_rrc.h \
+                 $(srcdir)/v22bis_rx_2400_floating_rrc.h \
+                 $(srcdir)/v22bis_tx_fixed_rrc.h \
+                 $(srcdir)/v22bis_tx_floating_rrc.h \
+                 $(srcdir)/v27ter_rx_2400_fixed_rrc.h \
+                 $(srcdir)/v27ter_rx_4800_fixed_rrc.h \
+                 $(srcdir)/v27ter_rx_2400_floating_rrc.h \
+                 $(srcdir)/v27ter_rx_4800_floating_rrc.h \
+                 $(srcdir)/v27ter_tx_2400_fixed_rrc.h \
+                 $(srcdir)/v27ter_tx_4800_fixed_rrc.h \
+                 $(srcdir)/v27ter_tx_2400_floating_rrc.h \
+                 $(srcdir)/v27ter_tx_4800_floating_rrc.h \
+                 $(srcdir)/v29rx_fixed_rrc.h \
+                 $(srcdir)/v29rx_floating_rrc.h \
+                 $(srcdir)/v29tx_fixed_rrc.h \
+                 $(srcdir)/v29tx_floating_rrc.h
+
</ins><span class="cx"> EXTRA_DIST = floating_fudge.h \
</span><span class="cx">              libspandsp.dsp \
</span><span class="cx">              libspandsp.2005.sln \
</span><span class="lines">@@ -31,6 +55,9 @@
</span><span class="cx">              libspandsp.2008.vcproj \
</span><span class="cx">              libtiff.2005.vcproj \
</span><span class="cx">              libtiff.2008.vcproj \
</span><ins>+             filter_tools.c \
+                 make_at_dictionary.c \
+                 make_modem_filter.c \
</ins><span class="cx">              msvc/config.h \
</span><span class="cx">              msvc/Download_TIFF.2005.vcproj \
</span><span class="cx">              msvc/Download_TIFF.2008.vcproj \
</span><span class="lines">@@ -111,7 +138,8 @@
</span><span class="cx">                         super_tone_rx.c \
</span><span class="cx">                         super_tone_tx.c \
</span><span class="cx">                         swept_tone.c \
</span><del>-                        t4.c \
</del><ins>+                        t4_rx.c \
+                        t4_tx.c \
</ins><span class="cx">                         t30.c \
</span><span class="cx">                         t30_api.c \
</span><span class="cx">                         t30_logging.c \
</span><span class="lines">@@ -190,7 +218,8 @@
</span><span class="cx">                          spandsp/super_tone_rx.h \
</span><span class="cx">                          spandsp/super_tone_tx.h \
</span><span class="cx">                          spandsp/swept_tone.h \
</span><del>-                         spandsp/t4.h \
</del><ins>+                         spandsp/t4_rx.h \
+                         spandsp/t4_tx.h \
</ins><span class="cx">                          spandsp/t30.h \
</span><span class="cx">                          spandsp/t30_api.h \
</span><span class="cx">                          spandsp/t30_fcf.h \
</span><span class="lines">@@ -252,12 +281,14 @@
</span><span class="cx">                          spandsp/private/super_tone_tx.h \
</span><span class="cx">                          spandsp/private/swept_tone.h \
</span><span class="cx">                          spandsp/private/t30.h \
</span><ins>+                         spandsp/private/t30_dis_dtc_dcs_bits.h \
</ins><span class="cx">                          spandsp/private/t31.h \
</span><span class="cx">                          spandsp/private/t38_core.h \
</span><span class="cx">                          spandsp/private/t38_gateway.h \
</span><span class="cx">                          spandsp/private/t38_non_ecm_buffer.h \
</span><span class="cx">                          spandsp/private/t38_terminal.h \
</span><del>-                         spandsp/private/t4.h \
</del><ins>+                         spandsp/private/t4_rx.h \
+                         spandsp/private/t4_tx.h \
</ins><span class="cx">                          spandsp/private/time_scale.h \
</span><span class="cx">                          spandsp/private/tone_detect.h \
</span><span class="cx">                          spandsp/private/tone_generate.h \
</span><span class="lines">@@ -282,7 +313,7 @@
</span><span class="cx">                         lpc10_encdecs.h \
</span><span class="cx">                         mmx_sse_decs.h \
</span><span class="cx">                         t30_local.h \
</span><del>-                        t4_states.h \
</del><ins>+                        t4_t6_decode_states.h \
</ins><span class="cx">                         v17_v32bis_rx_constellation_maps.h \
</span><span class="cx">                         v17_v32bis_tx_constellation_maps.h \
</span><span class="cx">                         v29tx_constellation_maps.h
</span><span class="lines">@@ -290,7 +321,7 @@
</span><span class="cx"> make_at_dictionary$(EXEEXT): $(top_srcdir)/src/make_at_dictionary.c
</span><span class="cx">         $(CC_FOR_BUILD) -o make_at_dictionary$(EXEEXT) $(top_srcdir)/src/make_at_dictionary.c  -DHAVE_CONFIG_H -I$(top_builddir)/src
</span><span class="cx"> 
</span><del>-make_modem_filter$(EXEEXT): $(top_srcdir)/src/make_modem_filter.c $(top_srcdir)/src/filter_tools.c 
</del><ins>+make_modem_filter$(EXEEXT): $(top_srcdir)/src/make_modem_filter.c $(top_srcdir)/src/filter_tools.c
</ins><span class="cx">         $(CC_FOR_BUILD) -o make_modem_filter$(EXEEXT) $(top_srcdir)/src/make_modem_filter.c $(top_srcdir)/src/filter_tools.c -DHAVE_CONFIG_H -I$(top_builddir)/src -lm
</span><span class="cx"> 
</span><span class="cx"> # We need to run make_at_dictionary, so it generates the
</span><span class="lines">@@ -489,13 +520,10 @@
</span><span class="cx">              -e &quot;s/\@INSERT_MATH_HEADER\@/#include &lt;math.h&gt;/&quot; $(srcdir)/spandsp.h.in &gt; $(srcdir)/msvc/spandsp.h
</span><span class="cx"> 
</span><span class="cx"> spandsp/version.h:
</span><ins>+        mkdir -p $(@D)
</ins><span class="cx">         NOWDATE=`date --utc +&quot;%Y%m%d&quot;` ; \
</span><span class="cx">         NOWTIME=`date --utc +&quot;%H%M%S&quot;` ; \
</span><span class="cx">         sed 's/$$SPANDSP_RELEASE_DATE/'$$NOWDATE'/;s/$$SPANDSP_RELEASE_TIME/'$$NOWTIME'/' \
</span><del>-                &lt;spandsp/version.h.in &gt;spandsp/version.h
</del><ins>+                &lt;$(srcdir)/spandsp/version.h.in &gt;$@
</ins><span class="cx"> 
</span><del>-dist-hook:
-        NOWDATE=`date --utc +&quot;%Y%m%d&quot;` ; \
-        NOWTIME=`date --utc +&quot;%H%M%S&quot;` ; \
-        sed 's/$$SPANDSP_RELEASE_DATE/'$$NOWDATE'/;s/$$SPANDSP_RELEASE_TIME/'$$NOWTIME'/' \
-                &lt;spandsp/version.h.in &gt;spandsp/version.h
</del><ins>+dist-hook: spandsp/version.h
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcadsic"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/adsi.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/adsi.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/adsi.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: adsi.c,v 1.76 2009/04/12 09:12:10 steveu Exp $
</del><ins>+ * $Id: adsi.c,v 1.77 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -431,12 +431,12 @@
</span><span class="cx">     switch (standard)
</span><span class="cx">     {
</span><span class="cx">     case ADSI_STANDARD_CLASS:
</span><del>-        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_BELL202], FALSE, adsi_rx_put_bit, s);
</del><ins>+        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_BELL202], FSK_FRAME_MODE_ASYNC, adsi_rx_put_bit, s);
</ins><span class="cx">         break;
</span><span class="cx">     case ADSI_STANDARD_CLIP:
</span><span class="cx">     case ADSI_STANDARD_ACLIP:
</span><span class="cx">     case ADSI_STANDARD_JCLIP:
</span><del>-        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_V23CH1], FALSE, adsi_rx_put_bit, s);
</del><ins>+        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_V23CH1], FSK_FRAME_MODE_ASYNC, adsi_rx_put_bit, s);
</ins><span class="cx">         break;
</span><span class="cx">     case ADSI_STANDARD_CLIP_DTMF:
</span><span class="cx">         dtmf_rx_init(&amp;(s-&gt;dtmfrx), adsi_rx_dtmf, s);
</span><span class="lines">@@ -444,7 +444,7 @@
</span><span class="cx">     case ADSI_STANDARD_TDD:
</span><span class="cx">         /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and
</span><span class="cx">            ride over the fraction. */
</span><del>-        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_WEITBRECHT], 7, adsi_tdd_put_async_byte, s);
</del><ins>+        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_WEITBRECHT], FSK_FRAME_MODE_5N1_FRAMES, adsi_tdd_put_async_byte, s);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     s-&gt;standard = standard;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcat_interpreterc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/at_interpreter.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/at_interpreter.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/at_interpreter.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: at_interpreter.c,v 1.41 2009/10/03 04:37:25 steveu Exp $
</del><ins>+ * $Id: at_interpreter.c,v 1.42 2009/10/09 14:53:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -3358,9 +3358,30 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+static const char *at_cmd_plus_F34(at_state_t *s, const char *t)
+{
+    static const int maxes[5] =
+    {
+        14, 14, 2, 14, 14
+    };
+    int *locations[5];
+    int i;
+
+    /* T.31 B.6.1 - Initial V.34 rate controls for FAX */
+    /* Syntax: +F34=[&lt;maxp&gt;][,[&lt;minp&gt;][,&lt;prefc&gt;][,&lt;maxp2&gt;][,&lt;minp2]] */
+    /* TODO */
+    t += 4;
+    for (i = 0;  i &lt; 5;  i++)
+        locations[i] = NULL;
+    if (!parse_n_out(s, &amp;t, locations, maxes, 5, &quot;+F34:&quot;, &quot;(0-14),(0-14),(0-2),(0-14),(0-14)&quot;))
+        return NULL;
+    return t;
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> static const char *at_cmd_plus_FAA(at_state_t *s, const char *t)
</span><span class="cx"> {
</span><del>-    /* T.32 8.5.2.5 - Adaptive Answer parameter */
</del><ins>+    /* T.32 8.5.2.5 - Adaptive answer parameter */
</ins><span class="cx">     /* TODO */
</span><span class="cx">     t += 4;
</span><span class="cx">     return t;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcfaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/fax.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/fax.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/fax.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fax.c,v 1.94 2009/09/04 14:38:46 steveu Exp $
</del><ins>+ * $Id: fax.c,v 1.96.4.1 2009/12/19 10:44:10 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -71,7 +71,8 @@
</span><span class="cx"> #include &quot;spandsp/v17rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/super_tone_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/modem_connect_tones.h&quot;
</span><del>-#include &quot;spandsp/t4.h&quot;
</del><ins>+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp/t30_fcf.h&quot;
</span><span class="cx"> #include &quot;spandsp/t35.h&quot;
</span><span class="lines">@@ -94,7 +95,8 @@
</span><span class="cx"> #include &quot;spandsp/private/modem_connect_tones.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/hdlc.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/fax_modems.h&quot;
</span><del>-#include &quot;spandsp/private/t4.h&quot;
</del><ins>+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/private/t30.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/fax.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -110,12 +112,12 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void tone_detected(void *user_data, int on, int level, int delay)
</del><ins>+static void tone_detected(void *user_data, int tone, int level, int delay)
</ins><span class="cx"> {
</span><span class="cx">     t30_state_t *s;
</span><span class="cx"> 
</span><span class="cx">     s = (t30_state_t *) user_data;
</span><del>-    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;FAX tone declared %s (%ddBm0)\n&quot;, (on)  ?  &quot;on&quot;  :  &quot;off&quot;, level);
</del><ins>+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s detected (%ddBm0)\n&quot;, modem_connect_tone_to_str(tone), level);
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -423,7 +425,7 @@
</span><span class="cx">     switch (type)
</span><span class="cx">     {
</span><span class="cx">     case T30_MODEM_V21:
</span><del>-        fsk_rx_init(&amp;t-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], TRUE, (put_bit_func_t) hdlc_rx_put_bit, put_bit_user_data);
</del><ins>+        fsk_rx_init(&amp;t-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, put_bit_user_data);
</ins><span class="cx">         fsk_rx_signal_cutoff(&amp;t-&gt;v21_rx, -45.5f);
</span><span class="cx">         set_rx_handler(s, (span_rx_handler_t *) &amp;fsk_rx, (span_rx_fillin_handler_t *) &amp;fsk_rx_fillin, &amp;t-&gt;v21_rx);
</span><span class="cx">         break;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcfax_modemsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/fax_modems.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/fax_modems.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/fax_modems.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fax_modems.c,v 1.7 2009/10/05 16:33:25 steveu Exp $
</del><ins>+ * $Id: fax_modems.c,v 1.8 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -45,6 +45,9 @@
</span><span class="cx"> #include &lt;assert.h&gt;
</span><span class="cx"> #include &lt;fcntl.h&gt;
</span><span class="cx"> #include &lt;time.h&gt;
</span><ins>+#if defined(LOG_FAX_AUDIO)
+#include &lt;unistd.h&gt;
+#endif
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp/telephony.h&quot;
</span><span class="cx"> #include &quot;spandsp/logging.h&quot;
</span><span class="lines">@@ -280,7 +283,7 @@
</span><span class="cx"> 
</span><span class="cx">     hdlc_rx_init(&amp;s-&gt;hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept, user_data);
</span><span class="cx">     hdlc_tx_init(&amp;s-&gt;hdlc_tx, FALSE, 2, FALSE, hdlc_tx_underflow, user_data);
</span><del>-    fsk_rx_init(&amp;s-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], TRUE, (put_bit_func_t) hdlc_rx_put_bit, &amp;s-&gt;hdlc_rx);
</del><ins>+    fsk_rx_init(&amp;s-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, &amp;s-&gt;hdlc_rx);
</ins><span class="cx">     fsk_rx_signal_cutoff(&amp;s-&gt;v21_rx, -39.09f);
</span><span class="cx">     fsk_tx_init(&amp;s-&gt;v21_tx, &amp;preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &amp;s-&gt;hdlc_tx);
</span><span class="cx">     v17_rx_init(&amp;s-&gt;v17_rx, 14400, non_ecm_put_bit, user_data);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcfskc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/fsk.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/fsk.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/fsk.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fsk.c,v 1.59 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: fsk.c,v 1.60 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -128,6 +128,22 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+SPAN_DECLARE(int) fsk_tx_restart(fsk_tx_state_t *s, const fsk_spec_t *spec)
+{
+    s-&gt;baud_rate = spec-&gt;baud_rate;
+    s-&gt;phase_rates[0] = dds_phase_rate((float) spec-&gt;freq_zero);
+    s-&gt;phase_rates[1] = dds_phase_rate((float) spec-&gt;freq_one);
+    s-&gt;scaling = dds_scaling_dbm0((float) spec-&gt;tx_level);
+    /* Initialise fractional sample baud generation. */
+    s-&gt;phase_acc = 0;
+    s-&gt;baud_frac = 0;
+    s-&gt;current_phase_rate = s-&gt;phase_rates[1];
+    
+    s-&gt;shutdown = FALSE;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> SPAN_DECLARE(fsk_tx_state_t *) fsk_tx_init(fsk_tx_state_t *s,
</span><span class="cx">                                            const fsk_spec_t *spec,
</span><span class="cx">                                            get_bit_func_t get_bit,
</span><span class="lines">@@ -138,20 +154,11 @@
</span><span class="cx">         if ((s = (fsk_tx_state_t *) malloc(sizeof(*s))) == NULL)
</span><span class="cx">             return NULL;
</span><span class="cx">     }
</span><ins>+    memset(s, 0, sizeof(*s));
</ins><span class="cx"> 
</span><del>-    s-&gt;baud_rate = spec-&gt;baud_rate;
</del><span class="cx">     s-&gt;get_bit = get_bit;
</span><span class="cx">     s-&gt;get_bit_user_data = user_data;
</span><del>-
-    s-&gt;phase_rates[0] = dds_phase_rate((float) spec-&gt;freq_zero);
-    s-&gt;phase_rates[1] = dds_phase_rate((float) spec-&gt;freq_one);
-    s-&gt;scaling = dds_scaling_dbm0((float) spec-&gt;tx_level);
-    /* Initialise fractional sample baud generation. */
-    s-&gt;phase_acc = 0;
-    s-&gt;baud_frac = 0;
-    s-&gt;current_phase_rate = s-&gt;phase_rates[1];
-    
-    s-&gt;shutdown = FALSE;
</del><ins>+    fsk_tx_restart(s, spec);
</ins><span class="cx">     return s;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -250,26 +257,13 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-SPAN_DECLARE(fsk_rx_state_t *) fsk_rx_init(fsk_rx_state_t *s,
-                                           const fsk_spec_t *spec,
-                                           int framing_mode,
-                                           put_bit_func_t put_bit,
-                                           void *user_data)
</del><ins>+SPAN_DECLARE(int) fsk_rx_restart(fsk_rx_state_t *s, const fsk_spec_t *spec, int framing_mode)
</ins><span class="cx"> {
</span><span class="cx">     int chop;
</span><span class="cx"> 
</span><del>-    if (s == NULL)
-    {
-        if ((s = (fsk_rx_state_t *) malloc(sizeof(*s))) == NULL)
-            return NULL;
-    }
-
-    memset(s, 0, sizeof(*s));
</del><span class="cx">     s-&gt;baud_rate = spec-&gt;baud_rate;
</span><span class="cx">     s-&gt;framing_mode = framing_mode;
</span><span class="cx">     fsk_rx_signal_cutoff(s, (float) spec-&gt;min_level);
</span><del>-    s-&gt;put_bit = put_bit;
-    s-&gt;put_bit_user_data = user_data;
</del><span class="cx"> 
</span><span class="cx">     /* Detect by correlating against the tones we want, over a period
</span><span class="cx">        of one baud. The correlation must be quadrature. */
</span><span class="lines">@@ -307,6 +301,26 @@
</span><span class="cx">     /* Initialise a power detector, so sense when a signal is present. */
</span><span class="cx">     power_meter_init(&amp;(s-&gt;power), 4);
</span><span class="cx">     s-&gt;signal_present = 0;
</span><ins>+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(fsk_rx_state_t *) fsk_rx_init(fsk_rx_state_t *s,
+                                           const fsk_spec_t *spec,
+                                           int framing_mode,
+                                           put_bit_func_t put_bit,
+                                           void *user_data)
+{
+    if (s == NULL)
+    {
+        if ((s = (fsk_rx_state_t *) malloc(sizeof(*s))) == NULL)
+            return NULL;
+    }
+    memset(s, 0, sizeof(*s));
+
+    s-&gt;put_bit = put_bit;
+    s-&gt;put_bit_user_data = user_data;
+    fsk_rx_restart(s, spec, framing_mode);
</ins><span class="cx">     return s;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -421,7 +435,7 @@
</span><span class="cx">         baudstate = (sum[0] &lt; sum[1]);
</span><span class="cx">         switch (s-&gt;framing_mode)
</span><span class="cx">         {
</span><del>-        case 1:
</del><ins>+        case FSK_FRAME_MODE_SYNC:
</ins><span class="cx">             /* Synchronous serial operation - e.g. for HDLC */
</span><span class="cx">             if (s-&gt;last_bit != baudstate)
</span><span class="cx">             {
</span><span class="lines">@@ -442,7 +456,7 @@
</span><span class="cx">                 s-&gt;put_bit(s-&gt;put_bit_user_data, baudstate);
</span><span class="cx">             }
</span><span class="cx">             break;
</span><del>-        case 0:
</del><ins>+        case FSK_FRAME_MODE_ASYNC:
</ins><span class="cx">             /* Fully asynchronous mode */
</span><span class="cx">             if (s-&gt;last_bit != baudstate)
</span><span class="cx">             {
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcgsm0610_rpec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/gsm0610_rpe.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">  * This code is based on the widely used GSM 06.10 code available from
</span><span class="cx">  * http://kbs.cs.tu-berlin.de/~jutta/toast.html
</span><span class="cx">  *
</span><del>- * $Id: gsm0610_rpe.c,v 1.25 2009/02/03 16:28:39 steveu Exp $
</del><ins>+ * $Id: gsm0610_rpe.c,v 1.25.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -87,13 +87,13 @@
</span><span class="cx">         &quot; emms;\n&quot;
</span><span class="cx">         &quot; addl $-10,%%ecx;\n&quot;
</span><span class="cx">         &quot; movl $0x1000,%%eax;\n&quot;
</span><del>-        &quot; movd %%eax,%%mm5;\n&quot;              /* for rounding */
</del><ins>+        &quot; movd %%eax,%%mm5;\n&quot;              /* For rounding */
</ins><span class="cx">         &quot; movq %[gsm_H],%%mm1;\n&quot;
</span><span class="cx">         &quot; movq %[gsm_H8],%%mm2;\n&quot;
</span><span class="cx">         &quot; movq %[gsm_H16],%%mm3;\n&quot;
</span><span class="cx">         &quot; xorl %%esi,%%esi;\n&quot;
</span><span class="cx">         &quot; .p2align 2;\n&quot;
</span><del>-        &quot;1:;\n&quot;
</del><ins>+        &quot;1:\n&quot;
</ins><span class="cx">         &quot; movq (%%ecx,%%esi,2),%%mm0;\n&quot;
</span><span class="cx">         &quot; pmaddwd %%mm1,%%mm0;\n&quot;
</span><span class="cx">  
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrclibspandsp2005vcproj"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/libspandsp.2005.vcproj (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/libspandsp.2005.vcproj        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.2005.vcproj        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -143,7 +143,8 @@
</span><span class="cx"> &lt;File RelativePath=&quot;super_tone_rx.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;super_tone_tx.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;swept_tone.c&quot;&gt;&lt;/File&gt;
</span><del>-&lt;File RelativePath=&quot;t4.c&quot;&gt;&lt;/File&gt;
</del><ins>+&lt;File RelativePath=&quot;t4_rx.c&quot;&gt;&lt;/File&gt;
+&lt;File RelativePath=&quot;t4_tx.c&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;t30.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;t30_api.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;t30_logging.c&quot;&gt;&lt;/File&gt;
</span><span class="lines">@@ -221,7 +222,8 @@
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/super_tone_rx.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/super_tone_tx.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/swept_tone.h&quot;&gt;&lt;/File&gt;
</span><del>-&lt;File RelativePath=&quot;spandsp/t4.h&quot;&gt;&lt;/File&gt;
</del><ins>+&lt;File RelativePath=&quot;spandsp/t4_rx.h&quot;&gt;&lt;/File&gt;
+&lt;File RelativePath=&quot;spandsp/t4_tx.h&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;spandsp/t30.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/t30_api.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/t30_fcf.h&quot;&gt;&lt;/File&gt;
</span><span class="lines">@@ -283,12 +285,14 @@
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/super_tone_tx.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/swept_tone.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t30.h&quot;&gt;&lt;/File&gt;
</span><ins>+&lt;File RelativePath=&quot;spandsp/private/t30_dis_dtc_dcs_bits.h&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t31.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_core.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_gateway.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_non_ecm_buffer.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_terminal.h&quot;&gt;&lt;/File&gt;
</span><del>-&lt;File RelativePath=&quot;spandsp/private/t4.h&quot;&gt;&lt;/File&gt;
</del><ins>+&lt;File RelativePath=&quot;spandsp/private/t4_rx.h&quot;&gt;&lt;/File&gt;
+&lt;File RelativePath=&quot;spandsp/private/t4_tx.h&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/time_scale.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/tone_detect.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/tone_generate.h&quot;&gt;&lt;/File&gt;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrclibspandsp2008vcproj"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/libspandsp.2008.vcproj (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/libspandsp.2008.vcproj        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.2008.vcproj        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -213,7 +213,8 @@
</span><span class="cx"> &lt;File RelativePath=&quot;super_tone_rx.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;super_tone_tx.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;swept_tone.c&quot;&gt;&lt;/File&gt;
</span><del>-&lt;File RelativePath=&quot;t4.c&quot;&gt;&lt;/File&gt;
</del><ins>+&lt;File RelativePath=&quot;t4_rx.c&quot;&gt;&lt;/File&gt;
+&lt;File RelativePath=&quot;t4_tx.c&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;t30.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;t30_api.c&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;t30_logging.c&quot;&gt;&lt;/File&gt;
</span><span class="lines">@@ -291,7 +292,8 @@
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/super_tone_rx.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/super_tone_tx.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/swept_tone.h&quot;&gt;&lt;/File&gt;
</span><del>-&lt;File RelativePath=&quot;spandsp/t4.h&quot;&gt;&lt;/File&gt;
</del><ins>+&lt;File RelativePath=&quot;spandsp/t4_rx.h&quot;&gt;&lt;/File&gt;
+&lt;File RelativePath=&quot;spandsp/t4_tx.h&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;spandsp/t30.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/t30_api.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/t30_fcf.h&quot;&gt;&lt;/File&gt;
</span><span class="lines">@@ -353,12 +355,14 @@
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/super_tone_tx.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/swept_tone.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t30.h&quot;&gt;&lt;/File&gt;
</span><ins>+&lt;File RelativePath=&quot;spandsp/private/t30_dis_dtc_dcs_bits.h&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t31.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_core.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_gateway.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_non_ecm_buffer.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/t38_terminal.h&quot;&gt;&lt;/File&gt;
</span><del>-&lt;File RelativePath=&quot;spandsp/private/t4.h&quot;&gt;&lt;/File&gt;
</del><ins>+&lt;File RelativePath=&quot;spandsp/private/t4_rx.h&quot;&gt;&lt;/File&gt;
+&lt;File RelativePath=&quot;spandsp/private/t4_tx.h&quot;&gt;&lt;/File&gt;
</ins><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/time_scale.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/tone_detect.h&quot;&gt;&lt;/File&gt;
</span><span class="cx"> &lt;File RelativePath=&quot;spandsp/private/tone_generate.h&quot;&gt;&lt;/File&gt;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrclibspandspdsp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/libspandsp.dsp (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/libspandsp.dsp        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/libspandsp.dsp        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -297,10 +297,14 @@
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="cx"> 
</span><del>-SOURCE=.\t4.c
</del><ins>+SOURCE=.\t4_rx.c
</ins><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="cx"> 
</span><ins>+SOURCE=.\t4_tx.c
+# End Source File
+# Begin Source File
+
</ins><span class="cx"> SOURCE=.\t30.c
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="lines">@@ -607,10 +611,14 @@
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="cx"> 
</span><del>-SOURCE=.\spandsp/t4.h
</del><ins>+SOURCE=.\spandsp/t4_rx.h
</ins><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="cx"> 
</span><ins>+SOURCE=.\spandsp/t4_tx.h
+# End Source File
+# Begin Source File
+
</ins><span class="cx"> SOURCE=.\spandsp/t30.h
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="lines">@@ -855,6 +863,10 @@
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="cx"> 
</span><ins>+SOURCE=.\spandsp/private/t30_dis_dtc_dcs_bits.h
+# End Source File
+# Begin Source File
+
</ins><span class="cx"> SOURCE=.\spandsp/private/t31.h
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="lines">@@ -875,10 +887,14 @@
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="cx"> 
</span><del>-SOURCE=.\spandsp/private/t4.h
</del><ins>+SOURCE=.\spandsp/private/t4_rx.h
</ins><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span><span class="cx"> 
</span><ins>+SOURCE=.\spandsp/private/t4_tx.h
+# End Source File
+# Begin Source File
+
</ins><span class="cx"> SOURCE=.\spandsp/private/time_scale.h
</span><span class="cx"> # End Source File
</span><span class="cx"> # Begin Source File
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcmake_at_dictionaryc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/make_at_dictionary.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/make_at_dictionary.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/make_at_dictionary.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: make_at_dictionary.c,v 1.5 2009/10/05 16:36:42 steveu Exp $
</del><ins>+ * $Id: make_at_dictionary.c,v 1.6 2009/10/09 14:53:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if defined(HAVE_CONFIG_H)
</span><span class="lines">@@ -231,6 +231,7 @@
</span><span class="cx">     &quot;+ESR&quot;,     /* V.250 6.5.3 - Selective repeat */ 
</span><span class="cx">     &quot;+ETBM&quot;,    /* V.250 6.5.6 - Call termination buffer management */ 
</span><span class="cx">     &quot;+EWIND&quot;,   /* V.250 6.5.7 - Window size */ 
</span><ins>+    &quot;+F34&quot;,     /* T.31 B.6.1 - Initial V.34 rate controls for FAX */
</ins><span class="cx">     &quot;+FAA&quot;,     /* T.32 8.5.2.5 - Adaptive Answer parameter */
</span><span class="cx">     &quot;+FAP&quot;,     /* T.32 8.5.1.12 - Addressing and polling capabilities parameter */
</span><span class="cx">     &quot;+FAR&quot;,     /* T.31 8.5.1 - Adaptive reception control */ 
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcmodem_connect_tonesc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/modem_connect_tones.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/modem_connect_tones.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/modem_connect_tones.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,11 +23,23 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: modem_connect_tones.c,v 1.37 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: modem_connect_tones.c,v 1.41 2009/11/06 19:21:33 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> /*! \file */
</span><span class="cx"> 
</span><ins>+/* CNG is 0.5s+-15% of 1100+-38Hz, 3s+-15% off, repeating.
+
+   CED is 0.2s silence, 3.3+-0.7s of 2100+-15Hz, and 75+-20ms of silence.
+   
+   ANS is 3.3+-0.7s of 2100+-15Hz.
+   
+   ANS/ is 3.3+-0.7s of 2100+-15Hz, with phase reversals (180+-10 degrees, hopping in &lt;1ms) every 450+-25ms.
+
+   ANSam/ is 2100+-1Hz, with phase reversals (180+-10 degrees, hopping in &lt;1ms) every 450+-25ms, and AM with a sinewave of 15+-0.1Hz. 
+   The modulated envelope ranges in amplitude between (0.8+-0.01) and (1.2+-0.01) times its average
+   amplitude. It lasts up to 5s, but will be stopped early if the V.8 protocol proceeds. */
+
</ins><span class="cx"> #if defined(HAVE_CONFIG_H)
</span><span class="cx"> #include &quot;config.h&quot;
</span><span class="cx"> #endif
</span><span class="lines">@@ -158,9 +170,9 @@
</span><span class="cx">     case MODEM_CONNECT_TONES_ANSAM:
</span><span class="cx">         if (s-&gt;duration_timer &lt; len)
</span><span class="cx">             len = s-&gt;duration_timer;
</span><del>-        if (s-&gt;duration_timer &gt; ms_to_samples(3300))
</del><ins>+        if (s-&gt;duration_timer &gt; ms_to_samples(5000))
</ins><span class="cx">         {
</span><del>-            if ((i = s-&gt;duration_timer - ms_to_samples(3300)) &gt; len)
</del><ins>+            if ((i = s-&gt;duration_timer - ms_to_samples(5000)) &gt; len)
</ins><span class="cx">                 i = len;
</span><span class="cx">             memset(amp, 0, sizeof(int16_t)*i);
</span><span class="cx">         }
</span><span class="lines">@@ -174,9 +186,9 @@
</span><span class="cx">     case MODEM_CONNECT_TONES_ANSAM_PR:
</span><span class="cx">         if (s-&gt;duration_timer &lt; len)
</span><span class="cx">             len = s-&gt;duration_timer;
</span><del>-        if (s-&gt;duration_timer &gt; ms_to_samples(3300))
</del><ins>+        if (s-&gt;duration_timer &gt; ms_to_samples(5000))
</ins><span class="cx">         {
</span><del>-            if ((i = s-&gt;duration_timer - ms_to_samples(3300)) &gt; len)
</del><ins>+            if ((i = s-&gt;duration_timer - ms_to_samples(5000)) &gt; len)
</ins><span class="cx">                 i = len;
</span><span class="cx">             memset(amp, 0, sizeof(int16_t)*i);
</span><span class="cx">         }
</span><span class="lines">@@ -221,28 +233,48 @@
</span><span class="cx">         s-&gt;tone_phase = 0;
</span><span class="cx">         s-&gt;mod_phase = 0;
</span><span class="cx">         s-&gt;mod_level = 0;
</span><ins>+        s-&gt;hop_timer = 0;
</ins><span class="cx">         break;
</span><span class="cx">     case MODEM_CONNECT_TONES_ANS:
</span><span class="cx">     case MODEM_CONNECT_TONES_ANSAM:
</span><span class="cx">         /* 0.2s of silence, then 2.6s to 4s of 2100Hz+-15Hz tone, then 75ms of silence. */
</span><span class="cx">         s-&gt;tone_phase_rate = dds_phase_rate(2100.0);
</span><span class="cx">         s-&gt;level = dds_scaling_dbm0(-11);
</span><del>-        s-&gt;duration_timer = ms_to_samples(200 + 2600);
-        s-&gt;mod_phase_rate = dds_phase_rate(15.0);
</del><ins>+        if (s-&gt;tone_type == MODEM_CONNECT_TONES_ANSAM)
+        {
+            s-&gt;mod_phase_rate = dds_phase_rate(15.0);
+            s-&gt;mod_level = s-&gt;level/5;
+            s-&gt;duration_timer = ms_to_samples(200 + 5000);
+        }
+        else
+        {
+            s-&gt;mod_phase_rate = 0;
+            s-&gt;mod_level = 0;
+            s-&gt;duration_timer = ms_to_samples(200 + 2600);
+        }
</ins><span class="cx">         s-&gt;tone_phase = 0;
</span><span class="cx">         s-&gt;mod_phase = 0;
</span><del>-        s-&gt;mod_level = (s-&gt;tone_type == MODEM_CONNECT_TONES_ANSAM)  ?  s-&gt;level/5  :  0;
</del><ins>+        s-&gt;hop_timer = 0;
</ins><span class="cx">         break;
</span><span class="cx">     case MODEM_CONNECT_TONES_ANS_PR:
</span><span class="cx">     case MODEM_CONNECT_TONES_ANSAM_PR:
</span><span class="cx">         s-&gt;tone_phase_rate = dds_phase_rate(2100.0);
</span><span class="cx">         s-&gt;level = dds_scaling_dbm0(-12);
</span><del>-        s-&gt;duration_timer = ms_to_samples(200 + 3300);
-        s-&gt;mod_phase_rate = dds_phase_rate(15.0);
</del><ins>+        if (s-&gt;tone_type == MODEM_CONNECT_TONES_ANSAM_PR)
+        {
+            s-&gt;mod_phase_rate = dds_phase_rate(15.0);
+            s-&gt;mod_level = s-&gt;level/5;
+            s-&gt;duration_timer = ms_to_samples(200 + 5000);
+        }
+        else
+        {
+            s-&gt;mod_phase_rate = 0;
+            s-&gt;mod_level = 0;
+            s-&gt;duration_timer = ms_to_samples(200 + 3300);
+        }
</ins><span class="cx">         s-&gt;tone_phase = 0;
</span><span class="cx">         s-&gt;mod_phase = 0;
</span><span class="cx">         s-&gt;hop_timer = ms_to_samples(450);
</span><del>-        s-&gt;mod_level = (s-&gt;tone_type == MODEM_CONNECT_TONES_ANSAM_PR)  ?  s-&gt;level/5  :  0;
</del><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="cx">         if (alloced)
</span><span class="lines">@@ -362,19 +394,20 @@
</span><span class="cx">     int16_t notched;
</span><span class="cx">     float v1;
</span><span class="cx">     float famp;
</span><del>-    
</del><ins>+    float filtered;
+
</ins><span class="cx">     switch (s-&gt;tone_type)
</span><span class="cx">     {
</span><span class="cx">     case MODEM_CONNECT_TONES_FAX_CNG:
</span><span class="cx">         for (i = 0;  i &lt; len;  i++)
</span><span class="cx">         {
</span><ins>+            famp = amp[i];
</ins><span class="cx">             /* A Cauer notch at 1100Hz, spread just wide enough to meet our detection bandwidth
</span><span class="cx">                criteria. */
</span><del>-            famp = amp[i];
-            v1 = 0.792928f*famp + 1.0018744927985f*s-&gt;z1 - 0.54196833412465f*s-&gt;z2;
-            famp = v1 - 1.2994747954630f*s-&gt;z1 + s-&gt;z2;
-            s-&gt;z2 = s-&gt;z1;
-            s-&gt;z1 = v1;
</del><ins>+            v1 = 0.792928f*famp + 1.0018744927985f*s-&gt;znotch_1 - 0.54196833412465f*s-&gt;znotch_2;
+            famp = v1 - 1.2994747954630f*s-&gt;znotch_1 + s-&gt;znotch_2;
+            s-&gt;znotch_2 = s-&gt;znotch_1;
+            s-&gt;znotch_1 = v1;
</ins><span class="cx">             notched = (int16_t) lfastrintf(famp);
</span><span class="cx"> 
</span><span class="cx">             /* Estimate the overall energy in the channel, and the energy in
</span><span class="lines">@@ -413,22 +446,29 @@
</span><span class="cx">     case MODEM_CONNECT_TONES_ANS:
</span><span class="cx">         for (i = 0;  i &lt; len;  i++)
</span><span class="cx">         {
</span><ins>+            famp = amp[i];
+            /* A Cauer bandpass at 15Hz, with which we demodulate the AM signal. */
+            v1 = fabs(famp) + 1.996667f*s-&gt;z15hz_1 - 0.9968004f*s-&gt;z15hz_2;
+            filtered = 0.001599787f*(v1 - s-&gt;z15hz_2);
+            s-&gt;z15hz_2 = s-&gt;z15hz_1;
+            s-&gt;z15hz_1 = v1;
+            s-&gt;am_level += abs(lfastrintf(filtered)) - (s-&gt;am_level &gt;&gt; 8);
+            //printf(&quot;%9.1f %10.4f %9d %9d\n&quot;, famp, filtered, s-&gt;am_level, s-&gt;channel_level);
</ins><span class="cx">             /* A Cauer notch at 2100Hz, spread just wide enough to meet our detection bandwidth
</span><span class="cx">                criteria. */
</span><span class="cx">             /* This is actually centred at 2095Hz, but gets the balance we want, due
</span><span class="cx">                to the asymmetric walls of the notch */
</span><del>-            famp = amp[i];
-            v1 = 0.76000f*famp - 0.1183852f*s-&gt;z1 - 0.5104039f*s-&gt;z2;
-            famp = v1 + 0.1567596f*s-&gt;z1 + s-&gt;z2;
-            s-&gt;z2 = s-&gt;z1;
-            s-&gt;z1 = v1;
</del><ins>+            v1 = 0.76000f*famp - 0.1183852f*s-&gt;znotch_1 - 0.5104039f*s-&gt;znotch_2;
+            famp = v1 + 0.1567596f*s-&gt;znotch_1 + s-&gt;znotch_2;
+            s-&gt;znotch_2 = s-&gt;znotch_1;
+            s-&gt;znotch_1 = v1;
</ins><span class="cx">             notched = (int16_t) lfastrintf(famp);
</span><span class="cx">             /* Estimate the overall energy in the channel, and the energy in
</span><span class="cx">                the notch (i.e. overall channel energy - tone energy =&gt; noise).
</span><span class="cx">                Use abs instead of multiply for speed (is it really faster?).
</span><span class="cx">                Damp the overall energy a little more for a stable result.
</span><span class="cx">                Damp the notch energy a little less, so we don't damp out the
</span><del>-               blip every time the phase reverses */
</del><ins>+               blip every time the phase reverses. */
</ins><span class="cx">             s-&gt;channel_level += ((abs(amp[i]) - s-&gt;channel_level) &gt;&gt; 5);
</span><span class="cx">             s-&gt;notch_level += ((abs(notched) - s-&gt;notch_level) &gt;&gt; 4);
</span><span class="cx">             /* This should cut off at about -43dBm0 */
</span><span class="lines">@@ -455,7 +495,11 @@
</span><span class="cx">                     if (s-&gt;tone_cycle_duration &gt;= ms_to_samples(450 - 25))
</span><span class="cx">                     {
</span><span class="cx">                         if (++s-&gt;good_cycles == 3)
</span><del>-                            report_tone_state(s, MODEM_CONNECT_TONES_ANS_PR, lfastrintf(log10f(s-&gt;channel_level/32768.0f)*20.0f + DBM0_MAX_POWER + 0.8f));
</del><ins>+                        {
+                            report_tone_state(s,
+                                              (s-&gt;am_level*15/256 &gt; s-&gt;channel_level)  ?  MODEM_CONNECT_TONES_ANSAM_PR  :  MODEM_CONNECT_TONES_ANS_PR,
+                                              lfastrintf(log10f(s-&gt;channel_level/32768.0f)*20.0f + DBM0_MAX_POWER + 0.8f));
+                        }
</ins><span class="cx">                     }
</span><span class="cx">                     else
</span><span class="cx">                     {
</span><span class="lines">@@ -466,17 +510,21 @@
</span><span class="cx">                 }
</span><span class="cx">                 else
</span><span class="cx">                 {
</span><del>-                    if (s-&gt;tone_cycle_duration &gt;= ms_to_samples(550))
</del><ins>+                    if (s-&gt;tone_cycle_duration &gt;= ms_to_samples(450 + 100))
</ins><span class="cx">                     {
</span><span class="cx">                         if (s-&gt;tone_present == MODEM_CONNECT_TONES_NONE)
</span><del>-                            report_tone_state(s, MODEM_CONNECT_TONES_ANS, lfastrintf(log10f(s-&gt;channel_level/32768.0f)*20.0f + DBM0_MAX_POWER + 0.8f));
</del><ins>+                        {
+                            report_tone_state(s,
+                                              (s-&gt;am_level*15/256 &gt; s-&gt;channel_level)  ?  MODEM_CONNECT_TONES_ANSAM  :  MODEM_CONNECT_TONES_ANS,
+                                              lfastrintf(log10f(s-&gt;channel_level/32768.0f)*20.0f + DBM0_MAX_POWER + 0.8f));
+                        }
</ins><span class="cx">                         s-&gt;good_cycles = 0;
</span><del>-                        s-&gt;tone_cycle_duration = ms_to_samples(550);
</del><ins>+                        s-&gt;tone_cycle_duration = ms_to_samples(450 + 100);
</ins><span class="cx">                     }
</span><span class="cx">                 }
</span><span class="cx">                 s-&gt;tone_on = TRUE;
</span><span class="cx">             }
</span><del>-            else
</del><ins>+            else if (s-&gt;notch_level*5 &gt; s-&gt;channel_level)
</ins><span class="cx">             {
</span><span class="cx">                 if (s-&gt;tone_present == MODEM_CONNECT_TONES_ANS)
</span><span class="cx">                 {
</span><span class="lines">@@ -528,7 +576,7 @@
</span><span class="cx">     {
</span><span class="cx">     case MODEM_CONNECT_TONES_FAX_PREAMBLE:
</span><span class="cx">     case MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE:
</span><del>-        fsk_rx_init(&amp;(s-&gt;v21rx), &amp;preset_fsk_specs[FSK_V21CH2], TRUE, v21_put_bit, s);
</del><ins>+        fsk_rx_init(&amp;(s-&gt;v21rx), &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, v21_put_bit, s);
</ins><span class="cx">         fsk_rx_signal_cutoff(&amp;(s-&gt;v21rx), -45.5f);
</span><span class="cx">         break;
</span><span class="cx">     case MODEM_CONNECT_TONES_ANS_PR:
</span><span class="lines">@@ -540,6 +588,7 @@
</span><span class="cx">     }
</span><span class="cx">     s-&gt;channel_level = 0;
</span><span class="cx">     s-&gt;notch_level = 0;
</span><ins>+    s-&gt;am_level = 0;
</ins><span class="cx">     s-&gt;tone_present = MODEM_CONNECT_TONES_NONE;
</span><span class="cx">     s-&gt;tone_cycle_duration = 0;
</span><span class="cx">     s-&gt;good_cycles = 0;
</span><span class="lines">@@ -547,8 +596,10 @@
</span><span class="cx">     s-&gt;tone_on = FALSE;
</span><span class="cx">     s-&gt;tone_callback = tone_callback;
</span><span class="cx">     s-&gt;callback_data = user_data;
</span><del>-    s-&gt;z1 = 0.0f;
-    s-&gt;z2 = 0.0f;
</del><ins>+    s-&gt;znotch_1 = 0.0f;
+    s-&gt;znotch_2 = 0.0f;
+    s-&gt;z15hz_1 = 0.0f;
+    s-&gt;z15hz_2 = 0.0f;
</ins><span class="cx">     s-&gt;num_bits = 0;
</span><span class="cx">     s-&gt;flags_seen = 0;
</span><span class="cx">     s-&gt;framing_ok_announced = FALSE;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcmsvcspandsph"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/msvc/spandsp.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/msvc/spandsp.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/msvc/spandsp.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: spandsp.h.in,v 1.19 2009/09/22 13:11:04 steveu Exp $
</del><ins>+ * $Id: spandsp.h.in,v 1.19.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -99,7 +99,8 @@
</span><span class="cx"> #include &lt;spandsp/v18.h&gt;
</span><span class="cx"> #include &lt;spandsp/v42.h&gt;
</span><span class="cx"> #include &lt;spandsp/v42bis.h&gt;
</span><del>-#include &lt;spandsp/t4.h&gt;
</del><ins>+#include &lt;spandsp/t4_rx.h&gt;
+#include &lt;spandsp/t4_tx.h&gt;
</ins><span class="cx"> #include &lt;spandsp/t30.h&gt;
</span><span class="cx"> #include &lt;spandsp/t30_api.h&gt;
</span><span class="cx"> #include &lt;spandsp/t30_fcf.h&gt;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspexposeh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/expose.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/expose.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/expose.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: expose.h,v 1.14 2009/09/22 13:11:04 steveu Exp $
</del><ins>+ * $Id: expose.h,v 1.14.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -71,7 +71,8 @@
</span><span class="cx"> #include &lt;spandsp/private/modem_connect_tones.h&gt;
</span><span class="cx"> #include &lt;spandsp/private/at_interpreter.h&gt;
</span><span class="cx"> #include &lt;spandsp/private/fax_modems.h&gt;
</span><del>-#include &lt;spandsp/private/t4.h&gt;
</del><ins>+#include &lt;spandsp/private/t4_rx.h&gt;
+#include &lt;spandsp/private/t4_tx.h&gt;
</ins><span class="cx"> #include &lt;spandsp/private/t30.h&gt;
</span><span class="cx"> #include &lt;spandsp/private/fax.h&gt;
</span><span class="cx"> #include &lt;spandsp/private/t38_core.h&gt;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspfskh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/fsk.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/fsk.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/fsk.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fsk.h,v 1.40 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: fsk.h,v 1.41 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -115,6 +115,15 @@
</span><span class="cx">     FSK_WEITBRECHT50    /* 50 baud version, used for TDD (Telecom Device for the Deaf) */
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+enum
+{
+    FSK_FRAME_MODE_ASYNC = 0,
+    FSK_FRAME_MODE_SYNC = 1,
+    FSK_FRAME_MODE_5N1_FRAMES = 7,      /* 5 bits of data + start bit + stop bit */
+    FSK_FRAME_MODE_7N1_FRAMES = 9,      /* 7 bits of data + start bit + stop bit */
+    FSK_FRAME_MODE_8N1_FRAMES = 10      /* 8 bits of data + start bit + stop bit */
+};
+
</ins><span class="cx"> SPAN_DECLARE_DATA extern const fsk_spec_t preset_fsk_specs[];
</span><span class="cx"> 
</span><span class="cx"> /*!
</span><span class="lines">@@ -149,6 +158,8 @@
</span><span class="cx">                                            get_bit_func_t get_bit,
</span><span class="cx">                                            void *user_data);
</span><span class="cx"> 
</span><ins>+SPAN_DECLARE(int) fsk_tx_restart(fsk_tx_state_t *s, const fsk_spec_t *spec);
+    
</ins><span class="cx"> SPAN_DECLARE(int) fsk_tx_release(fsk_tx_state_t *s);
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(int) fsk_tx_free(fsk_tx_state_t *s);
</span><span class="lines">@@ -203,6 +214,8 @@
</span><span class="cx">                                            put_bit_func_t put_bit,
</span><span class="cx">                                            void *user_data);
</span><span class="cx"> 
</span><ins>+SPAN_DECLARE(int) fsk_rx_restart(fsk_rx_state_t *s, const fsk_spec_t *spec, int framing_mode);
+
</ins><span class="cx"> SPAN_DECLARE(int) fsk_rx_release(fsk_rx_state_t *s);
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(int) fsk_rx_free(fsk_rx_state_t *s);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatemodem_connect_tonesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/modem_connect_tones.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/modem_connect_tones.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/modem_connect_tones.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -24,7 +24,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: modem_connect_tones.h,v 1.2 2009/01/29 18:30:14 steveu Exp $
</del><ins>+ * $Id: modem_connect_tones.h,v 1.3 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -66,12 +66,17 @@
</span><span class="cx">     void *callback_data;
</span><span class="cx"> 
</span><span class="cx">     /*! \brief The notch filter state. */
</span><del>-    float z1;
-    float z2;
</del><ins>+    float znotch_1;
+    float znotch_2;
+    /*! \brief The 15Hz AM  filter state. */
+    float z15hz_1;
+    float z15hz_2;
</ins><span class="cx">     /*! \brief The in notch power estimate */
</span><del>-    int notch_level;
</del><ins>+    int32_t notch_level;
</ins><span class="cx">     /*! \brief The total channel power estimate */
</span><del>-    int channel_level;
</del><ins>+    int32_t channel_level;
+    /*! \brief The 15Hz AM power estimate */
+    int32_t am_level;
</ins><span class="cx">     /*! \brief Sample counter for the small chunks of samples, after which a test is conducted. */
</span><span class="cx">     int chunk_remainder;
</span><span class="cx">     /*! \brief TRUE is the tone is currently confirmed present in the audio. */
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatet30h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/t30.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/t30.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/t30.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t30.h,v 1.5 2009/09/20 13:42:29 steveu Exp $
</del><ins>+ * $Id: t30.h,v 1.5.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -253,7 +253,7 @@
</span><span class="cx">     int tx_stop_page;
</span><span class="cx">     /*! \brief The current completion status. */
</span><span class="cx">     int current_status;
</span><del>-    /*! \brief Internet Aware FAX mode bit mask. */
</del><ins>+    /*! \brief Internet aware FAX mode bit mask. */
</ins><span class="cx">     int iaf;
</span><span class="cx">     /*! \brief A bit mask of the currently supported modem types. */
</span><span class="cx">     int supported_modems;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatet30_dis_dtc_dcs_bitsh"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/spandsp/private/t30_dis_dtc_dcs_bits.h (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/t30_dis_dtc_dcs_bits.h                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/t30_dis_dtc_dcs_bits.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,387 @@
</span><ins>+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * t30_dis_dtc_dcs_bits.h - ITU T.30 fax control bits definitions
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2009 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t30_dis_dtc_dcs_bits.h,v 1.1.4.1 2009/12/19 09:47:57 steveu Exp $
+ */
+
+/*! \file */
+
+#if !defined(_SPANDSP_PRIVATE_T30_DIS_DTC_DCS_BITS_H_)
+#define _SPANDSP_PRIVATE_T30_DIS_DTC_DCS_BITS_H_
+
+/* Indicates that the terminal has the Simple mode capability defined in ITU-T Rec. T.37.
+   Internet address signals CIA, TSA or CSA can be sent and received. The recipient terminal
+   may process or ignore this signal. */
+#define T30_DIS_BIT_T37                                     1
+#define T30_DCS_BIT_T37                                     1
+
+/* Indicates that the terminal has the capability to communicate using ITU-T Rec. T.38.
+   Internet address signals CIA, TSA or CSA can be sent and received. The recipient terminal
+   may process or ignore this signal. */
+#define T30_DIS_BIT_T38                                     3
+#define T30_DCS_BIT_T38                                     3
+
+/* Bit 4 set to &quot;1&quot; indicates 3rd Generation Mobile Network Access to the GSTN Connection.
+   Bit 4 set to &quot;0&quot; conveys no information about the type of connection. */
+#define T30_DIS_BIT_3G_MOBILE                               4
+#define T30_DCS_BIT_3G_MOBILE                               4
+
+/* When ISDN mode is used, in DIS/DTC bit 6 shall be set to &quot;0&quot;. */
+#define T30_DIS_BIT_V8_CAPABILITY                           6
+
+/* When ISDN mode is used, in DIS/DTC bit 7 shall be set to &quot;0&quot;. */
+#define T30_DIS_BIT_64_OCTET_ECM_FRAMES_PREFERRED           7
+
+/* Bit 9 indicates that there is a facsimile document ready to be polled from the answering
+   terrminal. It is not an indication of a capability. */
+#define T30_DIS_BIT_READY_TO_TRANSMIT_FAX_DOCUMENT          9
+
+/* In DIS/DTC bit 10 indicates that the answering terminal has receiving capabilities.
+   In DCS it is a command to the receiving terminal to set itself in the receive mode. */
+#define T30_DIS_BIT_READY_TO_RECEIVE_FAX_DOCUMENT           10
+#define T30_DCS_BIT_RECEIVE_FAX_DOCUMENT                    10
+
+/* Bits 11, 12, 13, 14 - modem type */
+
+#define T30_DIS_BIT_200_200_CAPABLE                         15
+#define T30_DCS_BIT_200_200                                 15
+
+#define T30_DIS_BIT_2D_CAPABLE                              16
+#define T30_DCS_BIT_2D_CODING                               16
+
+/* Standard facsimile terminals conforming to ITU-T Rec. T.4 must have the following capability:
+   Paper length = 297 mm. */
+
+/* Bits 17, 18 - recording width */
+
+/* Bits 19, 20 - paper length */
+
+/* Bits 21, 22, 23 - min scan line time */
+
+/* When ISDN mode is used, in DIS/DTC bits 21 to 23 shall be set to &quot;1&quot;. */
+
+#define T30_DIS_BIT_UNCOMPRESSED_CAPABLE                    26
+#define T30_DCS_BIT_UNCOMPRESSED_MODE                       26
+
+/* When ISDN mode is used, in DIS/DTC bit 27 shall be set to &quot;1&quot;. */
+#define T30_DIS_BIT_ECM_CAPABLE                             27
+#define T30_DCS_BIT_ECM                                     27
+
+/* The value of bit 28 in the DCS command is only valid when ECM is selected. */
+#define T30_DCS_BIT_64_OCTET_ECM_FRAMES                     28
+
+/* The value of bit 31 in the DCS command is only valid when ECM is selected. */
+#define T30_DIS_BIT_T6_CAPABLE                              31
+#define T30_DCS_BIT_T6_MODE                                 31
+
+#define T30_DIS_BIT_FNV_CAPABLE                             33
+#define T30_DCS_BIT_FNV_CAPABLE                             33
+
+#define T30_DIS_BIT_MULTIPLE_SELECTIVE_POLLING_CAPABLE      34
+
+#define T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE            35
+
+#define T30_DIS_BIT_T43_CAPABLE                             36
+#define T30_DCS_BIT_T43_CODING                              36
+
+#define T30_DIS_BIT_PLANE_INTERLEAVE_CAPABLE                37
+#define T30_DCS_BIT_PLANE_INTERLEAVE                        37
+
+#define T30_DIS_BIT_G726_CAPABLE                            38
+#define T30_DCS_BIT_G726                                    38
+
+#define T30_DIS_BIT_200_400_CAPABLE                         41
+#define T30_DCS_BIT_200_400                                 41
+
+#define T30_DIS_BIT_300_300_CAPABLE                         42
+#define T30_DCS_BIT_300_300                                 42
+
+#define T30_DIS_BIT_400_400_CAPABLE                         43
+#define T30_DCS_BIT_400_400                                 43
+
+/* Bits 44 and 45 are used only in conjunction with bits 15 and 43. Bit 44 in DCS, when used,
+   shall correctly indicate the resolution of the transmitted document, which means that bit 44 in DCS may
+   not always match the indication of bits 44 and 45 in DIS/DTC. Cross selection will cause the distortion
+   and reduction of reproducible area.
+   If a receiver indicates in DIS that it prefers to receive metric-based information, but the transmitter has
+   only the equivalent inch-based information (or vice versa), then communication shall still take place.
+   Bits 44 and 45 do not require the provision of any additional features on the terminal to
+   indicate to the sending or receiving user whether the information was transmitted or received on a metric-metric,
+   inch-inch, metric-inch, inch-metric basis. */
+
+#define T30_DIS_BIT_INCH_RESOLUTION_PREFERRED               44
+#define T30_DCS_BIT_INCH_RESOLUTION                         44
+
+#define T30_DIS_BIT_METRIC_RESOLUTION_PREFERRED             45
+
+#define T30_DIS_BIT_MIN_SCAN_TIME_HALVES                    46
+
+#define T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE               47
+
+#define T30_DIS_BIT_SUBADDRESSING_CAPABLE                   49
+#define T30_DCS_BIT_SUBADDRESS_TRANSMISSION                 49
+
+#define T30_DIS_BIT_PASSWORD                                50
+#define T30_DCS_BIT_SENDER_ID_TRANSMISSION                  50
+
+/* Bit 51 indicates that there is a data file ready to be polled from the answering terminal. It is
+   not an indication of a capability. This bit is used in conjunction with bits 53, 54, 55 and 57. */
+#define T30_DIS_BIT_READY_TO_TRANSMIT_DATA_FILE             51
+
+/* The binary file transfer protocol is described in ITU-T Rec. T.434.  */
+#define T30_DIS_BIT_BFT_CAPABLE                             53
+#define T30_DCS_BIT_BFT                                     53
+
+#define T30_DIS_BIT_DTM_CAPABLE                             54
+#define T30_DCS_BIT_DTM                                     54
+
+#define T30_DIS_BIT_EDI_CAPABLE                             55
+#define T30_DCS_BIT_EDI                                     55
+
+#define T30_DIS_BIT_BTM_CAPABLE                             57
+#define T30_DCS_BIT_BTM                                     57
+
+/* Bit 59 indicates that there is a character-coded or mixed-mode document ready to be polled
+   from the answering terminal. It is not an indication of a capability. This bit is used in
+   conjunction with bits 60, 62 and 65. */
+#define T30_DIS_BIT_READY_TO_TRANSMIT_MIXED_MODE_DOCUMENT   59
+
+#define T30_DIS_BIT_CHARACTER_MODE                          60
+#define T30_DCS_BIT_CHARACTER_MODE                          60
+
+#define T30_DIS_BIT_MIXED_MODE                              62
+#define T30_DCS_BIT_MIXED_MODE                              62
+
+#define T30_DIS_BIT_PROCESSABLE_MODE_26                     65
+
+#define T30_DIS_BIT_DIGITAL_NETWORK_CAPABLE                 66
+#define T30_DCS_BIT_DIGITAL_NETWORK_CAPABLE                 66
+
+#define T30_DIS_BIT_DUPLEX_CAPABLE                          67
+#define T30_DCS_BIT_DUPLEX_CAPABLE                          67
+
+#define T30_DIS_BIT_T81_CAPABLE                             68
+#define T30_DCS_BIT_FULL_COLOUR_MODEX                       68
+
+#define T30_DIS_BIT_FULL_COLOUR_CAPABLE                     69
+#define T30_DCS_BIT_FULL_COLOUR_MODE                        69
+
+/* In a DIS/DTC frame, setting bit 71 to &quot;0&quot; indicates that the called terminal can only accept
+   image data which has been digitized to 8 bits/pel/component for JPEG mode. This is also true for T.43
+   mode if bit 36 is also set to &quot;1&quot;. Setting bit 71 to &quot;1&quot; indicates that the called terminal can also accept
+   image data that are digitized to 12 bits/pel/component for JPEG mode. This is also true for T.43 mode if
+   bit 36 is also set to &quot;1&quot;. In a DCS frame, setting bit 71 to &quot;0&quot; indicates that the calling terminal's image
+   data are digitized to 8 bits/pel/component for JPEG mode. This is also true for T.43 mode if bit 36 is also
+   set to &quot;1&quot;. Setting bit 71 to &quot;1&quot; indicates that the calling terminal transmits image data which has been
+   digitized to 12 bits/pel/component for JPEG mode. This is also true for T.43 mode if bit 36 is also set
+   to &quot;1&quot;. */
+#define T30_DIS_BIT_12BIT_CAPABLE                           71
+#define T30_DCS_BIT_12BIT_COMPONENT                         71
+
+#define T30_DIS_BIT_NO_SUBSAMPLING                          73
+#define T30_DCS_BIT_NO_SUBSAMPLING                          73
+
+#define T30_DIS_BIT_CUSTOM_ILLUMINANT                       74
+#define T30_DCS_BIT_CUSTOM_ILLUMINANT                       74
+
+#define T30_DIS_BIT_CUSTOM_GAMUT_RANGE                      75
+#define T30_DCS_BIT_CUSTOM_GAMUT_RANGE                      75
+
+#define T30_DIS_BIT_NORTH_AMERICAN_LETTER_CAPABLE           76
+#define T30_DCS_BIT_NORTH_AMERICAN_LETTER                   76
+
+#define T30_DIS_BIT_NORTH_AMERICAN_LEGAL_CAPABLE            77
+#define T30_DCS_BIT_NORTH_AMERICAN_LEGAL                    77
+
+#define T30_DIS_BIT_T85_CAPABLE                             78
+#define T30_DCS_BIT_T85_MODE                                78
+
+#define T30_DIS_BIT_T85_L0_CAPABLE                          79
+#define T30_DCS_BIT_T85_L0_MODE                             79
+
+/* In a DIS/DTC frame, setting bit 97 to &quot;0&quot; indicates that the called terminal does not have the
+   capability to accept 300 pels/25.4 mm x 300 lines/25.4 mm or 400 pels/25.4 mm x 400 lines/25.4 mm
+   resolutions for colour/gray-scale images or T.44 Mixed Raster Content (MRC) mask layer.
+   
+   Setting bit 97 to &quot;1&quot; indicates that the called terminal does have the capability to accept
+   300 pels/25.4 mm x 300 lines/25.4 mm or 400 pels/25.4 mm x 400 lines/25.4 mm resolutions for
+   colour/gray-scale images and MRC mask layer. Bit 97 is valid only when bits 68 and 42 or 43
+   (300 pels/25.4 mm x 300 lines/25.4 mm or 400 pels/25.4 mm x 400 lines/25.4 mm) are set to &quot;1&quot;.
+   
+   In a DCS frame, setting bit 97 to &quot;0&quot; indicates that the calling terminal does not use
+   300 pels/25.4 mm x 300 lines/25.4 mm or 400 pels/25.4 mm x 400 lines/25.4 mm resolutions
+   for colour/gray-scale images and mask layer.
+   
+   Setting bit 97 to &quot;1&quot; indicates that the calling terminal uses 300 pels/25.4 mm x 300 lines/25.4 mm
+   or 400 pels/25.4 mm x 400 lines/25.4 mm resolutions for colour/gray-scale images and MRC mask layer.
+   Bit 97 is valid only when bits 68 and 42 or 43 (300 pels/25.4 mm x 300 lines/25.4 mm and
+   400 pels/25.4 mm x 400 lines/25.4 mm) are set to &quot;1&quot;.
+
+   In a DIS/DTC frame, combinations of bit 42, bit 43 and bit 97 indicate that the called terminal
+   has higher resolution capabilities as follows:
+
+            Resolution capabilities (pels/25.4 mm)
+    DIS/DTC     Monochrome              Colour/gray-scale
+    42 43 97    300 x 300   400 x 400   300 x 300   400 x 400
+     0  0  0    no          no          no          no
+     1  0  0    yes         no          no          no
+     0  1  0    no          yes         no          no
+     1  1  0    yes         yes         no          no
+     0  0  1    (invalid)
+     1  0  1    yes         no          yes         no
+     0  1  1    no          yes         no          yes
+     1  1  1    yes         yes         yes         yes
+        &quot;yes&quot; means that the called terminal has the corresponding capability.
+        &quot;no&quot; means that the called terminal does not have the corresponding capability. */
+#define T30_DIS_BIT_COLOUR_GREY_300_300_400_400_CAPABLE     97
+#define T30_DCS_BIT_COLOUR_GREY_300_300_400_400             97
+
+/* In a DIS/DTC frame, setting bit 98 to &quot;0&quot; indicates that the called terminal does not have the
+   capability to accept 100 pels/25.4 mm x 100 lines/25.4 mm spatial resolution for colour or gray-scale
+   images. Setting bit 98 to &quot;1&quot; indicates that the called terminal does have the capability to accept
+   100 pels/25.4 mm  x 100 lines/25.4 mm spatial resolution for colour or gray-scale images. Bit 98 is valid
+   only when bit 68 is set to &quot;1&quot;. In a DCS frame, setting bit 98 to &quot;0&quot; indicates that the calling terminal does
+   not use 100 pels/25.4 mm  x 100 lines/25.4 mm spatial resolution for colour or gray-scale images. Setting
+   bit 98 to &quot;1&quot; indicates that the calling terminal uses 100 pels/25.4 mm x 100 lines/25.4 mm spatial
+   resolution for colour or gray-scale images. */
+#define T30_DIS_BIT_COLOUR_GREY_100_100_CAPABLE             98
+#define T30_DCS_BIT_COLOUR_GREY_100_100                     98
+
+/* To provide an error recovery mechanism, when PWD/SEP/SUB/SID/PSA/IRA/ISP frames are sent with DCS or DTC,
+    bits 49, 102 and 50 in DCS or bits 47, 101, 50 and 35 in DTC shall be set to &quot;1&quot; with the following
+    meaning:
+    Bit DIS                                             DTC                                                 DCS
+    35  Polled SubAddress capability                    Polled SubAddress transmission                      Not allowed \x96 set to &quot;0&quot;
+    47  Selective polling capability                    Selective polling transmission                      Not allowed \x96 set to &quot;0&quot;
+    49  Subaddressing capability                        Not allowed (Set to &quot;0&quot;)                            Subaddressing transmission
+    50  Password                                        Password transmission                               Sender Identification transmission
+    101 Internet Selective Polling Address capability   Internet Selective Polling Address transmission     Not allowed \x96 set to &quot;0&quot;
+    102 Internet Routing Address capability             Not allowed (Set to &quot;0&quot;)                            Internet Routing Address transmission
+
+   Terminals conforming to the 1993 version of T.30 may set the above bits to &quot;0&quot; even though PWD/SEP/SUB
+   frames are transmitted. */
+#define T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS      101
+
+#define T30_DIS_BIT_INTERNET_ROUTING_ADDRESS                102
+#define T30_DCS_BIT_INTERNET_ROUTING_ADDRESS_TRANSMISSION   102
+
+#define T30_DIS_BIT_600_600_CAPABLE                         105
+#define T30_DCS_BIT_600_600                                 105
+
+#define T30_DIS_BIT_1200_1200_CAPABLE                       106
+#define T30_DCS_BIT_1200_1200                               106
+
+#define T30_DIS_BIT_300_600_CAPABLE                         107
+#define T30_DCS_BIT_300_600                                 107
+
+#define T30_DIS_BIT_400_800_CAPABLE                         108
+#define T30_DCS_BIT_400_800                                 108
+
+#define T30_DIS_BIT_600_1200_CAPABLE                        109
+#define T30_DCS_BIT_600_1200                                109
+
+#define T30_DIS_BIT_COLOUR_GREY_600_600_CAPABLE             110
+#define T30_DCS_BIT_COLOUR_GREY_600_600                     110
+
+#define T30_DIS_BIT_COLOUR_GREY_1200_1200_CAPABLE           111
+#define T30_DCS_BIT_COLOUR_GREY_1200_1200                   111
+
+#define T30_DIS_BIT_ALTERNATE_DOUBLE_SIDED_CAPABLE          113
+#define T30_DCS_BIT_ALTERNATE_DOUBLE_SIDED_CAPABLE          113
+
+#define T30_DIS_BIT_CONTINUOUS_DOUBLE_SIDED_CAPABLE         114
+#define T30_DCS_BIT_CONTINUOUS_DOUBLE_SIDED_CAPABLE         114
+
+#define T30_DIS_BIT_BLACK_AND_WHITE_MRC                     115
+
+#define T30_DIS_BIT_T45_CAPABLE                             116
+#define T30_DCS_BIT_T45_MODE                                116
+
+/* This bit defines the available colour space, when bit 92, 93 or 94 is set to &quot;1&quot;.
+   Available colour space for all combinations of bits 92, 93, 94 and 119 are shown in the following table.
+   It should be noted that terminals which conform to the 2003 and earlier versions of this Recommendation
+   will send LAB with &quot;1&quot; in bit 92, 93 or 94 even if bit 119 is set to &quot;1&quot;.
+
+        Available colour space for DIS/DTC bits 92, 93, 94 and 119
+
+    92 93 94 119    Mode of T.44        Available colour space
+     0  0  0  x     Not available       -
+     1  0  0  0     Mode 1              LAB only
+     1  0  0  1     Mode 1              YCC only
+     x  1  x  0     Mode 2 or higher    LAB only
+     x  x  1  0     Mode 2 or higher    LAB only
+     x  1  x  1     Mode 2 or higher    LAB and YCC
+     x  x  1  1     Mode 2 or higher    LAB and YCC
+
+        Colour space for DCS bits 92, 93, 94 and 119
+
+    92 93 94 119    Mode of T.44        Colour space
+     0  0  0  x*    Not available       -
+     1  0  0  0     Mode 1              LAB
+     1  0  0  1     Mode 1              YCC
+     x  1  x  0     Mode 2 or higher    LAB
+     x  x  1  0     Mode 2 or higher    LAB
+     x  1  x  1     Mode 2 or higher    YCC or mixing of YCC and LAB
+     x  x  1  1     Mode 2 or higher    YCC or mixing of YCC and LAB */
+#define T30_DIS_BIT_T44_COLOUR_SPACE                        119
+#define T30_DCS_BIT_T44_COLOUR_SPACE                        119
+
+/* Can only be set in the communication through the T.38 gateway, to cope with delay of network.
+   T.x timer (12+-1s) should be used after emitting RNR or TNR. However, after receiving
+   PPS signal in ECM mode, T.5 timer should be used. */
+#define T30_DIS_BIT_T38_FLOW_CONTROL_CAPABLE                121
+#define T30_DCS_BIT_T38_FLOW_CONTROL_CAPABLE                121
+
+/* For resolutions greater than 200 lines/25.4 mm, 4.2.1.1/T.4 specifies the use of specific K
+   factors for each standardized vertical resolution. To ensure backward compatibility with earlier
+   versions of ITU-T Rec. T.4, bit 122 indicates when such K factors are being used. */
+#define T30_DIS_BIT_K_GREATER_THAN_4                        122
+
+/* This bit should be set to &quot;1&quot; if the fax device is an Internet-Aware Fax Device as defined in
+   ITU-T Rec. T.38 and if it is not affected by the data signal rate indicated by the DIS and DTC
+   signals when communicating with another Internet-Aware Fax Device operating in T.38 mode. This
+   bit shall not be used in GSTN mode. */
+#define T30_DIS_BIT_T38_FAX_CAPABLE                         123
+/* This bit should be set to &quot;1&quot; if the fax device elects to operate in an Internet-Aware Fax mode
+   as defined in ITU-T Rec. T.38 in response to a device which has set the related DIS bit to &quot;1&quot;.
+   When this bit is set to &quot;1&quot;, the data signal rate of the modem (bits 11-14) should be set to &quot;0&quot;. */
+#define T30_DCS_BIT_T38_FAX_MODE                            123
+
+/* When either bit of 31, 36, 38, 51, 53, 54, 55, 57, 59, 60, 62, 65, 68, 78, 79, 115, 116 and 127 is
+   set to &quot;1&quot;, ECM must be used. If the value of bit field 92 to 94 is non-zero, then ECM must be used.
+
+   Annex K describes the optional continuous-tone colour and gray scale images mode
+   (sYCC-JPEG mode) protocol. When bit 127 in DIS/DTC frame is set to &quot;1&quot;, the called terminal has the
+   capability to accept sYCC-JPEG mode. This is defined with complete independent in the colour space
+   CIELAB. In addition, when bit 127 in DCS frame is set to &quot;1&quot;, ECM must be used and bits 15, 17, 18,
+   19, 20, 41, 42, 43, 45, 46, 68, 69, 71, 73, 74, 75, 76, 77, 97, 98, 105, 106, 107, 108,
+   109, 110 and 111 in DCS frame are &quot;Don't care&quot;, and should be set to &quot;0&quot;. In the case of
+   transmission of multiple images, a post message signal PPS-MPS between pages, PPS-NULL between
+   partial pages and PPS-EOP following the last page should be sent from the calling terminal to the
+   called terminal. */
+#define T30_DIS_BIT_SYCC_T81_CAPABLE                        127
+#define T30_DCS_BIT_SYCC_T81_MODE                           127
+
+#endif
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatet38_gatewayh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_gateway.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_gateway.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_gateway.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_gateway.h,v 1.4 2009/05/16 03:34:45 steveu Exp $
</del><ins>+ * $Id: t38_gateway.h,v 1.5 2009/11/07 08:58:58 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -163,8 +163,8 @@
</span><span class="cx">     int ecm_mode;
</span><span class="cx">     /*! \brief The current bit rate for the fast modem. */
</span><span class="cx">     int fast_bit_rate;
</span><del>-    /*! \brief The current fast modem type. */
-    int fast_modem;
</del><ins>+    /*! \brief The current fast receive modem type. */
+    int fast_rx_modem;
</ins><span class="cx">     /*! \brief The type of fast receive modem currently active, which may be T38_NONE */
</span><span class="cx">     int fast_rx_active;
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatet38_non_ecm_bufferh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/t38_non_ecm_buffer.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_non_ecm_buffer.h,v 1.2 2008/10/13 14:19:18 steveu Exp $
</del><ins>+ * $Id: t38_non_ecm_buffer.h,v 1.2.4.1 2009/12/19 06:43:28 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if !defined(_SPANDSP_PRIVATE_T38_NON_ECM_BUFFER_H_)
</span><span class="lines">@@ -36,7 +36,7 @@
</span><span class="cx"> {
</span><span class="cx">     /*! \brief Minimum number of bits per row, used when fill bits are being deleted on the
</span><span class="cx">                link, and restored at the emitting gateway. */
</span><del>-    int min_row_bits;
</del><ins>+    int min_bits_per_row;
</ins><span class="cx"> 
</span><span class="cx">     /*! \brief non-ECM modem transmit data buffer. */
</span><span class="cx">     uint8_t data[T38_NON_ECM_TX_BUF_LEN];
</span><span class="lines">@@ -55,8 +55,8 @@
</span><span class="cx">     /*! \brief The non-ECM flow control fill octet (0xFF before the first data, and 0x00
</span><span class="cx">                once data has started). */
</span><span class="cx">     uint8_t flow_control_fill_octet;
</span><del>-    /*! \brief TRUE if we are in the initial all ones part of non-ECM transmission. */
-    int at_initial_all_ones;
</del><ins>+    /*! \brief A code for the phase of input buffering, from initial all ones to completion. */
+    int input_phase;
</ins><span class="cx">     /*! \brief TRUE is the end of non-ECM data indication has been received. */
</span><span class="cx">     int data_finished;
</span><span class="cx">     /*! \brief The current octet being transmitted from the buffer. */
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatet4_rxh"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_rx.h (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_rx.h                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_rx.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,131 @@
</span><ins>+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * private/t4_rx.h - definitions for T.4 FAX receive processing
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2003 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t4_rx.h,v 1.6.2.8 2009/12/21 17:18:40 steveu Exp $
+ */
+
+#if !defined(_SPANDSP_PRIVATE_T4_RX_H_)
+#define _SPANDSP_PRIVATE_T4_RX_H_
+
+/*!
+    TIFF specific state information to go with T.4 compression or decompression handling.
+*/
+typedef struct
+{
+    /*! \brief The current file name. */
+    const char *file;
+    /*! \brief The libtiff context for the current TIFF file */
+    TIFF *tiff_file;
+
+    /*! \brief The number of pages in the current image file. */
+    int pages_in_file;
+
+    /*! \brief The compression type for output to the TIFF file. */
+    int32_t output_compression;
+    /*! \brief The TIFF photometric setting for the current page. */
+    uint16_t photo_metric;
+    /*! \brief The TIFF fill order setting for the current page. */
+    uint16_t fill_order;
+    /*! \brief The TIFF G3 FAX options. */
+    int32_t output_t4_options;
+
+    /* &quot;Background&quot; information about the FAX, which can be stored in the image file. */
+    /*! \brief The vendor of the machine which produced the file. */ 
+    const char *vendor;
+    /*! \brief The model of machine which produced the file. */ 
+    const char *model;
+    /*! \brief The local ident string. */ 
+    const char *local_ident;
+    /*! \brief The remote end's ident string. */ 
+    const char *far_ident;
+    /*! \brief The FAX sub-address. */ 
+    const char *sub_address;
+    /*! \brief The FAX DCS information, as an ASCII string. */ 
+    const char *dcs;
+
+    /*! \brief The first page to transfer. -1 to start at the beginning of the file. */
+    int start_page;
+    /*! \brief The last page to transfer. -1 to continue to the end of the file. */
+    int stop_page;
+} t4_tiff_state_t;
+
+typedef struct t4_t6_decode_state_s t4_t6_decode_state_t;
+
+/*!
+    T.4 1D, T4 2D and T6 decompressor state.
+*/
+struct t4_t6_decode_state_s
+{
+    /*! \brief Callback function to write a row of pixels to the image destination. */
+    t4_row_write_handler_t row_write_handler;
+    /*! \brief Opaque pointer passed to row_write_handler. */
+    void *row_write_user_data;
+
+    /*! \brief Incoming bit buffer for decompression. */
+    uint32_t rx_bitstream;
+    /*! \brief The number of bits currently in rx_bitstream. */
+    int rx_bits;
+    /*! \brief The number of bits to be skipped before trying to match the next code word. */
+    int rx_skip_bits;
+
+    /*! \brief This variable is used to count the consecutive EOLS we have seen. If it
+               reaches six, this is the end of the image. It is initially set to -1 for
+               1D and 2D decoding, as an indicator that we must wait for the first EOL,
+               before decoding any image data. */
+    int consecutive_eols;
+
+    /*! \brief The reference or starting changing element on the coding line. At the
+               start of the coding line, a0 is set on an imaginary white changing element
+               situated just before the first element on the line. During the coding of
+               the coding line, the position of a0 is defined by the previous coding mode.
+               (See T.4/4.2.1.3.2.). */
+    int a0;
+    /*! \brief The first changing element on the reference line to the right of a0 and of
+               opposite colour to a0. */
+    int b1;
+    /*! \brief The length of the in-progress run of black or white. */
+    int run_length;
+    /*! \brief 2D horizontal mode control. */
+    int black_white;
+    /*! \brief TRUE if the current run is black */
+    int its_black;
+
+    /*! \brief The current step into the current row run-lengths buffer. */
+    int a_cursor;
+    /*! \brief The current step into the reference row run-lengths buffer. */
+    int b_cursor;
+
+    /*! \brief A pointer into the image buffer indicating where the last row begins */
+    int last_row_starts_at;
+
+    /*! \brief The current number of consecutive bad rows. */
+    int curr_bad_row_run;
+    /*! \brief The longest run of consecutive bad rows seen in the current page. */
+    int longest_bad_row_run;
+    /*! \brief The total number of bad rows in the current page. */
+    int bad_rows;
+};
+
+#endif
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatet4_txh"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_tx.h (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_tx.h                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/t4_tx.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,142 @@
</span><ins>+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * private/t4_tx.h - definitions for T.4 FAX transmit processing
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2003 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t4_tx.h,v 1.7.2.4 2009/12/21 17:18:40 steveu Exp $
+ */
+
+#if !defined(_SPANDSP_PRIVATE_T4_TX_H_)
+#define _SPANDSP_PRIVATE_T4_TX_H_
+
+typedef struct t4_t6_encode_state_s t4_t6_encode_state_t;
+
+/*!
+    T.4 1D, T4 2D and T6 compressor state.
+*/
+struct t4_t6_encode_state_s
+{
+    /*! \brief The minimum number of encoded bits per row. This is a timing thing
+               for hardware FAX machines. */
+    int min_bits_per_row;
+    /*! \brief The current maximum contiguous rows that may be 2D encoded. */
+    int max_rows_to_next_1d_row;
+
+    /*! \brief The text which will be used in FAX page header. No text results
+               in no header line. */
+    const char *header_info;
+
+    /*! \brief Number of rows left that can be 2D encoded, before a 1D encoded row
+               must be used. */
+    int rows_to_next_1d_row;
+
+    /*! \brief The number of runs currently in the reference row. */
+    int ref_steps;
+
+    /*! \brief Pointer to the byte containing the next image bit to transmit. */
+    int bit_pos;
+    /*! \brief Pointer to the bit within the byte containing the next image bit to transmit. */
+    int bit_ptr;
+
+    /*! \brief Callback function to read a row of pixels from the image source. */
+    t4_row_read_handler_t row_read_handler;
+    /*! \brief Opaque pointer passed to row_read_handler. */
+    void *row_read_user_data;
+};
+
+/*!
+    T.4 FAX compression/decompression descriptor. This defines the working state
+    for a single instance of a T.4 FAX compression or decompression channel.
+*/
+struct t4_state_s
+{
+    /*! \brief The same structure is used for T.4 transmit and receive. This variable
+               records which mode is in progress. */
+    int rx;
+
+    /*! \brief The type of compression used between the FAX machines. */
+    int line_encoding;
+
+    /*! \brief The time at which handling of the current page began. */
+    time_t page_start_time;
+
+    /*! \brief The size of the compressed image on the line side, in bits. */
+    int line_image_size;
+
+    /*! \brief The current number of bytes per row of uncompressed image data. */
+    int bytes_per_row;
+    /*! \brief The size of the image in the image buffer, in bytes. */
+    int image_size;
+    /*! \brief The current size of the image buffer. */
+    int image_buffer_size;
+    /*! \brief A point to the image buffer. */
+    uint8_t *image_buffer;
+
+    /*! \brief The number of pages transferred to date. */
+    int current_page;
+    /*! \brief Column-to-column (X) resolution in pixels per metre. */
+    int x_resolution;
+    /*! \brief Row-to-row (Y) resolution in pixels per metre. */
+    int y_resolution;
+    /*! \brief Width of the current page, in pixels. */
+    int image_width;
+    /*! \brief Length of the current page, in pixels. */
+    int image_length;
+    /*! \brief Current pixel row number. */
+    int row;
+
+    /*! \brief This variable is set if we are treating the current row as a 2D encoded
+               one. */
+    int row_is_2d;
+    /*! \brief The current length of the current row. */
+    int row_len;
+
+    /*! \brief Black and white run-lengths for the current row. */
+    uint32_t *cur_runs;
+    /*! \brief Black and white run-lengths for the reference row. */
+    uint32_t *ref_runs;
+    /*! \brief Pointer to the buffer for the current pixel row. */
+    uint8_t *row_buf;
+
+    /*! \brief Encoded data bits buffer. */
+    uint32_t tx_bitstream;
+    /*! \brief The number of bits currently in tx_bitstream. */
+    int tx_bits;
+
+    /*! \brief The current number of bits in the current encoded row. */
+    int row_bits;
+    /*! \brief The minimum bits in any row of the current page. For monitoring only. */
+    int min_row_bits;
+    /*! \brief The maximum bits in any row of the current page. For monitoring only. */
+    int max_row_bits;
+
+    /*! \brief Error and flow logging control */
+    logging_state_t logging;
+
+    /*! \brief All TIFF file specific state information for the T.4 context. */
+    t4_tiff_state_t tiff;
+    t4_t6_decode_state_t t4_t6_rx;
+    t4_t6_encode_state_t t4_t6_tx;
+};
+
+#endif
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatev18h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/v18.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/v18.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/v18.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v18.h,v 1.4 2009/04/11 15:16:14 steveu Exp $
</del><ins>+ * $Id: v18.h,v 1.5 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> #if !defined(_SPANDSP_PRIVATE_V18_H_)
</span><span class="lines">@@ -31,7 +31,7 @@
</span><span class="cx"> struct v18_state_s
</span><span class="cx"> {
</span><span class="cx">     /*! \brief TRUE if we are the calling modem */
</span><del>-    int caller;
</del><ins>+    int calling_party;
</ins><span class="cx">     int mode;
</span><span class="cx">     put_msg_func_t put_msg;
</span><span class="cx">     void *user_data;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatev22bish"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/v22bis.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/v22bis.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/v22bis.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v22bis.h,v 1.11 2009/07/09 13:52:09 steveu Exp $
</del><ins>+ * $Id: v22bis.h,v 1.12 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if !defined(_SPANDSP_PRIVATE_V22BIS_H_)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">     /*! \brief The maximum permitted bit rate of the modem. Valid values are 1200 and 2400. */
</span><span class="cx">     int bit_rate;
</span><span class="cx">     /*! \brief TRUE is this is the calling side modem. */
</span><del>-    int caller;
</del><ins>+    int calling_party;
</ins><span class="cx">     /*! \brief The callback function used to get the next bit to be transmitted. */
</span><span class="cx">     get_bit_func_t get_bit;
</span><span class="cx">     /*! \brief A user specified opaque pointer passed to the get_bit callback routine. */
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatev42h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/v42.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/v42.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/v42.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v42.h,v 1.1 2008/11/15 14:43:08 steveu Exp $
</del><ins>+ * $Id: v42.h,v 1.2 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if !defined(_SPANDSP_PRIVATE_V42_H_)
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> struct v42_state_s
</span><span class="cx"> {
</span><span class="cx">     /*! TRUE if we are the calling party, otherwise FALSE */
</span><del>-    int caller;
</del><ins>+    int calling_party;
</ins><span class="cx">     /*! TRUE if we should detect whether the far end is V.42 capable. FALSE if we go
</span><span class="cx">         directly to protocol establishment */
</span><span class="cx">     int detect;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspprivatev8h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/private/v8.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/private/v8.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/private/v8.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v8.h,v 1.1 2008/10/13 13:14:01 steveu Exp $
</del><ins>+ * $Id: v8.h,v 1.3 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> #if !defined(_SPANDSP_PRIVATE_V8_H_)
</span><span class="lines">@@ -31,9 +31,15 @@
</span><span class="cx"> struct v8_state_s
</span><span class="cx"> {
</span><span class="cx">     /*! \brief TRUE if we are the calling modem */
</span><del>-    int caller;
-    /*! \brief The current state of the V8 protocol */
</del><ins>+    int calling_party;
+
+    v8_result_handler_t *result_handler;
+    void *result_handler_user_data;
+
+    /*! \brief The current state of the V.8 protocol */
</ins><span class="cx">     int state;
</span><ins>+    int fsk_tx_on;
+    int modem_connect_tone_tx_on;
</ins><span class="cx">     int negotiation_timer;
</span><span class="cx">     int ci_timer;
</span><span class="cx">     int ci_count;
</span><span class="lines">@@ -43,24 +49,14 @@
</span><span class="cx">     modem_connect_tones_tx_state_t ansam_tx;
</span><span class="cx">     modem_connect_tones_rx_state_t ansam_rx;
</span><span class="cx"> 
</span><del>-    v8_result_handler_t *result_handler;
-    void *result_handler_user_data;
-
</del><span class="cx">     /*! \brief Modulation schemes available at this end. */
</span><del>-    int available_modulations;
</del><ins>+    int local_end_modulations;
</ins><span class="cx">     int common_modulations;
</span><del>-    int negotiated_modulation;
-    int far_end_modulations;
-    
-    int call_function;
-    int protocol;
-    int pstn_access;
-    int nsf_seen;
-    int pcm_modem_availability;
-    int t66_seen;
</del><span class="cx"> 
</span><del>-    /* V8 data parsing */
-    unsigned int bit_stream;
</del><ins>+    v8_result_t result;
+
+    /* V.8 data parsing */
+    uint32_t bit_stream;
</ins><span class="cx">     int bit_cnt;
</span><span class="cx">     /* Indicates the type of message coming up */
</span><span class="cx">     int preamble_type;
</span><span class="lines">@@ -70,7 +66,7 @@
</span><span class="cx">     /*! \brief a reference copy of the last CM or JM message, used when
</span><span class="cx">                testing for matches. */
</span><span class="cx">     uint8_t cm_jm_data[64];
</span><del>-    int cm_jm_count;
</del><ins>+    int cm_jm_len;
</ins><span class="cx">     int got_cm_jm;
</span><span class="cx">     int got_cj;
</span><span class="cx">     int zero_byte_count;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspt30h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/t30.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/t30.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t30.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t30.h,v 1.126 2009/09/21 15:52:39 steveu Exp $
</del><ins>+ * $Id: t30.h,v 1.126.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -347,7 +347,7 @@
</span><span class="cx">     T30_SUPPORT_V17 = 0x04,
</span><span class="cx">     /*! Support the V.34 modem (up to 33,600bps) for image transfer. */
</span><span class="cx">     T30_SUPPORT_V34 = 0x08,
</span><del>-    /*! Support the Internet Aware FAX mode (no bit rate limit) for image transfer. */
</del><ins>+    /*! Support the Internet aware FAX mode (no bit rate limit) for image transfer. */
</ins><span class="cx">     T30_SUPPORT_IAF = 0x10
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="lines">@@ -361,16 +361,18 @@
</span><span class="cx">     T30_SUPPORT_T4_2D_COMPRESSION = 0x04,
</span><span class="cx">     /*! T.6 2D compression */
</span><span class="cx">     T30_SUPPORT_T6_COMPRESSION = 0x08,
</span><del>-    /*! T.85 monochrome JBIG coding */
</del><ins>+    /*! T.85 monochrome JBIG compression */
</ins><span class="cx">     T30_SUPPORT_T85_COMPRESSION = 0x10,
</span><del>-    /*! T.43 colour JBIG coding */
</del><ins>+    /*! T.43 colour JBIG compression */
</ins><span class="cx">     T30_SUPPORT_T43_COMPRESSION = 0x20,
</span><span class="cx">     /*! T.45 run length colour compression */
</span><span class="cx">     T30_SUPPORT_T45_COMPRESSION = 0x40,
</span><del>-    /*! T.81 + T.30 Annex E colour JPEG coding */
</del><ins>+    /*! T.81 + T.30 Annex E colour JPEG compression */
</ins><span class="cx">     T30_SUPPORT_T81_COMPRESSION = 0x80,
</span><del>-    /*! T.81 + T.30 Annex K colour sYCC-JPEG coding */
-    T30_SUPPORT_SYCC_T81_COMPRESSION = 0x100
</del><ins>+    /*! T.81 + T.30 Annex K colour sYCC-JPEG compression */
+    T30_SUPPORT_SYCC_T81_COMPRESSION = 0x100,
+    /*! T.88 monochrome JBIG2 compression */
+    T30_SUPPORT_T88_COMPRESSION = 0x200
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspt30_fcfh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/t30_fcf.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/t30_fcf.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t30_fcf.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -1,7 +1,7 @@
</span><span class="cx"> /*
</span><span class="cx">  * SpanDSP - a series of DSP components for telephony
</span><span class="cx">  *
</span><del>- * fcf.h - ITU T.30 fax control field definitions
</del><ins>+ * t30_fcf.h - ITU T.30 fax control field definitions
</ins><span class="cx">  *
</span><span class="cx">  * Written by Steve Underwood &lt;steveu@coppice.org&gt;
</span><span class="cx">  *
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t30_fcf.h,v 1.17 2008/08/03 03:44:00 steveu Exp $
</del><ins>+ * $Id: t30_fcf.h,v 1.18 2009/10/08 15:14:31 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspt38_non_ecm_bufferh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t38_non_ecm_buffer.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_non_ecm_buffer.h,v 1.7 2009/02/10 13:06:47 steveu Exp $
</del><ins>+ * $Id: t38_non_ecm_buffer.h,v 1.7.4.1 2009/12/19 06:43:28 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -35,9 +35,38 @@
</span><span class="cx"> \section t38_non_ecm_buffer_page_sec_1 What does it do?
</span><span class="cx"> 
</span><span class="cx"> The T.38 rate adapting non-ECM image data buffer is used to buffer TCF and non-ECM
</span><del>-FAX image data being gatewayed from a T.38 linke to an analogue FAX modem link.
</del><ins>+FAX image data being gatewayed from a T.38 link to an analogue FAX modem link.
</ins><span class="cx"> 
</span><ins>+As well as rate adapting, the buffer has the ability to impose a minimum on the number
+of bits per row of image data. This allows any row padding zeros to be stripped from
+the data stream, to minimise the data sent as T.38 packets, and be reinserted before
+the data is sent to its final destination. Not all T.38 implementations support this
+feature, so it's use must be negotiated.
+
</ins><span class="cx"> \section t38_non_ecm_buffer_page_sec_2 How does it work?
</span><ins>+
+When inserting padding bits, whether to ensure a minimum row time or for flow control,
+it is important the right value is inserted at the right point in the data sequence.
+If we are in the optional initial period of all ones, we can insert a byte of extra
+ones at any time. Once we pass that initial stage, TCF and image data need separate
+handling.
+
+TCF data is all zeros. Once the period of all zeros has begun it is OK to insert
+additional bytes of zeros at any point.
+
+Image data consists of rows, separated by EOL (end of line) markers. Inserting
+zeros at arbitrary times would corrupt the image. However, it is OK to insert a
+considerable number of extra zeros just before an EOL. Therefore we track where the
+EOL markers occur as we fill the buffer. As we empty the buffer stop outputting real
+data, and start outputting bytes of zero, if we reach this last EOL marker location.
+The EOL marker is 11 zeros following by 1 (1D mode) or 2 (2D mode) ones. Therefore, it
+always spills across 2 bytes in the buffer, and there is always a point where we can
+insert our extra zeros between bytes.
+
+Padding between the group of successive EOL markers which for the RTC (return to control)
+marker that ends an image causes some FAX machines not to recognise them as an RTC condition.
+Therefore, our padding applies special protection so padding never occurs between two
+successive EOL markers, with no pixel data between them.
</ins><span class="cx"> */
</span><span class="cx"> 
</span><span class="cx"> /*! The buffer length much be a power of two. The chosen length is big enough for
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspt4_rxh"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/spandsp/t4_rx.h (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/t4_rx.h                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t4_rx.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,344 @@
</span><ins>+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * t4_rx.h - definitions for T.4 FAX receive processing
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2003 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t4_rx.h,v 1.3.2.3 2009/12/21 17:18:40 steveu Exp $
+ */
+
+/*! \file */
+
+#if !defined(_SPANDSP_T4_RX_H_)
+#define _SPANDSP_T4_RX_H_
+
+/*! \page t4_page T.4 image compression and decompression
+
+\section t4_page_sec_1 What does it do?
+The T.4 image compression and decompression routines implement the 1D and 2D
+encoding methods defined in ITU specification T.4. They also implement the pure
+2D encoding method defined in T.6. These are image compression algorithms used
+for FAX transmission.
+
+\section t4_page_sec_1 How does it work?
+*/
+
+typedef int (*t4_row_write_handler_t)(void *user_data, const uint8_t buf[], size_t len);
+
+/*! Supported compression modes. */
+typedef enum
+{
+    /*! No compression */
+    T4_COMPRESSION_NONE = 0,
+    /*! T.1 1D compression */
+    T4_COMPRESSION_ITU_T4_1D = 1,
+    /*! T.4 2D compression */
+    T4_COMPRESSION_ITU_T4_2D = 2,
+    /*! T.6 2D compression */
+    T4_COMPRESSION_ITU_T6 = 3,
+    /*! T.85 monochrome JBIG coding */
+    T4_COMPRESSION_ITU_T85 = 4,
+    /*! T.43 colour JBIG coding */
+    T4_COMPRESSION_ITU_T43 = 5,
+    /*! T.45 run length colour compression */
+    T4_COMPRESSION_ITU_T45 = 6,
+    /*! T.81 + T.30 Annex E colour JPEG coding */
+    T4_COMPRESSION_ITU_T81 = 7,
+    /*! T.81 + T.30 Annex K colour sYCC-JPEG coding */
+    T4_COMPRESSION_ITU_SYCC_T81 = 8
+} t4_image_compression_t;
+
+/*! Supported X resolutions, in pixels per metre. */
+typedef enum
+{
+    T4_X_RESOLUTION_R4 = 4016,
+    T4_X_RESOLUTION_R8 = 8031,
+    T4_X_RESOLUTION_300 = 11811,
+    T4_X_RESOLUTION_R16 = 16063,
+    T4_X_RESOLUTION_600 = 23622,
+    T4_X_RESOLUTION_800 = 31496,
+    T4_X_RESOLUTION_1200 = 47244
+} t4_image_x_resolution_t;
+
+/*! Supported Y resolutions, in pixels per metre. */
+typedef enum
+{
+    T4_Y_RESOLUTION_STANDARD = 3850,
+    T4_Y_RESOLUTION_FINE = 7700,
+    T4_Y_RESOLUTION_300 = 11811,
+    T4_Y_RESOLUTION_SUPERFINE = 15400,  /* 400 is 15748 */
+    T4_Y_RESOLUTION_600 = 23622,
+    T4_Y_RESOLUTION_800 = 31496,
+    T4_Y_RESOLUTION_1200 = 47244
+} t4_image_y_resolution_t;
+
+/*!
+    Exact widths in PELs for the difference resolutions, and page widths.
+    Note:
+        The A4 widths also apply to North American letter and legal.
+        The R4 resolution widths are not supported in recent versions of T.30
+        Only images of exactly these widths are acceptable for FAX transmisson.
+
+    R4    864 pels/215mm for ISO A4, North American Letter and Legal
+    R4   1024 pels/255mm for ISO B4
+    R4   1216 pels/303mm for ISO A3
+    R8   1728 pels/215mm for ISO A4, North American Letter and Legal
+    R8   2048 pels/255mm for ISO B4
+    R8   2432 pels/303mm for ISO A3
+    R16  3456 pels/215mm for ISO A4, North American Letter and Legal
+    R16  4096 pels/255mm for ISO B4
+    R16  4864 pels/303mm for ISO A3
+*/
+typedef enum
+{
+    T4_WIDTH_R4_A4 = 864,
+    T4_WIDTH_R4_B4 = 1024,
+    T4_WIDTH_R4_A3 = 1216,
+    T4_WIDTH_R8_A4 = 1728,
+    T4_WIDTH_R8_B4 = 2048,
+    T4_WIDTH_R8_A3 = 2432,
+    T4_WIDTH_300_A4 = 2592,
+    T4_WIDTH_300_B4 = 3072,
+    T4_WIDTH_300_A3 = 3648,
+    T4_WIDTH_R16_A4 = 3456,
+    T4_WIDTH_R16_B4 = 4096,
+    T4_WIDTH_R16_A3 = 4864,
+    T4_WIDTH_600_A4 = 5184,
+    T4_WIDTH_600_B4 = 6144,
+    T4_WIDTH_600_A3 = 7296,
+    T4_WIDTH_1200_A4 = 10368,
+    T4_WIDTH_1200_B4 = 12288,
+    T4_WIDTH_1200_A3 = 14592
+} t4_image_width_t;
+
+/*!
+    Length of the various supported paper sizes, in pixels at the various Y resolutions.
+    Paper sizes are
+        A4 (215mm x 297mm)
+        B4 (255mm x 364mm)
+        A3 (303mm x 418.56mm)
+        North American Letter (215.9mm x 279.4mm)
+        North American Legal (215.9mm x 355.6mm)
+        Unlimited
+
+    T.4 does not accurately define the maximum number of scan lines in a page. A wide
+    variety of maximum row counts are used in the real world. It is important not to
+    set our sending limit too high, or a receiving machine might split pages. It is
+    important not to set it too low, or we might clip pages.
+
+    Values seen for standard resolution A4 pages include 1037, 1045, 1109, 1126 and 1143.
+    1109 seems the most-popular.  At fine res 2150, 2196, 2200, 2237, 2252-2262, 2264,
+    2286, and 2394 are used. 2255 seems the most popular. We try to use balanced choices
+    here.
+*/
+typedef enum
+{
+    /* A4 is 297mm long */
+    T4_LENGTH_STANDARD_A4 = 1143,
+    T4_LENGTH_FINE_A4 = 2286,
+    T4_LENGTH_300_A4 = 4665,
+    T4_LENGTH_SUPERFINE_A4 = 4573,
+    T4_LENGTH_600_A4 = 6998,
+    T4_LENGTH_800_A4 = 9330,
+    T4_LENGTH_1200_A4 = 13996,
+    /* B4 is 364mm long */
+    T4_LENGTH_STANDARD_B4 = 1401,
+    T4_LENGTH_FINE_B4 = 2802,
+    T4_LENGTH_300_B4 = 0,
+    T4_LENGTH_SUPERFINE_B4 = 5605,
+    T4_LENGTH_600_B4 = 0,
+    T4_LENGTH_800_B4 = 0,
+    T4_LENGTH_1200_B4 = 0,
+    /* North American letter is 279.4mm long */
+    T4_LENGTH_STANDARD_US_LETTER = 1075,
+    T4_LENGTH_FINE_US_LETTER = 2151,
+    T4_LENGTH_300_US_LETTER = 0,
+    T4_LENGTH_SUPERFINE_US_LETTER = 4302,
+    T4_LENGTH_600_US_LETTER = 0,
+    T4_LENGTH_800_US_LETTER = 0,
+    T4_LENGTH_1200_US_LETTER = 0,
+    /* North American legal is 355.6mm long */
+    T4_LENGTH_STANDARD_US_LEGAL = 1369,
+    T4_LENGTH_FINE_US_LEGAL = 2738,
+    T4_LENGTH_300_US_LEGAL = 0,
+    T4_LENGTH_SUPERFINE_US_LEGAL = 5476,
+    T4_LENGTH_600_US_LEGAL = 0,
+    T4_LENGTH_800_US_LEGAL = 0,
+    T4_LENGTH_1200_US_LEGAL = 0
+} t4_image_length_t;
+
+/*!
+    T.4 FAX compression/decompression descriptor. This defines the working state
+    for a single instance of a T.4 FAX compression or decompression channel.
+*/
+typedef struct t4_state_s t4_state_t;
+
+/*!
+    T.4 FAX compression/decompression statistics.
+*/
+typedef struct
+{
+    /*! \brief The number of pages transferred so far. */
+    int pages_transferred;
+    /*! \brief The number of pages in the file (&lt;0 if unknown). */
+    int pages_in_file;
+    /*! \brief The number of horizontal pixels in the most recent page. */
+    int width;
+    /*! \brief The number of vertical pixels in the most recent page. */
+    int length;
+    /*! \brief The number of bad pixel rows in the most recent page. */
+    int bad_rows;
+    /*! \brief The largest number of bad pixel rows in a block in the most recent page. */
+    int longest_bad_row_run;
+    /*! \brief The horizontal resolution of the page in pixels per metre */
+    int x_resolution;
+    /*! \brief The vertical resolution of the page in pixels per metre */
+    int y_resolution;
+    /*! \brief The type of compression used between the FAX machines */
+    int encoding;
+    /*! \brief The size of the image on the line, in bytes */
+    int line_image_size;
+} t4_stats_t;
+    
+#if defined(__cplusplus)
+extern &quot;C&quot; {
+#endif
+
+/*! \brief Prepare for reception of a document.
+    \param s The T.4 context.
+    \param file The name of the file to be received.
+    \param output_encoding The output encoding.
+    \return A pointer to the context, or NULL if there was a problem. */
+SPAN_DECLARE(t4_state_t *) t4_rx_init(t4_state_t *s, const char *file, int output_encoding);
+
+/*! \brief Prepare to receive the next page of the current document.
+    \param s The T.4 context.
+    \return zero for success, -1 for failure. */
+SPAN_DECLARE(int) t4_rx_start_page(t4_state_t *s);
+
+/*! \brief Put a bit of the current document page.
+    \param s The T.4 context.
+    \param bit The data bit.
+    \return TRUE when the bit ends the document page, otherwise FALSE. */
+SPAN_DECLARE(int) t4_rx_put_bit(t4_state_t *s, int bit);
+
+/*! \brief Put a byte of the current document page.
+    \param s The T.4 context.
+    \param byte The data byte.
+    \return TRUE when the byte ends the document page, otherwise FALSE. */
+SPAN_DECLARE(int) t4_rx_put_byte(t4_state_t *s, uint8_t byte);
+
+/*! \brief Put a byte of the current document page.
+    \param s The T.4 context.
+    \param buf The buffer containing the chunk.
+    \param len The length of the chunk.
+    \return TRUE when the byte ends the document page, otherwise FALSE. */
+SPAN_DECLARE(int) t4_rx_put_chunk(t4_state_t *s, const uint8_t buf[], int len);
+
+/*! \brief Complete the reception of a page.
+    \param s The T.4 receive context.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_rx_end_page(t4_state_t *s);
+
+/*! \brief End reception of a document. Tidy up and close the file.
+           This should be used to end T.4 reception started with
+           t4_rx_init.
+    \param s The T.4 receive context.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_rx_release(t4_state_t *s);
+
+/*! \brief End reception of a document. Tidy up, close the file and
+           free the context. This should be used to end T.4 reception
+           started with t4_rx_init.
+    \param s The T.4 receive context.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_rx_free(t4_state_t *s);
+
+/*! \brief Set the row write handler for a T.4 receive context.
+    \param s The T.4 receive context.
+    \param handler A pointer to the handler routine.
+    \param user_data An opaque pointer passed to the handler routine.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_state_t *s, t4_row_write_handler_t handler, void *user_data);
+
+/*! \brief Set the encoding for the received data.
+    \param s The T.4 context.
+    \param encoding The encoding. */
+SPAN_DECLARE(void) t4_rx_set_rx_encoding(t4_state_t *s, int encoding);
+
+/*! \brief Set the expected width of the received image, in pixel columns.
+    \param s The T.4 context.
+    \param width The number of pixels across the image. */
+SPAN_DECLARE(void) t4_rx_set_image_width(t4_state_t *s, int width);
+
+/*! \brief Set the row-to-row (y) resolution to expect for a received image.
+    \param s The T.4 context.
+    \param resolution The resolution, in pixels per metre. */
+SPAN_DECLARE(void) t4_rx_set_y_resolution(t4_state_t *s, int resolution);
+
+/*! \brief Set the column-to-column (x) resolution to expect for a received image.
+    \param s The T.4 context.
+    \param resolution The resolution, in pixels per metre. */
+SPAN_DECLARE(void) t4_rx_set_x_resolution(t4_state_t *s, int resolution);
+
+/*! \brief Set the DCS information of the fax, for inclusion in the file.
+    \param s The T.4 context.
+    \param dcs The DCS information, formatted as an ASCII string. */
+SPAN_DECLARE(void) t4_rx_set_dcs(t4_state_t *s, const char *dcs);
+
+/*! \brief Set the sub-address of the fax, for inclusion in the file.
+    \param s The T.4 context.
+    \param sub_address The sub-address string. */
+SPAN_DECLARE(void) t4_rx_set_sub_address(t4_state_t *s, const char *sub_address);
+
+/*! \brief Set the identity of the remote machine, for inclusion in the file.
+    \param s The T.4 context.
+    \param ident The identity string. */
+SPAN_DECLARE(void) t4_rx_set_far_ident(t4_state_t *s, const char *ident);
+
+/*! \brief Set the vendor of the remote machine, for inclusion in the file.
+    \param s The T.4 context.
+    \param vendor The vendor string, or NULL. */
+SPAN_DECLARE(void) t4_rx_set_vendor(t4_state_t *s, const char *vendor);
+
+/*! \brief Set the model of the remote machine, for inclusion in the file.
+    \param s The T.4 context.
+    \param model The model string, or NULL. */
+SPAN_DECLARE(void) t4_rx_set_model(t4_state_t *s, const char *model);
+
+/*! Get the current image transfer statistics. 
+    \brief Get the current transfer statistics.
+    \param s The T.4 context.
+    \param t A pointer to a statistics structure. */
+SPAN_DECLARE(void) t4_get_transfer_statistics(t4_state_t *s, t4_stats_t *t);
+
+/*! Get the short text name of an encoding format. 
+    \brief Get the short text name of an encoding format.
+    \param encoding The encoding type.
+    \return A pointer to the string. */
+SPAN_DECLARE(const char *) t4_encoding_to_str(int encoding);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspt4_txh"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/spandsp/t4_tx.h (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/t4_tx.h                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/t4_tx.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,179 @@
</span><ins>+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * t4_tx.h - definitions for T.4 FAX transmit processing
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2003 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t4_tx.h,v 1.2.2.3 2009/12/21 17:18:40 steveu Exp $
+ */
+
+/*! \file */
+
+#if !defined(_SPANDSP_T4_TX_H_)
+#define _SPANDSP_T4_TX_H_
+
+typedef int (*t4_row_read_handler_t)(void *user_data, uint8_t buf[], size_t len);
+
+#if defined(__cplusplus)
+extern &quot;C&quot; {
+#endif
+
+/*! \brief Prepare for transmission of a document.
+    \param s The T.4 context.
+    \param file The name of the file to be sent.
+    \param start_page The first page to send. -1 for no restriction.
+    \param stop_page The last page to send. -1 for no restriction.
+    \return A pointer to the context, or NULL if there was a problem. */
+SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page);
+
+/*! \brief Prepare to send the next page of the current document.
+    \param s The T.4 context.
+    \return zero for success, -1 for failure. */
+SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s);
+
+/*! \brief Prepare the current page for a resend.
+    \param s The T.4 context.
+    \return zero for success, -1 for failure. */
+SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s);
+
+/*! \brief Check for the existance of the next page, and whether its format is like the
+    current one. This information can be needed before it is determined that the current
+    page is finished with.
+    \param s The T.4 context.
+    \return 0 for next page found with the same format as the current page.
+            1 for next page found with different format from the current page.
+            -1 for no page found, or file failure. */
+SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s);
+
+/*! \brief Complete the sending of a page.
+    \param s The T.4 context.
+    \return zero for success, -1 for failure. */
+SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s);
+
+/*! \brief Return the next bit of the current document page, without actually
+           moving forward in the buffer. The document will be padded for the
+           current minimum scan line time.
+    \param s The T.4 context.
+    \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is
+            set (i.e. the returned value is 2 or 3). */
+SPAN_DECLARE(int) t4_tx_check_bit(t4_state_t *s);
+
+/*! \brief Get the next bit of the current document page. The document will
+           be padded for the current minimum scan line time.
+    \param s The T.4 context.
+    \return The next bit (i.e. 0 or 1). For the last bit of data, bit 1 is
+            set (i.e. the returned value is 2 or 3). */
+SPAN_DECLARE(int) t4_tx_get_bit(t4_state_t *s);
+
+/*! \brief Get the next byte of the current document page. The document will
+           be padded for the current minimum scan line time.
+    \param s The T.4 context.
+    \return The next byte. For the last byte of data, bit 8 is
+            set. In this case, one or more bits of the byte may be padded with
+            zeros, to complete the byte. */
+SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s);
+
+/*! \brief Get the next chunk of the current document page. The document will
+           be padded for the current minimum scan line time.
+    \param s The T.4 context.
+    \param buf The buffer into which the chunk is to written.
+    \param max_len The maximum length of the chunk.
+    \return The actual length of the chunk. If this is less than max_len it 
+            indicates that the end of the document has been reached. */
+SPAN_DECLARE(int) t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len);
+
+/*! \brief End the transmission of a document. Tidy up and close the file.
+           This should be used to end T.4 transmission started with t4_tx_init.
+    \param s The T.4 context.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_tx_release(t4_state_t *s);
+
+/*! \brief End the transmission of a document. Tidy up, close the file and
+           free the context. This should be used to end T.4 transmission
+           started with t4_tx_init.
+    \param s The T.4 context.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_tx_free(t4_state_t *s);
+
+/*! \brief Set the encoding for the encoded data.
+    \param s The T.4 context.
+    \param encoding The encoding. */
+SPAN_DECLARE(void) t4_tx_set_tx_encoding(t4_state_t *s, int encoding);
+
+/*! \brief Set the minimum number of encoded bits per row. This allows the
+           makes the encoding process to be set to comply with the minimum row
+           time specified by a remote receiving machine.
+    \param s The T.4 context.
+    \param bits The minimum number of bits per row. */
+SPAN_DECLARE(void) t4_tx_set_min_row_bits(t4_state_t *s, int bits);
+
+/*! \brief Set the identity of the local machine, for inclusion in page headers.
+    \param s The T.4 context.
+    \param ident The identity string. */
+SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident);
+
+/*! Set the info field, included in the header line included in each page of an encoded
+    FAX. This is a string of up to 50 characters. Other information (date, local ident, etc.)
+    are automatically included in the header. If the header info is set to NULL or a zero
+    length string, no header lines will be added to the encoded FAX.
+    \brief Set the header info.
+    \param s The T.4 context.
+    \param info A string, of up to 50 bytes, which will form the info field. */
+SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info);
+
+/*! \brief Set the row read handler for a T.4 transmit context.
+    \param s The T.4 transmit context.
+    \param handler A pointer to the handler routine.
+    \param user_data An opaque pointer passed to the handler routine.
+    \return 0 for success, otherwise -1. */
+SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data);
+
+/*! \brief Get the row-to-row (y) resolution of the current page.
+    \param s The T.4 context.
+    \return The resolution, in pixels per metre. */
+SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_state_t *s);
+
+/*! \brief Get the column-to-column (x) resolution of the current page.
+    \param s The T.4 context.
+    \return The resolution, in pixels per metre. */
+SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_state_t *s);
+
+/*! \brief Get the width of the current page, in pixel columns.
+    \param s The T.4 context.
+    \return The number of columns. */
+SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s);
+
+/*! \brief Get the number of pages in the file.
+    \param s The T.4 context.
+    \return The number of pages, or -1 if there is an error. */
+SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s);
+
+/*! \brief Get the currnet page number in the file.
+    \param s The T.4 context.
+    \return The page number, or -1 if there is an error. */
+SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s);
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandsptelephonyh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/telephony.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/telephony.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/telephony.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: telephony.h,v 1.18 2009/03/23 14:17:42 steveu Exp $
</del><ins>+ * $Id: telephony.h,v 1.18.4.2 2009/12/21 18:38:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if !defined(_SPANDSP_TELEPHONY_H_)
</span><span class="lines">@@ -69,8 +69,8 @@
</span><span class="cx"> /*! \brief A handler for transmit, where the buffer will be filled. */
</span><span class="cx"> typedef int (span_tx_handler_t)(void *s, int16_t amp[], int max_len);
</span><span class="cx"> 
</span><del>-#define ms_to_samples(t)            (((t)*SAMPLE_RATE)/1000)
-#define us_to_samples(t)            (((t)*SAMPLE_RATE)/1000000)
</del><ins>+#define ms_to_samples(t)            ((t)*(SAMPLE_RATE/1000))
+#define us_to_samples(t)            ((t)/(1000000/SAMPLE_RATE))
</ins><span class="cx"> 
</span><span class="cx"> #if !defined(FALSE)
</span><span class="cx"> #define FALSE 0
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspv18h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v18.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/v18.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v18.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v18.h,v 1.5 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: v18.h,v 1.6 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -69,14 +69,14 @@
</span><span class="cx"> /*! Initialise a V.18 context.
</span><span class="cx">     \brief Initialise a V.18 context.
</span><span class="cx">     \param s The V.18 context.
</span><del>-    \param caller TRUE if caller mode, else answerer mode.
</del><ins>+    \param calling_party TRUE if caller mode, else answerer mode.
</ins><span class="cx">     \param mode Mode of operation.
</span><span class="cx">     \param put_msg A callback routine called to deliver the received text
</span><span class="cx">            to the application.
</span><span class="cx">     \param user_data An opaque pointer for the callback routine.
</span><span class="cx">     \return A pointer to the V.18 context, or NULL if there was a problem. */
</span><span class="cx"> SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
</span><del>-                                     int caller,
</del><ins>+                                     int calling_party,
</ins><span class="cx">                                      int mode,
</span><span class="cx">                                      put_msg_func_t put_msg,
</span><span class="cx">                                      void *user_data);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspv22bish"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v22bis.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/v22bis.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v22bis.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v22bis.h,v 1.45 2009/07/09 13:52:09 steveu Exp $
</del><ins>+ * $Id: v22bis.h,v 1.46 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx">     \param s The modem context.
</span><span class="cx">     \param bit_rate The bit rate of the modem. Valid values are 1200 and 2400.
</span><span class="cx">     \param guard The guard tone option. 0 = none, 1 = 550Hz, 2 = 1800Hz.
</span><del>-    \param caller TRUE if this is the calling modem.
</del><ins>+    \param calling_party TRUE if this is the calling modem.
</ins><span class="cx">     \param get_bit The callback routine used to get the data to be transmitted.
</span><span class="cx">     \param put_bit The callback routine used to get the data to be transmitted.
</span><span class="cx">     \param user_data An opaque pointer, passed in calls to the get and put routines.
</span><span class="lines">@@ -172,7 +172,7 @@
</span><span class="cx"> SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s,
</span><span class="cx">                                            int bit_rate,
</span><span class="cx">                                            int guard,
</span><del>-                                           int caller,
</del><ins>+                                           int calling_party,
</ins><span class="cx">                                            get_bit_func_t get_bit,
</span><span class="cx">                                            void *get_bit_user_data,
</span><span class="cx">                                            put_bit_func_t put_bit,
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspv42h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v42.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/v42.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v42.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v42.h,v 1.30 2009/02/10 13:06:47 steveu Exp $
</del><ins>+ * $Id: v42.h,v 1.31 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \page v42_page V.42 modem error correction
</span><span class="lines">@@ -130,12 +130,12 @@
</span><span class="cx"> 
</span><span class="cx"> /*! Initialise a V.42 context.
</span><span class="cx">     \param s The V.42 context.
</span><del>-    \param caller TRUE if caller mode, else answerer mode.
</del><ins>+    \param calling_party TRUE if caller mode, else answerer mode.
</ins><span class="cx">     \param frame_handler A callback function to handle received frames of data.
</span><span class="cx">     \param user_data An opaque pointer passed to the frame handler routine.
</span><span class="cx">     \return ???
</span><span class="cx"> */
</span><del>-SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, int caller, int detect, v42_frame_handler_t frame_handler, void *user_data);
</del><ins>+SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, int calling_party, int detect, v42_frame_handler_t frame_handler, void *user_data);
</ins><span class="cx"> 
</span><span class="cx"> /*! Restart a V.42 context.
</span><span class="cx">     \param s The V.42 context.
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspv8h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/v8.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/v8.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/v8.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v8.h,v 1.28 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: v8.h,v 1.31 2009/11/04 16:10:14 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -50,13 +50,13 @@
</span><span class="cx"> enum v8_call_function_e
</span><span class="cx"> {
</span><span class="cx">     V8_CALL_TBS = 0,
</span><del>-    V8_CALL_H324,
-    V8_CALL_V18,
-    V8_CALL_T101,
-    V8_CALL_T30_TX,
-    V8_CALL_T30_RX,
-    V8_CALL_V_SERIES,
-    V8_CALL_FUNCTION_EXTENSION
</del><ins>+    V8_CALL_H324 = 1,
+    V8_CALL_V18 = 2,
+    V8_CALL_T101 = 3,
+    V8_CALL_T30_TX = 4,
+    V8_CALL_T30_RX = 5,
+    V8_CALL_V_SERIES = 6,
+    V8_CALL_FUNCTION_EXTENSION = 7
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum v8_modulation_e
</span><span class="lines">@@ -88,30 +88,33 @@
</span><span class="cx"> 
</span><span class="cx"> enum v8_pstn_access_e
</span><span class="cx"> {
</span><del>-    V8_PSTN_ACCESS_CALL_DCE_CELLULAR = 0x20,
-    V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR = 0x40,
-    V8_PSTN_ACCESS_DCE_ON_DIGTIAL = 0x80
</del><ins>+    V8_PSTN_ACCESS_CALL_DCE_CELLULAR = 0x01,
+    V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR = 0x02,
+    V8_PSTN_ACCESS_DCE_ON_DIGITAL = 0x04
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum v8_pcm_modem_availability_e
</span><span class="cx"> {
</span><del>-    V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE = 0x20,
-    V8_PSTN_PCM_MODEM_V90_V92_DIGITAL = 0x40,
-    V8_PSTN_PCM_MODEM_V91 = 0x80
</del><ins>+    V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE = 0x01,
+    V8_PSTN_PCM_MODEM_V90_V92_DIGITAL = 0x02,
+    V8_PSTN_PCM_MODEM_V91 = 0x04
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef struct v8_state_s v8_state_t;
</span><span class="cx"> 
</span><span class="cx"> struct v8_result_s
</span><span class="cx"> {
</span><ins>+    int modem_connect_tone_detected;
</ins><span class="cx">     int call_function;
</span><del>-    int available_modulations;
</del><ins>+    int far_end_modulations;
</ins><span class="cx">     int negotiated_modulation;
</span><span class="cx">     int protocol;
</span><span class="cx">     int pstn_access;
</span><span class="cx">     int nsf_seen;
</span><ins>+    int nsf;
</ins><span class="cx">     int pcm_modem_availability;
</span><span class="cx">     int t66_seen;
</span><ins>+    int t66;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #if defined(__cplusplus)
</span><span class="lines">@@ -122,14 +125,16 @@
</span><span class="cx"> /*! Initialise a V.8 context.
</span><span class="cx">     \brief Initialise a V.8 context.
</span><span class="cx">     \param s The V.8 context.
</span><del>-    \param caller TRUE if caller mode, else answerer mode.
</del><ins>+    \param calling_party TRUE if caller mode, else answerer mode.
+    \param use_ansam_pr TRUE if ANSam/ is to be used, else ANSam will be used.
</ins><span class="cx">     \param available_modulations A bitwise list of the modulation schemes to be
</span><span class="cx">            advertised as available here.
</span><span class="cx">     \param result_handler The callback routine used to handle the results of negotiation.
</span><span class="cx">     \param user_data An opaque pointer passed to the result_handler routine.
</span><span class="cx">     \return A pointer to the V.8 context, or NULL if there was a problem. */
</span><span class="cx"> SPAN_DECLARE(v8_state_t *) v8_init(v8_state_t *s,
</span><del>-                                   int caller,
</del><ins>+                                   int calling_party,
+                                   int use_ansam_pr,
</ins><span class="cx">                                    int available_modulations,
</span><span class="cx">                                    v8_result_handler_t *result_handler,
</span><span class="cx">                                    void *user_data);
</span><span class="lines">@@ -175,7 +180,9 @@
</span><span class="cx"> SPAN_DECLARE(const char *) v8_modulation_to_str(int modulation_scheme);
</span><span class="cx"> SPAN_DECLARE(const char *) v8_protocol_to_str(int protocol);
</span><span class="cx"> SPAN_DECLARE(const char *) v8_pstn_access_to_str(int pstn_access);
</span><ins>+SPAN_DECLARE(const char *) v8_nsf_to_str(int nsf);
</ins><span class="cx"> SPAN_DECLARE(const char *) v8_pcm_modem_availability_to_str(int pcm_modem_availability);
</span><ins>+SPAN_DECLARE(const char *) v8_t66_to_str(int t66);
</ins><span class="cx"> 
</span><span class="cx"> #if defined(__cplusplus)
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspversionh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -10,19 +10,19 @@
</span><span class="cx">  * All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * This program is free software; you can redistribute it and/or modify
</span><del>- * it under the terms of the GNU General Public License version 2, as
- * published by the Free Software Foundation.
</del><ins>+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
</ins><span class="cx">  *
</span><span class="cx">  * This program is distributed in the hope that it will be useful,
</span><span class="cx">  * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span class="cx">  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</span><del>- * GNU General Public License for more details.
</del><ins>+ * GNU Lesser General Public License for more details.
</ins><span class="cx">  *
</span><del>- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
</del><ins>+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
</ins><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: version.h.in,v 1.3 2009/03/01 12:39:02 steveu Exp $
</del><ins>+ * $Id: version.h.in,v 1.3.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if !defined(_SPANDSP_VERSION_H_)
</span><span class="lines">@@ -30,9 +30,9 @@
</span><span class="cx"> 
</span><span class="cx"> /* The date and time of the version are in UTC form. */
</span><span class="cx"> 
</span><del>-#define SPANDSP_RELEASE_DATE            20091005
-#define SPANDSP_RELEASE_TIME            163835
-#define SPANDSP_RELEASE_DATETIME_STRING &quot;20091005 163835&quot;
</del><ins>+#define SPANDSP_RELEASE_DATE            20091221
+#define SPANDSP_RELEASE_TIME            183911
+#define SPANDSP_RELEASE_DATETIME_STRING &quot;20091221 183911&quot;
</ins><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> /*- End of file ------------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandspversionhin"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp/version.h.in        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -10,19 +10,19 @@
</span><span class="cx">  * All rights reserved.
</span><span class="cx">  *
</span><span class="cx">  * This program is free software; you can redistribute it and/or modify
</span><del>- * it under the terms of the GNU General Public License version 2, as
- * published by the Free Software Foundation.
</del><ins>+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
</ins><span class="cx">  *
</span><span class="cx">  * This program is distributed in the hope that it will be useful,
</span><span class="cx">  * but WITHOUT ANY WARRANTY; without even the implied warranty of
</span><span class="cx">  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
</span><del>- * GNU General Public License for more details.
</del><ins>+ * GNU Lesser General Public License for more details.
</ins><span class="cx">  *
</span><del>- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
</del><ins>+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
</ins><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: version.h.in,v 1.3 2009/03/01 12:39:02 steveu Exp $
</del><ins>+ * $Id: version.h.in,v 1.3.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if !defined(_SPANDSP_VERSION_H_)
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcspandsphin"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/spandsp.h.in (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/spandsp.h.in        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/spandsp.h.in        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: spandsp.h.in,v 1.19 2009/09/22 13:11:04 steveu Exp $
</del><ins>+ * $Id: spandsp.h.in,v 1.19.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -96,7 +96,8 @@
</span><span class="cx"> #include &lt;spandsp/v18.h&gt;
</span><span class="cx"> #include &lt;spandsp/v42.h&gt;
</span><span class="cx"> #include &lt;spandsp/v42bis.h&gt;
</span><del>-#include &lt;spandsp/t4.h&gt;
</del><ins>+#include &lt;spandsp/t4_rx.h&gt;
+#include &lt;spandsp/t4_tx.h&gt;
</ins><span class="cx"> #include &lt;spandsp/t30.h&gt;
</span><span class="cx"> #include &lt;spandsp/t30_api.h&gt;
</span><span class="cx"> #include &lt;spandsp/t30_fcf.h&gt;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcsuper_tone_rxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/super_tone_rx.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/super_tone_rx.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/super_tone_rx.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: super_tone_rx.c,v 1.33 2009/02/10 13:06:46 steveu Exp $
</del><ins>+ * $Id: super_tone_rx.c,v 1.33.4.1 2009/12/19 09:47:56 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -218,8 +218,23 @@
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(int) super_tone_rx_free_descriptor(super_tone_rx_descriptor_t *desc)
</span><span class="cx"> {
</span><ins>+    int i;
+
</ins><span class="cx">     if (desc)
</span><ins>+    {
+        for (i = 0; i &lt; desc-&gt;tones; i++)
+        {
+            if (desc-&gt;tone_list[i])
+                free(desc-&gt;tone_list[i]);
+        }
+        if (desc-&gt;tone_list)
+            free(desc-&gt;tone_list);
+        if (desc-&gt;tone_segs)
+            free(desc-&gt;tone_segs);
+        if (desc-&gt;desc)
+            free(desc-&gt;desc);
</ins><span class="cx">         free(desc);
</span><ins>+    }
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct30c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t30.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t30.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t30.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t30.c,v 1.303 2009/09/21 15:51:18 steveu Exp $
</del><ins>+ * $Id: t30.c,v 1.305.4.3 2009/12/19 14:18:12 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -60,7 +60,8 @@
</span><span class="cx"> #include &quot;spandsp/v29tx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v27ter_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v27ter_tx.h&quot;
</span><del>-#include &quot;spandsp/t4.h&quot;
</del><ins>+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/t30_fcf.h&quot;
</span><span class="cx"> #include &quot;spandsp/t35.h&quot;
</span><span class="cx"> #include &quot;spandsp/t30.h&quot;
</span><span class="lines">@@ -68,8 +69,10 @@
</span><span class="cx"> #include &quot;spandsp/t30_logging.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp/private/logging.h&quot;
</span><del>-#include &quot;spandsp/private/t4.h&quot;
</del><ins>+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/private/t30.h&quot;
</span><ins>+#include &quot;spandsp/private/t30_dis_dtc_dcs_bits.h&quot;
</ins><span class="cx"> 
</span><span class="cx"> #include &quot;t30_local.h&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -215,108 +218,108 @@
</span><span class="cx"> /* All timers specified in milliseconds */
</span><span class="cx"> 
</span><span class="cx"> /*! Time-out T0 defines the amount of time an automatic calling terminal waits for the called terminal
</span><del>-to answer the call.
-T0 begins after the dialling of the number is completed and is reset:
-a) when T0 times out; or
-b) when timer T1 is started; or
-c) if the terminal is capable of detecting any condition which indicates that the call will not be
-   successful, when such a condition is detected.
-The recommended value of T0 is 60+-5s. However, when it is anticipated that a long call set-up
-time may be encountered, an alternative value of up to 120s may be used.
-NOTE - National regulations may require the use of other values for T0. */
</del><ins>+    to answer the call.
+    T0 begins after the dialling of the number is completed and is reset:
+    a) when T0 times out; or
+    b) when timer T1 is started; or
+    c) if the terminal is capable of detecting any condition which indicates that the call will not be
+       successful, when such a condition is detected.
+    The recommended value of T0 is 60+-5s. However, when it is anticipated that a long call set-up
+    time may be encountered, an alternative value of up to 120s may be used.
+    NOTE - National regulations may require the use of other values for T0. */
</ins><span class="cx"> #define DEFAULT_TIMER_T0                60000
</span><span class="cx"> 
</span><span class="cx"> /*! Time-out T1 defines the amount of time two terminals will continue to attempt to identify each
</span><del>-other. T1 is 35+-5s, begins upon entering phase B, and is reset upon detecting a valid signal or
-when T1 times out.
-For operating methods 3 and 4 (see 3.1), the calling terminal starts time-out T1 upon reception of
-the V.21 modulation scheme.
-For operating method 4 bis a (see 3.1), the calling terminal starts time-out T1 upon starting
-transmission using the V.21 modulation scheme.
-Annex A says T1 is also the timeout to be used for the receipt of the first HDLC frame after the
-start of high speed flags in ECM mode. This seems a strange reuse of the T1 name, so we distinguish
-it here by calling it T1A. */
</del><ins>+    other. T1 is 35+-5s, begins upon entering phase B, and is reset upon detecting a valid signal or
+    when T1 times out.
+    For operating methods 3 and 4 (see 3.1), the calling terminal starts time-out T1 upon reception of
+    the V.21 modulation scheme.
+    For operating method 4 bis a (see 3.1), the calling terminal starts time-out T1 upon starting
+    transmission using the V.21 modulation scheme.
+    Annex A says T1 is also the timeout to be used for the receipt of the first HDLC frame after the
+    start of high speed flags in ECM mode. This seems a strange reuse of the T1 name, so we distinguish
+    it here by calling it T1A. */
</ins><span class="cx"> #define DEFAULT_TIMER_T1                35000
</span><span class="cx"> #define DEFAULT_TIMER_T1A               35000
</span><span class="cx"> 
</span><span class="cx"> /*! Time-out T2 makes use of the tight control between commands and responses to detect the loss of
</span><del>-command/response synchronization. T2 is 6+-1s, and begins when initiating a command search
-(e.g., the first entrance into the &quot;command received&quot; subroutine, reference flow diagram in section 5.2).
-T2 is reset when an HDLC flag is received or when T2 times out. */
</del><ins>+    command/response synchronization. T2 is 6+-1s, and begins when initiating a command search
+    (e.g., the first entrance into the &quot;command received&quot; subroutine, reference flow diagram in section 5.2).
+    T2 is reset when an HDLC flag is received or when T2 times out. */
</ins><span class="cx"> #define DEFAULT_TIMER_T2                7000
</span><span class="cx"> 
</span><span class="cx"> /*! Once HDLC flags begin, T2 is reset, and a 3s timer begins. This timer is unnamed in T.30. Here we
</span><del>-term it T2A. No tolerance is specified for this timer. T2A specifies the maximum time to wait for the
-end of a frame, after the initial flag has been seen. */
</del><ins>+    term it T2A. No tolerance is specified for this timer. T2A specifies the maximum time to wait for the
+    end of a frame, after the initial flag has been seen. */
</ins><span class="cx"> #define DEFAULT_TIMER_T2A               3000
</span><span class="cx"> 
</span><span class="cx"> /*! If the HDLC carrier falls during reception, we need to apply a minimum time before continuing. If we
</span><del>-   don't, there are circumstances where we could continue and reply before the incoming signals have
-   really finished. E.g. if a bad DCS is received in a DCS-TCF sequence, we need wait for the TCF
-   carrier to pass, before continuing. This timer is specified as 200ms, but no tolerance is specified.
-   It is unnamed in T.30. Here we term it T2B */
</del><ins>+    don't, there are circumstances where we could continue and reply before the incoming signals have
+    really finished. E.g. if a bad DCS is received in a DCS-TCF sequence, we need wait for the TCF
+    carrier to pass, before continuing. This timer is specified as 200ms, but no tolerance is specified.
+    It is unnamed in T.30. Here we term it T2B */
</ins><span class="cx"> #define DEFAULT_TIMER_T2B               200
</span><span class="cx"> 
</span><span class="cx"> /*! Time-out T3 defines the amount of time a terminal will attempt to alert the local operator in
</span><del>-response to a procedural interrupt. Failing to achieve operator intervention, the terminal will
-discontinue this attempt and shall issue other commands or responses. T3 is 10+-5s, begins on the
-first detection of a procedural interrupt command/response signal (i.e., PIN/PIP or PRI-Q) and is
-reset when T3 times out or when the operator initiates a line request. */
</del><ins>+    response to a procedural interrupt. Failing to achieve operator intervention, the terminal will
+    discontinue this attempt and shall issue other commands or responses. T3 is 10+-5s, begins on the
+    first detection of a procedural interrupt command/response signal (i.e., PIN/PIP or PRI-Q) and is
+    reset when T3 times out or when the operator initiates a line request. */
</ins><span class="cx"> #define DEFAULT_TIMER_T3                15000
</span><span class="cx"> 
</span><span class="cx"> /*! Time-out T4 defines the amount of time a terminal will wait for flags to begin, when waiting for a
</span><del>-response from a remote terminal. T2 is 3s +-15%, and begins when initiating a response search
-(e.g., the first entrance into the &quot;response received&quot; subroutine, reference flow diagram in section 5.2).
-T4 is reset when an HDLC flag is received or when T4 times out.
-NOTE - For manual FAX units, the value of timer T4 may be either 3.0s +-15% or 4.5s +-15%.
-If the value of 4.5s is used, then after detection of a valid response to the first DIS, it may
-be reduced to 3.0s +-15%. T4 = 3.0s +-15% for automatic units. */
</del><ins>+    response from a remote terminal. T2 is 3s +-15%, and begins when initiating a response search
+    (e.g., the first entrance into the &quot;response received&quot; subroutine, reference flow diagram in section 5.2).
+    T4 is reset when an HDLC flag is received or when T4 times out.
+    NOTE - For manual FAX units, the value of timer T4 may be either 3.0s +-15% or 4.5s +-15%.
+    If the value of 4.5s is used, then after detection of a valid response to the first DIS, it may
+    be reduced to 3.0s +-15%. T4 = 3.0s +-15% for automatic units. */
</ins><span class="cx"> #define DEFAULT_TIMER_T4                3450
</span><span class="cx"> 
</span><span class="cx"> /*! Once HDLC flags begin, T4 is reset, and a 3s timer begins. This timer is unnamed in T.30. Here we
</span><del>-term it T4A. No tolerance is specified for this timer. T4A specifies the maximum time to wait for the
-end of a frame, after the initial flag has been seen. Note that a different timer is used for the fast
-HDLC in ECM mode, to provide time for physical paper handling. */
</del><ins>+    term it T4A. No tolerance is specified for this timer. T4A specifies the maximum time to wait for the
+    end of a frame, after the initial flag has been seen. Note that a different timer is used for the fast
+    HDLC in ECM mode, to provide time for physical paper handling. */
</ins><span class="cx"> #define DEFAULT_TIMER_T4A               3000
</span><span class="cx"> 
</span><span class="cx"> /*! If the HDLC carrier falls during reception, we need to apply a minimum time before continuing. if we
</span><del>-   don't, there are circumstances where we could continue and reply before the incoming signals have
-   really finished. E.g. if a bad DCS is received in a DCS-TCF sequence, we need wait for the TCF
-   carrier to pass, before continuing. This timer is specified as 200ms, but no tolerance is specified.
-   It is unnamed in T.30. Here we term it T4B */
</del><ins>+    don't, there are circumstances where we could continue and reply before the incoming signals have
+    really finished. E.g. if a bad DCS is received in a DCS-TCF sequence, we need wait for the TCF
+    carrier to pass, before continuing. This timer is specified as 200ms, but no tolerance is specified.
+    It is unnamed in T.30. Here we term it T4B */
</ins><span class="cx"> #define DEFAULT_TIMER_T4B               200
</span><span class="cx"> 
</span><span class="cx"> /*! Time-out T5 is defined for the optional T.4 error correction mode. Time-out T5 defines the amount
</span><del>-of time waiting for clearance of the busy condition of the receiving terminal. T5 is 60+-5s and
-begins on the first detection of the RNR response. T5 is reset when T5 times out or the MCF or PIP
-response is received or when the ERR or PIN response is received in the flow control process after
-transmitting the EOR command. If the timer T5 has expired, the DCN command is transmitted for
-call release. */
</del><ins>+    of time waiting for clearance of the busy condition of the receiving terminal. T5 is 60+-5s and
+    begins on the first detection of the RNR response. T5 is reset when T5 times out or the MCF or PIP
+    response is received or when the ERR or PIN response is received in the flow control process after
+    transmitting the EOR command. If the timer T5 has expired, the DCN command is transmitted for
+    call release. */
</ins><span class="cx"> #define DEFAULT_TIMER_T5                65000
</span><span class="cx"> 
</span><span class="cx"> /*! (Annex C - ISDN) Time-out T6 defines the amount of time two terminals will continue to attempt to
</span><del>-identify each other. T6 is 5+-0.5s. The timeout begins upon entering Phase B, and is reset upon
-detecting a valid signal, or when T6 times out. */
</del><ins>+    identify each other. T6 is 5+-0.5s. The timeout begins upon entering Phase B, and is reset upon
+    detecting a valid signal, or when T6 times out. */
</ins><span class="cx"> #define DEFAULT_TIMER_T6                5000
</span><span class="cx"> 
</span><span class="cx"> /*! (Annex C - ISDN) Time-out T7 is used to detect loss of command/response synchronization. T7 is 6+-1s.
</span><del>-The timeout begins when initiating a command search (e.g., the first entrance into the &quot;command received&quot;
-subroutine - see flow diagram in C.5) and is reset upon detecting a valid signal or when T7 times out. */
</del><ins>+    The timeout begins when initiating a command search (e.g., the first entrance into the &quot;command received&quot;
+    subroutine - see flow diagram in C.5) and is reset upon detecting a valid signal or when T7 times out. */
</ins><span class="cx"> #define DEFAULT_TIMER_T7                7000
</span><span class="cx"> 
</span><span class="cx"> /*! (Annex C - ISDN) Time-out T8 defines the amount of time waiting for clearance of the busy condition
</span><del>-of the receiving terminal. T8 is 10+-1s. The timeout begins on the first detection of the combination
-of no outstanding corrections and the RNR response. T8 is reset when T8 times out or MCF response is
-received. If the timer T8 expires, a DCN command is transmitted for call release. */
</del><ins>+    of the receiving terminal. T8 is 10+-1s. The timeout begins on the first detection of the combination
+    of no outstanding corrections and the RNR response. T8 is reset when T8 times out or MCF response is
+    received. If the timer T8 expires, a DCN command is transmitted for call release. */
</ins><span class="cx"> #define DEFAULT_TIMER_T8                10000
</span><span class="cx"> 
</span><span class="cx"> /*! Final time we allow for things to flush through the system, before we disconnect, in milliseconds.
</span><del>-   200ms should be fine for a PSTN call. For a T.38 call something longer is desirable. */
</del><ins>+    200ms should be fine for a PSTN call. For a T.38 call something longer is desirable. */
</ins><span class="cx"> #define FINAL_FLUSH_TIME                1000
</span><span class="cx"> 
</span><span class="cx"> /*! The number of PPRs received before CTC or EOR is sent in ECM mode. T.30 defines this as 4,
</span><del>-   but it could be varied, and the Japanese spec, for example, does make this value a
-   variable. */
</del><ins>+    but it could be varied, and the Japanese spec, for example, does make this value a
+    variable. */
</ins><span class="cx"> #define PPR_LIMIT_BEFORE_CTC_OR_EOR     4
</span><span class="cx"> 
</span><span class="cx"> /* HDLC message header byte values */
</span><span class="lines">@@ -401,10 +404,10 @@
</span><span class="cx">     switch (s-&gt;operation_in_progress)
</span><span class="cx">     {
</span><span class="cx">     case OPERATION_IN_PROGRESS_T4_TX:
</span><del>-        t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+        t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     case OPERATION_IN_PROGRESS_T4_RX:
</span><del>-        t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+        t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="lines">@@ -414,7 +417,7 @@
</span><span class="cx"> 
</span><span class="cx"> static int tx_start_page(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if (t4_tx_start_page(&amp;(s-&gt;t4)))
</del><ins>+    if (t4_tx_start_page(&amp;s-&gt;t4))
</ins><span class="cx">     {
</span><span class="cx">         terminate_operation_in_progress(s);
</span><span class="cx">         return -1;
</span><span class="lines">@@ -429,7 +432,7 @@
</span><span class="cx"> static int tx_end_page(t30_state_t *s)
</span><span class="cx"> {
</span><span class="cx">     s-&gt;retries = 0;
</span><del>-    if (t4_tx_end_page(&amp;(s-&gt;t4)) == 0)
</del><ins>+    if (t4_tx_end_page(&amp;s-&gt;t4) == 0)
</ins><span class="cx">     {
</span><span class="cx">         s-&gt;tx_page_number++;
</span><span class="cx">         s-&gt;ecm_block = 0;
</span><span class="lines">@@ -453,7 +456,7 @@
</span><span class="cx">     t4_rx_set_x_resolution(&amp;s-&gt;t4, s-&gt;x_resolution);
</span><span class="cx">     t4_rx_set_y_resolution(&amp;s-&gt;t4, s-&gt;y_resolution);
</span><span class="cx"> 
</span><del>-    if (t4_rx_start_page(&amp;(s-&gt;t4)))
</del><ins>+    if (t4_rx_start_page(&amp;s-&gt;t4))
</ins><span class="cx">         return -1;
</span><span class="cx">     /* Clear the buffer */
</span><span class="cx">     for (i = 0;  i &lt; 256;  i++)
</span><span class="lines">@@ -468,7 +471,7 @@
</span><span class="cx"> 
</span><span class="cx"> static int rx_end_page(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if (t4_rx_end_page(&amp;(s-&gt;t4)) == 0)
</del><ins>+    if (t4_rx_end_page(&amp;s-&gt;t4) == 0)
</ins><span class="cx">     {
</span><span class="cx">         s-&gt;rx_page_number++;
</span><span class="cx">         s-&gt;ecm_block = 0;
</span><span class="lines">@@ -619,7 +622,7 @@
</span><span class="cx">     int res;
</span><span class="cx">     int more;
</span><span class="cx"> 
</span><del>-    res = t4_tx_next_page_has_different_format(&amp;(s-&gt;t4));
</del><ins>+    res = t4_tx_next_page_has_different_format(&amp;s-&gt;t4);
</ins><span class="cx">     if (res == 0)
</span><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;More pages to come with the same format\n&quot;);
</span><span class="lines">@@ -628,7 +631,7 @@
</span><span class="cx">     if (res &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;More pages to come with a different format\n&quot;);
</span><del>-        s-&gt;tx_start_page = t4_tx_get_current_page_in_file(&amp;(s-&gt;t4)) + 1;
</del><ins>+        s-&gt;tx_start_page = t4_tx_get_current_page_in_file(&amp;s-&gt;t4) + 1;
</ins><span class="cx">         return (s-&gt;local_interrupt_pending)  ?  T30_PRI_EOM  :  T30_EOM;
</span><span class="cx">     }
</span><span class="cx">     /* Call a user handler, if one is set, to check if another document is to be sent.
</span><span class="lines">@@ -640,7 +643,7 @@
</span><span class="cx">         more = FALSE;
</span><span class="cx">     if (more)
</span><span class="cx">     {
</span><del>-        //if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 34))
</del><ins>+        //if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_MULTIPLE_SELECTIVE_POLLING_CAPABLE))
</ins><span class="cx">         //    return T30_EOS;
</span><span class="cx">         return (s-&gt;local_interrupt_pending)  ?  T30_PRI_EOM  :  T30_EOM;
</span><span class="cx">     }
</span><span class="lines">@@ -690,7 +693,7 @@
</span><span class="cx">     /* We filled the entire buffer */
</span><span class="cx">     s-&gt;ecm_frames = 256;
</span><span class="cx">     span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Partial page buffer full (%d per frame)\n&quot;, s-&gt;octets_per_ecm_frame);
</span><del>-    s-&gt;ecm_at_page_end = ((t4_tx_check_bit(&amp;(s-&gt;t4)) &amp; 2) != 0);
</del><ins>+    s-&gt;ecm_at_page_end = ((t4_tx_check_bit(&amp;s-&gt;t4) &amp; 2) != 0);
</ins><span class="cx">     return 256;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -900,28 +903,28 @@
</span><span class="cx"> 
</span><span class="cx"> static int send_psa_frame(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 35)  &amp;&amp;  s-&gt;tx_info.polled_sub_address[0])
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE)  &amp;&amp;  s-&gt;tx_info.polled_sub_address[0])
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending polled sub-address '%s'\n&quot;, s-&gt;tx_info.polled_sub_address);
</span><span class="cx">         send_20digit_msg_frame(s, T30_PSA, s-&gt;tx_info.polled_sub_address);
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 35);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE);
</ins><span class="cx">         return TRUE;
</span><span class="cx">     }
</span><del>-    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 35);
</del><ins>+    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE);
</ins><span class="cx">     return FALSE;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static int send_sep_frame(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 47)  &amp;&amp;  s-&gt;tx_info.selective_polling_address[0])
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE)  &amp;&amp;  s-&gt;tx_info.selective_polling_address[0])
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending selective polling address '%s'\n&quot;, s-&gt;tx_info.selective_polling_address);
</span><span class="cx">         send_20digit_msg_frame(s, T30_SEP, s-&gt;tx_info.selective_polling_address);
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 47);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE);
</ins><span class="cx">         return TRUE;
</span><span class="cx">     }
</span><del>-    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 47);
</del><ins>+    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE);
</ins><span class="cx">     return FALSE;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -929,14 +932,14 @@
</span><span class="cx"> static int send_sid_frame(t30_state_t *s)
</span><span class="cx"> {
</span><span class="cx">     /* Only send if there is an ID to send. */
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 50)  &amp;&amp;  s-&gt;tx_info.sender_ident[0])
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_PASSWORD)  &amp;&amp;  s-&gt;tx_info.sender_ident[0])
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending sender identification '%s'\n&quot;, s-&gt;tx_info.sender_ident);
</span><span class="cx">         send_20digit_msg_frame(s, T30_SID, s-&gt;tx_info.sender_ident);
</span><del>-        set_ctrl_bit(s-&gt;dcs_frame, 50);
</del><ins>+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_SENDER_ID_TRANSMISSION);
</ins><span class="cx">         return TRUE;
</span><span class="cx">     }
</span><del>-    clr_ctrl_bit(s-&gt;dcs_frame, 50);
</del><ins>+    clr_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_SENDER_ID_TRANSMISSION);
</ins><span class="cx">     return FALSE;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -944,14 +947,14 @@
</span><span class="cx"> static int send_pwd_frame(t30_state_t *s)
</span><span class="cx"> {
</span><span class="cx">     /* Only send if there is a password to send. */
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 50)  &amp;&amp;  s-&gt;tx_info.password[0])
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_PASSWORD)  &amp;&amp;  s-&gt;tx_info.password[0])
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending password '%s'\n&quot;, s-&gt;tx_info.password);
</span><span class="cx">         send_20digit_msg_frame(s, T30_PWD, s-&gt;tx_info.password);
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 50);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_PASSWORD);
</ins><span class="cx">         return TRUE;
</span><span class="cx">     }
</span><del>-    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 50);
</del><ins>+    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_PASSWORD);
</ins><span class="cx">     return FALSE;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -959,21 +962,21 @@
</span><span class="cx"> static int send_sub_frame(t30_state_t *s)
</span><span class="cx"> {
</span><span class="cx">     /* Only send if there is a sub-address to send. */
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 49)  &amp;&amp;  s-&gt;tx_info.sub_address[0])
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_SUBADDRESSING_CAPABLE)  &amp;&amp;  s-&gt;tx_info.sub_address[0])
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending sub-address '%s'\n&quot;, s-&gt;tx_info.sub_address);
</span><span class="cx">         send_20digit_msg_frame(s, T30_SUB, s-&gt;tx_info.sub_address);
</span><del>-        set_ctrl_bit(s-&gt;dcs_frame, 49);
</del><ins>+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_SUBADDRESS_TRANSMISSION);
</ins><span class="cx">         return TRUE;
</span><span class="cx">     }
</span><del>-    clr_ctrl_bit(s-&gt;dcs_frame, 49);
</del><ins>+    clr_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_SUBADDRESS_TRANSMISSION);
</ins><span class="cx">     return FALSE;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static int send_tsa_frame(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if ((test_ctrl_bit(s-&gt;far_dis_dtc_frame, 1)  ||  test_ctrl_bit(s-&gt;far_dis_dtc_frame, 3))  &amp;&amp;  0)
</del><ins>+    if ((test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T37)  ||  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T38))  &amp;&amp;  0)
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending transmitting subscriber internet address '%s'\n&quot;, &quot;&quot;);
</span><span class="cx">         return TRUE;
</span><span class="lines">@@ -984,20 +987,20 @@
</span><span class="cx"> 
</span><span class="cx"> static int send_ira_frame(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 102)  &amp;&amp;  0)
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_INTERNET_ROUTING_ADDRESS)  &amp;&amp;  0)
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending internet routing address '%s'\n&quot;, &quot;&quot;);
</span><del>-        set_ctrl_bit(s-&gt;dcs_frame, 102);
</del><ins>+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_INTERNET_ROUTING_ADDRESS_TRANSMISSION);
</ins><span class="cx">         return TRUE;
</span><span class="cx">     }
</span><del>-    clr_ctrl_bit(s-&gt;dcs_frame, 102);
</del><ins>+    clr_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_INTERNET_ROUTING_ADDRESS_TRANSMISSION);
</ins><span class="cx">     return FALSE;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static int send_cia_frame(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if ((test_ctrl_bit(s-&gt;far_dis_dtc_frame, 1)  ||  test_ctrl_bit(s-&gt;far_dis_dtc_frame, 3))  &amp;&amp;  0)
</del><ins>+    if ((test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T37)  ||  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T38))  &amp;&amp;  0)
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending calling subscriber internet address '%s'\n&quot;, &quot;&quot;);
</span><span class="cx">         return TRUE;
</span><span class="lines">@@ -1008,13 +1011,13 @@
</span><span class="cx"> 
</span><span class="cx"> static int send_isp_frame(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 101)  &amp;&amp;  0)
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS)  &amp;&amp;  0)
</ins><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Sending internet selective polling address '%s'\n&quot;, &quot;&quot;);
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 101);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS);
</ins><span class="cx">         return TRUE;
</span><span class="cx">     }
</span><del>-    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 101);
</del><ins>+    clr_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS);
</ins><span class="cx">     return FALSE;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -1058,14 +1061,14 @@
</span><span class="cx">     s-&gt;local_dis_dtc_frame[2] = (uint8_t) (T30_DIS | s-&gt;dis_received);
</span><span class="cx">     /* If we have a file name to receive into, then we are receive capable */
</span><span class="cx">     if (s-&gt;rx_file[0])
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 10);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_READY_TO_RECEIVE_FAX_DOCUMENT);
</ins><span class="cx">     else
</span><del>-        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 10);
</del><ins>+        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_READY_TO_RECEIVE_FAX_DOCUMENT);
</ins><span class="cx">     /* If we have a file name to transmit, then we are ready to transmit (polling) */
</span><span class="cx">     if (s-&gt;tx_file[0])
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 9);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_READY_TO_TRANSMIT_FAX_DOCUMENT);
</ins><span class="cx">     else
</span><del>-        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 9);
</del><ins>+        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_READY_TO_TRANSMIT_FAX_DOCUMENT);
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -1088,9 +1091,9 @@
</span><span class="cx">     /* Always say 256 octets per ECM frame preferred, as 64 is never used in the
</span><span class="cx">        real world. */
</span><span class="cx">     if ((s-&gt;iaf &amp; T30_IAF_MODE_T37))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 1);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T37);
</ins><span class="cx">     if ((s-&gt;iaf &amp; T30_IAF_MODE_T38))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 3);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T38);
</ins><span class="cx">     /* No 3G mobile  */
</span><span class="cx">     /* No V.8 */
</span><span class="cx">     /* 256 octets preferred - don't bother making this optional, as everything uses 256 */
</span><span class="lines">@@ -1121,57 +1124,67 @@
</span><span class="cx">     /* No scan-line padding required, but some may be specified by the application. */
</span><span class="cx">     set_ctrl_bits(s-&gt;local_dis_dtc_frame, s-&gt;local_min_scan_time_code, 21);
</span><span class="cx">     if ((s-&gt;supported_compressions &amp; T30_SUPPORT_NO_COMPRESSION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 26);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_UNCOMPRESSED_CAPABLE);
</ins><span class="cx">     if (s-&gt;ecm_allowed)
</span><span class="cx">     {
</span><span class="cx">         /* ECM allowed */
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 27);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_ECM_CAPABLE);
</ins><span class="cx">         /* Only offer the option of fancy compression schemes, if we are
</span><span class="cx">            also offering the ECM option needed to support them. */
</span><span class="cx">         if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T6_COMPRESSION))
</span><del>-            set_ctrl_bit(s-&gt;local_dis_dtc_frame, 31);
</del><ins>+            set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE);
</ins><span class="cx">         if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T43_COMPRESSION))
</span><del>-            set_ctrl_bit(s-&gt;local_dis_dtc_frame, 36);
</del><ins>+            set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T43_CAPABLE);
+#if 0
+        if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T45_COMPRESSION))
+            set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T45_CAPABLE);
+        if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T81_COMPRESSION))
+            set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T81_CAPABLE);
+        if ((s-&gt;supported_compressions &amp; T30_SUPPORT_SYCC_T81_COMPRESSION))
+            set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_SYCC_T81_CAPABLE);
</ins><span class="cx">         if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T85_COMPRESSION))
</span><del>-            set_ctrl_bit(s-&gt;local_dis_dtc_frame, 78);
</del><ins>+            set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE);
</ins><span class="cx">         /* No T.85 optional L0. */
</span><del>-        if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T45_COMPRESSION))
-            set_ctrl_bit(s-&gt;local_dis_dtc_frame, 116);
</del><ins>+        //if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T85_L0_COMPRESSION))
+        //    set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T85_L0_CAPABLE);
+        //if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T89_COMPRESSION))
+        //    set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T89_CAPABLE);
+#endif
</ins><span class="cx">     }
</span><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_FIELD_NOT_VALID))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 33);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_FNV_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_MULTIPLE_SELECTIVE_POLLING))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 34);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_MULTIPLE_SELECTIVE_POLLING_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_POLLED_SUB_ADDRESSING))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 35);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_POLLED_SUBADDRESSING_CAPABLE);
</ins><span class="cx">     /* No plane interleave */
</span><span class="cx">     /* No G.726 */
</span><span class="cx">     /* No extended voice coding */
</span><span class="cx">     if ((s-&gt;supported_resolutions &amp; T30_SUPPORT_SUPERFINE_RESOLUTION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 41);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_200_400_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_resolutions &amp; T30_SUPPORT_300_300_RESOLUTION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 42);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_300_300_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_resolutions &amp; (T30_SUPPORT_400_400_RESOLUTION | T30_SUPPORT_R16_RESOLUTION)))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 43);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_400_400_CAPABLE);
</ins><span class="cx">     /* Metric */ 
</span><del>-    set_ctrl_bit(s-&gt;local_dis_dtc_frame, 45);
</del><ins>+    set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_METRIC_RESOLUTION_PREFERRED);
</ins><span class="cx">     /* Superfine minimum scan line time pattern follows fine */
</span><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_SELECTIVE_POLLING))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 47);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_SELECTIVE_POLLING_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_SUB_ADDRESSING))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 49);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_SUBADDRESSING_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_IDENTIFICATION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 50);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_PASSWORD);
</ins><span class="cx">     /* Ready to transmit a data file (polling) */
</span><span class="cx">     if (s-&gt;tx_file[0])
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 51);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_READY_TO_TRANSMIT_DATA_FILE);
</ins><span class="cx">     /* No Binary file transfer (BFT) */
</span><span class="cx">     /* No Document transfer mode (DTM) */
</span><span class="cx">     /* No Electronic data interchange (EDI) */
</span><span class="cx">     /* No Basic transfer mode (BTM) */
</span><span class="cx">     /* No mixed mode (polling) */
</span><span class="cx">     /* No character mode */
</span><del>-    /* No mixed mode (Annex E/T.4) */
</del><ins>+    /* No mixed mode (T.4/Annex E) */
</ins><span class="cx">     /* No mode 26 (T.505) */
</span><span class="cx">     /* No digital network capability */
</span><span class="cx">     /* No duplex operation */
</span><span class="lines">@@ -1182,9 +1195,9 @@
</span><span class="cx">     /* No custom illuminant */
</span><span class="cx">     /* No custom gamut range */
</span><span class="cx">     if ((s-&gt;supported_image_sizes &amp; T30_SUPPORT_US_LETTER_LENGTH))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 76);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_NORTH_AMERICAN_LETTER_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_image_sizes &amp; T30_SUPPORT_US_LEGAL_LENGTH))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 77);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_NORTH_AMERICAN_LEGAL_CAPABLE);
</ins><span class="cx">     /* No HKM key management */
</span><span class="cx">     /* No RSA key management */
</span><span class="cx">     /* No override */
</span><span class="lines">@@ -1201,19 +1214,19 @@
</span><span class="cx">     /* No simple phase C BFT negotiations */
</span><span class="cx">     /* No extended BFT negotiations */
</span><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_INTERNET_SELECTIVE_POLLING_ADDRESS))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 101);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_INTERNET_SELECTIVE_POLLING_ADDRESS);
</ins><span class="cx">     if ((s-&gt;supported_t30_features &amp; T30_SUPPORT_INTERNET_ROUTING_ADDRESS))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 102);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_INTERNET_ROUTING_ADDRESS);
</ins><span class="cx">     if ((s-&gt;supported_resolutions &amp; T30_SUPPORT_600_600_RESOLUTION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 105);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_600_600_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_resolutions &amp; T30_SUPPORT_1200_1200_RESOLUTION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 106);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_1200_1200_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_resolutions &amp; T30_SUPPORT_300_600_RESOLUTION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 107);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_300_600_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_resolutions &amp; T30_SUPPORT_400_800_RESOLUTION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 108);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_400_800_CAPABLE);
</ins><span class="cx">     if ((s-&gt;supported_resolutions &amp; T30_SUPPORT_600_1200_RESOLUTION))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 109);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_600_1200_CAPABLE);
</ins><span class="cx">     /* No colour/grey scale 600x600 */
</span><span class="cx">     /* No colour/grey scale 1200x1200 */
</span><span class="cx">     /* No double sided printing (alternate mode) */
</span><span class="lines">@@ -1222,10 +1235,10 @@
</span><span class="cx">     /* No shared data memory */
</span><span class="cx">     /* No T.44 colour space */
</span><span class="cx">     if ((s-&gt;iaf &amp; T30_IAF_MODE_FLOW_CONTROL))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 121);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T38_FLOW_CONTROL_CAPABLE);
</ins><span class="cx">     /* No k &gt; 4 */
</span><span class="cx">     if ((s-&gt;iaf &amp; T30_IAF_MODE_CONTINUOUS_FLOW))
</span><del>-        set_ctrl_bit(s-&gt;local_dis_dtc_frame, 123);
</del><ins>+        set_ctrl_bit(s-&gt;local_dis_dtc_frame, T30_DIS_BIT_T38_FAX_CAPABLE);
</ins><span class="cx">     /* No T.89 profile */
</span><span class="cx">     s-&gt;local_dis_dtc_len = 19;
</span><span class="cx">     //t30_decode_dis_dtc_dcs(s, s-&gt;local_dis_dtc_frame, s-&gt;local_dis_dtc_len);
</span><span class="lines">@@ -1271,11 +1284,11 @@
</span><span class="cx"> 
</span><span class="cx"> #if 0
</span><span class="cx">     /* Check for T.37 simple mode. */
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 1))
-        set_ctrl_bit(s-&gt;dcs_frame, 1);
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T37))
+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_T37);
</ins><span class="cx">     /* Check for T.38 mode. */
</span><del>-    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, 3))
-        set_ctrl_bit(s-&gt;dcs_frame, 3);
</del><ins>+    if (test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T38))
+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_T38);
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     /* Set to required modem rate */
</span><span class="lines">@@ -1284,12 +1297,19 @@
</span><span class="cx">     /* Select the compression to use. */
</span><span class="cx">     switch (s-&gt;line_encoding)
</span><span class="cx">     {
</span><ins>+#if 0
+    case T4_COMPRESSION_ITU_T85:
+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_T85_MODE);
+        //set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_T85_L0_MODE);
+        set_ctrl_bits(s-&gt;dcs_frame, T30_MIN_SCAN_0MS, 21);
+        break;
+#endif
</ins><span class="cx">     case T4_COMPRESSION_ITU_T6:
</span><del>-        set_ctrl_bit(s-&gt;dcs_frame, 31);
</del><ins>+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_T6_MODE);
</ins><span class="cx">         set_ctrl_bits(s-&gt;dcs_frame, T30_MIN_SCAN_0MS, 21);
</span><span class="cx">         break;
</span><span class="cx">     case T4_COMPRESSION_ITU_T4_2D:
</span><del>-        set_ctrl_bit(s-&gt;dcs_frame, 16);
</del><ins>+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_2D_CODING);
</ins><span class="cx">         set_ctrl_bits(s-&gt;dcs_frame, s-&gt;min_scan_time_code, 21);
</span><span class="cx">         break;
</span><span class="cx">     case T4_COMPRESSION_ITU_T4_1D:
</span><span class="lines">@@ -1300,7 +1320,7 @@
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     /* We have a file to send, so tell the far end to go into receive mode. */
</span><del>-    set_ctrl_bit(s-&gt;dcs_frame, 10);
</del><ins>+    set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_RECEIVE_FAX_DOCUMENT);
</ins><span class="cx">     /* Set the Y resolution bits */
</span><span class="cx">     bad = T30_ERR_OK;
</span><span class="cx">     switch (s-&gt;y_resolution)
</span><span class="lines">@@ -1312,13 +1332,13 @@
</span><span class="cx">             if (!(s-&gt;supported_resolutions &amp; T30_SUPPORT_600_1200_RESOLUTION))
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="cx">             else
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 109);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_600_1200);
</ins><span class="cx">             break;
</span><span class="cx">         case T4_X_RESOLUTION_1200:
</span><span class="cx">             if (!(s-&gt;supported_resolutions &amp; T30_SUPPORT_1200_1200_RESOLUTION))
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="cx">             else
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 106);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_1200_1200);
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             bad = T30_ERR_NORESSUPPORT;
</span><span class="lines">@@ -1332,7 +1352,7 @@
</span><span class="cx">             if (!(s-&gt;supported_resolutions &amp; T30_SUPPORT_400_800_RESOLUTION))
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="cx">             else
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 108);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_400_800);
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             bad = T30_ERR_NORESSUPPORT;
</span><span class="lines">@@ -1346,13 +1366,13 @@
</span><span class="cx">             if (!(s-&gt;supported_resolutions &amp; T30_SUPPORT_300_600_RESOLUTION))
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="cx">             else
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 107);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_300_600);
</ins><span class="cx">             break;
</span><span class="cx">         case T4_X_RESOLUTION_600:
</span><span class="cx">             if (!(s-&gt;supported_resolutions &amp; T30_SUPPORT_600_600_RESOLUTION))
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="cx">             else
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 105);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_600_600);
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             bad = T30_ERR_NORESSUPPORT;
</span><span class="lines">@@ -1369,10 +1389,10 @@
</span><span class="cx">             switch (s-&gt;x_resolution)
</span><span class="cx">             {
</span><span class="cx">             case T4_X_RESOLUTION_R8:
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 41);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_200_400);
</ins><span class="cx">                 break;
</span><span class="cx">             case T4_X_RESOLUTION_R16:
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 43);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_400_400);
</ins><span class="cx">                 break;
</span><span class="cx">             default:
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="lines">@@ -1387,7 +1407,7 @@
</span><span class="cx">             if (!(s-&gt;supported_resolutions &amp; T30_SUPPORT_300_300_RESOLUTION))
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="cx">             else
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 42);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_300_300);
</ins><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             bad = T30_ERR_NORESSUPPORT;
</span><span class="lines">@@ -1404,7 +1424,7 @@
</span><span class="cx">             switch (s-&gt;x_resolution)
</span><span class="cx">             {
</span><span class="cx">             case T4_X_RESOLUTION_R8:
</span><del>-                set_ctrl_bit(s-&gt;dcs_frame, 15);
</del><ins>+                set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_200_200);
</ins><span class="cx">                 break;
</span><span class="cx">             default:
</span><span class="cx">                 bad = T30_ERR_NORESSUPPORT;
</span><span class="lines">@@ -1434,6 +1454,8 @@
</span><span class="cx">     /* Deal with the image width. The X resolution will fall in line with any valid width. */
</span><span class="cx">     /* Low (R4) res widths are not supported in recent versions of T.30 */
</span><span class="cx">     bad = T30_ERR_OK;
</span><ins>+    /* The following treats a width field of 11 like 10, which does what note 6 of Table 2/T.30
+       says we should do with the invalid value 11. */
</ins><span class="cx">     switch (s-&gt;image_width)
</span><span class="cx">     {
</span><span class="cx">     case T4_WIDTH_R8_A4:
</span><span class="lines">@@ -1451,7 +1473,7 @@
</span><span class="cx">         if ((s-&gt;far_dis_dtc_frame[5] &amp; (DISBIT2 | DISBIT1)) &lt; 1)
</span><span class="cx">             bad = T30_ERR_NOSIZESUPPORT;
</span><span class="cx">         else if (!(s-&gt;supported_image_sizes &amp; T30_SUPPORT_255MM_WIDTH))
</span><del>-            bad = T30_ERR_BADTIFF;
</del><ins>+            bad = T30_ERR_NOSIZESUPPORT;
</ins><span class="cx">         else
</span><span class="cx">             set_ctrl_bit(s-&gt;dcs_frame, 17);
</span><span class="cx">         break;
</span><span class="lines">@@ -1463,19 +1485,19 @@
</span><span class="cx">         if ((s-&gt;far_dis_dtc_frame[5] &amp; (DISBIT2 | DISBIT1)) &lt; 2)
</span><span class="cx">             bad = T30_ERR_NOSIZESUPPORT;
</span><span class="cx">         else if (!(s-&gt;supported_image_sizes &amp; T30_SUPPORT_303MM_WIDTH))    
</span><del>-            bad = T30_ERR_BADTIFF;
</del><ins>+            bad = T30_ERR_NOSIZESUPPORT;
</ins><span class="cx">         else
</span><span class="cx">             set_ctrl_bit(s-&gt;dcs_frame, 18);
</span><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="cx">         /* T.30 does not support this width */
</span><del>-        bad = T30_ERR_BADTIFF;
</del><ins>+        bad = T30_ERR_NOSIZESUPPORT;
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     if (bad != T30_ERR_OK)
</span><span class="cx">     {
</span><span class="cx">         s-&gt;current_status = bad;
</span><del>-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Image width (%d pixels) not a valid FAX image width\n&quot;, s-&gt;image_width);
</del><ins>+        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Image width (%d pixels) not an acceptable FAX image width\n&quot;, s-&gt;image_width);
</ins><span class="cx">         return -1;
</span><span class="cx">     }
</span><span class="cx">     switch (s-&gt;image_width)
</span><span class="lines">@@ -1488,36 +1510,36 @@
</span><span class="cx">     case T4_WIDTH_300_A4:
</span><span class="cx">     case T4_WIDTH_300_B4:
</span><span class="cx">     case T4_WIDTH_300_A3:
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 42)  &amp;&amp;  !test_ctrl_bit(s-&gt;far_dis_dtc_frame, 107))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_300_300_CAPABLE)  &amp;&amp;  !test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_300_600_CAPABLE))
</ins><span class="cx">             bad = T30_ERR_NOSIZESUPPORT;
</span><span class="cx">         break;
</span><span class="cx">     case T4_WIDTH_R16_A4:
</span><span class="cx">     case T4_WIDTH_R16_B4:
</span><span class="cx">     case T4_WIDTH_R16_A3:
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 43))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_400_400_CAPABLE))
</ins><span class="cx">             bad = T30_ERR_NOSIZESUPPORT;
</span><span class="cx">         break;
</span><span class="cx">     case T4_WIDTH_600_A4:
</span><span class="cx">     case T4_WIDTH_600_B4:
</span><span class="cx">     case T4_WIDTH_600_A3:
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 105)  &amp;&amp;  !test_ctrl_bit(s-&gt;far_dis_dtc_frame, 109))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_600_600_CAPABLE)  &amp;&amp;  !test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_600_1200_CAPABLE))
</ins><span class="cx">             bad = T30_ERR_NOSIZESUPPORT;
</span><span class="cx">         break;
</span><span class="cx">     case T4_WIDTH_1200_A4:
</span><span class="cx">     case T4_WIDTH_1200_B4:
</span><span class="cx">     case T4_WIDTH_1200_A3:
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 106))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_1200_1200_CAPABLE))
</ins><span class="cx">             bad = T30_ERR_NOSIZESUPPORT;
</span><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="cx">         /* T.30 does not support this width */
</span><del>-        bad = T30_ERR_BADTIFF;
</del><ins>+        bad = T30_ERR_NOSIZESUPPORT;
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     if (bad != T30_ERR_OK)
</span><span class="cx">     {
</span><span class="cx">         s-&gt;current_status = bad;
</span><del>-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Image width (%d pixels) not a valid FAX image width\n&quot;, s-&gt;image_width);
</del><ins>+        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Image width (%d pixels) not an acceptable FAX image width\n&quot;, s-&gt;image_width);
</ins><span class="cx">         return -1;
</span><span class="cx">     }
</span><span class="cx">     /* Deal with the image length */
</span><span class="lines">@@ -1529,12 +1551,19 @@
</span><span class="cx">         set_ctrl_bit(s-&gt;dcs_frame, 19);
</span><span class="cx"> 
</span><span class="cx">     if (s-&gt;error_correcting_mode)
</span><del>-        set_ctrl_bit(s-&gt;dcs_frame, 27);
</del><ins>+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_ECM);
</ins><span class="cx"> 
</span><del>-    if ((s-&gt;iaf &amp; T30_IAF_MODE_FLOW_CONTROL)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, 121))
-        set_ctrl_bit(s-&gt;dcs_frame, 121);
-    if ((s-&gt;iaf &amp; T30_IAF_MODE_CONTINUOUS_FLOW)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, 123))
-        set_ctrl_bit(s-&gt;dcs_frame, 123);
</del><ins>+    if ((s-&gt;iaf &amp; T30_IAF_MODE_FLOW_CONTROL)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T38_FLOW_CONTROL_CAPABLE))
+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_T38_FLOW_CONTROL_CAPABLE);
+    if ((s-&gt;iaf &amp; T30_IAF_MODE_CONTINUOUS_FLOW)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T38_FAX_CAPABLE))
+    {
+        /* Clear the modem type bits, in accordance with note 77 of Table 2/T.30 */
+        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 11);
+        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 12);
+        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 13);
+        clr_ctrl_bit(s-&gt;local_dis_dtc_frame, 14);
+        set_ctrl_bit(s-&gt;dcs_frame, T30_DCS_BIT_T38_FAX_MODE);
+    }
</ins><span class="cx">     s-&gt;dcs_len = 19;
</span><span class="cx">     //t30_decode_dis_dtc_dcs(s, s-&gt;dcs_frame, s-&gt;dcs_len);
</span><span class="cx">     return 0;
</span><span class="lines">@@ -1814,10 +1843,10 @@
</span><span class="cx">     switch (s-&gt;operation_in_progress)
</span><span class="cx">     {
</span><span class="cx">     case OPERATION_IN_PROGRESS_T4_TX:
</span><del>-        t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+        t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     case OPERATION_IN_PROGRESS_T4_RX:
</span><del>-        t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+        t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="lines">@@ -1855,16 +1884,16 @@
</span><span class="cx">     switch (s-&gt;y_resolution)
</span><span class="cx">     {
</span><span class="cx">     case T4_Y_RESOLUTION_SUPERFINE:
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 41))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_200_400_CAPABLE))
</ins><span class="cx">         {
</span><span class="cx">             s-&gt;current_status = T30_ERR_NORESSUPPORT;
</span><span class="cx">             span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Remote FAX does not support super-fine resolution.\n&quot;);
</span><span class="cx">             return -1;
</span><span class="cx">         }
</span><del>-        s-&gt;min_scan_time_code = translate_min_scan_time[(test_ctrl_bit(s-&gt;far_dis_dtc_frame, 46))  ?  2  :  1][min_bits_field];
</del><ins>+        s-&gt;min_scan_time_code = translate_min_scan_time[(test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_MIN_SCAN_TIME_HALVES))  ?  2  :  1][min_bits_field];
</ins><span class="cx">         break;
</span><span class="cx">     case T4_Y_RESOLUTION_FINE:
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 15))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_200_200_CAPABLE))
</ins><span class="cx">         {
</span><span class="cx">             s-&gt;current_status = T30_ERR_NORESSUPPORT;
</span><span class="cx">             span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Remote FAX does not support fine resolution.\n&quot;);
</span><span class="lines">@@ -1912,7 +1941,7 @@
</span><span class="cx">        must be evaluated before the minimum scan row bits can be evaluated. */
</span><span class="cx">     if ((min_row_bits = set_min_scan_time_code(s)) &lt; 0)
</span><span class="cx">     {
</span><del>-        t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+        t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">         s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">         return -1;
</span><span class="cx">     }
</span><span class="lines">@@ -1921,7 +1950,7 @@
</span><span class="cx"> 
</span><span class="cx">     if (tx_start_page(s))
</span><span class="cx">         return -1;
</span><del>-    s-&gt;image_width = t4_tx_get_image_width(&amp;(s-&gt;t4));
</del><ins>+    s-&gt;image_width = t4_tx_get_image_width(&amp;s-&gt;t4);
</ins><span class="cx">     if (s-&gt;error_correcting_mode)
</span><span class="cx">     {
</span><span class="cx">         if (get_partial_ecm_page(s) == 0)
</span><span class="lines">@@ -1933,7 +1962,7 @@
</span><span class="cx"> 
</span><span class="cx"> static int restart_sending_document(t30_state_t *s)
</span><span class="cx"> {
</span><del>-    t4_tx_restart_page(&amp;(s-&gt;t4));
</del><ins>+    t4_tx_restart_page(&amp;s-&gt;t4);
</ins><span class="cx">     s-&gt;retries = 0;
</span><span class="cx">     s-&gt;ecm_block = 0;
</span><span class="cx">     send_dcs_sequence(s, TRUE);
</span><span class="lines">@@ -2006,11 +2035,19 @@
</span><span class="cx">     /* 256 octets per ECM frame */
</span><span class="cx">     s-&gt;octets_per_ecm_frame = 256;
</span><span class="cx">     /* Select the compression to use. */
</span><del>-    if (s-&gt;error_correcting_mode  &amp;&amp;  (s-&gt;supported_compressions &amp; T30_SUPPORT_T6_COMPRESSION)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, 31))
</del><ins>+#if 0
+    if (s-&gt;error_correcting_mode  &amp;&amp;  (s-&gt;supported_compressions &amp; T30_SUPPORT_T85_COMPRESSION)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T85_CAPABLE))
</ins><span class="cx">     {
</span><ins>+        s-&gt;line_encoding = T4_COMPRESSION_ITU_T85;
+    }
+    else if (s-&gt;error_correcting_mode  &amp;&amp;  (s-&gt;supported_compressions &amp; T30_SUPPORT_T6_COMPRESSION)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE))
+#else
+    if (s-&gt;error_correcting_mode  &amp;&amp;  (s-&gt;supported_compressions &amp; T30_SUPPORT_T6_COMPRESSION)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_T6_CAPABLE))
+#endif
+    {
</ins><span class="cx">         s-&gt;line_encoding = T4_COMPRESSION_ITU_T6;
</span><span class="cx">     }
</span><del>-    else if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T4_2D_COMPRESSION)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, 16))
</del><ins>+    else if ((s-&gt;supported_compressions &amp; T30_SUPPORT_T4_2D_COMPRESSION)  &amp;&amp;  test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_2D_CAPABLE))
</ins><span class="cx">     {
</span><span class="cx">         s-&gt;line_encoding = T4_COMPRESSION_ITU_T4_2D;
</span><span class="cx">     }
</span><span class="lines">@@ -2018,7 +2055,7 @@
</span><span class="cx">     {
</span><span class="cx">         s-&gt;line_encoding = T4_COMPRESSION_ITU_T4_1D;
</span><span class="cx">     }
</span><del>-    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Selected compression %d\n&quot;, s-&gt;line_encoding);
</del><ins>+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Selected compression %s (%d)\n&quot;, t4_encoding_to_str(s-&gt;line_encoding), s-&gt;line_encoding);
</ins><span class="cx">     switch (s-&gt;far_dis_dtc_frame[4] &amp; (DISBIT6 | DISBIT5 | DISBIT4 | DISBIT3))
</span><span class="cx">     {
</span><span class="cx">     case (DISBIT6 | DISBIT4 | DISBIT3):
</span><span class="lines">@@ -2077,7 +2114,7 @@
</span><span class="cx">     if (s-&gt;tx_file[0])
</span><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Trying to send file '%s'\n&quot;, s-&gt;tx_file);
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 10))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_READY_TO_RECEIVE_FAX_DOCUMENT))
</ins><span class="cx">         {
</span><span class="cx">             span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s far end cannot receive\n&quot;, t30_frametype(msg[2]));
</span><span class="cx">             s-&gt;current_status = T30_ERR_RX_INCAPABLE;
</span><span class="lines">@@ -2103,7 +2140,7 @@
</span><span class="cx">     if (s-&gt;rx_file[0])
</span><span class="cx">     {
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Trying to receive file '%s'\n&quot;, s-&gt;rx_file);
</span><del>-        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, 9))
</del><ins>+        if (!test_ctrl_bit(s-&gt;far_dis_dtc_frame, T30_DIS_BIT_READY_TO_TRANSMIT_FAX_DOCUMENT))
</ins><span class="cx">         {
</span><span class="cx">             span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s far end cannot transmit\n&quot;, t30_frametype(msg[2]));
</span><span class="cx">             s-&gt;current_status = T30_ERR_TX_INCAPABLE;
</span><span class="lines">@@ -2174,30 +2211,30 @@
</span><span class="cx">             memset(dcs_frame + len, 0, T30_MAX_DIS_DTC_DCS_LEN - len);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    s-&gt;octets_per_ecm_frame = test_ctrl_bit(dcs_frame, 28)  ?  256  :  64;
</del><ins>+    s-&gt;octets_per_ecm_frame = test_ctrl_bit(dcs_frame, T30_DCS_BIT_64_OCTET_ECM_FRAMES)  ?  256  :  64;
</ins><span class="cx"> 
</span><del>-    if (test_ctrl_bit(dcs_frame, 106))
</del><ins>+    if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_1200_1200))
</ins><span class="cx">         s-&gt;x_resolution = T4_X_RESOLUTION_1200;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 105)  ||  test_ctrl_bit(dcs_frame, 109))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_600_600)  ||  test_ctrl_bit(dcs_frame, T30_DCS_BIT_600_1200))
</ins><span class="cx">         s-&gt;x_resolution = T4_X_RESOLUTION_600;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 43)  ||  test_ctrl_bit(dcs_frame, 108))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_400_400)  ||  test_ctrl_bit(dcs_frame, T30_DCS_BIT_400_800))
</ins><span class="cx">         s-&gt;x_resolution = T4_X_RESOLUTION_R16;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 42)  ||  test_ctrl_bit(dcs_frame, 107))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_300_300)  ||  test_ctrl_bit(dcs_frame, T30_DCS_BIT_300_600))
</ins><span class="cx">         s-&gt;x_resolution = T4_X_RESOLUTION_300;
</span><span class="cx">     else
</span><span class="cx">         s-&gt;x_resolution = T4_X_RESOLUTION_R8;
</span><span class="cx"> 
</span><del>-    if (test_ctrl_bit(dcs_frame, 106)  ||  test_ctrl_bit(dcs_frame, 109))
</del><ins>+    if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_1200_1200)  ||  test_ctrl_bit(dcs_frame, T30_DCS_BIT_600_1200))
</ins><span class="cx">         s-&gt;y_resolution = T4_Y_RESOLUTION_1200;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 108))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_400_800))
</ins><span class="cx">         s-&gt;y_resolution = T4_Y_RESOLUTION_800;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 105)  ||  test_ctrl_bit(dcs_frame, 107))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_600_600)  ||  test_ctrl_bit(dcs_frame, T30_DCS_BIT_300_600))
</ins><span class="cx">         s-&gt;y_resolution = T4_Y_RESOLUTION_600;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 41)  ||  test_ctrl_bit(dcs_frame, 43))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_200_400)  ||  test_ctrl_bit(dcs_frame, T30_DCS_BIT_400_400))
</ins><span class="cx">         s-&gt;y_resolution = T4_Y_RESOLUTION_SUPERFINE;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 42))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_300_300))
</ins><span class="cx">         s-&gt;y_resolution = T4_Y_RESOLUTION_300;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 15))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_200_200))
</ins><span class="cx">         s-&gt;y_resolution = T4_Y_RESOLUTION_FINE;
</span><span class="cx">     else
</span><span class="cx">         s-&gt;y_resolution = T4_Y_RESOLUTION_STANDARD;
</span><span class="lines">@@ -2218,14 +2255,20 @@
</span><span class="cx">     s-&gt;image_width = widths[i][dcs_frame[5] &amp; (DISBIT2 | DISBIT1)];
</span><span class="cx"> 
</span><span class="cx">     /* Check which compression we will use. */
</span><del>-    if (test_ctrl_bit(dcs_frame, 31))
</del><ins>+#if 0
+    if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T85_MODE))
+        s-&gt;line_encoding = T4_COMPRESSION_ITU_T85;
+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T6_MODE))
+#else
+    if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_T6_MODE))
+#endif
</ins><span class="cx">         s-&gt;line_encoding = T4_COMPRESSION_ITU_T6;
</span><del>-    else if (test_ctrl_bit(dcs_frame, 16))
</del><ins>+    else if (test_ctrl_bit(dcs_frame, T30_DCS_BIT_2D_CODING))
</ins><span class="cx">         s-&gt;line_encoding = T4_COMPRESSION_ITU_T4_2D;
</span><span class="cx">     else
</span><span class="cx">         s-&gt;line_encoding = T4_COMPRESSION_ITU_T4_1D;
</span><span class="cx">     span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Selected compression %d\n&quot;, s-&gt;line_encoding);
</span><del>-    if (!test_ctrl_bit(dcs_frame, 10))
</del><ins>+    if (!test_ctrl_bit(dcs_frame, T30_DCS_BIT_RECEIVE_FAX_DOCUMENT))
</ins><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_PROTOCOL_WARNING, &quot;Remote is not requesting receive in DCS\n&quot;);
</span><span class="cx"> 
</span><span class="cx">     if ((s-&gt;current_fallback = find_fallback_entry(dcs_frame[4] &amp; (DISBIT6 | DISBIT5 | DISBIT4 | DISBIT3))) &lt; 0)
</span><span class="lines">@@ -2233,7 +2276,7 @@
</span><span class="cx">         span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Remote asked for a modem standard we do not support\n&quot;);
</span><span class="cx">         return -1;
</span><span class="cx">     }
</span><del>-    s-&gt;error_correcting_mode = (test_ctrl_bit(dcs_frame, 27) != 0);
</del><ins>+    s-&gt;error_correcting_mode = (test_ctrl_bit(dcs_frame, T30_DCS_BIT_ECM) != 0);
</ins><span class="cx"> 
</span><span class="cx">     if (s-&gt;phase_b_handler)
</span><span class="cx">     {
</span><span class="lines">@@ -2671,7 +2714,6 @@
</span><span class="cx"> {
</span><span class="cx">     uint8_t fcf;
</span><span class="cx"> 
</span><del>-    /* We should be sending the TCF data right now */
</del><span class="cx">     fcf = msg[2] &amp; 0xFE;
</span><span class="cx">     switch (fcf)
</span><span class="cx">     {
</span><span class="lines">@@ -3055,14 +3097,14 @@
</span><span class="cx">         case T30_COPY_QUALITY_PERFECT:
</span><span class="cx">         case T30_COPY_QUALITY_GOOD:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_MCF);
</span><span class="cx">             break;
</span><span class="cx">         case T30_COPY_QUALITY_POOR:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_RTP);
</span><span class="lines">@@ -3113,14 +3155,14 @@
</span><span class="cx">         case T30_COPY_QUALITY_PERFECT:
</span><span class="cx">         case T30_COPY_QUALITY_GOOD:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_MCF);
</span><span class="cx">             break;
</span><span class="cx">         case T30_COPY_QUALITY_POOR:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_RTP);
</span><span class="lines">@@ -3140,7 +3182,7 @@
</span><span class="cx">         case T30_COPY_QUALITY_PERFECT:
</span><span class="cx">         case T30_COPY_QUALITY_GOOD:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_MCF);
</span><span class="lines">@@ -3148,7 +3190,7 @@
</span><span class="cx">             break;
</span><span class="cx">         case T30_COPY_QUALITY_POOR:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_RTP);
</span><span class="lines">@@ -3172,14 +3214,14 @@
</span><span class="cx">         case T30_COPY_QUALITY_PERFECT:
</span><span class="cx">         case T30_COPY_QUALITY_GOOD:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_MCF);
</span><span class="cx">             break;
</span><span class="cx">         case T30_COPY_QUALITY_POOR:
</span><span class="cx">             rx_end_page(s);
</span><del>-            t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             s-&gt;in_message = FALSE;
</span><span class="cx">             set_state(s, T30_STATE_III_Q_RTP);
</span><span class="lines">@@ -3516,7 +3558,7 @@
</span><span class="cx">             tx_end_page(s);
</span><span class="cx">             if (s-&gt;phase_d_handler)
</span><span class="cx">                 s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-            t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="cx">             {
</span><span class="lines">@@ -3530,7 +3572,7 @@
</span><span class="cx">             tx_end_page(s);
</span><span class="cx">             if (s-&gt;phase_d_handler)
</span><span class="cx">                 s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-            t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">             s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">             send_dcn(s);
</span><span class="cx">             if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="lines">@@ -3575,7 +3617,7 @@
</span><span class="cx">             tx_end_page(s);
</span><span class="cx">             if (s-&gt;phase_d_handler)
</span><span class="cx">                 s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-            t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">             /* TODO: should go back to T, and resend */
</span><span class="cx">             return_to_phase_b(s, TRUE);
</span><span class="cx">             break;
</span><span class="lines">@@ -3584,7 +3626,7 @@
</span><span class="cx">             tx_end_page(s);
</span><span class="cx">             if (s-&gt;phase_d_handler)
</span><span class="cx">                 s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-            t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+            t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">             send_dcn(s);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="lines">@@ -3895,7 +3937,7 @@
</span><span class="cx">                 tx_end_page(s);
</span><span class="cx">                 if (s-&gt;phase_d_handler)
</span><span class="cx">                     s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-                t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+                t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">                 s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">                 if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="cx">                 {
</span><span class="lines">@@ -3909,7 +3951,7 @@
</span><span class="cx">                 tx_end_page(s);
</span><span class="cx">                 if (s-&gt;phase_d_handler)
</span><span class="cx">                     s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-                t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+                t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">                 s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">                 send_dcn(s);
</span><span class="cx">                 if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="lines">@@ -3999,7 +4041,7 @@
</span><span class="cx">                 tx_end_page(s);
</span><span class="cx">                 if (s-&gt;phase_d_handler)
</span><span class="cx">                     s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-                t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+                t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">                 s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">                 if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="cx">                 {
</span><span class="lines">@@ -4013,7 +4055,7 @@
</span><span class="cx">                 tx_end_page(s);
</span><span class="cx">                 if (s-&gt;phase_d_handler)
</span><span class="cx">                     s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-                t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+                t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">                 s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">                 send_dcn(s);
</span><span class="cx">                 if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="lines">@@ -4119,7 +4161,7 @@
</span><span class="cx">                 tx_end_page(s);
</span><span class="cx">                 if (s-&gt;phase_d_handler)
</span><span class="cx">                     s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-                t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+                t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">                 s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">                 if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="cx">                 {
</span><span class="lines">@@ -4133,7 +4175,7 @@
</span><span class="cx">                 tx_end_page(s);
</span><span class="cx">                 if (s-&gt;phase_d_handler)
</span><span class="cx">                     s-&gt;phase_d_handler(s, s-&gt;phase_d_user_data, fcf);
</span><del>-                t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+                t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">                 s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span><span class="cx">                 send_dcn(s);
</span><span class="cx">                 if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="lines">@@ -5395,7 +5437,7 @@
</span><span class="cx">         break;
</span><span class="cx">     case T30_STATE_I:
</span><span class="cx">         /* Transferring real data. */
</span><del>-        bit = t4_tx_get_bit(&amp;(s-&gt;t4));
</del><ins>+        bit = t4_tx_get_bit(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     case T30_STATE_D_POST_TCF:
</span><span class="cx">     case T30_STATE_II_Q:
</span><span class="lines">@@ -5430,7 +5472,7 @@
</span><span class="cx">         break;
</span><span class="cx">     case T30_STATE_I:
</span><span class="cx">         /* Transferring real data. */
</span><del>-        byte = t4_tx_get_byte(&amp;(s-&gt;t4));
</del><ins>+        byte = t4_tx_get_byte(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     case T30_STATE_D_POST_TCF:
</span><span class="cx">     case T30_STATE_II_Q:
</span><span class="lines">@@ -5813,9 +5855,8 @@
</span><span class="cx">             }
</span><span class="cx">             break;
</span><span class="cx">         case T30_STATE_B:
</span><del>-            /* We have now allowed time for the last message to flush
-               through the system, so it is safe to report the end of the
-               call. */
</del><ins>+            /* We have now allowed time for the last message to flush through
+               the system, so it is safe to report the end of the call. */
</ins><span class="cx">             if (s-&gt;phase_e_handler)
</span><span class="cx">                 s-&gt;phase_e_handler(s, s-&gt;phase_e_user_data, s-&gt;current_status);
</span><span class="cx">             set_state(s, T30_STATE_CALL_FINISHED);
</span><span class="lines">@@ -5989,10 +6030,13 @@
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(void) t30_timer_update(t30_state_t *s, int samples)
</span><span class="cx"> {
</span><ins>+    int previous;
+
</ins><span class="cx">     if (s-&gt;timer_t0_t1 &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         if ((s-&gt;timer_t0_t1 -= samples) &lt;= 0)
</span><span class="cx">         {
</span><ins>+            s-&gt;timer_t0_t1 = 0;
</ins><span class="cx">             if (s-&gt;far_end_detected)
</span><span class="cx">                 timer_t1_expired(s);
</span><span class="cx">             else
</span><span class="lines">@@ -6002,13 +6046,21 @@
</span><span class="cx">     if (s-&gt;timer_t3 &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         if ((s-&gt;timer_t3 -= samples) &lt;= 0)
</span><ins>+        {
+            s-&gt;timer_t3 = 0;
</ins><span class="cx">             timer_t3_expired(s);
</span><ins>+        }
</ins><span class="cx">     }
</span><span class="cx">     if (s-&gt;timer_t2_t4 &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         if ((s-&gt;timer_t2_t4 -= samples) &lt;= 0)
</span><span class="cx">         {
</span><del>-            switch (s-&gt;timer_t2_t4_is)
</del><ins>+            previous = s-&gt;timer_t2_t4_is;
+            /* Don't allow the count to be left at a small negative number.
+               It looks cosmetically bad in the logs. */
+            s-&gt;timer_t2_t4 = 0;
+            s-&gt;timer_t2_t4_is = TIMER_IS_IDLE;
+            switch (previous)
</ins><span class="cx">             {
</span><span class="cx">             case TIMER_IS_T1A:
</span><span class="cx">                 timer_t1a_expired(s);
</span><span class="lines">@@ -6037,7 +6089,10 @@
</span><span class="cx">     if (s-&gt;timer_t5 &gt; 0)
</span><span class="cx">     {
</span><span class="cx">         if ((s-&gt;timer_t5 -= samples) &lt;= 0)
</span><ins>+        {
+            s-&gt;timer_t5 = 0;
</ins><span class="cx">             timer_t5_expired(s);
</span><ins>+        }
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -6199,10 +6254,10 @@
</span><span class="cx">     switch (s-&gt;operation_in_progress)
</span><span class="cx">     {
</span><span class="cx">     case OPERATION_IN_PROGRESS_T4_TX:
</span><del>-        t4_tx_release(&amp;(s-&gt;t4));
</del><ins>+        t4_tx_release(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     case OPERATION_IN_PROGRESS_T4_RX:
</span><del>-        t4_rx_release(&amp;(s-&gt;t4));
</del><ins>+        t4_rx_release(&amp;s-&gt;t4);
</ins><span class="cx">         break;
</span><span class="cx">     }
</span><span class="cx">     s-&gt;operation_in_progress = OPERATION_IN_PROGRESS_NONE;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct30_apic"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t30_api.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t30_api.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t30_api.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t30_api.c,v 1.13 2009/02/03 16:28:40 steveu Exp $
</del><ins>+ * $Id: t30_api.c,v 1.13.4.2 2009/12/19 14:18:13 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -60,7 +60,8 @@
</span><span class="cx"> #include &quot;spandsp/v29tx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v27ter_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v27ter_tx.h&quot;
</span><del>-#include &quot;spandsp/t4.h&quot;
</del><ins>+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/t30_fcf.h&quot;
</span><span class="cx"> #include &quot;spandsp/t35.h&quot;
</span><span class="cx"> #include &quot;spandsp/t30.h&quot;
</span><span class="lines">@@ -68,7 +69,8 @@
</span><span class="cx"> #include &quot;spandsp/t30_logging.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp/private/logging.h&quot;
</span><del>-#include &quot;spandsp/private/t4.h&quot;
</del><ins>+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/private/t30.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;t30_local.h&quot;
</span><span class="lines">@@ -83,7 +85,7 @@
</span><span class="cx">     if (strlen(id) &gt; T30_MAX_IDENT_LEN)
</span><span class="cx">         return -1;
</span><span class="cx">     strcpy(s-&gt;tx_info.ident, id);
</span><del>-    t4_tx_set_local_ident(&amp;(s-&gt;t4), s-&gt;tx_info.ident);
</del><ins>+    t4_tx_set_local_ident(&amp;s-&gt;t4, s-&gt;tx_info.ident);
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -544,7 +546,7 @@
</span><span class="cx">     if (strlen(info) &gt; T30_MAX_PAGE_HEADER_INFO)
</span><span class="cx">         return -1;
</span><span class="cx">     strcpy(s-&gt;header_info, info);
</span><del>-    t4_tx_set_header_info(&amp;(s-&gt;t4), s-&gt;header_info);
</del><ins>+    t4_tx_set_header_info(&amp;s-&gt;t4, s-&gt;header_info);
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct30_loggingc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t30_logging.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t30_logging.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t30_logging.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t30_logging.c,v 1.12 2009/04/12 09:12:10 steveu Exp $
</del><ins>+ * $Id: t30_logging.c,v 1.12.4.2 2009/12/19 10:44:10 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -60,14 +60,16 @@
</span><span class="cx"> #include &quot;spandsp/v29tx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v27ter_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v27ter_tx.h&quot;
</span><del>-#include &quot;spandsp/t4.h&quot;
</del><ins>+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/t30_fcf.h&quot;
</span><span class="cx"> #include &quot;spandsp/t35.h&quot;
</span><span class="cx"> #include &quot;spandsp/t30.h&quot;
</span><span class="cx"> #include &quot;spandsp/t30_logging.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp/private/logging.h&quot;
</span><del>-#include &quot;spandsp/private/t4.h&quot;
</del><ins>+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/private/t30.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;t30_local.h&quot;
</span><span class="lines">@@ -931,7 +933,7 @@
</span><span class="cx">     octet_bit_field(log, pkt, 121, &quot;Flow control capability for T.38 communication&quot;, NULL, NULL);
</span><span class="cx">     octet_bit_field(log, pkt, 122, &quot;K&gt;4&quot;, NULL, NULL);
</span><span class="cx">     octet_bit_field(log, pkt, 123, &quot;Internet aware T.38 mode fax (not affected by data signal rate bits)&quot;, NULL, NULL);
</span><del>-    octet_field(log, pkt, 124, 126, &quot;T.89 (Application profiles for ITU-T Rec T.8)&quot;, t89_profile_tags);
</del><ins>+    octet_field(log, pkt, 124, 126, &quot;T.89 (Application profiles for ITU-T Rec T.88)&quot;, t89_profile_tags);
</ins><span class="cx">     octet_bit_field(log, pkt, 127, &quot;sYCC-JPEG coding&quot;, NULL, NULL);
</span><span class="cx">     octet_bit_field(log, pkt, 128, &quot;Extension indicator&quot;, NULL, NULL);
</span><span class="cx">     if (!(pkt[18] &amp; DISBIT8))
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct31c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t31.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t31.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t31.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t31.c,v 1.153 2009/10/05 16:33:25 steveu Exp $
</del><ins>+ * $Id: t31.c,v 1.155.4.1 2009/12/19 10:44:10 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -74,7 +74,8 @@
</span><span class="cx"> #include &quot;spandsp/v17rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/super_tone_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/modem_connect_tones.h&quot;
</span><del>-#include &quot;spandsp/t4.h&quot;
</del><ins>+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/t30.h&quot;
</span><span class="cx"> #include &quot;spandsp/t30_logging.h&quot;
</span><span class="cx"> #include &quot;spandsp/t38_core.h&quot;
</span><span class="lines">@@ -1293,12 +1294,12 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void tone_detected(void *user_data, int on, int level, int delay)
</del><ins>+static void tone_detected(void *user_data, int tone, int level, int delay)
</ins><span class="cx"> {
</span><span class="cx">     t31_state_t *s;
</span><span class="cx"> 
</span><span class="cx">     s = (t31_state_t *) user_data;
</span><del>-    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;FAX tone declared %s (%ddBm0)\n&quot;, (on)  ?  &quot;on&quot;  :  &quot;off&quot;, level);
</del><ins>+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s detected (%ddBm0)\n&quot;, modem_connect_tone_to_str(tone), level);
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -1509,7 +1510,7 @@
</span><span class="cx">     s-&gt;hdlc_tx.len = 0;
</span><span class="cx">     s-&gt;dled = FALSE;
</span><span class="cx">     hdlc_rx_init(&amp;(s-&gt;audio.modems.hdlc_rx), FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept_frame, s);
</span><del>-    fsk_rx_init(&amp;(s-&gt;audio.modems.v21_rx), &amp;preset_fsk_specs[FSK_V21CH2], TRUE, (put_bit_func_t) hdlc_rx_put_bit, &amp;(s-&gt;audio.modems.hdlc_rx));
</del><ins>+    fsk_rx_init(&amp;(s-&gt;audio.modems.v21_rx), &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, &amp;(s-&gt;audio.modems.hdlc_rx));
</ins><span class="cx">     fsk_rx_signal_cutoff(&amp;(s-&gt;audio.modems.v21_rx), -39.09f);
</span><span class="cx">     s-&gt;at_state.transmit = TRUE;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct38_corec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t38_core.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t38_core.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t38_core.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_core.c,v 1.53 2009/07/14 13:54:22 steveu Exp $
</del><ins>+ * $Id: t38_core.c,v 1.54 2009/10/09 14:53:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -224,17 +224,17 @@
</span><span class="cx">     switch (profile)
</span><span class="cx">     {
</span><span class="cx">     case '1':
</span><del>-        return &quot;G3 Facsimile Terminal: (Sending Facsimile)&quot;;
</del><ins>+        return &quot;G3 FAX sending terminal&quot;;
</ins><span class="cx">     case '2':
</span><del>-        return &quot;G3 Facsimile Terminal: (Receiving Facsimile)&quot;;
</del><ins>+        return &quot;G3 FAX receiving terminal&quot;;
</ins><span class="cx">     case '3':
</span><del>-        return &quot;V.34 HDX and G3 Facsimile Terminal: (Sending Facsimile)&quot;;
</del><ins>+        return &quot;V.34 HDX and G3 FAX sending terminal&quot;;
</ins><span class="cx">     case '4':
</span><del>-        return &quot;V.34 HDX and G3 Facsimile Terminal: (Receiving Facsimile)&quot;;
</del><ins>+        return &quot;V.34 HDX and G3 FAX receiving terminal&quot;;
</ins><span class="cx">     case '5':
</span><del>-        return &quot;V.34 HDX-only Facsimile Terminal: (Sending Facsimile)&quot;;
</del><ins>+        return &quot;V.34 HDX-only FAX sending terminal&quot;;
</ins><span class="cx">     case '6':
</span><del>-        return &quot;V.34 HDX-only Facsimile Terminal: (Receiving Facsimile)&quot;;
</del><ins>+        return &quot;V.34 HDX-only FAX receiving terminal&quot;;
</ins><span class="cx">     }
</span><span class="cx">     return &quot;???&quot;;
</span><span class="cx"> }
</span><span class="lines">@@ -260,10 +260,10 @@
</span><span class="cx">             return &quot;NACK: No compatible mode available&quot;;
</span><span class="cx">         case '1':
</span><span class="cx">             /* Response for profiles 1 and 2 */
</span><del>-            return &quot;NACK: No V.34 fax, use G3 fax&quot;;
</del><ins>+            return &quot;NACK: No V.34 FAX, use G3 FAX&quot;;
</ins><span class="cx">         case '2':
</span><span class="cx">             /* Response for profiles 5 and 6 */
</span><del>-            return &quot;NACK: V.34 fax only.&quot;;
</del><ins>+            return &quot;NACK: V.34 only FAX.&quot;;
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     }
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct38_gatewayc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t38_gateway.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t38_gateway.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t38_gateway.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_gateway.c,v 1.164 2009/07/14 13:54:22 steveu Exp $
</del><ins>+ * $Id: t38_gateway.c,v 1.171.4.2 2009/12/19 10:44:10 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -73,7 +73,8 @@
</span><span class="cx"> #include &quot;spandsp/v17rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/super_tone_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/modem_connect_tones.h&quot;
</span><del>-#include &quot;spandsp/t4.h&quot;
</del><ins>+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/t30_fcf.h&quot;
</span><span class="cx"> #include &quot;spandsp/t35.h&quot;
</span><span class="cx"> #include &quot;spandsp/t30.h&quot;
</span><span class="lines">@@ -95,7 +96,8 @@
</span><span class="cx"> #include &quot;spandsp/private/modem_connect_tones.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/hdlc.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/fax_modems.h&quot;
</span><del>-#include &quot;spandsp/private/t4.h&quot;
</del><ins>+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/private/t30.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/t38_core.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/t38_non_ecm_buffer.h&quot;
</span><span class="lines">@@ -181,7 +183,7 @@
</span><span class="cx"> static void non_ecm_put_bit(void *user_data, int bit);
</span><span class="cx"> static void non_ecm_remove_fill_and_put_bit(void *user_data, int bit);
</span><span class="cx"> static void non_ecm_push_residue(t38_gateway_state_t *s);
</span><del>-static void tone_detected(void *user_data, int on, int level, int delay);
</del><ins>+static void tone_detected(void *user_data, int tone, int level, int delay);
</ins><span class="cx"> 
</span><span class="cx"> static void set_rx_handler(t38_gateway_state_t *s, span_rx_handler_t *handler, void *user_data)
</span><span class="cx"> {
</span><span class="lines">@@ -302,12 +304,12 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void tone_detected(void *user_data, int on, int level, int delay)
</del><ins>+static void tone_detected(void *user_data, int tone, int level, int delay)
</ins><span class="cx"> {
</span><span class="cx">     t38_gateway_state_t *s;
</span><span class="cx"> 
</span><span class="cx">     s = (t38_gateway_state_t *) user_data;
</span><del>-    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;FAX tone declared %s (%ddBm0)\n&quot;, (on)  ?  &quot;on&quot;  :  &quot;off&quot;, level);
</del><ins>+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s detected (%ddBm0)\n&quot;, modem_connect_tone_to_str(tone), level);
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -540,16 +542,16 @@
</span><span class="cx">         set_rx_active(s, TRUE);
</span><span class="cx">         break;
</span><span class="cx">     case T38_IND_V8_ANSAM:
</span><del>-        t-&gt;tx_bit_rate = 0;
</del><ins>+        t-&gt;tx_bit_rate = 300;
</ins><span class="cx">         break;
</span><span class="cx">     case T38_IND_V8_SIGNAL:
</span><del>-        t-&gt;tx_bit_rate = 0;
</del><ins>+        t-&gt;tx_bit_rate = 300;
</ins><span class="cx">         break;
</span><span class="cx">     case T38_IND_V34_CNTL_CHANNEL_1200:
</span><del>-        t-&gt;tx_bit_rate = 0;
</del><ins>+        t-&gt;tx_bit_rate = 1200;
</ins><span class="cx">         break;
</span><span class="cx">     case T38_IND_V34_PRI_CHANNEL:
</span><del>-        t-&gt;tx_bit_rate = 0;
</del><ins>+        t-&gt;tx_bit_rate = 33600;
</ins><span class="cx">         break;
</span><span class="cx">     case T38_IND_V34_CC_RETRAIN:
</span><span class="cx">         t-&gt;tx_bit_rate = 0;
</span><span class="lines">@@ -796,6 +798,13 @@
</span><span class="cx">     case T30_DCS | 1:
</span><span class="cx">         /* We need to check which modem type is about to be used, so we can start the
</span><span class="cx">            correct modem. */
</span><ins>+        s-&gt;core.fast_bit_rate = 0;
+        s-&gt;core.fast_rx_modem = T38_NONE;
+        s-&gt;core.image_data_mode = FALSE;
+        s-&gt;core.short_train = FALSE;
+        if (from_modem)
+            s-&gt;core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_BEGIN;
+        /*endif*/
</ins><span class="cx">         if (len &gt;= 5)
</span><span class="cx">         {
</span><span class="cx">             /* The table is short, and not searched often, so a brain-dead linear scan seems OK */
</span><span class="lines">@@ -807,8 +816,12 @@
</span><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             /*endfor*/
</span><ins>+            /* If we are processing a message from the modem side, the contents determine the fast receive modem.
+               we are to use. If it comes from the T.38 side the contents do not. */
</ins><span class="cx">             s-&gt;core.fast_bit_rate = modem_codes[i].bit_rate;
</span><del>-            s-&gt;core.fast_modem = modem_codes[i].modem_type;
</del><ins>+            if (from_modem)
+                s-&gt;core.fast_rx_modem = modem_codes[i].modem_type;
+            /*endif*/
</ins><span class="cx">         }
</span><span class="cx">         /*endif*/
</span><span class="cx">         if (len &gt;= 6)
</span><span class="lines">@@ -816,26 +829,34 @@
</span><span class="cx">             j = (buf[5] &amp; (DISBIT7 | DISBIT6 | DISBIT5)) &gt;&gt; 4;
</span><span class="cx">             span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Min bits test = 0x%X\n&quot;, buf[5]);
</span><span class="cx">             s-&gt;core.min_row_bits = (s-&gt;core.fast_bit_rate*minimum_scan_line_times[j])/1000;
</span><del>-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Min bits per row = %d\n&quot;, j);
</del><span class="cx">         }
</span><ins>+        else
+        {
+            s-&gt;core.min_row_bits = 0;
+        }
</ins><span class="cx">         /*endif*/
</span><span class="cx">         s-&gt;core.ecm_mode = (len &gt;= 7)  &amp;&amp;  (buf[6] &amp; DISBIT3);
</span><del>-        s-&gt;core.image_data_mode = FALSE;
-        s-&gt;core.short_train = FALSE;
-        if (from_modem)
-            s-&gt;core.timed_mode = TIMED_MODE_TCF_PREDICTABLE_MODEM_START_BEGIN;
-        /*endif*/
</del><ins>+        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Fast rx modem = %d/%d, ECM = %d, Min bits per row = %d\n&quot;, s-&gt;core.fast_rx_modem, s-&gt;core.fast_bit_rate, s-&gt;core.ecm_mode, s-&gt;core.min_row_bits);
</ins><span class="cx">         break;
</span><span class="cx">     case T30_PPS:
</span><span class="cx">     case T30_PPS | 1:
</span><span class="cx">         switch (buf[3] &amp; 0xFE)
</span><span class="cx">         {
</span><span class="cx">         case T30_EOP:
</span><ins>+        case T30_PRI_EOP:
</ins><span class="cx">         case T30_EOM:
</span><ins>+        case T30_PRI_EOM:
</ins><span class="cx">         case T30_EOS:
</span><ins>+#if 0
+            /* If we are hitting one of these conditions, it will take another DCS/DTC to select
+               the fast modem again, so abandon our idea of it. */
+            s-&gt;core.fast_bit_rate = 0;
+            s-&gt;core.fast_rx_modem = T38_NONE;
+            s-&gt;core.image_data_mode = FALSE;
+            s-&gt;core.short_train = FALSE;
+#endif
+            /* Fall through */
</ins><span class="cx">         case T30_MPS:
</span><del>-        case T30_PRI_EOP:
-        case T30_PRI_EOM:
</del><span class="cx">         case T30_PRI_MPS:
</span><span class="cx">             s-&gt;core.count_page_on_mcf = TRUE;
</span><span class="cx">             break;
</span><span class="lines">@@ -843,18 +864,27 @@
</span><span class="cx">         /*endswitch*/
</span><span class="cx">         break;
</span><span class="cx">     case T30_EOP:
</span><ins>+    case T30_EOP | 1:
+    case T30_PRI_EOP:
+    case T30_PRI_EOP | 1:
</ins><span class="cx">     case T30_EOM:
</span><ins>+    case T30_EOM | 1:
+    case T30_PRI_EOM:
+    case T30_PRI_EOM | 1:
</ins><span class="cx">     case T30_EOS:
</span><ins>+    case T30_EOS | 1:
+#if 0
+        /* If we are hitting one of these conditions, it will take another DCS/DTC to select
+           the fast modem again, so abandon our idea of t. */
+        s-&gt;core.fast_bit_rate = 0;
+        s-&gt;core.fast_rx_modem = T38_NONE;
+        s-&gt;core.image_data_mode = FALSE;
+        s-&gt;core.short_train = FALSE;
+#endif
+        /* Fall through */
</ins><span class="cx">     case T30_MPS:
</span><del>-    case T30_PRI_EOP:
-    case T30_PRI_EOM:
</del><ins>+    case T30_MPS | 1:
</ins><span class="cx">     case T30_PRI_MPS:
</span><del>-    case T30_EOP | 1:
-    case T30_EOM | 1:
-    case T30_EOS | 1:
-    case T30_MPS | 1:
-    case T30_PRI_EOP | 1:
-    case T30_PRI_EOM | 1:
</del><span class="cx">     case T30_PRI_MPS | 1:
</span><span class="cx">         s-&gt;core.count_page_on_mcf = TRUE;
</span><span class="cx">         break;
</span><span class="lines">@@ -1015,6 +1045,62 @@
</span><span class="cx"> 
</span><span class="cx">     s = (t38_gateway_state_t *) user_data;
</span><span class="cx">     xx = &amp;s-&gt;t38x;
</span><ins>+    /* There are a couple of special cases of data type that need their own treatment. */
+    switch (data_type)
+    {
+    case T38_DATA_V8:
+        switch (field_type)
+        {
+        case T38_FIELD_CM_MESSAGE:
+            if (len &gt;= 1)
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CM profile %d - %s\n&quot;, buf[0] - '0', t38_cm_profile_to_str(buf[0]));
+            else
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CM message - %d\n&quot;, len);
+            /*endif*/
+            break;
+        case T38_FIELD_JM_MESSAGE:
+            if (len &gt;= 2)
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;JM - %s\n&quot;, t38_jm_to_str(buf, len));
+            else
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for JM message - %d\n&quot;, len);
+            /*endif*/
+            break;
+        case T38_FIELD_CI_MESSAGE:
+            if (len &gt;= 1)
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CI 0x%X\n&quot;, buf[0]);
+            else
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CI message - %d\n&quot;, len);
+            /*endif*/
+            break;
+        default:
+            break;
+        }
+        /*endswitch*/
+        return 0;
+    case T38_DATA_V34_PRI_RATE:
+        switch (field_type)
+        {
+        case T38_FIELD_V34RATE:
+            if (len &gt;= 3)
+            {
+                xx-&gt;t38.v34_rate = t38_v34rate_to_bps(buf, len);
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;V.34 rate %d bps\n&quot;, xx-&gt;t38.v34_rate);
+            }   
+            else
+            {
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for V34rate message - %d\n&quot;, len);
+            }
+            /*endif*/
+            break;
+        default:
+            break;
+        }
+        /*endswitch*/
+        return 0;
+    default:
+        break;
+    }
+    /*endswitch*/
</ins><span class="cx">     switch (field_type)
</span><span class="cx">     {
</span><span class="cx">     case T38_FIELD_HDLC_DATA:
</span><span class="lines">@@ -1352,39 +1438,6 @@
</span><span class="cx">         /*endif*/
</span><span class="cx">         xx-&gt;corrupt_current_frame[0] = FALSE;
</span><span class="cx">         break;
</span><del>-    case T38_FIELD_CM_MESSAGE:
-        if (len &gt;= 1)
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CM profile %d - %s\n&quot;, buf[0] - '0', t38_cm_profile_to_str(buf[0]));
-        else
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CM message - %d\n&quot;, len);
-        /*endif*/
-        break;
-    case T38_FIELD_JM_MESSAGE:
-        if (len &gt;= 2)
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;JM - %s\n&quot;, t38_jm_to_str(buf, len));
-        else
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for JM message - %d\n&quot;, len);
-        /*endif*/
-        break;
-    case T38_FIELD_CI_MESSAGE:
-        if (len &gt;= 1)
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CI 0x%X\n&quot;, buf[0]);
-        else
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CI message - %d\n&quot;, len);
-        /*endif*/
-        break;
-    case T38_FIELD_V34RATE:
-        if (len &gt;= 3)
-        {
-            xx-&gt;t38.v34_rate = t38_v34rate_to_bps(buf, len);
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;V.34 rate %d bps\n&quot;, xx-&gt;t38.v34_rate);
-        }
-        else
-        {
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for V34rate message - %d\n&quot;, len);
-        }
-        /*endif*/
-        break;
</del><span class="cx">     default:
</span><span class="cx">         break;
</span><span class="cx">     }
</span><span class="lines">@@ -1944,14 +1997,14 @@
</span><span class="cx">         s-&gt;core.to_t38.in_bits = 0;
</span><span class="cx">         s-&gt;core.to_t38.out_octets = 0;
</span><span class="cx">     }
</span><del>-    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Restart rx modem - modem = %d, short train = %d, ECM = %d\n&quot;, s-&gt;core.fast_modem, s-&gt;core.short_train, s-&gt;core.ecm_mode);
</del><ins>+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Restart rx modem - modem = %d, short train = %d, ECM = %d\n&quot;, s-&gt;core.fast_rx_modem, s-&gt;core.short_train, s-&gt;core.ecm_mode);
</ins><span class="cx"> 
</span><span class="cx">     hdlc_rx_init(&amp;(s-&gt;audio.modems.hdlc_rx), FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, NULL, s);
</span><span class="cx">     s-&gt;audio.modems.rx_signal_present = FALSE;
</span><span class="cx">     s-&gt;audio.modems.rx_trained = FALSE;
</span><span class="cx">     /* Default to the transmit data being V.21, unless a faster modem pops up trained. */
</span><span class="cx">     s-&gt;t38x.current_tx_data_type = T38_DATA_V21;
</span><del>-    fsk_rx_init(&amp;(s-&gt;audio.modems.v21_rx), &amp;preset_fsk_specs[FSK_V21CH2], TRUE, (put_bit_func_t) t38_hdlc_rx_put_bit, &amp;(s-&gt;audio.modems.hdlc_rx));
</del><ins>+    fsk_rx_init(&amp;(s-&gt;audio.modems.v21_rx), &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) t38_hdlc_rx_put_bit, &amp;(s-&gt;audio.modems.hdlc_rx));
</ins><span class="cx"> #if 0
</span><span class="cx">     fsk_rx_signal_cutoff(&amp;(s-&gt;audio.modems.v21_rx), -45.5f);
</span><span class="cx"> #endif
</span><span class="lines">@@ -1971,7 +2024,7 @@
</span><span class="cx">     /*endif*/
</span><span class="cx">     to_t38_buffer_init(&amp;s-&gt;core.to_t38);
</span><span class="cx">     s-&gt;core.to_t38.octets_per_data_packet = 1;
</span><del>-    switch (s-&gt;core.fast_modem)
</del><ins>+    switch (s-&gt;core.fast_rx_modem)
</ins><span class="cx">     {
</span><span class="cx">     case T38_V17_RX:
</span><span class="cx">         v17_rx_restart(&amp;s-&gt;audio.modems.v17_rx, s-&gt;core.fast_bit_rate, s-&gt;core.short_train);
</span><span class="lines">@@ -2245,7 +2298,7 @@
</span><span class="cx">     t38_gateway_set_nsx_suppression(s, (const uint8_t *) &quot;\x00\x00\x00&quot;, 3, (const uint8_t *) &quot;\x00\x00\x00&quot;, 3);
</span><span class="cx"> 
</span><span class="cx">     s-&gt;core.to_t38.octets_per_data_packet = 1;
</span><del>-    s-&gt;core.ecm_allowed = FALSE;
</del><ins>+    s-&gt;core.ecm_allowed = TRUE;
</ins><span class="cx">     t38_non_ecm_buffer_init(&amp;s-&gt;core.non_ecm_to_modem, FALSE, 0);
</span><span class="cx">     restart_rx_modem(s);
</span><span class="cx">     s-&gt;core.timed_mode = TIMED_MODE_STARTUP;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct38_non_ecm_bufferc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t38_non_ecm_buffer.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_non_ecm_buffer.c,v 1.9 2009/10/05 16:33:25 steveu Exp $
</del><ins>+ * $Id: t38_non_ecm_buffer.c,v 1.9.4.1 2009/12/19 06:43:28 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -57,13 +57,22 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp/private/t38_non_ecm_buffer.h&quot;
</span><span class="cx"> 
</span><ins>+/* Phases */
+enum
+{
+    TCF_AT_INITIAL_ALL_ONES = 0,
+    TCF_AT_ALL_ZEROS = 1,
+    IMAGE_WAITING_FOR_FIRST_EOL = 2,
+    IMAGE_IN_PROGRESS = 3
+};
+
</ins><span class="cx"> static void restart_buffer(t38_non_ecm_buffer_state_t *s)
</span><span class="cx"> {
</span><span class="cx">     /* This should be called when draining the buffer is complete, which should
</span><span class="cx">        occur before any fresh data can possibly arrive to begin refilling it. */
</span><span class="cx">     s-&gt;octet = 0xFF;
</span><span class="cx">     s-&gt;flow_control_fill_octet = 0xFF;
</span><del>-    s-&gt;at_initial_all_ones = TRUE;
</del><ins>+    s-&gt;input_phase = (s-&gt;image_data_mode)  ?  IMAGE_WAITING_FOR_FIRST_EOL  :  TCF_AT_INITIAL_ALL_ONES;
</ins><span class="cx">     s-&gt;bit_stream = 0xFFFF;
</span><span class="cx">     s-&gt;out_ptr = 0;
</span><span class="cx">     s-&gt;in_ptr = 0;
</span><span class="lines">@@ -126,61 +135,164 @@
</span><span class="cx">     int upper;
</span><span class="cx">     int lower;
</span><span class="cx"> 
</span><ins>+    /* TCF consists of:
+            - zero or more ones, followed by
+            - about 1.5s of zeros
+       There may be a little junk at the end, as the modem shuts down.
+
+       We can stuff with extra ones in the initial period of all ones, and we can stuff with extra
+       zeros once the zeros start. The thing we need to be wary about is the odd zero bit in the
+       midst of the ones, due to a bit error. */
+
+    /* Non-ECM image data consists of:
+            - zero or more ones, followed by
+            - zero or more zeros, followed by
+            - an EOL (end of line), which marks the start of the image, followed by
+            - a succession of data rows, with an EOL at the end of each, followed by
+            - an RTC (return to control)
+       There may be a little junk at the end, as the modem shuts down.
+
+       An EOL 11 zeros followed by a one in a T.4 1D image or 11 zeros followed by a one followed
+       by a one or a zero in a T.4 2D image. An RTC consists of 6 EOLs in succession, with no
+       pixel data between them.
+    
+       We can stuff with ones until we get the first EOL into our buffer, then we can stuff with
+       zeros in front of each EOL at any point up the the RTC. We should not pad between the EOLs
+       which make up the RTC. Most FAX machines don't care about this, but a few will not recognise
+       the RTC if here is padding between the EOLs.
+    
+       We need to buffer whole rows before we output their beginning, so there is no possibility
+       of underflow mid-row. */
+
+    /* FoIP has latency issues, because of the fairly tight timeouts in the T.30 spec. We must
+       ensure our buffering does everything needed to avoid underflows, and to meet the minimum
+       row length requirements imposed by many mechanical FAX machines. We cannot, however,
+       afford to bulk up the data, by sending superfluous bytes. The resulting loop delay could
+       provoke an erroneous timeout of the acknowledgement signal. */
+
</ins><span class="cx">     i = 0;
</span><del>-    if (s-&gt;at_initial_all_ones)
</del><ins>+    switch (s-&gt;input_phase)
</ins><span class="cx">     {
</span><ins>+    case TCF_AT_INITIAL_ALL_ONES:
</ins><span class="cx">         /* Dump initial 0xFF bytes. We will add enough of our own to makes things flow
</span><span class="cx">            smoothly. If we don't strip these off, we might end up delaying the start of
</span><del>-           forwarding by a large amount, as we could end up with a large block of 0xFF
</del><ins>+           forwarding by a substantial amount, as we could end up with a large block of 0xFF
</ins><span class="cx">            bytes before the real data begins. This is especially true with PC FAX
</span><del>-           systems. This test is very simplistic, as a single bit error will throw it
-           off course. */
</del><ins>+           systems. This test is very simplistic, as bit errors could confuse it. */
</ins><span class="cx">         for (  ;  i &lt; len;  i++)
</span><span class="cx">         {
</span><span class="cx">             if (buf[i] != 0xFF)
</span><span class="cx">             {
</span><del>-                s-&gt;at_initial_all_ones = FALSE;
</del><ins>+                s-&gt;input_phase = TCF_AT_ALL_ZEROS;
+                s-&gt;flow_control_fill_octet = 0x00;
</ins><span class="cx">                 break;
</span><span class="cx">             }
</span><span class="cx">         }
</span><del>-    }
-    if (s-&gt;image_data_mode)
-    {
-        /* This is image data */
</del><ins>+        /* Fall through */
+    case TCF_AT_ALL_ZEROS:
</ins><span class="cx">         for (  ;  i &lt; len;  i++)
</span><span class="cx">         {
</span><del>-            /* Check for EOLs, because at an EOL we can pause and pump out zeros while
-               waiting for more incoming data. */
</del><ins>+            s-&gt;data[s-&gt;in_ptr] = buf[i];
+            s-&gt;latest_eol_ptr = s-&gt;in_ptr;
+            /* TODO: We can't buffer overflow, since we wrap around. However, the tail could
+                     overwrite itself if things fall badly behind. */
+            s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
+            s-&gt;in_octets++;
+        }
+        break;
+    case IMAGE_WAITING_FOR_FIRST_EOL:
+        /* Dump anything up to the first EOL. Let the output side stuff with 0xFF bytes while waiting
+           for that first EOL. What occurs before the first EOL is expected to be a period of all ones
+           and then a period of all zeros. We really don't care what junk might be there. By definition,
+           the image only starts at the first EOL. */
+        for (  ;  i &lt; len;  i++)
+        {
</ins><span class="cx">             if (buf[i])
</span><span class="cx">             {
</span><span class="cx">                 /* There might be an EOL here. Look for at least 11 zeros, followed by a one, split
</span><span class="cx">                    between two octets. Between those two octets we can insert numerous zero octets
</span><span class="cx">                    as a means of flow control. Note that we stuff in blocks of 8 bits, and not at
</span><span class="cx">                    the minimal level. */
</span><del>-                /* Or'ing with 0x800 here is simply to avoid zero words looking like they have -1
</del><ins>+                /* Or'ing with 0x800 here is to avoid zero words looking like they have -1
</ins><span class="cx">                    trailing zeros */
</span><span class="cx">                 upper = bottom_bit(s-&gt;bit_stream | 0x800);
</span><span class="cx">                 lower = top_bit(buf[i]);
</span><del>-                if (upper - lower &gt; 3)
</del><ins>+                if ((upper - lower) &gt; (11 - 8))
</ins><span class="cx">                 {
</span><ins>+                    /* This is an EOL - our first row is beginning. */
+                    s-&gt;input_phase = IMAGE_IN_PROGRESS;
+                    /* Start a new row */
+                    s-&gt;row_bits = lower - 8;
+                    s-&gt;latest_eol_ptr = s-&gt;in_ptr;
+                    s-&gt;flow_control_fill_octet = 0x00;
+
+                    /* If we push out two bytes of zero, and our latest non-zero byte
+                       we should definitely form a proper EOL to begin things, with a
+                       few harmless extra zero bits at the front. */
+                    s-&gt;data[s-&gt;in_ptr] = 0x00;
+                    s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
+                    s-&gt;data[s-&gt;in_ptr] = 0x00;
+                    s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
+                    s-&gt;data[s-&gt;in_ptr] = buf[i];
+                    s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
+                    s-&gt;in_octets += 3;
+                    s-&gt;bit_stream = (s-&gt;bit_stream &lt;&lt; 8) | buf[i];
+                    i++;
+                    break;
+                }
+            }
+            s-&gt;bit_stream = (s-&gt;bit_stream &lt;&lt; 8) | buf[i];
+        }
+        if (i &gt;= len)
+            break;
+        /* Fall through */
+    case IMAGE_IN_PROGRESS:
+        /* Now we have seen an EOL, we can stuff with zeros just in front of that EOL, or any
+           subsequent EOL that does not immediately follow a previous EOL (i.e. a candidate RTC).
+           We need to track our way through the image data, allowing the output side to only send
+           up to the last EOL. This prevents the possibility of underflow mid-row, where we cannot
+           safely stuff anything in the bit stream. */
+        for (  ;  i &lt; len;  i++)
+        {
+            if (buf[i])
+            {
+                /* There might be an EOL here. Look for at least 11 zeros, followed by a one, split
+                   between two octets. Between those two octets we can insert numerous zero octets
+                   as a means of flow control. Note that we stuff in blocks of 8 bits, and not at
+                   the minimal level. */
+                /* Or'ing with 0x800 here is to avoid zero words looking like they have -1
+                   trailing zeros */
+                upper = bottom_bit(s-&gt;bit_stream | 0x800);
+                lower = top_bit(buf[i]);
+                if ((upper - lower) &gt; (11 - 8))
+                {
+                    /* This is an EOL. */
</ins><span class="cx">                     s-&gt;row_bits += (8 - lower);
</span><del>-                    /* If the row is too short, extend it in chunks of a whole byte. */
-                    /* TODO: extend by the precise amount we should, instead of this
-                             rough approach. */
-                    while (s-&gt;row_bits &lt; s-&gt;min_row_bits)
</del><ins>+                    /* Make sure we don't stretch back to back EOLs, as that could spoil the RTC.
+                       This is a slightly crude check, as we don't know if we are processing a T.4 1D
+                       or T.4 2D image. Accepting 12 or 12 bits apart as meaning back to back is fine,
+                       as no 1D image row could be 1 bit long. */
+                    if (s-&gt;row_bits &lt; 12  ||  s-&gt;row_bits &gt; 13)
</ins><span class="cx">                     {
</span><del>-                        s-&gt;min_row_bits_fill_octets++;
-                        s-&gt;data[s-&gt;in_ptr] = 0;
-                        s-&gt;row_bits += 8;
-                        /* TODO: We can't buffer overflow, since we wrap around. However, the tail could
-                                 overwrite itself if things fall badly behind. */
-                        s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
</del><ins>+                        /* If the row is too short, extend it in chunks of a whole byte. */
+                        /* TODO: extend by the precise amount we should, instead of this
+                                 rough approach. */
+                        while (s-&gt;row_bits &lt; s-&gt;min_bits_per_row)
+                        {
+                            s-&gt;min_row_bits_fill_octets++;
+                            s-&gt;data[s-&gt;in_ptr] = 0;
+                            s-&gt;row_bits += 8;
+                            /* TODO: We can't buffer overflow, since we wrap around. However,
+                                     the tail could overwrite itself if things fall badly behind. */
+                            s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
+                        }
+                        /* This is now the limit for the output side, before it starts
+                           stuffing. */
+                        s-&gt;latest_eol_ptr = s-&gt;in_ptr;
</ins><span class="cx">                     }
</span><span class="cx">                     /* Start a new row */
</span><span class="cx">                     s-&gt;row_bits = lower - 8;
</span><span class="cx">                     s-&gt;in_rows++;
</span><del>-                    s-&gt;latest_eol_ptr = s-&gt;in_ptr;
-                    s-&gt;flow_control_fill_octet = 0x00;
</del><span class="cx">                 }
</span><span class="cx">             }
</span><span class="cx">             s-&gt;bit_stream = (s-&gt;bit_stream &lt;&lt; 8) | buf[i];
</span><span class="lines">@@ -191,27 +303,8 @@
</span><span class="cx">             s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
</span><span class="cx">             s-&gt;in_octets++;
</span><span class="cx">         }
</span><ins>+        break;
</ins><span class="cx">     }
</span><del>-    else
-    {
-        /* This is TCF data */
-        for (  ;  i &lt; len;  i++)
-        {
-            /* Check for zero bytes, as we can pause and pump out zeros while waiting
-               for more incoming data. Of course, the entire TCF data should be zero,
-               but it might not be, due to bit errors, or something weird happening. */
-            if (buf[i] == 0x00)
-            {
-                s-&gt;latest_eol_ptr = s-&gt;in_ptr;
-                s-&gt;flow_control_fill_octet = 0x00;
-            }
-            s-&gt;data[s-&gt;in_ptr] = buf[i];
-            /* TODO: We can't buffer overflow, since we wrap around. However, the tail could
-                     overwrite itself if things fall badly behind. */
-            s-&gt;in_ptr = (s-&gt;in_ptr + 1) &amp; (T38_NON_ECM_TX_BUF_LEN - 1);
-            s-&gt;in_octets++;
-        }
-    }
</del><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -249,14 +342,14 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-SPAN_DECLARE(void) t38_non_ecm_buffer_set_mode(t38_non_ecm_buffer_state_t *s, int mode, int min_row_bits)
</del><ins>+SPAN_DECLARE(void) t38_non_ecm_buffer_set_mode(t38_non_ecm_buffer_state_t *s, int mode, int min_bits_per_row)
</ins><span class="cx"> {
</span><span class="cx">     s-&gt;image_data_mode = mode;
</span><del>-    s-&gt;min_row_bits = min_row_bits;
</del><ins>+    s-&gt;min_bits_per_row = min_bits_per_row;
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-SPAN_DECLARE(t38_non_ecm_buffer_state_t *) t38_non_ecm_buffer_init(t38_non_ecm_buffer_state_t *s, int mode, int min_row_bits)
</del><ins>+SPAN_DECLARE(t38_non_ecm_buffer_state_t *) t38_non_ecm_buffer_init(t38_non_ecm_buffer_state_t *s, int mode, int min_bits_per_row)
</ins><span class="cx"> {
</span><span class="cx">     if (s == NULL)
</span><span class="cx">     {
</span><span class="lines">@@ -264,12 +357,9 @@
</span><span class="cx">             return NULL;
</span><span class="cx">     }
</span><span class="cx">     memset(s, 0, sizeof(*s));
</span><del>-    s-&gt;octet = 0xFF;
-    s-&gt;flow_control_fill_octet = 0xFF;
-    s-&gt;at_initial_all_ones = TRUE;
-    s-&gt;bit_stream = 0xFFFF;
</del><span class="cx">     s-&gt;image_data_mode = mode;
</span><del>-    s-&gt;min_row_bits = min_row_bits;
</del><ins>+    s-&gt;min_bits_per_row = min_bits_per_row;
+    restart_buffer(s);
</ins><span class="cx">     return s;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct38_terminalc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/t38_terminal.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t38_terminal.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/t38_terminal.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_terminal.c,v 1.128 2009/09/04 14:38:46 steveu Exp $
</del><ins>+ * $Id: t38_terminal.c,v 1.129.4.2 2009/12/19 10:44:10 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -63,7 +63,8 @@
</span><span class="cx"> #include &quot;spandsp/v27ter_rx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v17tx.h&quot;
</span><span class="cx"> #include &quot;spandsp/v17rx.h&quot;
</span><del>-#include &quot;spandsp/t4.h&quot;
</del><ins>+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/t30_fcf.h&quot;
</span><span class="cx"> #include &quot;spandsp/t35.h&quot;
</span><span class="cx"> #include &quot;spandsp/t30.h&quot;
</span><span class="lines">@@ -73,7 +74,8 @@
</span><span class="cx"> #include &quot;spandsp/t38_terminal.h&quot;
</span><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp/private/logging.h&quot;
</span><del>-#include &quot;spandsp/private/t4.h&quot;
</del><ins>+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
</ins><span class="cx"> #include &quot;spandsp/private/t30.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/t38_core.h&quot;
</span><span class="cx"> #include &quot;spandsp/private/t38_terminal.h&quot;
</span><span class="lines">@@ -231,8 +233,6 @@
</span><span class="cx">         front_end_status(s, T30_FRONT_END_CED_PRESENT);
</span><span class="cx">         break;
</span><span class="cx">     case T38_IND_V21_PREAMBLE:
</span><del>-        /* Some T.38 implementations insert these preamble indicators between HDLC frames, so
-           we need to be tolerant of that. */
</del><span class="cx">         fe-&gt;timeout_rx_samples = fe-&gt;samples + ms_to_samples(MID_RX_TIMEOUT);
</span><span class="cx">         front_end_status(s, T30_FRONT_END_SIGNAL_PRESENT);
</span><span class="cx">         break;
</span><span class="lines">@@ -248,6 +248,8 @@
</span><span class="cx">     case T38_IND_V17_12000_LONG_TRAINING:
</span><span class="cx">     case T38_IND_V17_14400_SHORT_TRAINING:
</span><span class="cx">     case T38_IND_V17_14400_LONG_TRAINING:
</span><ins>+    case T38_IND_V34_CNTL_CHANNEL_1200:
+    case T38_IND_V34_PRI_CHANNEL:
</ins><span class="cx">     case T38_IND_V33_12000_TRAINING:
</span><span class="cx">     case T38_IND_V33_14400_TRAINING:
</span><span class="cx">         /* We really don't care what kind of modem is delivering the following image data.
</span><span class="lines">@@ -257,22 +259,30 @@
</span><span class="cx">         break;
</span><span class="cx">     case T38_IND_V8_ANSAM:
</span><span class="cx">     case T38_IND_V8_SIGNAL:
</span><del>-    case T38_IND_V34_CNTL_CHANNEL_1200:
-    case T38_IND_V34_PRI_CHANNEL:
</del><span class="cx">     case T38_IND_V34_CC_RETRAIN:
</span><span class="cx">         /* V.34 support is a work in progress. */
</span><del>-        front_end_status(s, T30_FRONT_END_SIGNAL_PRESENT);
</del><span class="cx">         break;
</span><span class="cx">     default:
</span><span class="cx">         front_end_status(s, T30_FRONT_END_SIGNAL_ABSENT);
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    /*endswitch*/
</ins><span class="cx">     fe-&gt;hdlc_rx.len = 0;
</span><span class="cx">     fe-&gt;rx_data_missing = FALSE;
</span><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+static int fake_rx_indicator(t38_core_state_t *t, t38_terminal_state_t *s, int indicator)
+{
+    int ret;
+
+    ret = process_rx_indicator(t, s, indicator);
+    t-&gt;current_rx_indicator = indicator;
+    return ret;
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> static int process_rx_data(t38_core_state_t *t, void *user_data, int data_type, int field_type, const uint8_t *buf, int len)
</span><span class="cx"> {
</span><span class="cx">     t38_terminal_state_t *s;
</span><span class="lines">@@ -285,29 +295,64 @@
</span><span class="cx"> 
</span><span class="cx">     s = (t38_terminal_state_t *) user_data;
</span><span class="cx">     fe = &amp;s-&gt;t38_fe;
</span><del>-#if 0
-    /* In termination mode we don't care very much what the data type is. */
</del><ins>+    /* In termination mode we don't care very much what the data type is apart from a couple of
+       special cases. */
</ins><span class="cx">     switch (data_type)
</span><span class="cx">     {
</span><del>-    case T38_DATA_V21:
-    case T38_DATA_V27TER_2400:
-    case T38_DATA_V27TER_4800:
-    case T38_DATA_V29_7200:
-    case T38_DATA_V29_9600:
-    case T38_DATA_V17_7200:
-    case T38_DATA_V17_9600:
-    case T38_DATA_V17_12000:
-    case T38_DATA_V17_14400:
</del><span class="cx">     case T38_DATA_V8:
</span><ins>+        switch (field_type)
+        {
+        case T38_FIELD_CM_MESSAGE:
+            if (len &gt;= 1)
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CM profile %d - %s\n&quot;, buf[0] - '0', t38_cm_profile_to_str(buf[0]));
+            else
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CM message - %d\n&quot;, len);
+            //front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
+            break;
+        case T38_FIELD_JM_MESSAGE:
+            if (len &gt;= 2)
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;JM - %s\n&quot;, t38_jm_to_str(buf, len));
+            else
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for JM message - %d\n&quot;, len);
+            //front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
+            break;
+        case T38_FIELD_CI_MESSAGE:
+            if (len &gt;= 1)
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CI 0x%X\n&quot;, buf[0]);
+            else
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CI message - %d\n&quot;, len);
+            //front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
+            break;
+        default:
+            break;
+        }
+        /*endswitch*/
+        return 0;
</ins><span class="cx">     case T38_DATA_V34_PRI_RATE:
</span><del>-    case T38_DATA_V34_CC_1200:
-    case T38_DATA_V34_PRI_CH:
-    case T38_DATA_V33_12000:
-    case T38_DATA_V33_14400:
</del><ins>+        switch (field_type)
+        {
+        case T38_FIELD_V34RATE:
+            if (len &gt;= 3)
+            {
+                /* Just get and store the rate. The front end has no real interest in the
+                   actual bit rate. */
+                fe-&gt;t38.v34_rate = t38_v34rate_to_bps(buf, len);
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;V.34 rate %d bps\n&quot;, fe-&gt;t38.v34_rate);
+            }
+            else
+            {
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for V34rate message - %d\n&quot;, len);
+            }
+            break;
+        default:
+            break;
+        }
+        /*endswitch*/
+        return 0;
</ins><span class="cx">     default:
</span><span class="cx">         break;
</span><span class="cx">     }
</span><del>-#endif
</del><ins>+    /*endswitch*/
</ins><span class="cx">     switch (field_type)
</span><span class="cx">     {
</span><span class="cx">     case T38_FIELD_HDLC_DATA:
</span><span class="lines">@@ -316,8 +361,7 @@
</span><span class="cx">             /* HDLC can just start without any signal indicator on some platforms, even when
</span><span class="cx">                there is zero packet lost. Nasty, but true. Its a good idea to be tolerant of
</span><span class="cx">                loss, though, so accepting a sudden start of HDLC data is the right thing to do. */
</span><del>-            fe-&gt;timeout_rx_samples = fe-&gt;samples + ms_to_samples(MID_RX_TIMEOUT);
-            front_end_status(s, T30_FRONT_END_SIGNAL_PRESENT);
</del><ins>+            fake_rx_indicator(t, s, T38_IND_V21_PREAMBLE);
</ins><span class="cx">             /* All real HDLC messages in the FAX world start with 0xFF. If this one is not starting
</span><span class="cx">                with 0xFF it would appear some octets must have been missed before this one. */
</span><span class="cx">             if (len &lt;= 0  ||  buf[0] != 0xFF)
</span><span class="lines">@@ -386,7 +430,8 @@
</span><span class="cx">         }
</span><span class="cx">         fe-&gt;hdlc_rx.len = 0;
</span><span class="cx">         fe-&gt;rx_data_missing = FALSE;
</span><del>-        fe-&gt;timeout_rx_samples = 0;
</del><ins>+        /* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
+        fake_rx_indicator(t, s, T38_IND_NO_SIGNAL);
</ins><span class="cx">         break;
</span><span class="cx">     case T38_FIELD_HDLC_FCS_BAD_SIG_END:
</span><span class="cx">         if (len &gt; 0)
</span><span class="lines">@@ -406,7 +451,8 @@
</span><span class="cx">         }
</span><span class="cx">         fe-&gt;hdlc_rx.len = 0;
</span><span class="cx">         fe-&gt;rx_data_missing = FALSE;
</span><del>-        fe-&gt;timeout_rx_samples = 0;
</del><ins>+        /* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
+        fake_rx_indicator(t, s, T38_IND_NO_SIGNAL);
</ins><span class="cx">         break;
</span><span class="cx">     case T38_FIELD_HDLC_SIG_END:
</span><span class="cx">         if (len &gt; 0)
</span><span class="lines">@@ -428,9 +474,10 @@
</span><span class="cx">                The other is because the HDLC signal drops unexpectedly - i.e. not just after a final frame. */
</span><span class="cx">             fe-&gt;hdlc_rx.len = 0;
</span><span class="cx">             fe-&gt;rx_data_missing = FALSE;
</span><del>-            fe-&gt;timeout_rx_samples = 0;
</del><span class="cx">             front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
</span><span class="cx">         }
</span><ins>+        /* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
+        fake_rx_indicator(t, s, T38_IND_NO_SIGNAL);
</ins><span class="cx">         break;
</span><span class="cx">     case T38_FIELD_T4_NON_ECM_DATA:
</span><span class="cx">         if (!fe-&gt;rx_signal_present)
</span><span class="lines">@@ -468,40 +515,13 @@
</span><span class="cx">             front_end_status(s, T30_FRONT_END_RECEIVE_COMPLETE);
</span><span class="cx">         }
</span><span class="cx">         fe-&gt;rx_signal_present = FALSE;
</span><del>-        fe-&gt;timeout_rx_samples = 0;
</del><ins>+        /* Treat this like a no signal indicator has occurred, so if the no signal indicator is missing, we are still OK */
+        fake_rx_indicator(t, s, T38_IND_NO_SIGNAL);
</ins><span class="cx">         break;
</span><del>-    case T38_FIELD_CM_MESSAGE:
-        if (len &gt;= 1)
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CM profile %d - %s\n&quot;, buf[0] - '0', t38_cm_profile_to_str(buf[0]));
-        else
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CM message - %d\n&quot;, len);
-        break;
-    case T38_FIELD_JM_MESSAGE:
-        if (len &gt;= 2)
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;JM - %s\n&quot;, t38_jm_to_str(buf, len));
-        else
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for JM message - %d\n&quot;, len);
-        break;
-    case T38_FIELD_CI_MESSAGE:
-        if (len &gt;= 1)
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CI 0x%X\n&quot;, buf[0]);
-        else
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for CI message - %d\n&quot;, len);
-        break;
-    case T38_FIELD_V34RATE:
-        if (len &gt;= 3)
-        {
-            fe-&gt;t38.v34_rate = t38_v34rate_to_bps(buf, len);
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;V.34 rate %d bps\n&quot;, fe-&gt;t38.v34_rate);
-        }
-        else
-        {
-            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bad length for V34rate message - %d\n&quot;, len);
-        }
-        break;
</del><span class="cx">     default:
</span><span class="cx">         break;
</span><span class="cx">     }
</span><ins>+    /*endswitch*/
</ins><span class="cx">     return 0;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct4_rxc"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/t4_rx.c (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t4_rx.c                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/t4_rx.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,1227 @@
</span><ins>+//#define T4_STATE_DEBUGGING
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * t4_rx.c - ITU T.4 FAX receive processing
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2003, 2007 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t4_rx.c,v 1.12.2.8 2009/12/21 17:18:39 steveu Exp $
+ */
+
+/*
+ * Much of this file is based on the T.4 and T.6 support in libtiff, which requires
+ * the following notice in any derived source code:
+ *
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and 
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ * 
+ * THE SOFTWARE IS PROVIDED &quot;AS-IS&quot; AND WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+ * 
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * OF THIS SOFTWARE.
+ *
+ * Decoder support is derived from code in Frank Cringle's viewfax program;
+ *      Copyright (C) 1990, 1995  Frank D. Cringle.
+ */
+
+/*! \file */
+
+#if defined(HAVE_CONFIG_H)
+#include &quot;config.h&quot;
+#endif
+
+#include &lt;stdlib.h&gt;
+#include &lt;inttypes.h&gt;
+#include &lt;limits.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;fcntl.h&gt;
+#include &lt;unistd.h&gt;
+#include &lt;time.h&gt;
+#include &lt;memory.h&gt;
+#include &lt;string.h&gt;
+#if defined(HAVE_TGMATH_H)
+#include &lt;tgmath.h&gt;
+#endif
+#if defined(HAVE_MATH_H)
+#include &lt;math.h&gt;
+#endif
+#include &quot;floating_fudge.h&quot;
+#include &lt;tiffio.h&gt;
+
+#include &quot;spandsp/telephony.h&quot;
+#include &quot;spandsp/logging.h&quot;
+#include &quot;spandsp/bit_operations.h&quot;
+#include &quot;spandsp/async.h&quot;
+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
+#include &quot;spandsp/version.h&quot;
+
+#include &quot;spandsp/private/logging.h&quot;
+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
+
+/*! The number of centimetres in one inch */
+#define CM_PER_INCH                 2.54f
+
+/*! The number of EOLs to expect at the end of a T.4 page */
+#define EOLS_TO_END_ANY_RX_PAGE     6
+/*! The number of EOLs to check at the end of a T.4 page */
+#define EOLS_TO_END_T4_RX_PAGE      5
+/*! The number of EOLs to check at the end of a T.6 page */
+#define EOLS_TO_END_T6_RX_PAGE      2
+
+#if defined(T4_STATE_DEBUGGING)
+static void STATE_TRACE(const char *format, ...)
+{
+    va_list arg_ptr;
+
+    va_start(arg_ptr, format);
+    vprintf(format, arg_ptr);
+    va_end(arg_ptr);
+}
+/*- End of function --------------------------------------------------------*/
+#else
+#define STATE_TRACE(...) /**/
+#endif
+
+/*! T.4 run length table entry */
+typedef struct
+{
+    /*! Length of T.4 code, in bits */
+    uint16_t length;
+    /*! T.4 code */
+    uint16_t code;
+    /*! Run length, in bits */
+    int16_t run_length;
+} t4_run_table_entry_t;
+
+#include &quot;t4_t6_decode_states.h&quot;
+
+#if defined(HAVE_LIBTIFF)
+static int set_tiff_directory_info(t4_state_t *s)
+{
+    time_t now;
+    struct tm *tm;
+    char buf[256 + 1];
+    uint16_t resunit;
+    float x_resolution;
+    float y_resolution;
+    t4_tiff_state_t *t;
+
+    t = &amp;s-&gt;tiff;
+    /* Prepare the directory entry fully before writing the image, or libtiff complains */
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_COMPRESSION, t-&gt;output_compression);
+    if (t-&gt;output_compression == COMPRESSION_CCITT_T4)
+    {
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_T4OPTIONS, t-&gt;output_t4_options);
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_FAXMODE, FAXMODE_CLASSF);
+    }
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_IMAGEWIDTH, s-&gt;image_width);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_BITSPERSAMPLE, 1);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_SAMPLESPERPIXEL, 1);
+    if (t-&gt;output_compression == COMPRESSION_CCITT_T4
+        ||
+        t-&gt;output_compression == COMPRESSION_CCITT_T6)
+    {
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_ROWSPERSTRIP, -1L);
+    }
+    else
+    {
+        TIFFSetField(t-&gt;tiff_file,
+                     TIFFTAG_ROWSPERSTRIP,
+                     TIFFDefaultStripSize(t-&gt;tiff_file, 0));
+    }
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_MINISWHITE);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_FILLORDER, FILLORDER_LSB2MSB);
+
+    x_resolution = s-&gt;x_resolution/100.0f;
+    y_resolution = s-&gt;y_resolution/100.0f;
+    /* Metric seems the sane thing to use in the 21st century, but a lot of lousy software
+       gets FAX resolutions wrong, and more get it wrong using metric than using inches. */
+#if 0
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_XRESOLUTION, x_resolution);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_YRESOLUTION, y_resolution);
+    resunit = RESUNIT_CENTIMETER;
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit);
+#else
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_XRESOLUTION, floorf(x_resolution*CM_PER_INCH + 0.5f));
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_YRESOLUTION, floorf(y_resolution*CM_PER_INCH + 0.5f));
+    resunit = RESUNIT_INCH;
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_RESOLUTIONUNIT, resunit);
+#endif
+    /* TODO: add the version of spandsp */
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_SOFTWARE, &quot;Spandsp &quot; SPANDSP_RELEASE_DATETIME_STRING);
+    if (gethostname(buf, sizeof(buf)) == 0)
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_HOSTCOMPUTER, buf);
+
+#if defined(TIFFTAG_FAXDCS)
+    if (t-&gt;dcs)
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_FAXDCS, t-&gt;dcs);
+#endif
+    if (t-&gt;sub_address)
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_FAXSUBADDRESS, t-&gt;sub_address);
+    if (t-&gt;far_ident)
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_IMAGEDESCRIPTION, t-&gt;far_ident);
+    if (t-&gt;vendor)
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_MAKE, t-&gt;vendor);
+    if (t-&gt;model)
+        TIFFSetField(t-&gt;tiff_file, TIFFTAG_MODEL, t-&gt;model);
+
+    time(&amp;now);
+    tm = localtime(&amp;now);
+    sprintf(buf,
+            &quot;%4d/%02d/%02d %02d:%02d:%02d&quot;,
+            tm-&gt;tm_year + 1900,
+            tm-&gt;tm_mon + 1,
+            tm-&gt;tm_mday,
+            tm-&gt;tm_hour,
+            tm-&gt;tm_min,
+            tm-&gt;tm_sec);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_DATETIME, buf);
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_FAXRECVTIME, now - s-&gt;page_start_time);
+
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_IMAGELENGTH, s-&gt;image_length);
+    /* Set the total pages to 1. For any one page document we will get this
+       right. For multi-page documents we will need to come back and fill in
+       the right answer when we know it. */
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_PAGENUMBER, s-&gt;current_page++, 1);
+    s-&gt;tiff.pages_in_file = s-&gt;current_page;
+    if (t-&gt;output_compression == COMPRESSION_CCITT_T4)
+    {
+        if (s-&gt;t4_t6_rx.bad_rows)
+        {
+            TIFFSetField(t-&gt;tiff_file, TIFFTAG_BADFAXLINES, s-&gt;t4_t6_rx.bad_rows);
+            TIFFSetField(t-&gt;tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_REGENERATED);
+            TIFFSetField(t-&gt;tiff_file, TIFFTAG_CONSECUTIVEBADFAXLINES, s-&gt;t4_t6_rx.longest_bad_row_run);
+        }
+        else
+        {
+            TIFFSetField(t-&gt;tiff_file, TIFFTAG_CLEANFAXDATA, CLEANFAXDATA_CLEAN);
+        }
+    }
+    TIFFSetField(t-&gt;tiff_file, TIFFTAG_IMAGEWIDTH, s-&gt;image_width);
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int open_tiff_output_file(t4_state_t *s, const char *file)
+{
+    if ((s-&gt;tiff.tiff_file = TIFFOpen(file, &quot;w&quot;)) == NULL)
+        return -1;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static void write_tiff_image(t4_state_t *s)
+{
+    /* Set up the TIFF directory info... */
+    set_tiff_directory_info(s);
+    /* ..and then write the image... */
+    if (TIFFWriteEncodedStrip(s-&gt;tiff.tiff_file, 0, s-&gt;image_buffer, s-&gt;image_length*s-&gt;bytes_per_row) &lt; 0)
+        span_log(&amp;s-&gt;logging, SPAN_LOG_WARNING, &quot;%s: Error writing TIFF strip.\n&quot;, s-&gt;tiff.file);
+    /* ...then the directory entry, and libtiff is happy. */
+    TIFFWriteDirectory(s-&gt;tiff.tiff_file);
+}
+/*- End of function --------------------------------------------------------*/
+
+static int close_tiff_output_file(t4_state_t *s)
+{
+    int i;
+    t4_tiff_state_t *t;
+
+    t = &amp;s-&gt;tiff;
+    /* Perform any operations needed to tidy up a written TIFF file before
+       closure. */
+    if (s-&gt;current_page &gt; 1)
+    {
+        /* We need to edit the TIFF directories. Until now we did not know
+           the total page count, so the TIFF file currently says one. Now we
+           need to set the correct total page count associated with each page. */
+        for (i = 0;  i &lt; s-&gt;current_page;  i++)
+        {
+            TIFFSetDirectory(t-&gt;tiff_file, (tdir_t) i);
+            TIFFSetField(t-&gt;tiff_file, TIFFTAG_PAGENUMBER, i, s-&gt;current_page);
+            TIFFWriteDirectory(t-&gt;tiff_file);
+        }
+    }
+    TIFFClose(t-&gt;tiff_file);
+    t-&gt;tiff_file = NULL;
+    if (t-&gt;file)
+    {
+        /* Try not to leave a file behind, if we didn't receive any pages to
+           put in it. */
+        if (s-&gt;current_page == 0)
+            remove(t-&gt;file);
+        free((char *) t-&gt;file);
+        t-&gt;file = NULL;
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+#else
+
+static int set_tiff_directory_info(t4_state_t *s)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int get_tiff_directory_info(t4_state_t *s)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_tiff_directory_info(t4_state_t *s)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int open_tiff_input_file(t4_state_t *s, const char *file)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int read_tiff_image(t4_state_t *s)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int close_tiff_input_file(t4_state_t *s)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int open_tiff_output_file(t4_state_t *s, const char *file)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static void write_tiff_image(t4_state_t *s)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int close_tiff_output_file(t4_state_t *s)
+{
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
+static void update_row_bit_info(t4_state_t *s)
+{
+    if (s-&gt;row_bits &gt; s-&gt;max_row_bits)
+        s-&gt;max_row_bits = s-&gt;row_bits;
+    if (s-&gt;row_bits &lt; s-&gt;min_row_bits)
+        s-&gt;min_row_bits = s-&gt;row_bits;
+    s-&gt;row_bits = 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+#if defined(__i386__)  ||  defined(__x86_64__)  ||  defined(__ppc__)  ||   defined(__powerpc__)
+static __inline__ int run_length(unsigned int bits)
+{
+    return 7 - top_bit(bits);
+}
+/*- End of function --------------------------------------------------------*/
+#else
+static __inline__ int run_length(unsigned int bits)
+{
+    static const uint8_t run_len[256] =
+    {
+        8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, /* 0x00 - 0x0F */
+        3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, /* 0x10 - 0x1F */
+        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x20 - 0x2F */
+        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, /* 0x30 - 0x3F */
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x4F */
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x5F */
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x6F */
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x7F */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 - 0x8F */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 - 0x9F */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xA0 - 0xAF */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xB0 - 0xBF */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xC0 - 0xCF */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xD0 - 0xDF */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xE0 - 0xEF */
+        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xF0 - 0xFF */
+    };
+
+    return run_len[bits];
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
+static int free_buffers(t4_state_t *s)
+{
+    if (s-&gt;image_buffer)
+    {
+        free(s-&gt;image_buffer);
+        s-&gt;image_buffer = NULL;
+        s-&gt;image_buffer_size = 0;
+    }
+    if (s-&gt;cur_runs)
+    {
+        free(s-&gt;cur_runs);
+        s-&gt;cur_runs = NULL;
+    }
+    if (s-&gt;ref_runs)
+    {
+        free(s-&gt;ref_runs);
+        s-&gt;ref_runs = NULL;
+    }
+    if (s-&gt;row_buf)
+    {
+        free(s-&gt;row_buf);
+        s-&gt;row_buf = NULL;
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ void add_run_to_row(t4_state_t *s)
+{
+    if (s-&gt;t4_t6_rx.run_length &gt;= 0)
+    {
+        s-&gt;row_len += s-&gt;t4_t6_rx.run_length;
+        /* Don't allow rows to grow too long, and overflow the buffers */
+        if (s-&gt;row_len &lt;= s-&gt;image_width)
+            s-&gt;cur_runs[s-&gt;t4_t6_rx.a_cursor++] = s-&gt;t4_t6_rx.run_length;
+    }
+    s-&gt;t4_t6_rx.run_length = 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int put_decoded_row(t4_state_t *s)
+{
+    static const int msbmask[9] =
+    {
+        0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff
+    };
+    uint8_t *t;
+    uint32_t i;
+    uint32_t *p;
+    int fudge;
+    int row_starts_at;
+    int x;
+    int j;
+
+    if (s-&gt;t4_t6_rx.run_length)
+        add_run_to_row(s);
+#if defined(T4_STATE_DEBUGGING)
+    /* Dump the runs of black and white for analysis */
+    {
+        int total;
+
+        total = 0;
+        for (x = 0;  x &lt; s-&gt;t4_t6_rx.b_cursor;  x++)
+            total += s-&gt;ref_runs[x];
+        printf(&quot;Ref (%d)&quot;, total);
+        for (x = 0;  x &lt; s-&gt;t4_t6_rx.b_cursor;  x++)
+            printf(&quot; %&quot; PRIu32, s-&gt;ref_runs[x]);
+        printf(&quot;\n&quot;);
+        total = 0;
+        for (x = 0;  x &lt; s-&gt;t4_t6_rx.a_cursor;  x++)
+            total += s-&gt;cur_runs[x];
+        printf(&quot;Cur (%d)&quot;, total);
+        for (x = 0;  x &lt; s-&gt;t4_t6_rx.a_cursor;  x++)
+            printf(&quot; %&quot; PRIu32, s-&gt;cur_runs[x]);
+        printf(&quot;\n&quot;);
+    }
+#endif
+    row_starts_at = s-&gt;image_size;
+    /* Make sure there is enough room for another row */
+    if (s-&gt;image_size + s-&gt;bytes_per_row &gt;= s-&gt;image_buffer_size)
+    {
+        if ((t = realloc(s-&gt;image_buffer, s-&gt;image_buffer_size + 100*s-&gt;bytes_per_row)) == NULL)
+            return -1;
+        s-&gt;image_buffer_size += 100*s-&gt;bytes_per_row;
+        s-&gt;image_buffer = t;
+    }
+    if (s-&gt;row_len == s-&gt;image_width)
+    {
+        STATE_TRACE(&quot;%d Good row - %d %s\n&quot;, s-&gt;image_length, s-&gt;row_len, (s-&gt;row_is_2d)  ?  &quot;2D&quot;  :  &quot;1D&quot;);
+        if (s-&gt;t4_t6_rx.curr_bad_row_run)
+        {
+            if (s-&gt;t4_t6_rx.curr_bad_row_run &gt; s-&gt;t4_t6_rx.longest_bad_row_run)
+                s-&gt;t4_t6_rx.longest_bad_row_run = s-&gt;t4_t6_rx.curr_bad_row_run;
+            s-&gt;t4_t6_rx.curr_bad_row_run = 0;
+        }
+        /* Convert the runs to a bit image of the row */
+        /* White/black/white... runs, always starting with white. That means the first run could be
+           zero length. */
+        for (x = 0, fudge = 0;  x &lt; s-&gt;t4_t6_rx.a_cursor;  x++, fudge ^= 0xFF)
+        {
+            i = s-&gt;cur_runs[x];
+            if ((int) i &gt;= s-&gt;tx_bits)
+            {
+                s-&gt;tx_bitstream = (s-&gt;tx_bitstream &lt;&lt; s-&gt;tx_bits) | (msbmask[s-&gt;tx_bits] &amp; fudge);
+                for (i += (8 - s-&gt;tx_bits);  i &gt;= 8;  i -= 8)
+                {
+                    s-&gt;tx_bits = 8;
+                    s-&gt;image_buffer[s-&gt;image_size++] = (uint8_t) s-&gt;tx_bitstream;
+                    s-&gt;tx_bitstream = fudge;
+                }
+            }
+            s-&gt;tx_bitstream = (s-&gt;tx_bitstream &lt;&lt; i) | (msbmask[i] &amp; fudge);
+            s-&gt;tx_bits -= i;
+        }
+        s-&gt;image_length++;
+    }
+    else
+    {
+        STATE_TRACE(&quot;%d Bad row - %d %s\n&quot;, s-&gt;image_length, s-&gt;row_len, (s-&gt;row_is_2d)  ?  &quot;2D&quot;  :  &quot;1D&quot;);
+        /* Try to clean up the bad runs, and produce something reasonable as the reference
+           row for the next row. Use a copy of the previous good row as the actual current
+           row. If the row only fell apart near the end, reusing it might be the best
+           solution. */
+        for (j = 0, fudge = 0;  j &lt; s-&gt;t4_t6_rx.a_cursor  &amp;&amp;  fudge &lt; s-&gt;image_width;  j++)
+            fudge += s-&gt;cur_runs[j];
+        if (fudge &lt; s-&gt;image_width)
+        {
+            /* Try to pad with white, and avoid black, to minimise mess on the image. */
+            if ((s-&gt;t4_t6_rx.a_cursor &amp; 1))
+            {
+                /* We currently finish in white. We could extend that, but it is probably of
+                   the right length. Changing it would only further mess up what happens in the
+                   next row. It seems better to add a black spot, and an extra white run. */
+                s-&gt;cur_runs[s-&gt;t4_t6_rx.a_cursor++] = 1;
+                fudge++;
+                if (fudge &lt; s-&gt;image_width)
+                    s-&gt;cur_runs[s-&gt;t4_t6_rx.a_cursor++] = s-&gt;image_width - fudge;
+            }
+            else
+            {
+                /* We currently finish on black, so we add an extra white run to fill out the line. */
+                s-&gt;cur_runs[s-&gt;t4_t6_rx.a_cursor++] = s-&gt;image_width - fudge;
+            }
+        }
+        else
+        {
+            /* Trim the last element to align with the proper image width */
+            s-&gt;cur_runs[s-&gt;t4_t6_rx.a_cursor] += (s-&gt;image_width - fudge);
+        }
+        /* Ensure there is a previous line to copy from. */
+        if (s-&gt;image_size != s-&gt;t4_t6_rx.last_row_starts_at)
+        {
+            /* Copy the previous row over this one */
+            memcpy(s-&gt;image_buffer + s-&gt;image_size, s-&gt;image_buffer + s-&gt;t4_t6_rx.last_row_starts_at, s-&gt;bytes_per_row);
+            s-&gt;image_size += s-&gt;bytes_per_row;
+            s-&gt;image_length++;
+        }
+        s-&gt;t4_t6_rx.bad_rows++;
+        s-&gt;t4_t6_rx.curr_bad_row_run++;
+    }
+
+    /* Pad the row as it becomes the reference row, so there are no odd runs to pick up if we
+       step off the end of the list. */
+    s-&gt;cur_runs[s-&gt;t4_t6_rx.a_cursor] = 0;
+    s-&gt;cur_runs[s-&gt;t4_t6_rx.a_cursor + 1] = 0;
+
+    /* Prepare the buffers for the next row. */
+    s-&gt;t4_t6_rx.last_row_starts_at = row_starts_at;
+    /* Swap the buffers */
+    p = s-&gt;cur_runs;
+    s-&gt;cur_runs = s-&gt;ref_runs;
+    s-&gt;ref_runs = p;
+
+    s-&gt;t4_t6_rx.b_cursor = 1;
+    s-&gt;t4_t6_rx.a_cursor = 0;
+    s-&gt;t4_t6_rx.b1 = s-&gt;ref_runs[0];
+    s-&gt;t4_t6_rx.a0 = 0;
+    
+    s-&gt;t4_t6_rx.run_length = 0;
+
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_end_page(t4_state_t *s)
+{
+    int row;
+    int i;
+
+    if (s-&gt;line_encoding == T4_COMPRESSION_ITU_T6)
+    {
+        /* Push enough zeros through the decoder to flush out any remaining codes */
+        for (i = 0;  i &lt; 13;  i++)
+            t4_rx_put_bit(s, 0);
+    }
+    if (s-&gt;t4_t6_rx.curr_bad_row_run)
+    {
+        if (s-&gt;t4_t6_rx.curr_bad_row_run &gt; s-&gt;t4_t6_rx.longest_bad_row_run)
+            s-&gt;t4_t6_rx.longest_bad_row_run = s-&gt;t4_t6_rx.curr_bad_row_run;
+        s-&gt;t4_t6_rx.curr_bad_row_run = 0;
+    }
+
+    if (s-&gt;image_size == 0)
+        return -1;
+
+    if (s-&gt;t4_t6_rx.row_write_handler)
+    {
+        for (row = 0;  row &lt; s-&gt;image_length;  row++)
+        {
+            if (s-&gt;t4_t6_rx.row_write_handler(s-&gt;t4_t6_rx.row_write_user_data, s-&gt;image_buffer + row*s-&gt;bytes_per_row, s-&gt;bytes_per_row) &lt; 0)
+            {
+                span_log(&amp;s-&gt;logging, SPAN_LOG_WARNING, &quot;Write error at row %d.\n&quot;, row);
+                break;
+            }
+        }
+        /* Write a blank row to indicate the end of the image. */
+        if (s-&gt;t4_t6_rx.row_write_handler(s-&gt;t4_t6_rx.row_write_user_data, NULL, 0) &lt; 0)
+            span_log(&amp;s-&gt;logging, SPAN_LOG_WARNING, &quot;Write error at row %d.\n&quot;, row);
+    }
+    else
+    {
+        write_tiff_image(s);
+    }
+    s-&gt;t4_t6_rx.rx_bits = 0;
+    s-&gt;t4_t6_rx.rx_skip_bits = 0;
+    s-&gt;t4_t6_rx.rx_bitstream = 0;
+    s-&gt;t4_t6_rx.consecutive_eols = EOLS_TO_END_ANY_RX_PAGE;
+
+    s-&gt;image_size = 0;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ void drop_rx_bits(t4_state_t *s, int bits)
+{
+    /* Only remove one bit right now. The rest need to be removed step by step,
+       checking for a misaligned EOL along the way. This is time consuming, but
+       if we don't do it a single bit error can severely damage an image. */
+    s-&gt;row_bits += bits;
+    s-&gt;t4_t6_rx.rx_skip_bits += (bits - 1);
+    s-&gt;t4_t6_rx.rx_bits--;
+    s-&gt;t4_t6_rx.rx_bitstream &gt;&gt;= 1;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ void force_drop_rx_bits(t4_state_t *s, int bits)
+{
+    /* This should only be called to drop the bits of an EOL, as that is the
+       only place where it is safe to drop them all at once. */
+    s-&gt;row_bits += bits;
+    s-&gt;t4_t6_rx.rx_skip_bits = 0;
+    s-&gt;t4_t6_rx.rx_bits -= bits;
+    s-&gt;t4_t6_rx.rx_bitstream &gt;&gt;= bits;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int rx_put_bits(t4_state_t *s, uint32_t bit_string, int quantity)
+{
+    int bits;
+
+    /* We decompress bit by bit, as the data stream is received. We need to
+       scan continuously for EOLs, so we might as well work this way. */
+    s-&gt;line_image_size += quantity;
+    s-&gt;t4_t6_rx.rx_bitstream |= (bit_string &lt;&lt; s-&gt;t4_t6_rx.rx_bits);
+    /* The longest item we need to scan for is 13 bits long (a 2D EOL), so we
+       need a minimum of 13 bits in the buffer to proceed with any bit stream
+       analysis. */
+    if ((s-&gt;t4_t6_rx.rx_bits += quantity) &lt; 13)
+        return FALSE;
+    if (s-&gt;t4_t6_rx.consecutive_eols)
+    {
+        /* Check if the image has already terminated. */
+        if (s-&gt;t4_t6_rx.consecutive_eols &gt;= EOLS_TO_END_ANY_RX_PAGE)
+            return TRUE;
+        /* Check if the image hasn't even started. */
+        if (s-&gt;t4_t6_rx.consecutive_eols &lt; 0)
+        {
+            /* We are waiting for the very first EOL (1D or 2D only). */
+            /* We need to take this bit by bit, as the EOL could be anywhere,
+               and any junk could preceed it. */
+            while ((s-&gt;t4_t6_rx.rx_bitstream &amp; 0xFFF) != 0x800)
+            {
+                s-&gt;t4_t6_rx.rx_bitstream &gt;&gt;= 1;
+                if (--s-&gt;t4_t6_rx.rx_bits &lt; 13)
+                    return FALSE;
+            }
+            /* We have an EOL, so now the page begins and we can proceed to
+               process the bit stream as image data. */
+            s-&gt;t4_t6_rx.consecutive_eols = 0;
+            if (s-&gt;line_encoding == T4_COMPRESSION_ITU_T4_1D)
+            {
+                s-&gt;row_is_2d = FALSE;
+                force_drop_rx_bits(s, 12);
+            }
+            else
+            {
+                s-&gt;row_is_2d = !(s-&gt;t4_t6_rx.rx_bitstream &amp; 0x1000);
+                force_drop_rx_bits(s, 13);
+            }
+        }
+    }
+
+    while (s-&gt;t4_t6_rx.rx_bits &gt;= 13)
+    {
+        /* We need to check for EOLs bit by bit through the whole stream. If
+           we just try looking between code words, we will miss an EOL when a bit
+           error has throw the code words completely out of step. The can mean
+           recovery takes many lines, and the image gets really messed up. */
+        /* Although EOLs are not inserted at the end of each row of a T.6 image,
+           they are still perfectly valid, and can terminate an image. */
+        if ((s-&gt;t4_t6_rx.rx_bitstream &amp; 0x0FFF) == 0x0800)
+        {
+            STATE_TRACE(&quot;EOL\n&quot;);
+            if (s-&gt;row_len == 0)
+            {
+                /* A zero length row - i.e. 2 consecutive EOLs - is distinctly
+                   the end of page condition. That's all we actually get on a
+                   T.6 page. However, there are a minimum of 6 EOLs at the end of
+                   any T.4 page. We can look for more than 2 EOLs in case bit
+                   errors simulate the end of page condition at the wrong point.
+                   Such robust checking is irrelevant for a T.6 page, as it should
+                   be error free. */
+                /* Note that for a T.6 page we should get here on the very first
+                   EOL, as the row length should be zero at that point. Therefore
+                   we should count up both EOLs, unless there is some bogus partial
+                   row ahead of them. */
+                s-&gt;t4_t6_rx.consecutive_eols++;
+                if (s-&gt;line_encoding == T4_COMPRESSION_ITU_T6)
+                {
+                    if (s-&gt;t4_t6_rx.consecutive_eols &gt;= EOLS_TO_END_T6_RX_PAGE)
+                    {
+                        s-&gt;t4_t6_rx.consecutive_eols = EOLS_TO_END_ANY_RX_PAGE;
+                        return TRUE;
+                    }
+                }
+                else
+                {
+                    if (s-&gt;t4_t6_rx.consecutive_eols &gt;= EOLS_TO_END_T4_RX_PAGE)
+                    {
+                        s-&gt;t4_t6_rx.consecutive_eols = EOLS_TO_END_ANY_RX_PAGE;
+                        return TRUE;
+                    }
+                }
+            }
+            else
+            {
+                /* The EOLs are not back-to-back, so they are not part of the
+                   end of page condition. */
+                if (s-&gt;t4_t6_rx.run_length &gt; 0)
+                    add_run_to_row(s);
+                s-&gt;t4_t6_rx.consecutive_eols = 0;
+                if (put_decoded_row(s))
+                    return TRUE;
+                update_row_bit_info(s);
+            }
+            if (s-&gt;line_encoding == T4_COMPRESSION_ITU_T4_2D)
+            {
+                s-&gt;row_is_2d = !(s-&gt;t4_t6_rx.rx_bitstream &amp; 0x1000);
+                force_drop_rx_bits(s, 13);
+            }
+            else
+            {
+                force_drop_rx_bits(s, 12);
+            }
+            s-&gt;t4_t6_rx.its_black = FALSE;
+            s-&gt;t4_t6_rx.black_white = 0;
+            s-&gt;t4_t6_rx.run_length = 0;
+            s-&gt;row_len = 0;
+            continue;
+        }
+        if (s-&gt;t4_t6_rx.rx_skip_bits)
+        {
+            /* We are clearing out the remaining bits of the last code word we
+               absorbed. */
+            s-&gt;t4_t6_rx.rx_skip_bits--;
+            s-&gt;t4_t6_rx.rx_bits--;
+            s-&gt;t4_t6_rx.rx_bitstream &gt;&gt;= 1;
+            continue;
+        }
+        if (s-&gt;row_is_2d  &amp;&amp;  s-&gt;t4_t6_rx.black_white == 0)
+        {
+            bits = s-&gt;t4_t6_rx.rx_bitstream &amp; 0x7F;
+            STATE_TRACE(&quot;State %d, %d - &quot;,
+                        t4_2d_table[bits].state,
+                        t4_2d_table[bits].width);
+            if (s-&gt;row_len &gt;= s-&gt;image_width)
+            {
+                drop_rx_bits(s, t4_2d_table[bits].width);
+                continue;
+            }
+            if (s-&gt;t4_t6_rx.a_cursor)
+            {
+                /* Move past a0, always staying on the current colour */
+                for (  ;  s-&gt;t4_t6_rx.b1 &lt;= s-&gt;t4_t6_rx.a0;  s-&gt;t4_t6_rx.b_cursor += 2)
+                    s-&gt;t4_t6_rx.b1 += (s-&gt;ref_runs[s-&gt;t4_t6_rx.b_cursor] + s-&gt;ref_runs[s-&gt;t4_t6_rx.b_cursor + 1]);
+            }
+            switch (t4_2d_table[bits].state)
+            {
+            case S_Horiz:
+                STATE_TRACE(&quot;Horiz %d %d %d\n&quot;,
+                            s-&gt;image_width,
+                            s-&gt;t4_t6_rx.a0,
+                            s-&gt;t4_t6_rx.a_cursor);
+                /* We now need to extract a white/black or black/white pair of runs, using the 1D
+                   method. If the first of the pair takes us exactly to the end of the row, there
+                   should still be a zero length element for the second of the pair. */
+                s-&gt;t4_t6_rx.its_black = s-&gt;t4_t6_rx.a_cursor &amp; 1;
+                s-&gt;t4_t6_rx.black_white = 2;
+                break;
+            case S_Vert:
+                STATE_TRACE(&quot;Vert[%d] %d %d %d %d\n&quot;,
+                            t4_2d_table[bits].param,
+                            s-&gt;image_width,
+                            s-&gt;t4_t6_rx.a0,
+                            s-&gt;t4_t6_rx.b1,
+                            s-&gt;t4_t6_rx.run_length);
+                s-&gt;t4_t6_rx.run_length += (s-&gt;t4_t6_rx.b1 - s-&gt;t4_t6_rx.a0 + t4_2d_table[bits].param);
+                s-&gt;t4_t6_rx.a0 = s-&gt;t4_t6_rx.b1 + t4_2d_table[bits].param;
+                add_run_to_row(s);
+                /* We need to move one step in one direction or the other, to change to the
+                   opposite colour */
+                if (t4_2d_table[bits].param &gt;= 0)
+                {
+                    s-&gt;t4_t6_rx.b1 += s-&gt;ref_runs[s-&gt;t4_t6_rx.b_cursor++];
+                }
+                else
+                {
+                    if (s-&gt;t4_t6_rx.b_cursor)
+                        s-&gt;t4_t6_rx.b1 -= s-&gt;ref_runs[--s-&gt;t4_t6_rx.b_cursor];
+                }
+                break;
+            case S_Pass:
+                STATE_TRACE(&quot;Pass %d %d %d %d %d\n&quot;,
+                            s-&gt;image_width,
+                            s-&gt;t4_t6_rx.a0,
+                            s-&gt;t4_t6_rx.b1,
+                            s-&gt;ref_runs[s-&gt;t4_t6_rx.b_cursor],
+                            s-&gt;ref_runs[s-&gt;t4_t6_rx.b_cursor + 1]);
+                s-&gt;t4_t6_rx.b1 += s-&gt;ref_runs[s-&gt;t4_t6_rx.b_cursor++];
+                s-&gt;t4_t6_rx.run_length += (s-&gt;t4_t6_rx.b1 - s-&gt;t4_t6_rx.a0);
+                s-&gt;t4_t6_rx.a0 = s-&gt;t4_t6_rx.b1;
+                s-&gt;t4_t6_rx.b1 += s-&gt;ref_runs[s-&gt;t4_t6_rx.b_cursor++];
+                break;
+            case S_Ext:
+                /* We do not currently handle any kind of extension */
+                STATE_TRACE(&quot;Ext %d %d %d 0x%x\n&quot;,
+                            s-&gt;image_width,
+                            s-&gt;t4_t6_rx.a0,
+                            ((s-&gt;t4_t6_rx.rx_bitstream &gt;&gt; t4_2d_table[bits].width) &amp; 0x7),
+                            s-&gt;t4_t6_rx.rx_bitstream);
+                /* TODO: The uncompressed option should be implemented. */
+                break;
+            case S_Null:
+                STATE_TRACE(&quot;Null\n&quot;);
+                break;
+            default:
+                STATE_TRACE(&quot;Unexpected T.4 state\n&quot;);
+                span_log(&amp;s-&gt;logging, SPAN_LOG_WARNING, &quot;Unexpected T.4 state %d\n&quot;, t4_2d_table[bits].state);
+                break;
+            }
+            drop_rx_bits(s, t4_2d_table[bits].width);
+        }
+        else
+        {
+            if (s-&gt;t4_t6_rx.its_black)
+            {
+                bits = s-&gt;t4_t6_rx.rx_bitstream &amp; 0x1FFF;
+                STATE_TRACE(&quot;State %d, %d - Black %d %d %d\n&quot;,
+                            t4_1d_black_table[bits].state,
+                            t4_1d_black_table[bits].width,
+                            s-&gt;image_width,
+                            s-&gt;t4_t6_rx.a0,
+                            t4_1d_black_table[bits].param);
+                switch (t4_1d_black_table[bits].state)
+                {
+                case S_MakeUpB:
+                case S_MakeUp:
+                    s-&gt;t4_t6_rx.run_length += t4_1d_black_table[bits].param;
+                    s-&gt;t4_t6_rx.a0 += t4_1d_black_table[bits].param;
+                    break;
+                case S_TermB:
+                    s-&gt;t4_t6_rx.its_black = FALSE;
+                    if (s-&gt;row_len &lt; s-&gt;image_width)
+                    {
+                        s-&gt;t4_t6_rx.run_length += t4_1d_black_table[bits].param;
+                        s-&gt;t4_t6_rx.a0 += t4_1d_black_table[bits].param;
+                        add_run_to_row(s);
+                    }
+                    if (s-&gt;t4_t6_rx.black_white)
+                        s-&gt;t4_t6_rx.black_white--;
+                    break;
+                default:
+                    /* Bad black */
+                    s-&gt;t4_t6_rx.black_white = 0;
+                    break;
+                }
+                drop_rx_bits(s, t4_1d_black_table[bits].width);
+            }
+            else
+            {
+                bits = s-&gt;t4_t6_rx.rx_bitstream &amp; 0xFFF;
+                STATE_TRACE(&quot;State %d, %d - White %d %d %d\n&quot;,
+                            t4_1d_white_table[bits].state,
+                            t4_1d_white_table[bits].width,
+                            s-&gt;image_width,
+                            s-&gt;t4_t6_rx.a0,
+                            t4_1d_white_table[bits].param);
+                switch (t4_1d_white_table[bits].state)
+                {
+                case S_MakeUpW:
+                case S_MakeUp:
+                    s-&gt;t4_t6_rx.run_length += t4_1d_white_table[bits].param;
+                    s-&gt;t4_t6_rx.a0 += t4_1d_white_table[bits].param;
+                    break;
+                case S_TermW:
+                    s-&gt;t4_t6_rx.its_black = TRUE;
+                    if (s-&gt;row_len &lt; s-&gt;image_width)
+                    {
+                        s-&gt;t4_t6_rx.run_length += t4_1d_white_table[bits].param;
+                        s-&gt;t4_t6_rx.a0 += t4_1d_white_table[bits].param;
+                        add_run_to_row(s);
+                    }
+                    if (s-&gt;t4_t6_rx.black_white)
+                        s-&gt;t4_t6_rx.black_white--;
+                    break;
+                default:
+                    /* Bad white */
+                    s-&gt;t4_t6_rx.black_white = 0;
+                    break;
+                }
+                drop_rx_bits(s, t4_1d_white_table[bits].width);
+            }
+        }
+        if (s-&gt;t4_t6_rx.a0 &gt;= s-&gt;image_width)
+            s-&gt;t4_t6_rx.a0 = s-&gt;image_width - 1;
+
+        if (s-&gt;line_encoding == T4_COMPRESSION_ITU_T6)
+        {
+            /* T.6 has no EOL markers. We sense the end of a line by its length alone. */
+            /* The last test here is a backstop protection, so a corrupt image cannot
+               cause us to do bad things. Bad encoders have actually been seen, which
+               demand such protection. */
+            if (s-&gt;t4_t6_rx.black_white == 0  &amp;&amp;  s-&gt;row_len &gt;= s-&gt;image_width)
+            {
+                STATE_TRACE(&quot;EOL T.6\n&quot;);
+                if (s-&gt;t4_t6_rx.run_length &gt; 0)
+                    add_run_to_row(s);
+                update_row_bit_info(s);
+                if (put_decoded_row(s))
+                    return TRUE;
+                s-&gt;t4_t6_rx.its_black = FALSE;
+                s-&gt;t4_t6_rx.black_white = 0;
+                s-&gt;t4_t6_rx.run_length = 0;
+                s-&gt;row_len = 0;
+            }
+        }
+    }
+    return FALSE;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_put_bit(t4_state_t *s, int bit)
+{
+    return rx_put_bits(s, bit &amp; 1, 1);
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_put_byte(t4_state_t *s, uint8_t byte)
+{
+    return rx_put_bits(s, byte &amp; 0xFF, 8);
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_put_chunk(t4_state_t *s, const uint8_t buf[], int len)
+{
+    int i;
+    uint8_t byte;
+
+    for (i = 0;  i &lt; len;  i++)
+    {
+        byte = buf[i];
+        if (rx_put_bits(s, byte &amp; 0xFF, 8))
+            return TRUE;
+    }
+    return FALSE;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_set_row_write_handler(t4_state_t *s, t4_row_write_handler_t handler, void *user_data)
+{
+    s-&gt;t4_t6_rx.row_write_handler = handler;
+    s-&gt;t4_t6_rx.row_write_user_data = user_data;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(t4_state_t *) t4_rx_init(t4_state_t *s, const char *file, int output_encoding)
+{
+    if (s == NULL)
+    {
+        if ((s = (t4_state_t *) malloc(sizeof(*s))) == NULL)
+            return NULL;
+    }
+    memset(s, 0, sizeof(*s));
+    span_log_init(&amp;s-&gt;logging, SPAN_LOG_NONE, NULL);
+    span_log_set_protocol(&amp;s-&gt;logging, &quot;T.4&quot;);
+    s-&gt;rx = TRUE;
+    
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Start rx document\n&quot;);
+
+    if (open_tiff_output_file(s, file) &lt; 0)
+        return NULL;
+
+    /* Save the file name for logging reports. */
+    s-&gt;tiff.file = strdup(file);
+    /* Only provide for one form of coding throughout the file, even though the
+       coding on the wire could change between pages. */
+    switch (output_encoding)
+    {
+    case T4_COMPRESSION_ITU_T4_1D:
+        s-&gt;tiff.output_compression = COMPRESSION_CCITT_T4;
+        s-&gt;tiff.output_t4_options = GROUP3OPT_FILLBITS;
+        break;
+    case T4_COMPRESSION_ITU_T4_2D:
+        s-&gt;tiff.output_compression = COMPRESSION_CCITT_T4;
+        s-&gt;tiff.output_t4_options = GROUP3OPT_FILLBITS | GROUP3OPT_2DENCODING;
+        break;
+    case T4_COMPRESSION_ITU_T6:
+        s-&gt;tiff.output_compression = COMPRESSION_CCITT_T6;
+        s-&gt;tiff.output_t4_options = 0;
+        break;
+    }
+
+    /* Until we have a valid figure for the bytes per row, we need it to be set to a suitable
+       value to ensure it will be seen as changing when the real value is used. */
+    s-&gt;bytes_per_row = 0;
+
+    s-&gt;current_page = 0;
+    s-&gt;tiff.pages_in_file = 0;
+    s-&gt;tiff.start_page = 0;
+    s-&gt;tiff.stop_page = INT_MAX;
+
+    s-&gt;image_buffer = NULL;
+    s-&gt;image_buffer_size = 0;
+
+    /* Set some default values */
+    s-&gt;x_resolution = T4_X_RESOLUTION_R8;
+    s-&gt;y_resolution = T4_Y_RESOLUTION_FINE;
+    s-&gt;image_width = T4_WIDTH_R8_A4;
+
+    return s;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_start_page(t4_state_t *s)
+{
+    int bytes_per_row;
+    int run_space;
+    uint32_t *bufptr;
+
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Start rx page - compression %d\n&quot;, s-&gt;line_encoding);
+    if (s-&gt;tiff.tiff_file == NULL)
+        return -1;
+
+    /* Calculate the scanline/tile width. */
+    bytes_per_row = (s-&gt;image_width + 7)/8;
+    run_space = (s-&gt;image_width + 4)*sizeof(uint32_t);
+    if (bytes_per_row != s-&gt;bytes_per_row)
+    {
+        /* Allocate the space required for decoding the new row length. */
+        s-&gt;bytes_per_row = bytes_per_row;
+        if ((bufptr = (uint32_t *) realloc(s-&gt;cur_runs, run_space)) == NULL)
+            return -1;
+        s-&gt;cur_runs = bufptr;
+        if ((bufptr = (uint32_t *) realloc(s-&gt;ref_runs, run_space)) == NULL)
+            return -1;
+        s-&gt;ref_runs = bufptr;
+    }
+    memset(s-&gt;cur_runs, 0, run_space);
+    memset(s-&gt;ref_runs, 0, run_space);
+
+    s-&gt;t4_t6_rx.rx_bits = 0;
+    s-&gt;t4_t6_rx.rx_skip_bits = 0;
+    s-&gt;t4_t6_rx.rx_bitstream = 0;
+    s-&gt;row_bits = 0;
+    s-&gt;min_row_bits = INT_MAX;
+    s-&gt;max_row_bits = 0;
+
+    s-&gt;row_is_2d = (s-&gt;line_encoding == T4_COMPRESSION_ITU_T6);
+    /* We start at -1 EOLs for 1D and 2D decoding, as an indication we are waiting for the
+       first EOL. T.6 coding starts without any preamble. */
+    s-&gt;t4_t6_rx.consecutive_eols = (s-&gt;line_encoding == T4_COMPRESSION_ITU_T6)  ?  0  :  -1;
+
+    s-&gt;t4_t6_rx.bad_rows = 0;
+    s-&gt;t4_t6_rx.longest_bad_row_run = 0;
+    s-&gt;t4_t6_rx.curr_bad_row_run = 0;
+    s-&gt;image_length = 0;
+    s-&gt;tx_bitstream = 0;
+    s-&gt;tx_bits = 8;
+    s-&gt;image_size = 0;
+    s-&gt;line_image_size = 0;
+    s-&gt;t4_t6_rx.last_row_starts_at = 0;
+
+    s-&gt;row_len = 0;
+    s-&gt;t4_t6_rx.its_black = FALSE;
+    s-&gt;t4_t6_rx.black_white = 0;
+
+    /* Initialise the reference line to all white */
+    s-&gt;ref_runs[0] =
+    s-&gt;ref_runs[1] =
+    s-&gt;ref_runs[2] =
+    s-&gt;ref_runs[3] = s-&gt;image_width;
+
+    s-&gt;t4_t6_rx.b_cursor = 1;
+    s-&gt;t4_t6_rx.a_cursor = 0;
+    s-&gt;t4_t6_rx.b1 = s-&gt;ref_runs[0];
+    s-&gt;t4_t6_rx.a0 = 0;
+
+    s-&gt;t4_t6_rx.run_length = 0;
+
+    time (&amp;s-&gt;page_start_time);
+
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_release(t4_state_t *s)
+{
+    if (!s-&gt;rx)
+        return -1;
+    if (s-&gt;tiff.tiff_file)
+        close_tiff_output_file(s);
+    free_buffers(s);
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_rx_free(t4_state_t *s)
+{
+    int ret;
+
+    ret = t4_rx_release(s);
+    free(s);
+    return ret;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_rx_encoding(t4_state_t *s, int encoding)
+{
+    s-&gt;line_encoding = encoding;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_image_width(t4_state_t *s, int width)
+{
+    s-&gt;image_width = width;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_y_resolution(t4_state_t *s, int resolution)
+{
+    s-&gt;y_resolution = resolution;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_x_resolution(t4_state_t *s, int resolution)
+{
+    s-&gt;x_resolution = resolution;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_dcs(t4_state_t *s, const char *dcs)
+{
+    s-&gt;tiff.dcs = (dcs  &amp;&amp;  dcs[0])  ?  dcs  :  NULL;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_sub_address(t4_state_t *s, const char *sub_address)
+{
+    s-&gt;tiff.sub_address = (sub_address  &amp;&amp;  sub_address[0])  ?  sub_address  :  NULL;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_far_ident(t4_state_t *s, const char *ident)
+{
+    s-&gt;tiff.far_ident = (ident  &amp;&amp;  ident[0])  ?  ident  :  NULL;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_vendor(t4_state_t *s, const char *vendor)
+{
+    s-&gt;tiff.vendor = vendor;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_rx_set_model(t4_state_t *s, const char *model)
+{
+    s-&gt;tiff.model = model;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_get_transfer_statistics(t4_state_t *s, t4_stats_t *t)
+{
+    t-&gt;pages_transferred = s-&gt;current_page - s-&gt;tiff.start_page;
+    t-&gt;pages_in_file = s-&gt;tiff.pages_in_file;
+    t-&gt;width = s-&gt;image_width;
+    t-&gt;length = s-&gt;image_length;
+    t-&gt;bad_rows = s-&gt;t4_t6_rx.bad_rows;
+    t-&gt;longest_bad_row_run = s-&gt;t4_t6_rx.longest_bad_row_run;
+    t-&gt;x_resolution = s-&gt;x_resolution;
+    t-&gt;y_resolution = s-&gt;y_resolution;
+    t-&gt;encoding = s-&gt;line_encoding;
+    t-&gt;line_image_size = s-&gt;line_image_size/8;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(const char *) t4_encoding_to_str(int encoding)
+{
+    switch (encoding)
+    {
+    case T4_COMPRESSION_ITU_T4_1D:
+        return &quot;T.4 1-D&quot;;
+    case T4_COMPRESSION_ITU_T4_2D:
+        return &quot;T.4 2-D&quot;;
+    case T4_COMPRESSION_ITU_T6:
+        return &quot;T.6&quot;;
+    }
+    return &quot;???&quot;;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct4_t6_decode_statesh"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/t4_t6_decode_states.h (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t4_t6_decode_states.h                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/t4_t6_decode_states.h        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,12486 @@
</span><ins>+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * t4_t6_decode_states.h - state tables for T.4/T.6 FAX image decoding
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2004 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t4_t6_decode_states.h,v 1.1.2.4 2009/12/19 10:21:43 steveu Exp $
+ */
+
+/* Legitimate runs of zero bits which are the tail end of one code
+   plus the start of the next code do not exceed 10 bits. */
+
+/* Finite state machine state codes */
+enum
+{
+    S_Null      = 0,
+    S_Pass      = 1,
+    S_Horiz     = 2,
+    S_Vert      = 3,
+    S_Ext       = 4,
+    S_TermW     = 5,
+    S_TermB     = 6,
+    S_MakeUpW   = 7,
+    S_MakeUpB   = 8,
+    S_MakeUp    = 9,
+    S_EOL       = 10
+};
+
+/*! T.4 finite state machine state table entry */
+typedef struct
+{
+    /*! State */
+    uint8_t state;
+    /*! Width of code in bits */
+    uint8_t width;
+    /*! Run length in bits */
+    int16_t param;
+} t4_table_entry_t;
+
+static const t4_table_entry_t t4_2d_table[128] =
+{
+    {S_Null,       1,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Vert,       6,   -2},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Vert,       7,   -3},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Vert,       6,    2},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Ext,        7,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Vert,       6,   -2},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Vert,       7,    3},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Vert,       6,    2},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0},
+    {S_Pass,       4,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,   -1},
+    {S_Vert,       1,    0},
+    {S_Horiz,      3,    0},
+    {S_Vert,       1,    0},
+    {S_Vert,       3,    1},
+    {S_Vert,       1,    0}
+};
+
+static const t4_table_entry_t t4_1d_white_table[4096] =
+{
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    11, 1792},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    11, 1856},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2112},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2368},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 1984},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    11, 1920},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2240},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2496},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_EOL,       12,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    11, 1792},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    11, 1856},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2176},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2432},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2048},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    11, 1920},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1472},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1216},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  960},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  704},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2304},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  832},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1600},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1344},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1088},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_Null,       1,    0},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   39},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    8,  576},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   55},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   45},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   53},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  448},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   35},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   51},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,   63},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1536},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   43},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1280},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   29},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   33},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   49},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   61},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   47},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   59},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   41},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1024},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   31},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   57},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    9,  768},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   37},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  320},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_MakeUp,    12, 2560},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   20},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   24},
+    {S_TermW,      6,   14},
+    {S_TermW,      7,   28},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   23},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   27},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   40},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9,  896},
+    {S_TermW,      4,    6},
+    {S_TermW,      7,   19},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   56},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   46},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   54},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  512},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   36},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   52},
+    {S_TermW,      6,   15},
+    {S_TermW,      8,    0},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_MakeUpW,    9, 1728},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   44},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    9, 1408},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   30},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      6,   12},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    6, 1664},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   34},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      8,   50},
+    {S_TermW,      6,   14},
+    {S_TermW,      8,   62},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      8,   48},
+    {S_TermW,      4,    3},
+    {S_TermW,      8,   60},
+    {S_TermW,      4,    5},
+    {S_TermW,      8,   42},
+    {S_TermW,      6,   16},
+    {S_MakeUpW,    9, 1152},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   32},
+    {S_TermW,      5,    8},
+    {S_TermW,      8,   58},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      7,   22},
+    {S_TermW,      4,    3},
+    {S_TermW,      5,   11},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   26},
+    {S_TermW,      5,    9},
+    {S_MakeUpW,    8,  640},
+    {S_TermW,      4,    6},
+    {S_TermW,      8,   38},
+    {S_MakeUpW,    5,  128},
+    {S_TermW,      7,   25},
+    {S_TermW,      6,   15},
+    {S_MakeUpW,    8,  384},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7},
+    {S_TermW,      6,   13},
+    {S_TermW,      4,    3},
+    {S_TermW,      7,   18},
+    {S_TermW,      4,    5},
+    {S_TermW,      7,   21},
+    {S_TermW,      6,   17},
+    {S_MakeUpW,    7,  256},
+    {S_TermW,      4,    6},
+    {S_TermW,      6,    1},
+    {S_TermW,      5,    8},
+    {S_MakeUpW,    6,  192},
+    {S_MakeUpW,    5,   64},
+    {S_TermW,      5,   10},
+    {S_TermW,      4,    4},
+    {S_TermW,      4,    2},
+    {S_TermW,      4,    7}
+};
+
+static const t4_table_entry_t t4_1d_black_table[8192] =
+{
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1792},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   23},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   20},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   25},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  128},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   56},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   30},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1856},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   57},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   21},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   54},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   52},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   48},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2112},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   44},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   36},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  384},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   28},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   60},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   40},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2368},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 1984},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   50},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   34},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1664},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   26},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1408},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   32},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1920},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   61},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   42},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1024},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  768},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   62},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2240},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   46},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   38},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  512},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   19},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   24},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   22},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2496},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_EOL,       12,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1792},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   23},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   20},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   25},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  192},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1280},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   31},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1856},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   58},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   21},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  896},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  640},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   49},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2176},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   45},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   37},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  448},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   29},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1536},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   41},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2432},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2048},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   51},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   35},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  320},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   27},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   59},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   33},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1920},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  256},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   43},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1152},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   55},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   63},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2304},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   47},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   39},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   53},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   19},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   24},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   22},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2560},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1792},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   23},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   20},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   25},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  128},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   56},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   30},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1856},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   57},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   21},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   54},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   52},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   48},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2112},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   44},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   36},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  384},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   28},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   60},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   40},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2368},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 1984},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   50},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   34},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1728},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   26},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1472},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   32},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1920},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   61},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   42},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1088},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  832},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   62},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2240},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   46},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   38},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  576},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   19},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   24},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   22},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2496},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_EOL,       12,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1792},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   23},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   20},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   25},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  192},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1344},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   31},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1856},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   58},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   21},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  960},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13,  704},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   49},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2176},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   45},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   37},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  448},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   29},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1600},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   41},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2432},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   18},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   17},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2048},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   51},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   35},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  320},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   27},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   59},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   33},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    11, 1920},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   12,  256},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   43},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   13, 1216},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      9,   15},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   55},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   63},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2304},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   47},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   39},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     12,   53},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_Null,       1,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   13},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   19},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   24},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     11,   22},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUp,    12, 2560},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   10},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,   16},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,     10,    0},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_MakeUpB,   10,   64},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    9},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   11},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      8,   14},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      6,    8},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      7,   12},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    6},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2},
+    {S_TermB,      5,    7},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    1},
+    {S_TermB,      2,    2},
+    {S_TermB,      4,    5},
+    {S_TermB,      2,    3},
+    {S_TermB,      3,    4},
+    {S_TermB,      2,    2}
+};
+
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrct4_txc"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/libs/spandsp/src/t4_tx.c (0 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/t4_tx.c                                (rev 0)
+++ freeswitch/trunk/libs/spandsp/src/t4_tx.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -0,0 +1,1539 @@
</span><ins>+//#define T4_STATE_DEBUGGING
+/*
+ * SpanDSP - a series of DSP components for telephony
+ *
+ * t4_tx.c - ITU T.4 FAX transmit processing
+ *
+ * Written by Steve Underwood &lt;steveu@coppice.org&gt;
+ *
+ * Copyright (C) 2003, 2007 Steve Underwood
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 2.1,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * $Id: t4_tx.c,v 1.13.2.9 2009/12/21 17:18:40 steveu Exp $
+ */
+
+/*
+ * Much of this file is based on the T.4 and T.6 support in libtiff, which requires
+ * the following notice in any derived source code:
+ *
+ * Copyright (c) 1990-1997 Sam Leffler
+ * Copyright (c) 1991-1997 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and 
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the names of
+ * Sam Leffler and Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Sam Leffler and Silicon Graphics.
+ * 
+ * THE SOFTWARE IS PROVIDED &quot;AS-IS&quot; AND WITHOUT WARRANTY OF ANY KIND, 
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
+ * 
+ * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
+ * OF THIS SOFTWARE.
+ */
+
+/*! \file */
+
+#if defined(HAVE_CONFIG_H)
+#include &quot;config.h&quot;
+#endif
+
+#include &lt;stdlib.h&gt;
+#include &lt;inttypes.h&gt;
+#include &lt;limits.h&gt;
+#include &lt;stdio.h&gt;
+#include &lt;fcntl.h&gt;
+#include &lt;unistd.h&gt;
+#include &lt;time.h&gt;
+#include &lt;memory.h&gt;
+#include &lt;string.h&gt;
+#if defined(HAVE_TGMATH_H)
+#include &lt;tgmath.h&gt;
+#endif
+#if defined(HAVE_MATH_H)
+#include &lt;math.h&gt;
+#endif
+#include &quot;floating_fudge.h&quot;
+#include &lt;tiffio.h&gt;
+
+#include &quot;spandsp/telephony.h&quot;
+#include &quot;spandsp/logging.h&quot;
+#include &quot;spandsp/bit_operations.h&quot;
+#include &quot;spandsp/async.h&quot;
+#include &quot;spandsp/t4_rx.h&quot;
+#include &quot;spandsp/t4_tx.h&quot;
+#include &quot;spandsp/version.h&quot;
+
+#include &quot;spandsp/private/logging.h&quot;
+#include &quot;spandsp/private/t4_rx.h&quot;
+#include &quot;spandsp/private/t4_tx.h&quot;
+
+/*! The number of centimetres in one inch */
+#define CM_PER_INCH                 2.54f
+
+/*! The number of EOLs to be sent at the end of a T.4 page */
+#define EOLS_TO_END_T4_TX_PAGE      6
+/*! The number of EOLs to be sent at the end of a T.6 page */
+#define EOLS_TO_END_T6_TX_PAGE      2
+
+#if defined(T4_STATE_DEBUGGING)
+static void STATE_TRACE(const char *format, ...)
+{
+    va_list arg_ptr;
+
+    va_start(arg_ptr, format);
+    vprintf(format, arg_ptr);
+    va_end(arg_ptr);
+}
+/*- End of function --------------------------------------------------------*/
+#else
+#define STATE_TRACE(...) /**/
+#endif
+
+/*! T.4 run length table entry */
+typedef struct
+{
+    /*! Length of T.4 code, in bits */
+    uint16_t length;
+    /*! T.4 code */
+    uint16_t code;
+    /*! Run length, in bits */
+    int16_t run_length;
+} t4_run_table_entry_t;
+
+#include &quot;faxfont.h&quot;
+
+/* Legitimate runs of zero bits which are the tail end of one code
+   plus the start of the next code do not exceed 10 bits. */
+
+/*
+ * Note that these tables are ordered such that the index into the table
+ * is known to be either the run length, or (run length / 64) + a fixed
+ * offset.
+ */
+static const t4_run_table_entry_t t4_white_codes[] =
+{
+    { 8, 0x00AC,    0},         /* 0011 0101 */
+    { 6, 0x0038,    1},         /* 0001 11 */
+    { 4, 0x000E,    2},         /* 0111 */
+    { 4, 0x0001,    3},         /* 1000 */
+    { 4, 0x000D,    4},         /* 1011 */
+    { 4, 0x0003,    5},         /* 1100 */
+    { 4, 0x0007,    6},         /* 1110 */
+    { 4, 0x000F,    7},         /* 1111 */
+    { 5, 0x0019,    8},         /* 1001 1 */
+    { 5, 0x0005,    9},         /* 1010 0 */
+    { 5, 0x001C,   10},         /* 0011 1 */
+    { 5, 0x0002,   11},         /* 0100 0 */
+    { 6, 0x0004,   12},         /* 0010 00 */
+    { 6, 0x0030,   13},         /* 0000 11 */
+    { 6, 0x000B,   14},         /* 1101 00 */
+    { 6, 0x002B,   15},         /* 1101 01 */
+    { 6, 0x0015,   16},         /* 1010 10 */
+    { 6, 0x0035,   17},         /* 1010 11 */
+    { 7, 0x0072,   18},         /* 0100 111 */
+    { 7, 0x0018,   19},         /* 0001 100 */
+    { 7, 0x0008,   20},         /* 0001 000 */
+    { 7, 0x0074,   21},         /* 0010 111 */
+    { 7, 0x0060,   22},         /* 0000 011 */
+    { 7, 0x0010,   23},         /* 0000 100 */
+    { 7, 0x000A,   24},         /* 0101 000 */
+    { 7, 0x006A,   25},         /* 0101 011 */
+    { 7, 0x0064,   26},         /* 0010 011 */
+    { 7, 0x0012,   27},         /* 0100 100 */
+    { 7, 0x000C,   28},         /* 0011 000 */
+    { 8, 0x0040,   29},         /* 0000 0010 */
+    { 8, 0x00C0,   30},         /* 0000 0011 */
+    { 8, 0x0058,   31},         /* 0001 1010 */
+    { 8, 0x00D8,   32},         /* 0001 1011 */
+    { 8, 0x0048,   33},         /* 0001 0010 */
+    { 8, 0x00C8,   34},         /* 0001 0011 */
+    { 8, 0x0028,   35},         /* 0001 0100 */
+    { 8, 0x00A8,   36},         /* 0001 0101 */
+    { 8, 0x0068,   37},         /* 0001 0110 */
+    { 8, 0x00E8,   38},         /* 0001 0111 */
+    { 8, 0x0014,   39},         /* 0010 1000 */
+    { 8, 0x0094,   40},         /* 0010 1001 */
+    { 8, 0x0054,   41},         /* 0010 1010 */
+    { 8, 0x00D4,   42},         /* 0010 1011 */
+    { 8, 0x0034,   43},         /* 0010 1100 */
+    { 8, 0x00B4,   44},         /* 0010 1101 */
+    { 8, 0x0020,   45},         /* 0000 0100 */
+    { 8, 0x00A0,   46},         /* 0000 0101 */
+    { 8, 0x0050,   47},         /* 0000 1010 */
+    { 8, 0x00D0,   48},         /* 0000 1011 */
+    { 8, 0x004A,   49},         /* 0101 0010 */
+    { 8, 0x00CA,   50},         /* 0101 0011 */
+    { 8, 0x002A,   51},         /* 0101 0100 */
+    { 8, 0x00AA,   52},         /* 0101 0101 */
+    { 8, 0x0024,   53},         /* 0010 0100 */
+    { 8, 0x00A4,   54},         /* 0010 0101 */
+    { 8, 0x001A,   55},         /* 0101 1000 */
+    { 8, 0x009A,   56},         /* 0101 1001 */
+    { 8, 0x005A,   57},         /* 0101 1010 */
+    { 8, 0x00DA,   58},         /* 0101 1011 */
+    { 8, 0x0052,   59},         /* 0100 1010 */
+    { 8, 0x00D2,   60},         /* 0100 1011 */
+    { 8, 0x004C,   61},         /* 0011 0010 */
+    { 8, 0x00CC,   62},         /* 0011 0011 */
+    { 8, 0x002C,   63},         /* 0011 0100 */
+    { 5, 0x001B,   64},         /* 1101 1 */
+    { 5, 0x0009,  128},         /* 1001 0 */
+    { 6, 0x003A,  192},         /* 0101 11 */
+    { 7, 0x0076,  256},         /* 0110 111 */
+    { 8, 0x006C,  320},         /* 0011 0110 */
+    { 8, 0x00EC,  384},         /* 0011 0111 */
+    { 8, 0x0026,  448},         /* 0110 0100 */
+    { 8, 0x00A6,  512},         /* 0110 0101 */
+    { 8, 0x0016,  576},         /* 0110 1000 */
+    { 8, 0x00E6,  640},         /* 0110 0111 */
+    { 9, 0x0066,  704},         /* 0110 0110 0 */
+    { 9, 0x0166,  768},         /* 0110 0110 1 */
+    { 9, 0x0096,  832},         /* 0110 1001 0 */
+    { 9, 0x0196,  896},         /* 0110 1001 1 */
+    { 9, 0x0056,  960},         /* 0110 1010 0 */
+    { 9, 0x0156, 1024},         /* 0110 1010 1 */
+    { 9, 0x00D6, 1088},         /* 0110 1011 0 */
+    { 9, 0x01D6, 1152},         /* 0110 1011 1 */
+    { 9, 0x0036, 1216},         /* 0110 1100 0 */
+    { 9, 0x0136, 1280},         /* 0110 1100 1 */
+    { 9, 0x00B6, 1344},         /* 0110 1101 0 */
+    { 9, 0x01B6, 1408},         /* 0110 1101 1 */
+    { 9, 0x0032, 1472},         /* 0100 1100 0 */
+    { 9, 0x0132, 1536},         /* 0100 1100 1 */
+    { 9, 0x00B2, 1600},         /* 0100 1101 0 */
+    { 6, 0x0006, 1664},         /* 0110 00 */
+    { 9, 0x01B2, 1728},         /* 0100 1101 1 */
+    {11, 0x0080, 1792},         /* 0000 0001 000 */
+    {11, 0x0180, 1856},         /* 0000 0001 100 */
+    {11, 0x0580, 1920},         /* 0000 0001 101 */
+    {12, 0x0480, 1984},         /* 0000 0001 0010 */
+    {12, 0x0C80, 2048},         /* 0000 0001 0011 */
+    {12, 0x0280, 2112},         /* 0000 0001 0100 */
+    {12, 0x0A80, 2176},         /* 0000 0001 0101 */
+    {12, 0x0680, 2240},         /* 0000 0001 0110 */
+    {12, 0x0E80, 2304},         /* 0000 0001 0111 */
+    {12, 0x0380, 2368},         /* 0000 0001 1100 */
+    {12, 0x0B80, 2432},         /* 0000 0001 1101 */
+    {12, 0x0780, 2496},         /* 0000 0001 1110 */
+    {12, 0x0F80, 2560},         /* 0000 0001 1111 */
+};
+
+static const t4_run_table_entry_t t4_black_codes[] =
+{
+    {10, 0x03B0,    0},         /* 0000 1101 11 */
+    { 3, 0x0002,    1},         /* 010 */
+    { 2, 0x0003,    2},         /* 11 */
+    { 2, 0x0001,    3},         /* 10 */
+    { 3, 0x0006,    4},         /* 011 */
+    { 4, 0x000C,    5},         /* 0011 */
+    { 4, 0x0004,    6},         /* 0010 */
+    { 5, 0x0018,    7},         /* 0001 1 */
+    { 6, 0x0028,    8},         /* 0001 01 */
+    { 6, 0x0008,    9},         /* 0001 00 */
+    { 7, 0x0010,   10},         /* 0000 100 */
+    { 7, 0x0050,   11},         /* 0000 101 */
+    { 7, 0x0070,   12},         /* 0000 111 */
+    { 8, 0x0020,   13},         /* 0000 0100 */
+    { 8, 0x00E0,   14},         /* 0000 0111 */
+    { 9, 0x0030,   15},         /* 0000 1100 0 */
+    {10, 0x03A0,   16},         /* 0000 0101 11 */
+    {10, 0x0060,   17},         /* 0000 0110 00 */
+    {10, 0x0040,   18},         /* 0000 0010 00 */
+    {11, 0x0730,   19},         /* 0000 1100 111 */
+    {11, 0x00B0,   20},         /* 0000 1101 000 */
+    {11, 0x01B0,   21},         /* 0000 1101 100 */
+    {11, 0x0760,   22},         /* 0000 0110 111 */
+    {11, 0x00A0,   23},         /* 0000 0101 000 */
+    {11, 0x0740,   24},         /* 0000 0010 111 */
+    {11, 0x00C0,   25},         /* 0000 0011 000 */
+    {12, 0x0530,   26},         /* 0000 1100 1010 */
+    {12, 0x0D30,   27},         /* 0000 1100 1011 */
+    {12, 0x0330,   28},         /* 0000 1100 1100 */
+    {12, 0x0B30,   29},         /* 0000 1100 1101 */
+    {12, 0x0160,   30},         /* 0000 0110 1000 */
+    {12, 0x0960,   31},         /* 0000 0110 1001 */
+    {12, 0x0560,   32},         /* 0000 0110 1010 */
+    {12, 0x0D60,   33},         /* 0000 0110 1011 */
+    {12, 0x04B0,   34},         /* 0000 1101 0010 */
+    {12, 0x0CB0,   35},         /* 0000 1101 0011 */
+    {12, 0x02B0,   36},         /* 0000 1101 0100 */
+    {12, 0x0AB0,   37},         /* 0000 1101 0101 */
+    {12, 0x06B0,   38},         /* 0000 1101 0110 */
+    {12, 0x0EB0,   39},         /* 0000 1101 0111 */
+    {12, 0x0360,   40},         /* 0000 0110 1100 */
+    {12, 0x0B60,   41},         /* 0000 0110 1101 */
+    {12, 0x05B0,   42},         /* 0000 1101 1010 */
+    {12, 0x0DB0,   43},         /* 0000 1101 1011 */
+    {12, 0x02A0,   44},         /* 0000 0101 0100 */
+    {12, 0x0AA0,   45},         /* 0000 0101 0101 */
+    {12, 0x06A0,   46},         /* 0000 0101 0110 */
+    {12, 0x0EA0,   47},         /* 0000 0101 0111 */
+    {12, 0x0260,   48},         /* 0000 0110 0100 */
+    {12, 0x0A60,   49},         /* 0000 0110 0101 */
+    {12, 0x04A0,   50},         /* 0000 0101 0010 */
+    {12, 0x0CA0,   51},         /* 0000 0101 0011 */
+    {12, 0x0240,   52},         /* 0000 0010 0100 */
+    {12, 0x0EC0,   53},         /* 0000 0011 0111 */
+    {12, 0x01C0,   54},         /* 0000 0011 1000 */
+    {12, 0x0E40,   55},         /* 0000 0010 0111 */
+    {12, 0x0140,   56},         /* 0000 0010 1000 */
+    {12, 0x01A0,   57},         /* 0000 0101 1000 */
+    {12, 0x09A0,   58},         /* 0000 0101 1001 */
+    {12, 0x0D40,   59},         /* 0000 0010 1011 */
+    {12, 0x0340,   60},         /* 0000 0010 1100 */
+    {12, 0x05A0,   61},         /* 0000 0101 1010 */
+    {12, 0x0660,   62},         /* 0000 0110 0110 */
+    {12, 0x0E60,   63},         /* 0000 0110 0111 */
+    {10, 0x03C0,   64},         /* 0000 0011 11 */
+    {12, 0x0130,  128},         /* 0000 1100 1000 */
+    {12, 0x0930,  192},         /* 0000 1100 1001 */
+    {12, 0x0DA0,  256},         /* 0000 0101 1011 */
+    {12, 0x0CC0,  320},         /* 0000 0011 0011 */
+    {12, 0x02C0,  384},         /* 0000 0011 0100 */
+    {12, 0x0AC0,  448},         /* 0000 0011 0101 */
+    {13, 0x06C0,  512},         /* 0000 0011 0110 0 */
+    {13, 0x16C0,  576},         /* 0000 0011 0110 1 */
+    {13, 0x0A40,  640},         /* 0000 0010 0101 0 */
+    {13, 0x1A40,  704},         /* 0000 0010 0101 1 */
+    {13, 0x0640,  768},         /* 0000 0010 0110 0 */
+    {13, 0x1640,  832},         /* 0000 0010 0110 1 */
+    {13, 0x09C0,  896},         /* 0000 0011 1001 0 */
+    {13, 0x19C0,  960},         /* 0000 0011 1001 1 */
+    {13, 0x05C0, 1024},         /* 0000 0011 1010 0 */
+    {13, 0x15C0, 1088},         /* 0000 0011 1010 1 */
+    {13, 0x0DC0, 1152},         /* 0000 0011 1011 0 */
+    {13, 0x1DC0, 1216},         /* 0000 0011 1011 1 */
+    {13, 0x0940, 1280},         /* 0000 0010 1001 0 */
+    {13, 0x1940, 1344},         /* 0000 0010 1001 1 */
+    {13, 0x0540, 1408},         /* 0000 0010 1010 0 */
+    {13, 0x1540, 1472},         /* 0000 0010 1010 1 */
+    {13, 0x0B40, 1536},         /* 0000 0010 1101 0 */
+    {13, 0x1B40, 1600},         /* 0000 0010 1101 1 */
+    {13, 0x04C0, 1664},         /* 0000 0011 0010 0 */
+    {13, 0x14C0, 1728},         /* 0000 0011 0010 1 */
+    {11, 0x0080, 1792},         /* 0000 0001 000 */
+    {11, 0x0180, 1856},         /* 0000 0001 100 */
+    {11, 0x0580, 1920},         /* 0000 0001 101 */
+    {12, 0x0480, 1984},         /* 0000 0001 0010 */
+    {12, 0x0C80, 2048},         /* 0000 0001 0011 */
+    {12, 0x0280, 2112},         /* 0000 0001 0100 */
+    {12, 0x0A80, 2176},         /* 0000 0001 0101 */
+    {12, 0x0680, 2240},         /* 0000 0001 0110 */
+    {12, 0x0E80, 2304},         /* 0000 0001 0111 */
+    {12, 0x0380, 2368},         /* 0000 0001 1100 */
+    {12, 0x0B80, 2432},         /* 0000 0001 1101 */
+    {12, 0x0780, 2496},         /* 0000 0001 1110 */
+    {12, 0x0F80, 2560},         /* 0000 0001 1111 */
+};
+
+static int encode_row(t4_state_t *s);
+
+static void make_header(t4_state_t *s, char *header)
+{
+    time_t now;
+    struct tm tm;
+    static const char *months[] =
+    {
+        &quot;Jan&quot;,
+        &quot;Feb&quot;,
+        &quot;Mar&quot;,
+        &quot;Apr&quot;,
+        &quot;May&quot;,
+        &quot;Jun&quot;,
+        &quot;Jul&quot;,
+        &quot;Aug&quot;,
+        &quot;Sep&quot;,
+        &quot;Oct&quot;,
+        &quot;Nov&quot;,
+        &quot;Dec&quot;
+    };
+
+    time(&amp;now);
+    tm = *localtime(&amp;now);
+    snprintf(header,
+             132,
+             &quot;  %2d-%s-%d  %02d:%02d    %-50s %-21s   p.%d&quot;,
+             tm.tm_mday,
+             months[tm.tm_mon],
+             tm.tm_year + 1900,
+             tm.tm_hour,
+             tm.tm_min,
+             s-&gt;t4_t6_tx.header_info,
+             s-&gt;tiff.local_ident,
+             s-&gt;current_page + 1);
+}
+/*- End of function --------------------------------------------------------*/
+
+static int t4_tx_put_fax_header(t4_state_t *s)
+{
+    int row;
+    int i;
+    int repeats;
+    int pattern;
+    int row_bufptr;
+    char *t;
+    char header[132 + 1];
+
+    /* Modify the resulting image to include a header line, typical of hardware FAX machines */
+    make_header(s, header);
+    switch (s-&gt;y_resolution)
+    {
+    case T4_Y_RESOLUTION_1200:
+        repeats = 12;
+        break;
+    case T4_Y_RESOLUTION_800:
+        repeats = 8;
+        break;
+    case T4_Y_RESOLUTION_600:
+        repeats = 6;
+        break;
+    case T4_Y_RESOLUTION_SUPERFINE:
+        repeats = 4;
+        break;
+    case T4_Y_RESOLUTION_300:
+        repeats = 3;
+        break;
+    case T4_Y_RESOLUTION_FINE:
+        repeats = 2;
+        break;
+    default:
+        repeats = 1;
+        break;
+    }
+    for (row = 0;  row &lt; 16;  row++)
+    {
+        t = header;
+        row_bufptr = 0;
+        for (t = header;  *t  &amp;&amp;  row_bufptr &lt;= s-&gt;bytes_per_row - 2;  t++)
+        {
+            pattern = header_font[(uint8_t) *t][row];
+            s-&gt;row_buf[row_bufptr++] = (uint8_t) (pattern &gt;&gt; 8);
+            s-&gt;row_buf[row_bufptr++] = (uint8_t) (pattern &amp; 0xFF);
+        }
+        for (  ;  row_bufptr &lt; s-&gt;bytes_per_row;  )
+            s-&gt;row_buf[row_bufptr++] = 0;
+        for (i = 0;  i &lt; repeats;  i++)
+        {
+            if (encode_row(s))
+                return -1;
+        }
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_resolution(int res_unit, float actual, float expected)
+{
+    if (res_unit == RESUNIT_INCH)
+        actual *= 1.0f/CM_PER_INCH;
+    return (expected*0.95f &lt;= actual  &amp;&amp;  actual &lt;= expected*1.05f);
+}
+/*- End of function --------------------------------------------------------*/
+
+static int get_tiff_directory_info(t4_state_t *s)
+{
+    static const struct
+    {
+        float resolution;
+        int code;
+    } x_res_table[] =
+    {
+        { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4},
+        { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8},
+        { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300},
+        { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16},
+        { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600},
+        { 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800},
+        {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200},
+        {             -1.00f, -1}
+    };
+    static const struct
+    {
+        float resolution;
+        int code;
+        int max_rows_to_next_1d_row;
+    } y_res_table[] =
+    {
+        {             38.50f, T4_Y_RESOLUTION_STANDARD, 2},
+        {             77.00f, T4_Y_RESOLUTION_FINE, 4},
+        { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300, 6},
+        {            154.00f, T4_Y_RESOLUTION_SUPERFINE, 8},
+        { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600, 12},
+        { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800, 16},
+        {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200, 24},
+        {             -1.00f, -1, -1}
+    };
+    uint16_t res_unit;
+    uint16_t parm16;
+    uint32_t parm32;
+    float x_resolution;
+    float y_resolution;
+    int i;
+    t4_tiff_state_t *t;
+
+    t = &amp;s-&gt;tiff;
+    parm16 = 0;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_BITSPERSAMPLE, &amp;parm16);
+    if (parm16 != 1)
+        return -1;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_SAMPLESPERPIXEL, &amp;parm16);
+    if (parm16 != 1)
+        return -1;
+    parm32 = 0;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_IMAGEWIDTH, &amp;parm32);
+    s-&gt;image_width = parm32;
+    s-&gt;bytes_per_row = (s-&gt;image_width + 7)/8;
+    parm32 = 0;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_IMAGELENGTH, &amp;parm32);
+    s-&gt;image_length = parm32;
+    x_resolution = 0.0f;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_XRESOLUTION, &amp;x_resolution);
+    y_resolution = 0.0f;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_YRESOLUTION, &amp;y_resolution);
+    res_unit = RESUNIT_INCH;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_RESOLUTIONUNIT, &amp;res_unit);
+    t-&gt;photo_metric = PHOTOMETRIC_MINISWHITE;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_PHOTOMETRIC, &amp;t-&gt;photo_metric);
+    if (t-&gt;photo_metric != PHOTOMETRIC_MINISWHITE)
+        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s: Photometric needs swapping.\n&quot;, t-&gt;file);
+    t-&gt;fill_order = FILLORDER_LSB2MSB;
+#if 0
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_FILLORDER, &amp;t-&gt;fill_order);
+    if (t-&gt;fill_order != FILLORDER_LSB2MSB)
+        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s: Fill order needs swapping.\n&quot;, t-&gt;file);
+#endif
+
+    /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the
+       precise value. The other value should be exact. */
+    /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */
+    s-&gt;x_resolution = T4_X_RESOLUTION_R8;
+    for (i = 0;  x_res_table[i].code &gt; 0;  i++)
+    {
+        if (test_resolution(res_unit, x_resolution, x_res_table[i].resolution))
+        {
+            s-&gt;x_resolution = x_res_table[i].code;
+            break;
+        }
+    }
+
+    s-&gt;y_resolution = T4_Y_RESOLUTION_STANDARD;
+    s-&gt;t4_t6_tx.max_rows_to_next_1d_row = 2;
+    for (i = 0;  y_res_table[i].code &gt; 0;  i++)
+    {
+        if (test_resolution(res_unit, y_resolution, y_res_table[i].resolution))
+        {
+            s-&gt;y_resolution = y_res_table[i].code;
+            s-&gt;t4_t6_tx.max_rows_to_next_1d_row = y_res_table[i].max_rows_to_next_1d_row;
+            break;
+        }
+    }
+
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int test_tiff_directory_info(t4_state_t *s)
+{
+    static const struct
+    {
+        float resolution;
+        int code;
+    } x_res_table[] =
+    {
+        { 102.0f/CM_PER_INCH, T4_X_RESOLUTION_R4},
+        { 204.0f/CM_PER_INCH, T4_X_RESOLUTION_R8},
+        { 300.0f/CM_PER_INCH, T4_X_RESOLUTION_300},
+        { 408.0f/CM_PER_INCH, T4_X_RESOLUTION_R16},
+        { 600.0f/CM_PER_INCH, T4_X_RESOLUTION_600},
+        { 800.0f/CM_PER_INCH, T4_X_RESOLUTION_800},
+        {1200.0f/CM_PER_INCH, T4_X_RESOLUTION_1200},
+        {             -1.00f, -1}
+    };
+    static const struct
+    {
+        float resolution;
+        int code;
+        int max_rows_to_next_1d_row;
+    } y_res_table[] =
+    {
+        {             38.50f, T4_Y_RESOLUTION_STANDARD, 2},
+        {             77.00f, T4_Y_RESOLUTION_FINE, 4},
+        { 300.0f/CM_PER_INCH, T4_Y_RESOLUTION_300, 6},
+        {            154.00f, T4_Y_RESOLUTION_SUPERFINE, 8},
+        { 600.0f/CM_PER_INCH, T4_Y_RESOLUTION_600, 12},
+        { 800.0f/CM_PER_INCH, T4_Y_RESOLUTION_800, 16},
+        {1200.0f/CM_PER_INCH, T4_Y_RESOLUTION_1200, 24},
+        {             -1.00f, -1, -1}
+    };
+    uint16_t res_unit;
+    uint16_t parm16;
+    uint32_t parm32;
+    float x_resolution;
+    float y_resolution;
+    int i;
+    t4_tiff_state_t *t;
+
+    t = &amp;s-&gt;tiff;
+    parm16 = 0;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_BITSPERSAMPLE, &amp;parm16);
+    if (parm16 != 1)
+        return -1;
+    parm32 = 0;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_IMAGEWIDTH, &amp;parm32);
+    if (s-&gt;image_width != (int) parm32)
+        return 1;
+    x_resolution = 0.0f;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_XRESOLUTION, &amp;x_resolution);
+    y_resolution = 0.0f;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_YRESOLUTION, &amp;y_resolution);
+    res_unit = RESUNIT_INCH;
+    TIFFGetField(t-&gt;tiff_file, TIFFTAG_RESOLUTIONUNIT, &amp;res_unit);
+
+    /* Allow a little range for the X resolution in centimeters. The spec doesn't pin down the
+       precise value. The other value should be exact. */
+    /* Treat everything we can't match as R8. Most FAXes are this resolution anyway. */
+    for (i = 0;  x_res_table[i].code &gt; 0;  i++)
+    {
+        if (test_resolution(res_unit, x_resolution, x_res_table[i].resolution))
+            break;
+    }
+    if (s-&gt;x_resolution != x_res_table[i].code)
+        return 1;
+    for (i = 0;  y_res_table[i].code &gt; 0;  i++)
+    {
+        if (test_resolution(res_unit, y_resolution, y_res_table[i].resolution))
+            break;
+    }
+    if (s-&gt;y_resolution != y_res_table[i].code)
+        return 1;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int get_tiff_total_pages(t4_state_t *s)
+{
+    int max;
+
+    /* Each page *should* contain the total number of pages, but can this be
+       trusted? Some files say 0. Actually searching for the last page is
+       more reliable. */
+    max = 0;
+    while (TIFFSetDirectory(s-&gt;tiff.tiff_file, (tdir_t) max))
+        max++;
+    /* Back to the previous page */
+    if (!TIFFSetDirectory(s-&gt;tiff.tiff_file, (tdir_t) s-&gt;current_page))
+        return -1;
+    return max;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int open_tiff_input_file(t4_state_t *s, const char *file)
+{
+    if ((s-&gt;tiff.tiff_file = TIFFOpen(file, &quot;r&quot;)) == NULL)
+        return -1;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int read_tiff_image(t4_state_t *s)
+{
+    int row;
+    int image_length;
+    int i;
+
+    image_length = 0;
+    TIFFGetField(s-&gt;tiff.tiff_file, TIFFTAG_IMAGELENGTH, &amp;image_length);
+    for (row = 0;  row &lt; image_length;  row++)
+    {
+        if (TIFFReadScanline(s-&gt;tiff.tiff_file, s-&gt;row_buf, row, 0) &lt;= 0)
+        {
+            span_log(&amp;s-&gt;logging, SPAN_LOG_WARNING, &quot;%s: Read error at row %d.\n&quot;, s-&gt;tiff.file, row);
+            break;
+        }
+        if (s-&gt;tiff.photo_metric != PHOTOMETRIC_MINISWHITE)
+        {
+            for (i = 0;  i &lt; s-&gt;bytes_per_row;  i++)
+                s-&gt;row_buf[i] = ~s-&gt;row_buf[i];
+        }
+        if (s-&gt;tiff.fill_order != FILLORDER_LSB2MSB)
+            bit_reverse(s-&gt;row_buf, s-&gt;row_buf, s-&gt;bytes_per_row);
+        if (encode_row(s))
+            return -1;
+    }
+    return image_length;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int close_tiff_input_file(t4_state_t *s)
+{
+    TIFFClose(s-&gt;tiff.tiff_file);
+    s-&gt;tiff.tiff_file = NULL;
+    if (s-&gt;tiff.file)
+        free((char *) s-&gt;tiff.file);
+    s-&gt;tiff.file = NULL;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static void update_row_bit_info(t4_state_t *s)
+{
+    if (s-&gt;row_bits &gt; s-&gt;max_row_bits)
+        s-&gt;max_row_bits = s-&gt;row_bits;
+    if (s-&gt;row_bits &lt; s-&gt;min_row_bits)
+        s-&gt;min_row_bits = s-&gt;row_bits;
+    s-&gt;row_bits = 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int free_buffers(t4_state_t *s)
+{
+    if (s-&gt;image_buffer)
+    {
+        free(s-&gt;image_buffer);
+        s-&gt;image_buffer = NULL;
+        s-&gt;image_buffer_size = 0;
+    }
+    if (s-&gt;cur_runs)
+    {
+        free(s-&gt;cur_runs);
+        s-&gt;cur_runs = NULL;
+    }
+    if (s-&gt;ref_runs)
+    {
+        free(s-&gt;ref_runs);
+        s-&gt;ref_runs = NULL;
+    }
+    if (s-&gt;row_buf)
+    {
+        free(s-&gt;row_buf);
+        s-&gt;row_buf = NULL;
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int row_to_run_lengths(uint32_t list[], const uint8_t row[], int width)
+{
+    uint32_t flip;
+    uint32_t x;
+    int span;
+    int entry;
+    int frag;
+    int rem;
+    int limit;
+    int i;
+    int pos;
+
+    /* Deal with whole words first. We know we are starting on a word boundary. */
+    entry = 0;
+    flip = 0;
+    limit = (width &gt;&gt; 3) &amp; ~3;
+    span = 0;
+    pos = 0;
+    for (i = 0;  i &lt; limit;  i += sizeof(uint32_t))
+    {
+        x = *((uint32_t *) &amp;row[i]);
+        if (x != flip)
+        {
+            x = ((uint32_t) row[i] &lt;&lt; 24) | ((uint32_t) row[i + 1] &lt;&lt; 16) | ((uint32_t) row[i + 2] &lt;&lt; 8) | ((uint32_t) row[i + 3]);
+            /* We know we are going to find at least one transition. */
+            frag = 31 - top_bit(x ^ flip);
+            pos += ((i &lt;&lt; 3) - span + frag);
+            list[entry++] = pos;
+            x &lt;&lt;= frag;
+            flip ^= 0xFFFFFFFF;
+            rem = 32 - frag;
+            /* Now see if there are any more */
+            while ((frag = 31 - top_bit(x ^ flip)) &lt; rem)
+            {
+                pos += frag;
+                list[entry++] = pos;
+                x &lt;&lt;= frag;
+                flip ^= 0xFFFFFFFF;
+                rem -= frag;
+            }
+            /* Save the remainder of the word */
+            span = (i &lt;&lt; 3) + 32 - rem;
+        }
+    }
+    /* Now deal with some whole bytes, if there are any left. */
+    limit = width &gt;&gt; 3;
+    flip &amp;= 0xFF000000;
+    if (i &lt; limit)
+    {
+        for (  ;  i &lt; limit;  i++)
+        {
+            x = (uint32_t) row[i] &lt;&lt; 24;
+            if (x != flip)
+            {
+                /* We know we are going to find at least one transition. */
+                frag = 31 - top_bit(x ^ flip);
+                pos += ((i &lt;&lt; 3) - span + frag);
+                list[entry++] = pos;
+                x &lt;&lt;= frag;
+                flip ^= 0xFF000000;
+                rem = 8 - frag;
+                /* Now see if there are any more */
+                while ((frag = 31 - top_bit(x ^ flip)) &lt; rem)
+                {
+                    pos += frag;
+                    list[entry++] = pos;
+                    x &lt;&lt;= frag;
+                    flip ^= 0xFF000000;
+                    rem -= frag;
+                }   
+                /* Save the remainder of the word */
+                span = (i &lt;&lt; 3) + 8 - rem;
+            }
+        }
+    }
+    /* Deal with any left over fractional byte. */
+    span = (i &lt;&lt; 3) - span;
+    if ((rem = width &amp; 7))
+    {
+        x = row[i];
+        x &lt;&lt;= 24;
+        do
+        {
+            frag = 31 - top_bit(x ^ flip);
+            if (frag &gt; rem)
+                frag = rem;
+            pos += (span + frag);
+            list[entry++] = pos;
+            x &lt;&lt;= frag;
+            span = 0;
+            flip ^= 0xFF000000;
+            rem -= frag;
+        }
+        while (rem &gt; 0);
+    }
+    else
+    {
+        if (span)
+        {
+            pos += span;
+            list[entry++] = pos;
+        }
+    }
+    return entry;
+}
+/*- End of function --------------------------------------------------------*/
+
+static __inline__ int put_encoded_bits(t4_state_t *s, uint32_t bits, int length)
+{
+    uint8_t *t;
+
+    /* We might be called with a large length value, to spew out a mass of zero bits for
+       minimum row length padding. */
+    s-&gt;tx_bitstream |= (bits &lt;&lt; s-&gt;tx_bits);
+    s-&gt;tx_bits += length;
+    s-&gt;row_bits += length;
+    if ((s-&gt;image_size + (s-&gt;tx_bits + 7)/8) &gt;= s-&gt;image_buffer_size)
+    {
+        if ((t = realloc(s-&gt;image_buffer, s-&gt;image_buffer_size + 100*s-&gt;bytes_per_row)) == NULL)
+            return -1;
+        s-&gt;image_buffer = t;
+        s-&gt;image_buffer_size += 100*s-&gt;bytes_per_row;
+    }
+    while (s-&gt;tx_bits &gt;= 8)
+    {
+        s-&gt;image_buffer[s-&gt;image_size++] = (uint8_t) (s-&gt;tx_bitstream &amp; 0xFF);
+        s-&gt;tx_bitstream &gt;&gt;= 8;
+        s-&gt;tx_bits -= 8;
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+/*
+ * Write the sequence of codes that describes
+ * the specified span of zero's or one's.  The
+ * appropriate table that holds the make-up and
+ * terminating codes is supplied.
+ */
+static __inline__ int put_1d_span(t4_state_t *s, int32_t span, const t4_run_table_entry_t *tab)
+{
+    const t4_run_table_entry_t *te;
+
+    te = &amp;tab[63 + (2560 &gt;&gt; 6)];
+    while (span &gt;= 2560 + 64)
+    {
+        if (put_encoded_bits(s, te-&gt;code, te-&gt;length))
+            return -1;
+        span -= te-&gt;run_length;
+    }
+    te = &amp;tab[63 + (span &gt;&gt; 6)];
+    if (span &gt;= 64)
+    {
+        if (put_encoded_bits(s, te-&gt;code, te-&gt;length))
+            return -1;
+        span -= te-&gt;run_length;
+    }
+    if (put_encoded_bits(s, tab[span].code, tab[span].length))
+        return -1;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+#define pixel_is_black(x,bit) (((x)[(bit) &gt;&gt; 3] &lt;&lt; ((bit) &amp; 7)) &amp; 0x80)
+
+/*
+ * Write an EOL code to the output stream.  We also handle writing the tag
+ * bit for the next scanline when doing 2D encoding.
+ */
+static void encode_eol(t4_state_t *s)
+{
+    uint32_t code;
+    int length;
+
+    if (s-&gt;line_encoding == T4_COMPRESSION_ITU_T4_2D)
+    {
+        code = 0x0800 | ((!s-&gt;row_is_2d) &lt;&lt; 12);
+        length = 13;
+    }
+    else
+    {
+        /* T.4 1D EOL, or T.6 EOFB */
+        code = 0x800;
+        length = 12;
+    }
+    if (s-&gt;row_bits)
+    {
+        /* We may need to pad the row to a minimum length, unless we are in T.6 mode.
+           In T.6 we only come here at the end of the page to add the EOFB marker, which
+           is like two 1D EOLs. */
+        if (s-&gt;line_encoding != T4_COMPRESSION_ITU_T6)
+        {
+            if (s-&gt;row_bits + length &lt; s-&gt;t4_t6_tx.min_bits_per_row)
+                put_encoded_bits(s, 0, s-&gt;t4_t6_tx.min_bits_per_row - (s-&gt;row_bits + length));
+        }
+        put_encoded_bits(s, code, length);
+        update_row_bit_info(s);
+    }
+    else
+    {
+        /* We don't pad zero length rows. They are the consecutive EOLs which end a page. */
+        put_encoded_bits(s, code, length);
+        /* Don't do the full update row bit info, or the minimum suddenly drops to the
+           length of an EOL. Just clear the row bits, so we treat the next EOL as an
+           end of page EOL, with no padding. */
+        s-&gt;row_bits = 0;
+    }
+}
+/*- End of function --------------------------------------------------------*/
+
+/*
+ * 2D-encode a row of pixels.  Consult ITU specification T.4 for the algorithm.
+ */
+static void encode_2d_row(t4_state_t *s)
+{
+    static const t4_run_table_entry_t codes[] =
+    {
+        { 7, 0x60, 0 },         /* VR3          0000 011 */
+        { 6, 0x30, 0 },         /* VR2          0000 11 */
+        { 3, 0x06, 0 },         /* VR1          011 */
+        { 1, 0x01, 0 },         /* V0           1 */
+        { 3, 0x02, 0 },         /* VL1          010 */
+        { 6, 0x10, 0 },         /* VL2          0000 10 */
+        { 7, 0x20, 0 },         /* VL3          0000 010 */
+        { 3, 0x04, 0 },         /* horizontal   001 */
+        { 4, 0x08, 0 }          /* pass         0001 */
+    };
+
+    /* The reference or starting changing element on the coding line. At the start of the coding
+       line, a0 is set on an imaginary white changing element situated just before the first element
+       on the line. During the coding of the coding line, the position of a0 is defined by the
+       previous coding mode. (See T.4/4.2.1.3.2.) */
+    int a0;
+    /* The next changing element to the right of a0 on the coding line. */
+    int a1;
+    /* The next changing element to the right of a1 on the coding line. */
+    int a2;
+    /* The first changing element on the reference line to the right of a0 and of opposite colour to a0. */
+    int b1;
+    /* The next changing element to the right of b1 on the reference line. */
+    int b2;
+    int diff;
+    int a_cursor;
+    int b_cursor;
+    int cur_steps;
+    uint32_t *p;
+
+    /*
+                                                    b1          b2 
+            XX  XX  XX  XX  XX  --  --  --  --  --  XX  XX  XX  --  --  --  --  --
+            XX  XX  XX  --  --  --  --  --  XX  XX  XX  XX  XX  XX  --  --  --  --
+                        a0                  a1                      a2
+
+
+        a)  Pass mode
+            This mode is identified when the position of b2 lies to the left of a1. When this mode
+            has been coded, a0 is set on the element of the coding line below b2 in preparation for
+            the next coding (i.e. on a0').
+            
+                                    b1          b2 
+            XX  XX  XX  XX  --  --  XX  XX  XX  --  --  --  --  --
+            XX  XX  --  --  --  --  --  --  --  --  --  --  XX  XX 
+                    a0                          a0'         a1
+                                Pass mode
+                                
+
+            However, the state where b2 occurs just above a1, as shown in the figure below, is not
+            considered as a pass mode.
+
+                                    b1          b2 
+            XX  XX  XX  XX  --  --  XX  XX  XX  --  --  --  --  --
+            XX  XX  --  --  --  --  --  --  --  XX  XX  XX  XX  XX
+                    a0                          a1
+                                Not pass mode
+
+
+        b)  Vertical mode
+            When this mode is identified, the position of a1 is coded relative to the position of b1.
+            The relative distance a1b1 can take on one of seven values V(0), VR(1), VR(2), VR(3),
+            VL(1), VL(2) and VL(3), each of which is represented by a separate code word. The
+            subscripts R and L indicate that a1 is to the right or left respectively of b1, and the
+            number in brackets indicates the value of the distance a1b1. After vertical mode coding
+            has occurred, the position of a0 is set on a1 (see figure below).
+
+        c)  Horizontal mode
+            When this mode is identified, both the run-lengths a0a1 and a1a2 are coded using the code
+            words H + M(a0a1) + M(a1a2). H is the flag code word 001 taken from the two-dimensional
+            code table. M(a0a1) and M(a1a2) are code words which represent the length and &quot;colour&quot;
+            of the runs a0a1 and a1a2 respectively and are taken from the appropriate white or black
+            one-dimensional code tables. After a horizontal mode coding, the position of a0 is set on
+            a2 (see figure below).
+
+                                                            Vertical
+                                                            &lt;a1 b1&gt;
+                                                                    b1              b2 
+            --  XX  XX  XX  XX  XX  --  --  --  --  --  --  --  --  XX  XX  XX  XX  --  --  --
+            --  --  --  --  --  --  --  --  --  --  --  --  XX  XX  XX  XX  XX  XX  XX  --  --
+                                    a0                      a1                          a2
+                                   &lt;-------- a0a1 --------&gt;&lt;-------- a1a2 ------------&gt;
+                                                    Horizontal mode
+                          Vertical and horizontal modes
+     */
+    /* The following implements the 2-D encoding section of the flow chart in Figure7/T.4 */
+    cur_steps = row_to_run_lengths(s-&gt;cur_runs, s-&gt;row_buf, s-&gt;image_width);
+    /* Stretch the row a little, so when we step by 2 we are guaranteed to
+       hit an entry showing the row length */
+    s-&gt;cur_runs[cur_steps] =
+    s-&gt;cur_runs[cur_steps + 1] =
+    s-&gt;cur_runs[cur_steps + 2] = s-&gt;cur_runs[cur_steps - 1];
+
+    a0 = 0;
+    a1 = s-&gt;cur_runs[0];
+    b1 = s-&gt;ref_runs[0];
+    a_cursor = 0;
+    b_cursor = 0;
+    for (;;)
+    {
+        b2 = s-&gt;ref_runs[b_cursor + 1];
+        if (b2 &gt;= a1)
+        {
+            diff = b1 - a1;
+            if (abs(diff) &lt;= 3)
+            {
+                /* Vertical mode coding */
+                put_encoded_bits(s, codes[diff + 3].code, codes[diff + 3].length);
+                a0 = a1;
+                a_cursor++;
+            }
+            else
+            {
+                /* Horizontal mode coding */
+                a2 = s-&gt;cur_runs[a_cursor + 1];
+                put_encoded_bits(s, codes[7].code, codes[7].length);
+                if (a0 + a1 == 0  ||  pixel_is_black(s-&gt;row_buf, a0) == 0)
+                {
+                    put_1d_span(s, a1 - a0, t4_white_codes);
+                    put_1d_span(s, a2 - a1, t4_black_codes);
+                }
+                else
+                {
+                    put_1d_span(s, a1 - a0, t4_black_codes);
+                    put_1d_span(s, a2 - a1, t4_white_codes);
+                }
+                a0 = a2;
+                a_cursor += 2;
+            }
+            if (a0 &gt;= s-&gt;image_width)
+                break;
+            if (a_cursor &gt;= cur_steps)
+                a_cursor = cur_steps - 1;
+            a1 = s-&gt;cur_runs[a_cursor];
+        }
+        else
+        {
+            /* Pass mode coding */
+            put_encoded_bits(s, codes[8].code, codes[8].length);
+            /* We now set a0 to somewhere in the middle of its current run,
+               but we know are aren't moving beyond that run. */
+            a0 = b2;
+            if (a0 &gt;= s-&gt;image_width)
+                break;
+        }
+        /* We need to hunt for the correct position in the reference row, as the
+           runs there have no particular alignment with the runs in the current
+           row. */
+        if (pixel_is_black(s-&gt;row_buf, a0))
+            b_cursor |= 1;
+        else
+            b_cursor &amp;= ~1;
+        if (a0 &lt; (int) s-&gt;ref_runs[b_cursor])
+        {
+            for (  ;  b_cursor &gt;= 0;  b_cursor -= 2)
+            {
+                if (a0 &gt;= (int) s-&gt;ref_runs[b_cursor])
+                    break;
+            }
+            b_cursor += 2;
+        }
+        else
+        {
+            for (  ;  b_cursor &lt; s-&gt;t4_t6_tx.ref_steps;  b_cursor += 2)
+            {
+                if (a0 &lt; (int) s-&gt;ref_runs[b_cursor])
+                    break;
+            }
+            if (b_cursor &gt;= s-&gt;t4_t6_tx.ref_steps)
+                b_cursor = s-&gt;t4_t6_tx.ref_steps - 1;
+        }
+        b1 = s-&gt;ref_runs[b_cursor];
+    }
+    /* Swap the buffers */
+    s-&gt;t4_t6_tx.ref_steps = cur_steps;
+    p = s-&gt;cur_runs;
+    s-&gt;cur_runs = s-&gt;ref_runs;
+    s-&gt;ref_runs = p;
+}
+/*- End of function --------------------------------------------------------*/
+
+/*
+ * 1D-encode a row of pixels. The encoding is a sequence of all-white or
+ * all-black spans of pixels encoded with Huffman codes.
+ */
+static void encode_1d_row(t4_state_t *s)
+{
+    int i;
+
+    /* Do our work in the reference row buffer, and it is already in place if
+       we need a reference row for a following 2D encoded row. */
+    s-&gt;t4_t6_tx.ref_steps = row_to_run_lengths(s-&gt;ref_runs, s-&gt;row_buf, s-&gt;image_width);
+    put_1d_span(s, s-&gt;ref_runs[0], t4_white_codes);
+    for (i = 1;  i &lt; s-&gt;t4_t6_tx.ref_steps;  i++)
+        put_1d_span(s, s-&gt;ref_runs[i] - s-&gt;ref_runs[i - 1], (i &amp; 1)  ?  t4_black_codes  :  t4_white_codes);
+    /* Stretch the row a little, so when we step by 2 we are guaranteed to
+       hit an entry showing the row length */
+    s-&gt;ref_runs[s-&gt;t4_t6_tx.ref_steps] =
+    s-&gt;ref_runs[s-&gt;t4_t6_tx.ref_steps + 1] =
+    s-&gt;ref_runs[s-&gt;t4_t6_tx.ref_steps + 2] = s-&gt;ref_runs[s-&gt;t4_t6_tx.ref_steps - 1];
+}
+/*- End of function --------------------------------------------------------*/
+
+static int encode_row(t4_state_t *s)
+{
+    switch (s-&gt;line_encoding)
+    {
+    case T4_COMPRESSION_ITU_T6:
+        /* T.6 compression is a trivial step up from T.4 2D, so we just
+           throw it in here. T.6 is only used with error correction,
+           so it does not need independantly compressed (i.e. 1D) lines
+           to recover from data errors. It doesn't need EOLs, either. */
+        if (s-&gt;row_bits)
+            update_row_bit_info(s);
+        encode_2d_row(s);
+        break;
+    case T4_COMPRESSION_ITU_T4_2D:
+        encode_eol(s);
+        if (s-&gt;row_is_2d)
+        {
+            encode_2d_row(s);
+            s-&gt;t4_t6_tx.rows_to_next_1d_row--;
+        }
+        else
+        {
+            encode_1d_row(s);
+            s-&gt;row_is_2d = TRUE;
+        }
+        if (s-&gt;t4_t6_tx.rows_to_next_1d_row &lt;= 0)
+        {
+            /* Insert a row of 1D encoding */
+            s-&gt;row_is_2d = FALSE;
+            s-&gt;t4_t6_tx.rows_to_next_1d_row = s-&gt;t4_t6_tx.max_rows_to_next_1d_row - 1;
+        }
+        break;
+    default:
+    case T4_COMPRESSION_ITU_T4_1D:
+        encode_eol(s);
+        encode_1d_row(s);
+        break;
+    }
+    s-&gt;row++;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_set_row_read_handler(t4_state_t *s, t4_row_read_handler_t handler, void *user_data)
+{
+    s-&gt;t4_t6_tx.row_read_handler = handler;
+    s-&gt;t4_t6_tx.row_read_user_data = user_data;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(t4_state_t *) t4_tx_init(t4_state_t *s, const char *file, int start_page, int stop_page)
+{
+    int run_space;
+
+    if (s == NULL)
+    {
+        if ((s = (t4_state_t *) malloc(sizeof(*s))) == NULL)
+            return NULL;
+    }
+    memset(s, 0, sizeof(*s));
+    span_log_init(&amp;s-&gt;logging, SPAN_LOG_NONE, NULL);
+    span_log_set_protocol(&amp;s-&gt;logging, &quot;T.4&quot;);
+    s-&gt;rx = FALSE;
+
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Start tx document\n&quot;);
+
+    if (open_tiff_input_file(s, file) &lt; 0)
+        return NULL;
+    s-&gt;tiff.file = strdup(file);
+    s-&gt;current_page =
+    s-&gt;tiff.start_page = (start_page &gt;= 0)  ?  start_page  :  0;
+    s-&gt;tiff.stop_page = (stop_page &gt;= 0)  ?  stop_page : INT_MAX;
+
+    if (!TIFFSetDirectory(s-&gt;tiff.tiff_file, (tdir_t) s-&gt;current_page))
+        return NULL;
+    if (get_tiff_directory_info(s))
+    {
+        close_tiff_input_file(s);
+        return NULL;
+    }
+
+    s-&gt;t4_t6_tx.rows_to_next_1d_row = s-&gt;t4_t6_tx.max_rows_to_next_1d_row - 1;
+
+    s-&gt;tiff.pages_in_file = -1;
+
+    run_space = (s-&gt;image_width + 4)*sizeof(uint32_t);
+    if ((s-&gt;cur_runs = (uint32_t *) malloc(run_space)) == NULL)
+        return NULL;
+    if ((s-&gt;ref_runs = (uint32_t *) malloc(run_space)) == NULL)
+    {
+        free_buffers(s);
+        close_tiff_input_file(s);
+        return NULL;
+    }
+    if ((s-&gt;row_buf = malloc(s-&gt;bytes_per_row)) == NULL)
+    {
+        free_buffers(s);
+        close_tiff_input_file(s);
+        return NULL;
+    }
+    s-&gt;ref_runs[0] =
+    s-&gt;ref_runs[1] =
+    s-&gt;ref_runs[2] =
+    s-&gt;ref_runs[3] = s-&gt;image_width;
+    s-&gt;t4_t6_tx.ref_steps = 1;
+    s-&gt;image_buffer_size = 0;
+    return s;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_start_page(t4_state_t *s)
+{
+    int row;
+    int i;
+    int run_space;
+    int len;
+    int old_image_width;
+    uint8_t *bufptr8;
+    uint32_t *bufptr;
+
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Start tx page %d\n&quot;, s-&gt;current_page);
+    if (s-&gt;current_page &gt; s-&gt;tiff.stop_page)
+        return -1;
+    if (s-&gt;tiff.tiff_file == NULL)
+        return -1;
+    old_image_width = s-&gt;image_width;
+    if (s-&gt;t4_t6_tx.row_read_handler == NULL)
+    {
+#if defined(HAVE_LIBTIFF)
+        if (!TIFFSetDirectory(s-&gt;tiff.tiff_file, (tdir_t) s-&gt;current_page))
+            return -1;
+        get_tiff_directory_info(s);
+#endif
+    }
+    s-&gt;image_size = 0;
+    s-&gt;tx_bitstream = 0;
+    s-&gt;tx_bits = 0;
+    s-&gt;row_is_2d = (s-&gt;line_encoding == T4_COMPRESSION_ITU_T6);
+    s-&gt;t4_t6_tx.rows_to_next_1d_row = s-&gt;t4_t6_tx.max_rows_to_next_1d_row - 1;
+
+    /* Allow for pages being of different width. */
+    run_space = (s-&gt;image_width + 4)*sizeof(uint32_t);
+    if (old_image_width != s-&gt;image_width)
+    {
+        s-&gt;bytes_per_row = (s-&gt;image_width + 7)/8;
+
+        if ((bufptr = (uint32_t *) realloc(s-&gt;cur_runs, run_space)) == NULL)
+            return -1;
+        s-&gt;cur_runs = bufptr;
+        if ((bufptr = (uint32_t *) realloc(s-&gt;ref_runs, run_space)) == NULL)
+            return -1;
+        s-&gt;ref_runs = bufptr;
+        if ((bufptr8 = realloc(s-&gt;row_buf, s-&gt;bytes_per_row)) == NULL)
+            return -1;
+        s-&gt;row_buf = bufptr8;
+    }
+    s-&gt;ref_runs[0] =
+    s-&gt;ref_runs[1] =
+    s-&gt;ref_runs[2] =
+    s-&gt;ref_runs[3] = s-&gt;image_width;
+    s-&gt;t4_t6_tx.ref_steps = 1;
+
+    s-&gt;row_bits = 0;
+    s-&gt;min_row_bits = INT_MAX;
+    s-&gt;max_row_bits = 0;
+
+    if (s-&gt;t4_t6_tx.header_info  &amp;&amp;  s-&gt;t4_t6_tx.header_info[0])
+    {
+        if (t4_tx_put_fax_header(s))
+            return -1;
+    }
+    if (s-&gt;t4_t6_tx.row_read_handler)
+    {
+        for (row = 0;  ;  row++)
+        {
+            if ((len = s-&gt;t4_t6_tx.row_read_handler(s-&gt;t4_t6_tx.row_read_user_data, s-&gt;row_buf, s-&gt;bytes_per_row)) &lt; 0)
+            {
+                span_log(&amp;s-&gt;logging, SPAN_LOG_WARNING, &quot;%s: Read error at row %d.\n&quot;, s-&gt;tiff.file, row);
+                break;
+            }
+            if (len == 0)
+                break;
+            if (encode_row(s))
+                return -1;
+        }
+        s-&gt;image_length = row;
+    }
+    else
+    {
+        if ((s-&gt;image_length = read_tiff_image(s)) &lt; 0)
+            return -1;
+    }
+    if (s-&gt;line_encoding == T4_COMPRESSION_ITU_T6)
+    {
+        /* Attach an EOFB (end of facsimile block == 2 x EOLs) to the end of the page */
+        for (i = 0;  i &lt; EOLS_TO_END_T6_TX_PAGE;  i++)
+            encode_eol(s);
+    }
+    else
+    {
+        /* Attach an RTC (return to control == 6 x EOLs) to the end of the page */
+        s-&gt;row_is_2d = FALSE;
+        for (i = 0;  i &lt; EOLS_TO_END_T4_TX_PAGE;  i++)
+            encode_eol(s);
+    }
+
+    /* Force any partial byte in progress to flush using ones. Any post EOL padding when
+       sending is normally ones, so this is consistent. */
+    put_encoded_bits(s, 0xFF, 7);
+    s-&gt;t4_t6_tx.bit_pos = 7;
+    s-&gt;t4_t6_tx.bit_ptr = 0;
+    s-&gt;line_image_size = s-&gt;image_size*8;
+
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_next_page_has_different_format(t4_state_t *s)
+{
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Checking for the existance of page %d\n&quot;, s-&gt;current_page + 1);
+    if (s-&gt;current_page &gt;= s-&gt;tiff.stop_page)
+        return -1;
+    if (s-&gt;t4_t6_tx.row_read_handler == NULL)
+    {
+#if defined(HAVE_LIBTIFF)
+        if (s-&gt;tiff.tiff_file == NULL)
+            return -1;
+        if (!TIFFSetDirectory(s-&gt;tiff.tiff_file, (tdir_t) s-&gt;current_page + 1))
+            return -1;
+        return test_tiff_directory_info(s);
+#endif
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_restart_page(t4_state_t *s)
+{
+    s-&gt;t4_t6_tx.bit_pos = 7;
+    s-&gt;t4_t6_tx.bit_ptr = 0;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_end_page(t4_state_t *s)
+{
+    s-&gt;current_page++;
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_bit(t4_state_t *s)
+{
+    int bit;
+
+    if (s-&gt;t4_t6_tx.bit_ptr &gt;= s-&gt;image_size)
+        return SIG_STATUS_END_OF_DATA;
+    bit = (s-&gt;image_buffer[s-&gt;t4_t6_tx.bit_ptr] &gt;&gt; (7 - s-&gt;t4_t6_tx.bit_pos)) &amp; 1;
+    if (--s-&gt;t4_t6_tx.bit_pos &lt; 0)
+    {
+        s-&gt;t4_t6_tx.bit_pos = 7;
+        s-&gt;t4_t6_tx.bit_ptr++;
+    }
+    return bit;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_byte(t4_state_t *s)
+{
+    if (s-&gt;t4_t6_tx.bit_ptr &gt;= s-&gt;image_size)
+        return 0x100;
+    return s-&gt;image_buffer[s-&gt;t4_t6_tx.bit_ptr++];
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_chunk(t4_state_t *s, uint8_t buf[], int max_len)
+{
+    if (s-&gt;t4_t6_tx.bit_ptr &gt;= s-&gt;image_size)
+        return 0;
+    if (s-&gt;t4_t6_tx.bit_ptr + max_len &gt; s-&gt;image_size)
+        max_len = s-&gt;image_size - s-&gt;t4_t6_tx.bit_ptr;
+    memcpy(buf, &amp;s-&gt;image_buffer[s-&gt;t4_t6_tx.bit_ptr], max_len);
+    s-&gt;t4_t6_tx.bit_ptr += max_len;
+    return max_len;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_check_bit(t4_state_t *s)
+{
+    int bit;
+
+    if (s-&gt;t4_t6_tx.bit_ptr &gt;= s-&gt;image_size)
+        return SIG_STATUS_END_OF_DATA;
+    bit = (s-&gt;image_buffer[s-&gt;t4_t6_tx.bit_ptr] &gt;&gt; s-&gt;t4_t6_tx.bit_pos) &amp; 1;
+    return bit;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_release(t4_state_t *s)
+{
+    if (s-&gt;rx)
+        return -1;
+    if (s-&gt;tiff.tiff_file)
+        close_tiff_input_file(s);
+    free_buffers(s);
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_free(t4_state_t *s)
+{
+    int ret;
+
+    ret = t4_tx_release(s);
+    free(s);
+    return ret;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_tx_set_tx_encoding(t4_state_t *s, int encoding)
+{
+    s-&gt;line_encoding = encoding;
+    s-&gt;t4_t6_tx.rows_to_next_1d_row = s-&gt;t4_t6_tx.max_rows_to_next_1d_row - 1;
+    s-&gt;row_is_2d = FALSE;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_tx_set_min_row_bits(t4_state_t *s, int bits)
+{
+    s-&gt;t4_t6_tx.min_bits_per_row = bits;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_tx_set_local_ident(t4_state_t *s, const char *ident)
+{
+    s-&gt;tiff.local_ident = (ident  &amp;&amp;  ident[0])  ?  ident  :  NULL;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(void) t4_tx_set_header_info(t4_state_t *s, const char *info)
+{
+    s-&gt;t4_t6_tx.header_info = (info  &amp;&amp;  info[0])  ?  info  :  NULL;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_y_resolution(t4_state_t *s)
+{
+    return s-&gt;y_resolution;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_x_resolution(t4_state_t *s)
+{
+    return s-&gt;x_resolution;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_image_width(t4_state_t *s)
+{
+    return s-&gt;image_width;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_pages_in_file(t4_state_t *s)
+{
+    int max;
+
+    max = 0;
+    if (s-&gt;t4_t6_tx.row_read_handler == NULL)
+        max = get_tiff_total_pages(s);
+    if (max &gt;= 0)
+        s-&gt;tiff.pages_in_file = max;
+    return max;
+}
+/*- End of function --------------------------------------------------------*/
+
+SPAN_DECLARE(int) t4_tx_get_current_page_in_file(t4_state_t *s)
+{
+    return s-&gt;current_page;
+}
+/*- End of function --------------------------------------------------------*/
+/*- End of file ------------------------------------------------------------*/
</ins></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcv17rxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/v17rx.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/v17rx.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/v17rx.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v17rx.c,v 1.153 2009/07/09 14:17:57 steveu Exp $
</del><ins>+ * $Id: v17rx.c,v 1.153.4.4 2009/12/19 14:18:13 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -121,22 +121,28 @@
</span><span class="cx"> /* Coefficients for the band edge symbol timing synchroniser (alpha = 0.99) */
</span><span class="cx"> /* low_edge = 2.0f*M_PI*(CARRIER_NOMINAL_FREQ - BAUD_RATE/2.0f)/SAMPLE_RATE; */
</span><span class="cx"> /* high_edge = 2.0f*M_PI*(CARRIER_NOMINAL_FREQ + BAUD_RATE/2.0f)/SAMPLE_RATE; */
</span><ins>+#define SIN_LOW_BAND_EDGE               0.453990499f
+#define COS_LOW_BAND_EDGE               0.891006542f
+#define SIN_HIGH_BAND_EDGE              0.707106781f
+#define COS_HIGH_BAND_EDGE             -0.707106781f
+#define ALPHA                           0.99f
+
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINTx)
</span><del>-#define SYNC_LOW_BAND_EDGE_COEFF_0      ((int)(FP_FACTOR* 1.764193f))   /* 2*alpha*cos(low_edge) */
-#define SYNC_LOW_BAND_EDGE_COEFF_1      ((int)(FP_FACTOR*-0.980100f))   /* -alpha^2 */
-#define SYNC_HIGH_BAND_EDGE_COEFF_0     ((int)(FP_FACTOR*-1.400072f))   /* 2*alpha*cos(high_edge) */
-#define SYNC_HIGH_BAND_EDGE_COEFF_1     ((int)(FP_FACTOR*-0.980100f))   /* -alpha^2 */
-#define SYNC_CROSS_CORR_COEFF_A         ((int)(FP_FACTOR*-0.932131f))   /* -alpha^2*sin(freq_diff) */
-#define SYNC_CROSS_CORR_COEFF_B         ((int)(FP_FACTOR* 0.700036f))   /* alpha*sin(high_edge) */
-#define SYNC_CROSS_CORR_COEFF_C         ((int)(FP_FACTOR*-0.449451f))   /* -alpha*sin(low_edge) */
</del><ins>+#define SYNC_LOW_BAND_EDGE_COEFF_0      ((int)(FP_FACTOR*(2.0f*ALPHA*COS_LOW_BAND_EDGE)))
+#define SYNC_LOW_BAND_EDGE_COEFF_1      ((int)(FP_FACTOR*(-ALPHA*ALPHA)))
+#define SYNC_LOW_BAND_EDGE_COEFF_2      ((int)(FP_FACTOR*(-ALPHA*SIN_LOW_BAND_EDGE)))
+#define SYNC_HIGH_BAND_EDGE_COEFF_0     ((int)(FP_FACTOR*(2.0f*ALPHA*COS_HIGH_BAND_EDGE)))
+#define SYNC_HIGH_BAND_EDGE_COEFF_1     ((int)(FP_FACTOR*(-ALPHA*ALPHA)))
+#define SYNC_HIGH_BAND_EDGE_COEFF_2     ((int)(FP_FACTOR*(-ALPHA*SIN_HIGH_BAND_EDGE)))
+#define SYNC_MIXED_EDGES_COEFF_3        ((int)(FP_FACTOR*(-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE))))
</ins><span class="cx"> #else
</span><del>-#define SYNC_LOW_BAND_EDGE_COEFF_0       1.764193f                      /* 2*alpha*cos(low_edge) */
-#define SYNC_LOW_BAND_EDGE_COEFF_1      -0.980100f                      /* -alpha^2 */
-#define SYNC_HIGH_BAND_EDGE_COEFF_0     -1.400072f                      /* 2*alpha*cos(high_edge) */
-#define SYNC_HIGH_BAND_EDGE_COEFF_1     -0.980100f                      /* -alpha^2 */
-#define SYNC_CROSS_CORR_COEFF_A         -0.932131f                      /* -alpha^2*sin(freq_diff) */
-#define SYNC_CROSS_CORR_COEFF_B          0.700036f                      /* alpha*sin(high_edge) */
-#define SYNC_CROSS_CORR_COEFF_C         -0.449451f                      /* -alpha*sin(low_edge) */
</del><ins>+#define SYNC_LOW_BAND_EDGE_COEFF_0      (2.0f*ALPHA*COS_LOW_BAND_EDGE)
+#define SYNC_LOW_BAND_EDGE_COEFF_1      (-ALPHA*ALPHA)
+#define SYNC_LOW_BAND_EDGE_COEFF_2      (-ALPHA*SIN_LOW_BAND_EDGE)
+#define SYNC_HIGH_BAND_EDGE_COEFF_0     (2.0f*ALPHA*COS_HIGH_BAND_EDGE)
+#define SYNC_HIGH_BAND_EDGE_COEFF_1     (-ALPHA*ALPHA)
+#define SYNC_HIGH_BAND_EDGE_COEFF_2     (-ALPHA*SIN_HIGH_BAND_EDGE)
+#define SYNC_MIXED_EDGES_COEFF_3        (-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE))
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINTx)
</span><span class="lines">@@ -533,12 +539,18 @@
</span><span class="cx"> 
</span><span class="cx">     /* This routine adapts the position of the half baud samples entering the equalizer. */
</span><span class="cx"> 
</span><ins>+    /* This symbol sync scheme is based on the technique first described by Dominique Godard in
+        Passband Timing Recovery in an All-Digital Modem Receiver
+        IEEE TRANSACTIONS ON COMMUNICATIONS, VOL. COM-26, NO. 5, MAY 1978 */
+
+    /* This is slightly rearranged for figure 3b of the Godard paper, as this saves a couple of
+       maths operations */
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINTx)
</span><span class="cx">     /* TODO: The scalings used here need more thorough evaluation, to see if overflows are possible. */
</span><span class="cx">     /* Cross correlate */
</span><del>-    v = (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_CROSS_CORR_COEFF_A
-      + (((s-&gt;symbol_sync_low[0] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_CROSS_CORR_COEFF_B
-      + (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[0] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_CROSS_CORR_COEFF_C;
</del><ins>+    v = (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[0] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_LOW_BAND_EDGE_COEFF_2
+      - (((s-&gt;symbol_sync_low[0] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_HIGH_BAND_EDGE_COEFF_2
+      + (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_MIXED_EDGES_COEFF_3;
</ins><span class="cx">     /* Filter away any DC component */
</span><span class="cx">     p = v - s-&gt;symbol_sync_dc_filter[1];
</span><span class="cx">     s-&gt;symbol_sync_dc_filter[1] = s-&gt;symbol_sync_dc_filter[0];
</span><span class="lines">@@ -548,9 +560,9 @@
</span><span class="cx">     if (abs(s-&gt;baud_phase) &gt; 100*FP_FACTOR)
</span><span class="cx">     {
</span><span class="cx">         if (s-&gt;baud_phase &gt; 0)
</span><del>-            i = (s-&gt;baud_phase &gt; 1000*FP_FACTOR)  ?  5  :  1;
</del><ins>+            i = (s-&gt;baud_phase &gt; 1000*FP_FACTOR)  ?  15  :  1;
</ins><span class="cx">         else
</span><del>-            i = (s-&gt;baud_phase &lt; -1000*FP_FACTOR)  ?  -5  :  -1;
</del><ins>+            i = (s-&gt;baud_phase &lt; -1000*FP_FACTOR)  ?  -15  :  -1;
</ins><span class="cx"> 
</span><span class="cx">         //printf(&quot;v = %10.5f %5d - %f %f %d %d\n&quot;, v, i, p, s-&gt;baud_phase, s-&gt;total_baud_timing_correction);
</span><span class="cx">         s-&gt;eq_put_step += i;
</span><span class="lines">@@ -558,9 +570,9 @@
</span><span class="cx">     }
</span><span class="cx"> #else
</span><span class="cx">     /* Cross correlate */
</span><del>-    v = s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[1]*SYNC_CROSS_CORR_COEFF_A
-      + s-&gt;symbol_sync_low[0]*s-&gt;symbol_sync_high[1]*SYNC_CROSS_CORR_COEFF_B
-      + s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[0]*SYNC_CROSS_CORR_COEFF_C;
</del><ins>+    v = s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[0]*SYNC_LOW_BAND_EDGE_COEFF_2
+      - s-&gt;symbol_sync_low[0]*s-&gt;symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_2
+      + s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[1]*SYNC_MIXED_EDGES_COEFF_3;
</ins><span class="cx"> 
</span><span class="cx">     /* Filter away any DC component  */
</span><span class="cx">     p = v - s-&gt;symbol_sync_dc_filter[1];
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcv18c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/v18.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/v18.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/v18.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v18.c,v 1.10 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: v18.c,v 1.12 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -738,7 +738,7 @@
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(v18_state_t *) v18_init(v18_state_t *s,
</span><del>-                                     int caller,
</del><ins>+                                     int calling_party,
</ins><span class="cx">                                      int mode,
</span><span class="cx">                                      put_msg_func_t put_msg,
</span><span class="cx">                                      void *user_data)
</span><span class="lines">@@ -749,7 +749,7 @@
</span><span class="cx">             return NULL;
</span><span class="cx">     }
</span><span class="cx">     memset(s, 0, sizeof(*s));
</span><del>-    s-&gt;caller = caller;
</del><ins>+    s-&gt;calling_party = calling_party;
</ins><span class="cx">     s-&gt;mode = mode;
</span><span class="cx">     s-&gt;put_msg = put_msg;
</span><span class="cx">     s-&gt;user_data = user_data;
</span><span class="lines">@@ -763,7 +763,7 @@
</span><span class="cx">         s-&gt;baudot_tx_shift = 2;
</span><span class="cx">         /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and
</span><span class="cx">            ride over the fraction. */
</span><del>-        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_WEITBRECHT], 7, v18_tdd_put_async_byte, s);
</del><ins>+        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_WEITBRECHT], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s);
</ins><span class="cx">         s-&gt;baudot_rx_shift = 0;
</span><span class="cx">         break;
</span><span class="cx">     case V18_MODE_5BIT_50:
</span><span class="lines">@@ -773,7 +773,7 @@
</span><span class="cx">         s-&gt;baudot_tx_shift = 2;
</span><span class="cx">         /* TDD uses 5 bit data, no parity and 1.5 stop bits. We scan for the first stop bit, and
</span><span class="cx">            ride over the fraction. */
</span><del>-        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_WEITBRECHT50], 7, v18_tdd_put_async_byte, s);
</del><ins>+        fsk_rx_init(&amp;(s-&gt;fskrx), &amp;preset_fsk_specs[FSK_WEITBRECHT50], FSK_FRAME_MODE_5N1_FRAMES, v18_tdd_put_async_byte, s);
</ins><span class="cx">         s-&gt;baudot_rx_shift = 0;
</span><span class="cx">         break;
</span><span class="cx">     case V18_MODE_DTMF:
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcv22bis_rxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/v22bis_rx.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/v22bis_rx.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/v22bis_rx.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v22bis_rx.c,v 1.68 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: v22bis_rx.c,v 1.69 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -490,7 +490,7 @@
</span><span class="cx">                error could be higher. */
</span><span class="cx">             s-&gt;rx.gardner_step = 4;
</span><span class="cx">             s-&gt;rx.pattern_repeats = 0;
</span><del>-            if (s-&gt;caller)
</del><ins>+            if (s-&gt;calling_party)
</ins><span class="cx">                 s-&gt;rx.training = V22BIS_RX_TRAINING_STAGE_UNSCRAMBLED_ONES;
</span><span class="cx">             else
</span><span class="cx">                 s-&gt;rx.training = V22BIS_RX_TRAINING_STAGE_SCRAMBLED_ONES_AT_1200;
</span><span class="lines">@@ -586,7 +586,7 @@
</span><span class="cx">                     span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;+++ S1 detected (%d long)\n&quot;, s-&gt;rx.pattern_repeats);
</span><span class="cx">                     if (s-&gt;bit_rate == 2400)
</span><span class="cx">                     {
</span><del>-                        if (!s-&gt;caller)
</del><ins>+                        if (!s-&gt;calling_party)
</ins><span class="cx">                         {
</span><span class="cx">                             /* Accept establishment at 2400bps */
</span><span class="cx">                             span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;+++ starting U0011 (S1) (Answerer)\n&quot;);
</span><span class="lines">@@ -601,7 +601,7 @@
</span><span class="cx">             if (s-&gt;rx.training_count &gt;= ms_to_symbols(270))
</span><span class="cx">             {
</span><span class="cx">                 /* If we haven't seen the S1 signal by now, we are committed to be in 1200bps mode */
</span><del>-                if (s-&gt;caller)
</del><ins>+                if (s-&gt;calling_party)
</ins><span class="cx">                 {
</span><span class="cx">                     span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;+++ Rx normal operation (1200)\n&quot;);
</span><span class="cx">                     /* The transmit side needs to sustain the scrambled ones for a timed period */
</span><span class="lines">@@ -625,7 +625,7 @@
</span><span class="cx">         }
</span><span class="cx">         else
</span><span class="cx">         {
</span><del>-            if (s-&gt;caller)
</del><ins>+            if (s-&gt;calling_party)
</ins><span class="cx">             {
</span><span class="cx">                 if (s-&gt;rx.training_count &gt;= ms_to_symbols(100 + 450))
</span><span class="cx">                 {
</span><span class="lines">@@ -716,7 +716,7 @@
</span><span class="cx">         /* Calculate the I filter, with an arbitrary phase step, just so we can calculate
</span><span class="cx">            the signal power of the required carrier, with any guard tone or spillback of our
</span><span class="cx">            own transmitted signal suppressed. */
</span><del>-        if (s-&gt;caller)
</del><ins>+        if (s-&gt;calling_party)
</ins><span class="cx">         {
</span><span class="cx">             ii = rx_pulseshaper_2400_re[6][0]*s-&gt;rx.rrc_filter[s-&gt;rx.rrc_filter_step];
</span><span class="cx">             for (j = 1;  j &lt; V22BIS_RX_FILTER_STEPS;  j++)
</span><span class="lines">@@ -769,7 +769,7 @@
</span><span class="cx">                 if (step &gt; PULSESHAPER_COEFF_SETS - 1)
</span><span class="cx">                     step = PULSESHAPER_COEFF_SETS - 1;
</span><span class="cx">                 s-&gt;rx.eq_put_step += PULSESHAPER_COEFF_SETS*40/(3*2);
</span><del>-                if (s-&gt;caller)
</del><ins>+                if (s-&gt;calling_party)
</ins><span class="cx">                 {
</span><span class="cx">                     ii = rx_pulseshaper_2400_re[step][0]*s-&gt;rx.rrc_filter[s-&gt;rx.rrc_filter_step];
</span><span class="cx">                     qq = rx_pulseshaper_2400_im[step][0]*s-&gt;rx.rrc_filter[s-&gt;rx.rrc_filter_step];
</span><span class="lines">@@ -836,7 +836,7 @@
</span><span class="cx">     s-&gt;rx.training_count = 0;
</span><span class="cx">     s-&gt;rx.signal_present = FALSE;
</span><span class="cx"> 
</span><del>-    s-&gt;rx.carrier_phase_rate = dds_phase_ratef((s-&gt;caller)  ?  2400.0f  :  1200.0f);
</del><ins>+    s-&gt;rx.carrier_phase_rate = dds_phase_ratef((s-&gt;calling_party)  ?  2400.0f  :  1200.0f);
</ins><span class="cx">     s-&gt;rx.carrier_phase = 0;
</span><span class="cx">     power_meter_init(&amp;(s-&gt;rx.rx_power), 5);
</span><span class="cx">     v22bis_rx_signal_cutoff(s, -45.5f);
</span><span class="lines">@@ -855,7 +855,7 @@
</span><span class="cx">     s-&gt;rx.training_error = 0.0f;
</span><span class="cx">     s-&gt;rx.total_baud_timing_correction = 0;
</span><span class="cx">     /* We want the carrier to pull in faster on the answerer side, as it has very little time to adapt. */
</span><del>-    s-&gt;rx.carrier_track_i = (s-&gt;caller)  ?  8000.0f  :  40000.0f;
</del><ins>+    s-&gt;rx.carrier_track_i = (s-&gt;calling_party)  ?  8000.0f  :  40000.0f;
</ins><span class="cx">     s-&gt;rx.carrier_track_p = 8000000.0f;
</span><span class="cx"> 
</span><span class="cx">     s-&gt;negotiated_bit_rate = 1200;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcv22bis_txc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/v22bis_tx.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/v22bis_tx.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/v22bis_tx.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v22bis_tx.c,v 1.63 2009/06/02 16:03:56 steveu Exp $
</del><ins>+ * $Id: v22bis_tx.c,v 1.64 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -346,7 +346,7 @@
</span><span class="cx">         if (++s-&gt;tx.training_count &gt;= ms_to_symbols(100))
</span><span class="cx">         {
</span><span class="cx">             span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;+++ starting S11 after U0011\n&quot;);
</span><del>-            if (s-&gt;caller)
</del><ins>+            if (s-&gt;calling_party)
</ins><span class="cx">             {
</span><span class="cx">                 s-&gt;tx.training_count = 0;
</span><span class="cx">                 s-&gt;tx.training = V22BIS_TX_TRAINING_STAGE_S11;
</span><span class="lines">@@ -523,7 +523,7 @@
</span><span class="cx">     s-&gt;tx.rrc_filter_step = 0;
</span><span class="cx">     s-&gt;tx.scramble_reg = 0;
</span><span class="cx">     s-&gt;tx.scrambler_pattern_count = 0;
</span><del>-    if (s-&gt;caller)
</del><ins>+    if (s-&gt;calling_party)
</ins><span class="cx">         s-&gt;tx.training = V22BIS_TX_TRAINING_STAGE_INITIAL_SILENCE;
</span><span class="cx">     else
</span><span class="cx">         s-&gt;tx.training = V22BIS_TX_TRAINING_STAGE_INITIAL_TIMED_SILENCE;
</span><span class="lines">@@ -634,7 +634,7 @@
</span><span class="cx"> SPAN_DECLARE(v22bis_state_t *) v22bis_init(v22bis_state_t *s,
</span><span class="cx">                                            int bit_rate,
</span><span class="cx">                                            int guard,
</span><del>-                                           int caller,
</del><ins>+                                           int calling_party,
</ins><span class="cx">                                            get_bit_func_t get_bit,
</span><span class="cx">                                            void *get_bit_user_data,
</span><span class="cx">                                            put_bit_func_t put_bit,
</span><span class="lines">@@ -657,14 +657,14 @@
</span><span class="cx">     span_log_init(&amp;s-&gt;logging, SPAN_LOG_NONE, NULL);
</span><span class="cx">     span_log_set_protocol(&amp;s-&gt;logging, &quot;V.22bis&quot;);
</span><span class="cx">     s-&gt;bit_rate = bit_rate;
</span><del>-    s-&gt;caller = caller;
</del><ins>+    s-&gt;calling_party = calling_party;
</ins><span class="cx"> 
</span><span class="cx">     s-&gt;get_bit = get_bit;
</span><span class="cx">     s-&gt;get_bit_user_data = get_bit_user_data;
</span><span class="cx">     s-&gt;put_bit = put_bit;
</span><span class="cx">     s-&gt;put_bit_user_data = put_bit_user_data;
</span><span class="cx"> 
</span><del>-    if (s-&gt;caller)
</del><ins>+    if (s-&gt;calling_party)
</ins><span class="cx">     {
</span><span class="cx">         s-&gt;tx.carrier_phase_rate = dds_phase_ratef(1200.0f);
</span><span class="cx">     }
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcv29rxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/v29rx.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/v29rx.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/v29rx.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v29rx.c,v 1.167 2009/07/08 15:11:09 steveu Exp $
</del><ins>+ * $Id: v29rx.c,v 1.167.4.4 2009/12/19 14:18:13 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -131,22 +131,28 @@
</span><span class="cx"> /* Coefficients for the band edge symbol timing synchroniser (alpha = 0.99) */
</span><span class="cx"> /* low_edge = 2.0f*M_PI*(CARRIER_NOMINAL_FREQ - BAUD_RATE/2.0f)/SAMPLE_RATE; */
</span><span class="cx"> /* high_edge = 2.0f*M_PI*(CARRIER_NOMINAL_FREQ + BAUD_RATE/2.0f)/SAMPLE_RATE; */
</span><ins>+#define SIN_LOW_BAND_EDGE               0.382683432f
+#define COS_LOW_BAND_EDGE               0.923879533f
+#define SIN_HIGH_BAND_EDGE              0.760405966f
+#define COS_HIGH_BAND_EDGE             -0.649448048f
+#define ALPHA                           0.99f
+
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><del>-#define SYNC_LOW_BAND_EDGE_COEFF_0      ((int)(FP_FACTOR* 1.829281f))   /* 2*alpha*cos(low_edge) */
-#define SYNC_LOW_BAND_EDGE_COEFF_1      ((int)(FP_FACTOR*-0.980100f))   /* -alpha^2 */
-#define SYNC_HIGH_BAND_EDGE_COEFF_0     ((int)(FP_FACTOR*-1.285907f))   /* 2*alpha*cos(high_edge) */
-#define SYNC_HIGH_BAND_EDGE_COEFF_1     ((int)(FP_FACTOR*-0.980100f))   /* -alpha^2 */
-#define SYNC_CROSS_CORR_COEFF_A         ((int)(FP_FACTOR*-0.932131f))   /* -alpha^2*sin(freq_diff) */
-#define SYNC_CROSS_CORR_COEFF_B         ((int)(FP_FACTOR* 0.752802f))   /* alpha*sin(high_edge) */
-#define SYNC_CROSS_CORR_COEFF_C         ((int)(FP_FACTOR*-0.378857f))   /* -alpha*sin(low_edge) */
</del><ins>+#define SYNC_LOW_BAND_EDGE_COEFF_0      ((int)(FP_FACTOR*(2.0f*ALPHA*COS_LOW_BAND_EDGE)))
+#define SYNC_LOW_BAND_EDGE_COEFF_1      ((int)(FP_FACTOR*(-ALPHA*ALPHA)))
+#define SYNC_LOW_BAND_EDGE_COEFF_2      ((int)(FP_FACTOR*(-ALPHA*SIN_LOW_BAND_EDGE)))
+#define SYNC_HIGH_BAND_EDGE_COEFF_0     ((int)(FP_FACTOR*(2.0f*ALPHA*COS_HIGH_BAND_EDGE)))
+#define SYNC_HIGH_BAND_EDGE_COEFF_1     ((int)(FP_FACTOR*(-ALPHA*ALPHA)))
+#define SYNC_HIGH_BAND_EDGE_COEFF_2     ((int)(FP_FACTOR*(-ALPHA*SIN_HIGH_BAND_EDGE)))
+#define SYNC_MIXED_EDGES_COEFF_3        ((int)(FP_FACTOR*(-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE))))
</ins><span class="cx"> #else
</span><del>-#define SYNC_LOW_BAND_EDGE_COEFF_0       1.829281f                      /* 2*alpha*cos(low_edge) */
-#define SYNC_LOW_BAND_EDGE_COEFF_1      -0.980100f                      /* -alpha^2 */
-#define SYNC_HIGH_BAND_EDGE_COEFF_0     -1.285907f                      /* 2*alpha*cos(high_edge) */
-#define SYNC_HIGH_BAND_EDGE_COEFF_1     -0.980100f                      /* -alpha^2 */
-#define SYNC_CROSS_CORR_COEFF_A         -0.932131f                      /* -alpha^2*sin(freq_diff) */
-#define SYNC_CROSS_CORR_COEFF_B          0.752802f                      /* alpha*sin(high_edge) */
-#define SYNC_CROSS_CORR_COEFF_C         -0.378857f                      /* -alpha*sin(low_edge) */
</del><ins>+#define SYNC_LOW_BAND_EDGE_COEFF_0      (2.0f*ALPHA*COS_LOW_BAND_EDGE)
+#define SYNC_LOW_BAND_EDGE_COEFF_1      (-ALPHA*ALPHA)
+#define SYNC_LOW_BAND_EDGE_COEFF_2      (-ALPHA*SIN_LOW_BAND_EDGE)
+#define SYNC_HIGH_BAND_EDGE_COEFF_0     (2.0f*ALPHA*COS_HIGH_BAND_EDGE)
+#define SYNC_HIGH_BAND_EDGE_COEFF_1     (-ALPHA*ALPHA)
+#define SYNC_HIGH_BAND_EDGE_COEFF_2     (-ALPHA*SIN_HIGH_BAND_EDGE)
+#define SYNC_MIXED_EDGES_COEFF_3        (-ALPHA*ALPHA*(SIN_HIGH_BAND_EDGE*COS_LOW_BAND_EDGE - SIN_LOW_BAND_EDGE*COS_HIGH_BAND_EDGE))
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(float) v29_rx_carrier_frequency(v29_rx_state_t *s)
</span><span class="lines">@@ -489,12 +495,18 @@
</span><span class="cx"> 
</span><span class="cx">     /* This routine adapts the position of the half baud samples entering the equalizer. */
</span><span class="cx"> 
</span><ins>+    /* This symbol sync scheme is based on the technique first described by Dominique Godard in
+        Passband Timing Recovery in an All-Digital Modem Receiver
+        IEEE TRANSACTIONS ON COMMUNICATIONS, VOL. COM-26, NO. 5, MAY 1978 */
+
+    /* This is slightly rearranged for figure 3b of the Godard paper, as this saves a couple of
+       maths operations */
</ins><span class="cx"> #if defined(SPANDSP_USE_FIXED_POINT)
</span><span class="cx">     /* TODO: The scalings used here need more thorough evaluation, to see if overflows are possible. */
</span><span class="cx">     /* Cross correlate */
</span><del>-    v = (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_CROSS_CORR_COEFF_A
-      + (((s-&gt;symbol_sync_low[0] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_CROSS_CORR_COEFF_B
-      + (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[0] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_CROSS_CORR_COEFF_C;
</del><ins>+    v = (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[0] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_LOW_BAND_EDGE_COEFF_2
+      - (((s-&gt;symbol_sync_low[0] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_HIGH_BAND_EDGE_COEFF_2
+      + (((s-&gt;symbol_sync_low[1] &gt;&gt; 5)*(s-&gt;symbol_sync_high[1] &gt;&gt; 4)) &gt;&gt; 15)*SYNC_MIXED_EDGES_COEFF_3;
</ins><span class="cx">     /* Filter away any DC component */
</span><span class="cx">     p = v - s-&gt;symbol_sync_dc_filter[1];
</span><span class="cx">     s-&gt;symbol_sync_dc_filter[1] = s-&gt;symbol_sync_dc_filter[0];
</span><span class="lines">@@ -514,9 +526,9 @@
</span><span class="cx">     }
</span><span class="cx"> #else
</span><span class="cx">     /* Cross correlate */
</span><del>-    v = s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[1]*SYNC_CROSS_CORR_COEFF_A
-      + s-&gt;symbol_sync_low[0]*s-&gt;symbol_sync_high[1]*SYNC_CROSS_CORR_COEFF_B
-      + s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[0]*SYNC_CROSS_CORR_COEFF_C;
</del><ins>+    v = s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[0]*SYNC_LOW_BAND_EDGE_COEFF_2
+      - s-&gt;symbol_sync_low[0]*s-&gt;symbol_sync_high[1]*SYNC_HIGH_BAND_EDGE_COEFF_2
+      + s-&gt;symbol_sync_low[1]*s-&gt;symbol_sync_high[1]*SYNC_MIXED_EDGES_COEFF_3;
</ins><span class="cx">     /* Filter away any DC component */
</span><span class="cx">     p = v - s-&gt;symbol_sync_dc_filter[1];
</span><span class="cx">     s-&gt;symbol_sync_dc_filter[1] = s-&gt;symbol_sync_dc_filter[0];
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcv42c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/v42.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/v42.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/v42.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v42.c,v 1.50 2009/02/10 13:06:47 steveu Exp $
</del><ins>+ * $Id: v42.c,v 1.51 2009/11/04 15:52:06 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /* THIS IS A WORK IN PROGRESS. IT IS NOT FINISHED. */
</span><span class="lines">@@ -1138,11 +1138,11 @@
</span><span class="cx">             break;
</span><span class="cx">         /*endif*/
</span><span class="cx">         s-&gt;rxstream &amp;= 0x3FF;
</span><del>-        if (s-&gt;caller  &amp;&amp;  s-&gt;rxstream == 0x145)
</del><ins>+        if (s-&gt;calling_party  &amp;&amp;  s-&gt;rxstream == 0x145)
</ins><span class="cx">         {
</span><span class="cx">             s-&gt;rx_negotiation_step++;
</span><span class="cx">         }
</span><del>-        else if (!s-&gt;caller  &amp;&amp;  s-&gt;rxstream == 0x111)
</del><ins>+        else if (!s-&gt;calling_party  &amp;&amp;  s-&gt;rxstream == 0x111)
</ins><span class="cx">         {
</span><span class="cx">             s-&gt;rx_negotiation_step++;
</span><span class="cx">         }
</span><span class="lines">@@ -1174,15 +1174,15 @@
</span><span class="cx">             break;
</span><span class="cx">         /*endif*/
</span><span class="cx">         s-&gt;rxstream &amp;= 0x3FF;
</span><del>-        if (s-&gt;caller  &amp;&amp;  s-&gt;rxstream == 0x185)
</del><ins>+        if (s-&gt;calling_party  &amp;&amp;  s-&gt;rxstream == 0x185)
</ins><span class="cx">         {
</span><span class="cx">             s-&gt;rx_negotiation_step++;
</span><span class="cx">         }
</span><del>-        else if (s-&gt;caller  &amp;&amp;  s-&gt;rxstream == 0x001)
</del><ins>+        else if (s-&gt;calling_party  &amp;&amp;  s-&gt;rxstream == 0x001)
</ins><span class="cx">         {
</span><span class="cx">             s-&gt;rx_negotiation_step++;
</span><span class="cx">         }
</span><del>-        else if (!s-&gt;caller  &amp;&amp;  s-&gt;rxstream == 0x113)
</del><ins>+        else if (!s-&gt;calling_party  &amp;&amp;  s-&gt;rxstream == 0x113)
</ins><span class="cx">         {
</span><span class="cx">             s-&gt;rx_negotiation_step++;
</span><span class="cx">         }
</span><span class="lines">@@ -1206,7 +1206,7 @@
</span><span class="cx">             {
</span><span class="cx">                 /* HIT */
</span><span class="cx">                 s-&gt;rx_negotiation_step++;
</span><del>-                if (s-&gt;caller)
</del><ins>+                if (s-&gt;calling_party)
</ins><span class="cx">                 {
</span><span class="cx">                     if (s-&gt;t400_timer &gt;= 0)
</span><span class="cx">                     {
</span><span class="lines">@@ -1252,7 +1252,7 @@
</span><span class="cx"> {
</span><span class="cx">     int bit;
</span><span class="cx"> 
</span><del>-    if (s-&gt;caller)
</del><ins>+    if (s-&gt;calling_party)
</ins><span class="cx">     {
</span><span class="cx">         if (s-&gt;txbits &lt;= 0)
</span><span class="cx">         {
</span><span class="lines">@@ -1355,7 +1355,7 @@
</span><span class="cx"> {
</span><span class="cx">     span_schedule_init(&amp;s-&gt;lapm.sched);
</span><span class="cx"> 
</span><del>-    s-&gt;lapm.we_are_originator = s-&gt;caller;
</del><ins>+    s-&gt;lapm.we_are_originator = s-&gt;calling_party;
</ins><span class="cx">     lapm_restart(&amp;s-&gt;lapm);
</span><span class="cx">     if (s-&gt;detect)
</span><span class="cx">     {
</span><span class="lines">@@ -1379,7 +1379,7 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, int caller, int detect, v42_frame_handler_t frame_handler, void *user_data)
</del><ins>+SPAN_DECLARE(v42_state_t *) v42_init(v42_state_t *s, int calling_party, int detect, v42_frame_handler_t frame_handler, void *user_data)
</ins><span class="cx"> {
</span><span class="cx">     int alloced;
</span><span class="cx">     
</span><span class="lines">@@ -1394,7 +1394,7 @@
</span><span class="cx">         alloced = TRUE;
</span><span class="cx">     }
</span><span class="cx">     memset(s, 0, sizeof(*s));
</span><del>-    s-&gt;caller = caller;
</del><ins>+    s-&gt;calling_party = calling_party;
</ins><span class="cx">     s-&gt;detect = detect;
</span><span class="cx">     s-&gt;lapm.iframe_receive = frame_handler;
</span><span class="cx">     s-&gt;lapm.iframe_receive_user_data = user_data;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspsrcv8c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/src/v8.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/src/v8.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/src/v8.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v8.c,v 1.39 2009/06/24 00:34:38 steveu Exp $
</del><ins>+ * $Id: v8.c,v 1.42 2009/11/04 16:10:14 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx">  
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> #include &quot;spandsp/logging.h&quot;
</span><span class="cx"> #include &quot;spandsp/queue.h&quot;
</span><span class="cx"> #include &quot;spandsp/async.h&quot;
</span><ins>+#include &quot;spandsp/vector_int.h&quot;
</ins><span class="cx"> #include &quot;spandsp/complex.h&quot;
</span><span class="cx"> #include &quot;spandsp/dds.h&quot;
</span><span class="cx"> #include &quot;spandsp/tone_detect.h&quot;
</span><span class="lines">@@ -67,7 +68,6 @@
</span><span class="cx"> enum
</span><span class="cx"> {
</span><span class="cx">     V8_WAIT_1S,
</span><del>-    V8_CI,
</del><span class="cx">     V8_CI_ON,
</span><span class="cx">     V8_CI_OFF,
</span><span class="cx">     V8_HEARD_ANSAM,
</span><span class="lines">@@ -76,7 +76,6 @@
</span><span class="cx">     V8_CM_WAIT,
</span><span class="cx"> 
</span><span class="cx">     V8_SIGC,
</span><del>-    V8_WAIT_200MS,
</del><span class="cx">     V8_JM_ON,
</span><span class="cx">     V8_SIGA,
</span><span class="cx"> 
</span><span class="lines">@@ -91,6 +90,23 @@
</span><span class="cx">     V8_SYNC_V92
</span><span class="cx"> } v8_sync_types_e;
</span><span class="cx"> 
</span><ins>+enum
+{
+    V8_CALL_FUNCTION_TAG = 0x01,
+    V8_MODULATION_TAG = 0x05,
+    V8_PROTOCOLS_TAG = 0x0A,
+    V8_PSTN_ACCESS_TAG = 0x0D,
+    V8_NSF_TAG = 0x0F,
+    V8_PCM_MODEM_AVAILABILITY_TAG = 0x07,
+    V8_T66_TAG = 0x0E
+};
+
+enum
+{
+    V8_CI_SYNC_OCTET = 0x00,
+    V8_CM_JM_SYNC_OCTET = 0xE0
+};
+
</ins><span class="cx"> SPAN_DECLARE(const char *) v8_call_function_to_str(int call_function)
</span><span class="cx"> {
</span><span class="cx">     switch (call_function)
</span><span class="lines">@@ -172,16 +188,89 @@
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(const char *) v8_pstn_access_to_str(int pstn_access)
</span><span class="cx"> {
</span><ins>+    switch (pstn_access)
+    {
+    case V8_PSTN_ACCESS_CALL_DCE_CELLULAR:
+        return &quot;Calling modem on cellular&quot;;
+    case V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR:
+        return &quot;Answering modem on cellular&quot;;
+    case V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR | V8_PSTN_ACCESS_CALL_DCE_CELLULAR:
+        return &quot;Answering and calling modems on cellular&quot;;
+    case V8_PSTN_ACCESS_DCE_ON_DIGITAL:
+        return &quot;DCE on digital&quot;;
+    case V8_PSTN_ACCESS_DCE_ON_DIGITAL | V8_PSTN_ACCESS_CALL_DCE_CELLULAR:
+        return &quot;DCE on digital, and calling modem on cellular&quot;;
+    case V8_PSTN_ACCESS_DCE_ON_DIGITAL | V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR:
+        return &quot;DCE on digital, answering modem on cellular&quot;;
+    case V8_PSTN_ACCESS_DCE_ON_DIGITAL | V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR | V8_PSTN_ACCESS_CALL_DCE_CELLULAR:
+        return &quot;DCE on digital, and answering and calling modems on cellular&quot;;
+    }
</ins><span class="cx">     return &quot;???&quot;;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+SPAN_DECLARE(const char *) v8_nsf_to_str(int nsf)
+{
+    switch (nsf)
+    {
+    case 0:
+        return &quot;???&quot;;
+    }
+    return &quot;???&quot;;
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> SPAN_DECLARE(const char *) v8_pcm_modem_availability_to_str(int pcm_modem_availability)
</span><span class="cx"> {
</span><ins>+    switch (pcm_modem_availability)
+    {
+    case 0:
+        return &quot;PCM unavailable&quot;;
+    case V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE:
+        return &quot;V.90/V.92 analogue available&quot;;
+    case V8_PSTN_PCM_MODEM_V90_V92_DIGITAL:
+        return &quot;V.90/V.92 digital available&quot;;
+    case V8_PSTN_PCM_MODEM_V90_V92_DIGITAL | V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE:
+        return &quot;V.90/V.92 digital/analogue available&quot;;
+    case V8_PSTN_PCM_MODEM_V91:
+        return &quot;V.91 available&quot;;
+    case V8_PSTN_PCM_MODEM_V91 | V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE:
+        return &quot;V.91 and V.90/V.92 analogue available&quot;;
+    case V8_PSTN_PCM_MODEM_V91 | V8_PSTN_PCM_MODEM_V90_V92_DIGITAL:
+        return &quot;V.91 and V.90/V.92 digital available&quot;;
+    case V8_PSTN_PCM_MODEM_V91 | V8_PSTN_PCM_MODEM_V90_V92_DIGITAL | V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE:
+        return &quot;V.91 and V.90/V.92 digital/analogue available&quot;;
+    }
</ins><span class="cx">     return &quot;???&quot;;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+SPAN_DECLARE(const char *) v8_t66_to_str(int t66)
+{
+    /* T.66 doesn't really define any V.8 values. The bits are all reserved. */
+    switch (t66)
+    {
+    case 0:
+        return &quot;???&quot;;
+    case 1:
+        return &quot;Reserved TIA&quot;;
+    case 2:
+        return &quot;Reserved&quot;;
+    case 3:
+        return &quot;Reserved TIA + others&quot;;
+    case 4:
+        return &quot;Reserved&quot;;
+    case 5:
+        return &quot;Reserved TIA + others&quot;;
+    case 6:
+        return &quot;Reserved&quot;;
+    case 7:
+        return &quot;Reserved TIA + others&quot;;
+    }
+    return &quot;???&quot;;
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> SPAN_DECLARE(void) v8_log_supported_modulations(v8_state_t *s, int modulation_schemes)
</span><span class="cx"> {
</span><span class="cx">     const char *comma;
</span><span class="lines">@@ -203,11 +292,8 @@
</span><span class="cx"> 
</span><span class="cx"> static const uint8_t *process_call_function(v8_state_t *s, const uint8_t *p)
</span><span class="cx"> {
</span><del>-    int call_function;
-
-    call_function = (*p &gt;&gt; 5) &amp; 0x07;
-    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s\n&quot;, v8_call_function_to_str(call_function));
-    s-&gt;call_function = call_function;
</del><ins>+    s-&gt;result.call_function = (*p &gt;&gt; 5) &amp; 0x07;
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s\n&quot;, v8_call_function_to_str(s-&gt;result.call_function));
</ins><span class="cx">     return ++p;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -225,6 +311,7 @@
</span><span class="cx">     if (*p &amp; 0x20)
</span><span class="cx">         far_end_modulations |= V8_MOD_V90;
</span><span class="cx"> 
</span><ins>+    /* Check for an extension octet */
</ins><span class="cx">     if ((*++p &amp; 0x38) == 0x10)
</span><span class="cx">     {
</span><span class="cx">         if (*p &amp; 0x80)
</span><span class="lines">@@ -238,6 +325,7 @@
</span><span class="cx">         if (*p &amp; 0x01)
</span><span class="cx">             far_end_modulations |= V8_MOD_V32;
</span><span class="cx"> 
</span><ins>+        /* Check for an extension octet */
</ins><span class="cx">         if ((*++p &amp; 0x38) == 0x10)
</span><span class="cx">         {
</span><span class="cx">             if (*p &amp; 0x80)
</span><span class="lines">@@ -250,77 +338,59 @@
</span><span class="cx">                 far_end_modulations |= V8_MOD_V26BIS;
</span><span class="cx">             if (*p &amp; 0x01)
</span><span class="cx">                 far_end_modulations |= V8_MOD_V26TER;
</span><del>-            /* Skip any future extensions we do not understand */
-            while  ((*++p &amp; 0x38) == 0x10)
-                /* dummy loop */;
</del><span class="cx">         }
</span><span class="cx">     }
</span><del>-    s-&gt;far_end_modulations = far_end_modulations;
-    v8_log_supported_modulations(s, s-&gt;far_end_modulations);
</del><ins>+    s-&gt;result.far_end_modulations = far_end_modulations;
+    v8_log_supported_modulations(s, s-&gt;result.far_end_modulations);
</ins><span class="cx">     return ++p;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static const uint8_t *process_protocols(v8_state_t *s, const uint8_t *p)
</span><span class="cx"> {
</span><del>-    int protocol;
-
-    protocol = (*p &gt;&gt; 5) &amp; 0x07;
-    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;%s\n&quot;, v8_protocol_to_str(protocol));
-    s-&gt;protocol = protocol;
</del><ins>+    s-&gt;result.protocol = (*p &gt;&gt; 5) &amp; 0x07;
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, &quot;%s\n&quot;, v8_protocol_to_str(s-&gt;result.protocol));
</ins><span class="cx">     return ++p;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static const uint8_t *process_pstn_access(v8_state_t *s, const uint8_t *p)
</span><span class="cx"> {
</span><del>-    int pstn_access;
-
-    pstn_access = (*p &gt;&gt; 5) &amp; 0x07;
-    if (pstn_access &amp; V8_PSTN_ACCESS_DCE_ON_DIGTIAL)
-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;DCE on digital network connection\n&quot;);
-    else
-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;DCE on analogue network connection\n&quot;);
-    if (pstn_access &amp; V8_PSTN_ACCESS_ANSWER_DCE_CELLULAR)
-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Answer DCE on cellular connection\n&quot;);
-    if (pstn_access &amp; V8_PSTN_ACCESS_CALL_DCE_CELLULAR)
-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Call DCE on cellular connection\n&quot;);
</del><ins>+    s-&gt;result.pstn_access = (*p &gt;&gt; 5) &amp; 0x07;
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, &quot;%s\n&quot;, v8_pstn_access_to_str(s-&gt;result.pstn_access));
</ins><span class="cx">     return ++p;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static const uint8_t *process_non_standard_facilities(v8_state_t *s, const uint8_t *p)
</span><span class="cx"> {
</span><del>-    ++p;
-    p += *p;
</del><ins>+    s-&gt;result.nsf = (*p &gt;&gt; 5) &amp; 0x07;
+    s-&gt;result.nsf_seen = TRUE;
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, &quot;%s\n&quot;, v8_nsf_to_str(s-&gt;result.nsf));
</ins><span class="cx">     return p;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static const uint8_t *process_pcm_modem_availability(v8_state_t *s, const uint8_t *p)
</span><span class="cx"> {
</span><del>-    int pcm_availability;
-
-    pcm_availability = (*p &gt;&gt; 5) &amp; 0x07;
-    if (pcm_availability &amp; V8_PSTN_PCM_MODEM_V91)
-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;V.91 available\n&quot;);
-    if (pcm_availability &amp; V8_PSTN_PCM_MODEM_V90_V92_DIGITAL)
-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;V.90 or V.92 digital modem available\n&quot;);
-    if (pcm_availability &amp; V8_PSTN_PCM_MODEM_V90_V92_ANALOGUE)
-        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;V.90 or V.92 analogue modem available\n&quot;);
</del><ins>+    s-&gt;result.pcm_modem_availability = (*p &gt;&gt; 5) &amp; 0x07;
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, &quot;%s\n&quot;, v8_pcm_modem_availability_to_str(s-&gt;result.pcm_modem_availability));
</ins><span class="cx">     return ++p;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static const uint8_t *process_t66(v8_state_t *s, const uint8_t *p)
</span><span class="cx"> {
</span><ins>+    s-&gt;result.t66 = (*p &gt;&gt; 5) &amp; 0x07;
+    s-&gt;result.t66_seen = TRUE;
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW | SPAN_LOG_SUPPRESS_LABELLING, &quot;%s\n&quot;, v8_t66_to_str(s-&gt;result.t66));
</ins><span class="cx">     return ++p;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> static void ci_decode(v8_state_t *s)
</span><span class="cx"> {
</span><del>-    if ((s-&gt;rx_data[0] &amp; 0x1F) == 0x01)
</del><ins>+    if ((s-&gt;rx_data[0] &amp; 0x1F) == V8_CALL_FUNCTION_TAG)
</ins><span class="cx">         process_call_function(s, &amp;s-&gt;rx_data[0]);
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -333,57 +403,60 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     /* We must receive two consecutive identical CM or JM sequences to accept it. */
</span><del>-    if (s-&gt;cm_jm_count &lt;= 0
</del><ins>+    if (s-&gt;cm_jm_len &lt;= 0
</ins><span class="cx">         ||
</span><del>-        s-&gt;cm_jm_count != s-&gt;rx_data_ptr
</del><ins>+        s-&gt;cm_jm_len != s-&gt;rx_data_ptr
</ins><span class="cx">         ||
</span><span class="cx">         memcmp(s-&gt;cm_jm_data, s-&gt;rx_data, s-&gt;rx_data_ptr))
</span><span class="cx">     {
</span><span class="cx">         /* Save the current CM or JM sequence */
</span><del>-        s-&gt;cm_jm_count = s-&gt;rx_data_ptr;
</del><ins>+        s-&gt;cm_jm_len = s-&gt;rx_data_ptr;
</ins><span class="cx">         memcpy(s-&gt;cm_jm_data, s-&gt;rx_data, s-&gt;rx_data_ptr);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    /* We have a pair of matching CMs or JMs */
</del><ins>+    /* We have a matching pair of CMs or JMs, so we are happy this is correct. */
</ins><span class="cx">     s-&gt;got_cm_jm = TRUE;
</span><span class="cx"> 
</span><span class="cx">     span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Decoding\n&quot;);
</span><span class="cx"> 
</span><span class="cx">     /* Zero indicates the end */
</span><del>-    s-&gt;cm_jm_data[s-&gt;cm_jm_count] = 0;
</del><ins>+    s-&gt;cm_jm_data[s-&gt;cm_jm_len] = 0;
</ins><span class="cx"> 
</span><del>-    s-&gt;far_end_modulations = 0;
</del><ins>+    s-&gt;result.far_end_modulations = 0;
</ins><span class="cx">     p = s-&gt;cm_jm_data;
</span><span class="cx"> 
</span><span class="cx">     while (*p)
</span><span class="cx">     {
</span><span class="cx">         switch (*p &amp; 0x1F)
</span><span class="cx">         {
</span><del>-        case 0x01:
</del><ins>+        case V8_CALL_FUNCTION_TAG:
</ins><span class="cx">             p = process_call_function(s, p);
</span><span class="cx">             break;
</span><del>-        case 0x05:
</del><ins>+        case V8_MODULATION_TAG:
</ins><span class="cx">             p = process_modulation_mode(s, p);
</span><span class="cx">             break;
</span><del>-        case 0x0A:
</del><ins>+        case V8_PROTOCOLS_TAG:
</ins><span class="cx">             p = process_protocols(s, p);
</span><span class="cx">             break;
</span><del>-        case 0x0D:
</del><ins>+        case V8_PSTN_ACCESS_TAG:
</ins><span class="cx">             p = process_pstn_access(s, p);
</span><span class="cx">             break;
</span><del>-        case 0x0F:
</del><ins>+        case V8_NSF_TAG:
</ins><span class="cx">             p = process_non_standard_facilities(s, p);
</span><span class="cx">             break;
</span><del>-        case 0x07:
</del><ins>+        case V8_PCM_MODEM_AVAILABILITY_TAG:
</ins><span class="cx">             p = process_pcm_modem_availability(s, p);
</span><span class="cx">             break;
</span><del>-        case 0x0E:
</del><ins>+        case V8_T66_TAG:
</ins><span class="cx">             p = process_t66(s, p);
</span><span class="cx">             break;
</span><span class="cx">         default:
</span><span class="cx">             p++;
</span><span class="cx">             break;
</span><span class="cx">         }
</span><ins>+        /* Skip any future extensions we do not understand */
+        while ((*p &amp; 0x38) == 0x10)
+            p++;
</ins><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -411,43 +484,60 @@
</span><span class="cx">         }
</span><span class="cx">         return;
</span><span class="cx">     }
</span><ins>+    //span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Bit %d\n&quot;, bit);
</ins><span class="cx">     /* Wait until we sync. */
</span><span class="cx">     s-&gt;bit_stream = (s-&gt;bit_stream &gt;&gt; 1) | (bit &lt;&lt; 19);
</span><del>-    if (s-&gt;bit_stream == 0x803FF)
</del><ins>+    /* CI preamble is 10 ones then a framed 0x00
+       CM/JM preamble is 10 ones then a framed 0x07
+       V.92 preamble is 10 ones then a framed 0x55
+       Should we look at all 10 ones? The first couple might be
+       settling down. */
+    /* The preamble + synchronisation bit sequence should be unique in
+       any bit stream, so we can rely on seeing this at any time as being
+       a real sync code. */
+    switch (s-&gt;bit_stream)
+    {
+    case 0x803FF:
</ins><span class="cx">         new_preamble_type = V8_SYNC_CI;
</span><del>-    else if (s-&gt;bit_stream == 0xF03FF)
</del><ins>+        break;
+    case 0xF03FF:
</ins><span class="cx">         new_preamble_type = V8_SYNC_CM_JM;
</span><del>-    else if (s-&gt;bit_stream == 0xAABFF)
</del><ins>+        break;
+    case 0xAABFF:
</ins><span class="cx">         new_preamble_type = V8_SYNC_V92;
</span><del>-    else
</del><ins>+        break;
+    default:
</ins><span class="cx">         new_preamble_type = V8_SYNC_UNKNOWN;
</span><del>-    if (new_preamble_type)
</del><ins>+        break;
+    }
+    if (new_preamble_type != V8_SYNC_UNKNOWN)
</ins><span class="cx">     {
</span><ins>+        /* We have seen a fresh sync code */
</ins><span class="cx">         /* Debug */
</span><span class="cx">         if (span_log_test(&amp;s-&gt;logging, SPAN_LOG_FLOW))
</span><span class="cx">         {
</span><del>-            if (s-&gt;preamble_type == V8_SYNC_CI)
</del><ins>+            if (s-&gt;preamble_type != V8_SYNC_UNKNOWN)
</ins><span class="cx">             {
</span><del>-                tag = &quot;CI: &quot;;
</del><ins>+                switch (s-&gt;preamble_type)
+                {
+                case V8_SYNC_CI:
+                    tag = &quot;CI: &quot;;
+                    break;
+                case V8_SYNC_CM_JM:
+                    tag = (s-&gt;calling_party)  ?  &quot;JM: &quot;  :  &quot;CM: &quot;;
+                    break;
+                case V8_SYNC_V92:
+                    tag = &quot;V92: &quot;;
+                    break;
+                default:
+                    tag = &quot;??: &quot;;
+                    break;
+                }
+                span_log_buf(&amp;s-&gt;logging, SPAN_LOG_FLOW, tag, s-&gt;rx_data, s-&gt;rx_data_ptr);
</ins><span class="cx">             }
</span><del>-            else if (s-&gt;preamble_type == V8_SYNC_CM_JM)
-            {
-                if (s-&gt;caller)
-                    tag = &quot;JM: &quot;;
-                else
-                    tag = &quot;CM: &quot;;
-            }
-            else if (s-&gt;preamble_type == V8_SYNC_V92)
-            {
-                tag = &quot;V92: &quot;;
-            }
-            else
-            {
-                tag = &quot;??: &quot;;
-            }
-            span_log_buf(&amp;s-&gt;logging, SPAN_LOG_FLOW, tag, s-&gt;rx_data, s-&gt;rx_data_ptr);
</del><span class="cx">         }
</span><del>-        /* Decode previous sequence */
</del><ins>+        /* If we were handling a valid sync code then we should process what has been
+           received to date. */
</ins><span class="cx">         switch (s-&gt;preamble_type)
</span><span class="cx">         {
</span><span class="cx">         case V8_SYNC_CI:
</span><span class="lines">@@ -462,16 +552,16 @@
</span><span class="cx">         s-&gt;rx_data_ptr = 0;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    /* Parse octets with 1 bit start, 1 bit stop */
-    if (s-&gt;preamble_type)
</del><ins>+    if (s-&gt;preamble_type != V8_SYNC_UNKNOWN)
</ins><span class="cx">     {
</span><ins>+        /* Parse octets with 1 bit start, 1 bit stop */
</ins><span class="cx">         s-&gt;bit_cnt++;
</span><span class="cx">         /* Start, stop? */
</span><span class="cx">         if ((s-&gt;bit_stream &amp; 0x80400) == 0x80000  &amp;&amp;  s-&gt;bit_cnt &gt;= 10)
</span><span class="cx">         {
</span><span class="cx">             /* Store the available data */
</span><span class="cx">             data = (uint8_t) ((s-&gt;bit_stream &gt;&gt; 11) &amp; 0xFF);
</span><del>-            /* CJ detection */
</del><ins>+            /* CJ (3 successive zero octets) detection */
</ins><span class="cx">             if (data == 0)
</span><span class="cx">             {
</span><span class="cx">                 if (++s-&gt;zero_byte_count == 3)
</span><span class="lines">@@ -492,13 +582,14 @@
</span><span class="cx"> 
</span><span class="cx"> static void v8_decode_init(v8_state_t *s)
</span><span class="cx"> {
</span><del>-    if (s-&gt;caller)
-        fsk_rx_init(&amp;s-&gt;v21rx, &amp;preset_fsk_specs[FSK_V21CH2], FALSE, put_bit, s);
-    else
-        fsk_rx_init(&amp;s-&gt;v21rx, &amp;preset_fsk_specs[FSK_V21CH1], FALSE, put_bit, s);
-    s-&gt;preamble_type = 0;
</del><ins>+    fsk_rx_init(&amp;s-&gt;v21rx,
+                &amp;preset_fsk_specs[(s-&gt;calling_party)  ?  FSK_V21CH2  :  FSK_V21CH1],
+                FSK_FRAME_MODE_ASYNC,
+                put_bit,
+                s);
+    s-&gt;preamble_type = V8_SYNC_UNKNOWN;
</ins><span class="cx">     s-&gt;bit_stream = 0;
</span><del>-    s-&gt;cm_jm_count = 0;
</del><ins>+    s-&gt;cm_jm_len = 0;
</ins><span class="cx">     s-&gt;got_cm_jm = FALSE;
</span><span class="cx">     s-&gt;got_cj = FALSE;
</span><span class="cx">     s-&gt;zero_byte_count = 0;
</span><span class="lines">@@ -513,11 +604,22 @@
</span><span class="cx"> 
</span><span class="cx">     s = user_data;
</span><span class="cx">     if (queue_read(s-&gt;tx_queue, &amp;bit, 1) &lt;= 0)
</span><del>-        bit = 1;
</del><ins>+        return SIG_STATUS_END_OF_DATA;
</ins><span class="cx">     return bit;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+static void v8_put_preamble(v8_state_t *s)
+{
+    static const uint8_t preamble[10] =
+    {
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+    };
+
+    queue_write(s-&gt;tx_queue, preamble, 10);
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> static void v8_put_byte(v8_state_t *s, int data)
</span><span class="cx"> {
</span><span class="cx">     int i;
</span><span class="lines">@@ -538,17 +640,12 @@
</span><span class="cx"> static void send_cm_jm(v8_state_t *s, int mod_mask)
</span><span class="cx"> {
</span><span class="cx">     int val;
</span><del>-    static const uint8_t preamble[20] =
-    {
-        /* 10 1's (0x3FF), then 10 bits of CM sync (0x00F) */
-        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1
-    };
</del><span class="cx"> 
</span><span class="cx">     /* Send a CM, or a JM as appropriate */
</span><del>-    queue_write(s-&gt;tx_queue, preamble, 20);
-    
</del><ins>+    v8_put_preamble(s);
+    v8_put_byte(s, V8_CM_JM_SYNC_OCTET);
</ins><span class="cx">     /* Data call */
</span><del>-    v8_put_byte(s, (V8_CALL_V_SERIES &lt;&lt; 5) | 0x01);
</del><ins>+    v8_put_byte(s, (V8_CALL_V_SERIES &lt;&lt; 5) | V8_CALL_FUNCTION_TAG);
</ins><span class="cx">     
</span><span class="cx">     /* Supported modulations */
</span><span class="cx">     val = 0x05;
</span><span class="lines">@@ -584,12 +681,12 @@
</span><span class="cx">         val |= 0x80;
</span><span class="cx">     v8_put_byte(s, val);
</span><span class="cx"> 
</span><del>-    v8_put_byte(s, (0 &lt;&lt; 5) | 0x07);
</del><ins>+    v8_put_byte(s, (0 &lt;&lt; 5) | V8_PCM_MODEM_AVAILABILITY_TAG);
</ins><span class="cx"> 
</span><del>-    v8_put_byte(s, (V8_PROTOCOL_LAPM_V42 &lt;&lt; 5) | 0x0A);
</del><ins>+    v8_put_byte(s, (V8_PROTOCOL_LAPM_V42 &lt;&lt; 5) | V8_PROTOCOLS_TAG);
</ins><span class="cx"> 
</span><span class="cx">     /* No cellular right now */    
</span><del>-    v8_put_byte(s, (0 &lt;&lt; 5) | 0x0D);
</del><ins>+    v8_put_byte(s, (0 &lt;&lt; 5) | V8_PSTN_ACCESS_TAG);
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="lines">@@ -615,75 +712,122 @@
</span><span class="cx"> 
</span><span class="cx">     //span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;v8_tx state %d\n&quot;, s-&gt;state);
</span><span class="cx">     len = 0;
</span><del>-    switch (s-&gt;state)
</del><ins>+    if (s-&gt;modem_connect_tone_tx_on)
</ins><span class="cx">     {
</span><del>-    case V8_CI_ON:
-    case V8_CM_ON:
-    case V8_JM_ON:
-    case V8_CJ_ON:
-        len = fsk_tx(&amp;s-&gt;v21tx, amp, max_len);
-        break;
-    case V8_CM_WAIT:
-        /* Send the ANSam tone */
-        len = modem_connect_tones_tx(&amp;s-&gt;ansam_tx, amp, max_len);
-        break;
</del><ins>+        if (s-&gt;modem_connect_tone_tx_on &gt; ms_to_samples(75))
+        {
+            /* Send the ANSam tone */
+            len = modem_connect_tones_tx(&amp;s-&gt;ansam_tx, amp, max_len);
+            if (len &lt; max_len)
+            {
+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;ANSam or ANSam/ ended\n&quot;);
+                s-&gt;modem_connect_tone_tx_on = ms_to_samples(75);
+            }
+        }
+        else
+        {
+            if (max_len &gt; s-&gt;modem_connect_tone_tx_on)
+                len = s-&gt;modem_connect_tone_tx_on;
+            else
+                len = max_len;
+            vec_zeroi16(amp, len);
+            s-&gt;modem_connect_tone_tx_on -= len;
+        }
</ins><span class="cx">     }
</span><ins>+    if (s-&gt;fsk_tx_on  &amp;&amp;  len &lt; max_len)
+    {
+        max_len -= len;
+        len = fsk_tx(&amp;s-&gt;v21tx, amp + len, max_len);
+        if (len &lt; max_len)
+        {
+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;FSK ends\n&quot;);
+            s-&gt;fsk_tx_on = FALSE;
+        }
+    }
</ins><span class="cx">     return len;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><ins>+static void v8_send_ci(v8_state_t *s)
+{
+    int i;
+
+    /* Send 4 CI packets in a burst (the spec says at least 3) */
+    for (i = 0;  i &lt; 4;  i++)
+    {
+        v8_put_preamble(s);
+        v8_put_byte(s, V8_CI_SYNC_OCTET);
+        v8_put_byte(s, (V8_CALL_V_SERIES &lt;&lt; 5) | V8_CALL_FUNCTION_TAG);
+    }
+}
+/*- End of function --------------------------------------------------------*/
+
+static void handle_modem_connect_tone(v8_state_t *s, int tone)
+{
+    s-&gt;result.modem_connect_tone_detected = tone;
+    span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;'%s' recognised\n&quot;, modem_connect_tone_to_str(tone));
+    if (tone == MODEM_CONNECT_TONES_ANSAM
+        ||
+        tone == MODEM_CONNECT_TONES_ANSAM_PR)
+    {
+        /* Set the Te interval. The spec. says 500ms is the minimum,
+           but gives reasons why 1 second is a better value. */
+        s-&gt;state = V8_HEARD_ANSAM;
+        s-&gt;ci_timer = ms_to_samples(1000);
+    }
+    else
+    {
+        /* If we found a connect tone, and it isn't one of the modulated answer tones,
+           indicating V.8 startup, we are not going to do V.8 processing. */
+        span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Non-V.8 modem connect tone detected\n&quot;);
+        s-&gt;state = V8_PARKED;
+        if (s-&gt;result_handler)
+            s-&gt;result_handler(s-&gt;result_handler_user_data, &amp;s-&gt;result);
+    }
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> SPAN_DECLARE_NONSTD(int) v8_rx(v8_state_t *s, const int16_t *amp, int len)
</span><span class="cx"> {
</span><span class="cx">     int i;
</span><span class="cx">     int residual_samples;
</span><del>-    v8_result_t result;
-    static const uint8_t preamble[20] =
-    {
-        /* 10 1's (0x3FF), then 10 bits of CI sync (0x001) */
-        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
-    };
</del><ins>+    int tone;
</ins><span class="cx"> 
</span><span class="cx">     //span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;v8_rx state %d\n&quot;, s-&gt;state);
</span><span class="cx">     residual_samples = 0;
</span><span class="cx">     switch (s-&gt;state)
</span><span class="cx">     {
</span><span class="cx">     case V8_WAIT_1S:
</span><ins>+        residual_samples = modem_connect_tones_rx(&amp;s-&gt;ansam_rx, amp, len);
</ins><span class="cx">         /* Wait 1 second before sending the first CI packet */
</span><span class="cx">         if ((s-&gt;negotiation_timer -= len) &gt; 0)
</span><span class="cx">             break;
</span><del>-        s-&gt;state = V8_CI;
-        s-&gt;ci_count = 0;
-        modem_connect_tones_rx_init(&amp;s-&gt;ansam_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
-        fsk_tx_init(&amp;s-&gt;v21tx, &amp;preset_fsk_specs[FSK_V21CH1], get_bit, s);
-        /* Fall through to the next state */
-    case V8_CI:
-        residual_samples = modem_connect_tones_rx(&amp;s-&gt;ansam_rx, amp, len);
-        /* Send 4 CI packets in a burst (the spec says at least 3) */
-        for (i = 0;  i &lt; 4;  i++)
-        {
-            /* 10 1's (0x3FF), then CI sync (0x001) */
-            queue_write(s-&gt;tx_queue, preamble, 20);
-            v8_put_byte(s, (V8_CALL_V_SERIES &lt;&lt; 5) | 0x01);
-        }
</del><ins>+        fsk_tx_restart(&amp;s-&gt;v21tx, &amp;preset_fsk_specs[FSK_V21CH1]);
+        v8_send_ci(s);
</ins><span class="cx">         s-&gt;state = V8_CI_ON;
</span><ins>+        s-&gt;fsk_tx_on = TRUE;
</ins><span class="cx">         break;
</span><span class="cx">     case V8_CI_ON:
</span><span class="cx">         residual_samples = modem_connect_tones_rx(&amp;s-&gt;ansam_rx, amp, len);
</span><ins>+        /* Check if an ANSam or ANSam/ tone has been detected */
+        if ((tone = modem_connect_tones_rx_get(&amp;s-&gt;ansam_rx)) != MODEM_CONNECT_TONES_NONE)
+        {
+            handle_modem_connect_tone(s, tone);
+            break;
+        }
</ins><span class="cx">         if (queue_empty(s-&gt;tx_queue))
</span><span class="cx">         {
</span><span class="cx">             s-&gt;state = V8_CI_OFF;
</span><span class="cx">             s-&gt;ci_timer = ms_to_samples(500);
</span><ins>+            break;
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case V8_CI_OFF:
</span><span class="cx">         residual_samples = modem_connect_tones_rx(&amp;s-&gt;ansam_rx, amp, len);
</span><del>-        /* Check if an ANSam tone has been detected */
-        if (modem_connect_tones_rx_get(&amp;s-&gt;ansam_rx))
</del><ins>+        /* Check if an ANSam or ANSam/ tone has been detected */
+        if ((tone = modem_connect_tones_rx_get(&amp;s-&gt;ansam_rx)) != MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">         {
</span><del>-            /* Set the Te interval. The spec. says 500ms is the minimum,
-               but gives reasons why 1 second is a better value. */
-            s-&gt;ci_timer = ms_to_samples(1000);
-            s-&gt;state = V8_HEARD_ANSAM;
</del><ins>+            handle_modem_connect_tone(s, tone);
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         if ((s-&gt;ci_timer -= len) &lt;= 0)
</span><span class="lines">@@ -691,6 +835,7 @@
</span><span class="cx">             if (++s-&gt;ci_count &gt;= 10)
</span><span class="cx">             {
</span><span class="cx">                 /* The spec says we should give up now. */
</span><ins>+                span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Timeout waiting for modem connect tone\n&quot;);
</ins><span class="cx">                 s-&gt;state = V8_PARKED;
</span><span class="cx">                 if (s-&gt;result_handler)
</span><span class="cx">                     s-&gt;result_handler(s-&gt;result_handler_user_data, NULL);
</span><span class="lines">@@ -698,46 +843,54 @@
</span><span class="cx">             else
</span><span class="cx">             {
</span><span class="cx">                 /* Try again */
</span><del>-                s-&gt;state = V8_CI;
</del><ins>+                fsk_tx_restart(&amp;s-&gt;v21tx, &amp;preset_fsk_specs[FSK_V21CH1]);
+                v8_send_ci(s);
+                s-&gt;state = V8_CI_ON;
+                s-&gt;fsk_tx_on = TRUE;
</ins><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case V8_HEARD_ANSAM:
</span><del>-        /* We have heard the ANSam signal, but we still need to wait for the
</del><ins>+        /* We have heard the ANSam or ANSam/ signal, but we still need to wait for the
</ins><span class="cx">            end of the Te timeout period to comply with the spec. */
</span><span class="cx">         if ((s-&gt;ci_timer -= len) &lt;= 0)
</span><span class="cx">         {
</span><span class="cx">             v8_decode_init(s);
</span><ins>+            s-&gt;negotiation_timer = ms_to_samples(5000);
+            fsk_tx_restart(&amp;s-&gt;v21tx, &amp;preset_fsk_specs[FSK_V21CH1]);
+            send_cm_jm(s, s-&gt;local_end_modulations);
</ins><span class="cx">             s-&gt;state = V8_CM_ON;
</span><del>-            s-&gt;negotiation_timer = ms_to_samples(5000);
-            send_cm_jm(s, s-&gt;available_modulations);
</del><ins>+            s-&gt;fsk_tx_on = TRUE;
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case V8_CM_ON:
</span><span class="cx">         residual_samples = fsk_rx(&amp;s-&gt;v21rx, amp, len);
</span><span class="cx">         if (s-&gt;got_cm_jm)
</span><span class="cx">         {
</span><del>-            /* Now JM has been detected we send CJ and wait for 75 ms
</del><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;JM recognised\n&quot;);
+            /* Now JM has been detected, we send CJ and wait for 75 ms
</ins><span class="cx">                before finishing the V.8 analysis. */
</span><del>-            s-&gt;negotiated_modulation = select_modulation(s-&gt;far_end_modulations);
</del><ins>+            s-&gt;result.negotiated_modulation = select_modulation(s-&gt;result.far_end_modulations);
</ins><span class="cx"> 
</span><del>-            queue_flush(s-&gt;tx_queue);
-            for (i = 0;  i &lt; 9;  i++)
</del><ins>+            fsk_tx_restart(&amp;s-&gt;v21tx, &amp;preset_fsk_specs[FSK_V21CH1]);
+            for (i = 0;  i &lt; 3;  i++)
</ins><span class="cx">                 v8_put_byte(s, 0);
</span><span class="cx">             s-&gt;state = V8_CJ_ON;
</span><ins>+            s-&gt;fsk_tx_on = TRUE;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         if ((s-&gt;negotiation_timer -= len) &lt;= 0)
</span><span class="cx">         {
</span><span class="cx">             /* Timeout */
</span><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Timeout waiting for JM\n&quot;);
</ins><span class="cx">             s-&gt;state = V8_PARKED;
</span><span class="cx">             if (s-&gt;result_handler)
</span><span class="cx">                 s-&gt;result_handler(s-&gt;result_handler_user_data, NULL);
</span><span class="cx">         }
</span><del>-        if (queue_empty(s-&gt;tx_queue))
</del><ins>+        if (queue_contents(s-&gt;tx_queue) &lt; 10)
</ins><span class="cx">         {
</span><span class="cx">             /* Send CM again */
</span><del>-            send_cm_jm(s, s-&gt;available_modulations);
</del><ins>+            send_cm_jm(s, s-&gt;local_end_modulations);
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case V8_CJ_ON:
</span><span class="lines">@@ -752,49 +905,33 @@
</span><span class="cx">         if ((s-&gt;negotiation_timer -= len) &lt;= 0)
</span><span class="cx">         {
</span><span class="cx">             /* The V.8 negotiation has succeeded. */
</span><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Negotiation succeeded\n&quot;);
</ins><span class="cx">             s-&gt;state = V8_PARKED;
</span><span class="cx">             if (s-&gt;result_handler)
</span><del>-            {
-                result.call_function = s-&gt;call_function;
-                result.available_modulations = s-&gt;far_end_modulations;
-                result.negotiated_modulation = s-&gt;negotiated_modulation;
-                result.protocol = s-&gt;protocol;
-                result.pstn_access = s-&gt;pstn_access;
-                result.nsf_seen = s-&gt;nsf_seen;
-                result.pcm_modem_availability = s-&gt;pcm_modem_availability;
-                result.t66_seen = s-&gt;t66_seen;
-                s-&gt;result_handler(s-&gt;result_handler_user_data, &amp;result);
-            }
</del><ins>+                s-&gt;result_handler(s-&gt;result_handler_user_data, &amp;s-&gt;result);
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><del>-    case V8_WAIT_200MS:
-        if ((s-&gt;negotiation_timer -= len) &lt;= 0)
-        {
-            /* Send the ANSam tone */
-            modem_connect_tones_tx_init(&amp;s-&gt;ansam_tx, MODEM_CONNECT_TONES_ANSAM_PR);
-                
-            v8_decode_init(s);
-            s-&gt;state = V8_CM_WAIT;
-            s-&gt;negotiation_timer = ms_to_samples(5000);
-        }
-        break;
</del><span class="cx">     case V8_CM_WAIT:
</span><span class="cx">         residual_samples = fsk_rx(&amp;s-&gt;v21rx, amp, len);
</span><span class="cx">         if (s-&gt;got_cm_jm)
</span><span class="cx">         {
</span><del>-            /* Stop sending ANSam and send JM instead */
</del><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CM recognised\n&quot;);
+            /* Stop sending ANSam or ANSam/ and send JM instead */
</ins><span class="cx">             fsk_tx_init(&amp;s-&gt;v21tx, &amp;preset_fsk_specs[FSK_V21CH2], get_bit, s);
</span><span class="cx">             /* Set the timeout for JM */
</span><span class="cx">             s-&gt;negotiation_timer = ms_to_samples(5000); 
</span><span class="cx">             s-&gt;state = V8_JM_ON;
</span><del>-            s-&gt;common_modulations = s-&gt;available_modulations &amp; s-&gt;far_end_modulations;
-            s-&gt;negotiated_modulation = select_modulation(s-&gt;common_modulations);
</del><ins>+            s-&gt;common_modulations = s-&gt;local_end_modulations &amp; s-&gt;result.far_end_modulations;
+            s-&gt;result.negotiated_modulation = select_modulation(s-&gt;common_modulations);
</ins><span class="cx">             send_cm_jm(s, s-&gt;common_modulations);
</span><ins>+            s-&gt;modem_connect_tone_tx_on = ms_to_samples(75);
+            s-&gt;fsk_tx_on = TRUE;
</ins><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">         if ((s-&gt;negotiation_timer -= len) &lt;= 0)
</span><span class="cx">         {
</span><span class="cx">             /* Timeout */
</span><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Timeout waiting for CM\n&quot;);
</ins><span class="cx">             s-&gt;state = V8_PARKED;
</span><span class="cx">             if (s-&gt;result_handler)
</span><span class="cx">                 s-&gt;result_handler(s-&gt;result_handler_user_data, NULL);
</span><span class="lines">@@ -804,7 +941,9 @@
</span><span class="cx">         residual_samples = fsk_rx(&amp;s-&gt;v21rx, amp, len);
</span><span class="cx">         if (s-&gt;got_cj)
</span><span class="cx">         {
</span><del>-            /* Stop sending JM, and wait 75 ms */
</del><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;CJ recognised\n&quot;);
+            /* Stop sending JM, flushing anything left in the buffer, and wait 75 ms */
+            queue_flush(s-&gt;tx_queue);
</ins><span class="cx">             s-&gt;negotiation_timer = ms_to_samples(75);
</span><span class="cx">             s-&gt;state = V8_SIGA;
</span><span class="cx">             break;
</span><span class="lines">@@ -812,12 +951,13 @@
</span><span class="cx">         if ((s-&gt;negotiation_timer -= len) &lt;= 0)
</span><span class="cx">         {
</span><span class="cx">             /* Timeout */
</span><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Timeout waiting for CJ\n&quot;);
</ins><span class="cx">             s-&gt;state = V8_PARKED;
</span><span class="cx">             if (s-&gt;result_handler)
</span><span class="cx">                 s-&gt;result_handler(s-&gt;result_handler_user_data, NULL);
</span><span class="cx">             break;
</span><span class="cx">         }
</span><del>-        if (queue_empty(s-&gt;tx_queue))
</del><ins>+        if (queue_contents(s-&gt;tx_queue) &lt; 10)
</ins><span class="cx">         {
</span><span class="cx">             /* Send JM */
</span><span class="cx">             send_cm_jm(s, s-&gt;common_modulations);
</span><span class="lines">@@ -827,19 +967,10 @@
</span><span class="cx">         if ((s-&gt;negotiation_timer -= len) &lt;= 0)
</span><span class="cx">         {
</span><span class="cx">             /* The V.8 negotiation has succeeded. */
</span><ins>+            span_log(&amp;s-&gt;logging, SPAN_LOG_FLOW, &quot;Negotiation succeeded\n&quot;);
</ins><span class="cx">             s-&gt;state = V8_PARKED;
</span><span class="cx">             if (s-&gt;result_handler)
</span><del>-            {
-                result.call_function = s-&gt;call_function;
-                result.available_modulations = s-&gt;far_end_modulations;
-                result.negotiated_modulation = s-&gt;negotiated_modulation;
-                result.protocol = s-&gt;protocol;
-                result.pstn_access = s-&gt;pstn_access;
-                result.nsf_seen = s-&gt;nsf_seen;
-                result.pcm_modem_availability = s-&gt;pcm_modem_availability;
-                result.t66_seen = s-&gt;t66_seen;
-                s-&gt;result_handler(s-&gt;result_handler_user_data, &amp;result);
-            }
</del><ins>+                s-&gt;result_handler(s-&gt;result_handler_user_data, &amp;s-&gt;result);
</ins><span class="cx">         }
</span><span class="cx">         break;
</span><span class="cx">     case V8_PARKED:
</span><span class="lines">@@ -857,7 +988,8 @@
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><span class="cx"> SPAN_DECLARE(v8_state_t *) v8_init(v8_state_t *s,
</span><del>-                                   int caller,
</del><ins>+                                   int calling_party,
+                                   int use_ansam_pr,
</ins><span class="cx">                                    int available_modulations,
</span><span class="cx">                                    v8_result_handler_t *result_handler,
</span><span class="cx">                                    void *user_data)
</span><span class="lines">@@ -868,22 +1000,36 @@
</span><span class="cx">             return NULL;
</span><span class="cx">     }
</span><span class="cx">     memset(s, 0, sizeof(*s));
</span><del>-    s-&gt;caller = caller;
-    s-&gt;available_modulations = available_modulations;
</del><ins>+    span_log_init(&amp;s-&gt;logging, SPAN_LOG_NONE, NULL);
+    span_log_set_protocol(&amp;s-&gt;logging, &quot;V.8&quot;);
+    s-&gt;local_end_modulations = available_modulations;
</ins><span class="cx">     s-&gt;result_handler = result_handler;
</span><span class="cx">     s-&gt;result_handler_user_data = user_data;
</span><span class="cx"> 
</span><span class="cx">     s-&gt;ci_timer = 0;
</span><del>-    if (s-&gt;caller)
</del><ins>+    if (calling_party)
</ins><span class="cx">     {
</span><ins>+        s-&gt;calling_party = TRUE;
</ins><span class="cx">         s-&gt;state = V8_WAIT_1S;
</span><span class="cx">         s-&gt;negotiation_timer = ms_to_samples(1000);
</span><ins>+        s-&gt;ci_count = 0;
+        modem_connect_tones_rx_init(&amp;s-&gt;ansam_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
+        fsk_tx_init(&amp;s-&gt;v21tx, &amp;preset_fsk_specs[FSK_V21CH1], get_bit, s);
</ins><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><del>-        s-&gt;state = V8_WAIT_200MS;
-        s-&gt;negotiation_timer = ms_to_samples(200);
</del><ins>+        /* Send the ANSam or ANSam/ tone */
+        s-&gt;calling_party = FALSE;
+        modem_connect_tones_tx_init(&amp;s-&gt;ansam_tx,
+                                    (use_ansam_pr)  ?  MODEM_CONNECT_TONES_ANSAM_PR  :  MODEM_CONNECT_TONES_ANSAM);
+                
+        v8_decode_init(s);
+        s-&gt;state = V8_CM_WAIT;
+        s-&gt;negotiation_timer = ms_to_samples(200 + 5000);
+        s-&gt;modem_connect_tone_tx_on = ms_to_samples(75) + 1;
</ins><span class="cx">     }
</span><ins>+    s-&gt;result.modem_connect_tone_detected = MODEM_CONNECT_TONES_NONE;
+
</ins><span class="cx">     if ((s-&gt;tx_queue = queue_init(NULL, 1024, 0)) == NULL)
</span><span class="cx">         return NULL;
</span><span class="cx">     return s;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsat_interpreter_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/at_interpreter_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: at_interpreter_tests.c,v 1.23 2009/05/30 15:23:13 steveu Exp $
</del><ins>+ * $Id: at_interpreter_tests.c,v 1.24 2009/10/09 14:53:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -234,6 +234,9 @@
</span><span class="cx">     {&quot;AT+ETBM?\r&quot;, &quot;\r\n+ETBM:0,0\r\n\r\nOK\r\n&quot;},
</span><span class="cx">     {&quot;AT+EWIND=?\r&quot;, &quot;\r\n+EWIND:(1-127),(1-127)\r\n\r\nOK\r\n&quot;},   /* V.250 6.5.7 - Window size */ 
</span><span class="cx">     {&quot;AT+EWIND?\r&quot;, &quot;\r\n+EWIND:0,0\r\n\r\nOK\r\n&quot;},
</span><ins>+    {&quot;AT+F34=?\r&quot;,  &quot;\r\n+F34:(0-14),(0-14),(0-2),(0-14),(0-14)\r\n\r\nOK\r\n&quot;},
+                                                                    /* T.31 B.6.1 - Initial V.34 rate controls for FAX */
+    {&quot;AT+F34?\r&quot;, &quot;\r\n+F34:0,0,0,0,0\r\n\r\nOK\r\n&quot;},
</ins><span class="cx">     {&quot;AT+FAR=?\r&quot;, &quot;\r\n0,1\r\n\r\nOK\r\n&quot;},                        /* T.31 8.5.1 - Adaptive reception control */ 
</span><span class="cx">     {&quot;AT+FAR?\r&quot;, &quot;\r\n0\r\n\r\nOK\r\n&quot;},
</span><span class="cx">     {&quot;AT+FCL=?\r&quot;, &quot;\r\n(0-255)\r\n\r\nOK\r\n&quot;},                    /* T.31 8.5.2 - Carrier loss timeout */ 
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsfax_decodec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/fax_decode.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/fax_decode.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/fax_decode.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fax_decode.c,v 1.57 2009/09/15 14:01:53 steveu Exp $
</del><ins>+ * $Id: fax_decode.c,v 1.58 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \page fax_decode_page FAX decoder
</span><span class="lines">@@ -479,7 +479,7 @@
</span><span class="cx">     span_log_set_protocol(&amp;t30_dummy.logging, &quot;T.30&quot;);
</span><span class="cx"> 
</span><span class="cx">     hdlc_rx_init(&amp;hdlcrx, FALSE, TRUE, 5, hdlc_accept, NULL);
</span><del>-    fsk = fsk_rx_init(NULL, &amp;preset_fsk_specs[FSK_V21CH2], TRUE, v21_put_bit, NULL);
</del><ins>+    fsk = fsk_rx_init(NULL, &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, v21_put_bit, NULL);
</ins><span class="cx">     v17 = v17_rx_init(NULL, 14400, v17_put_bit, NULL);
</span><span class="cx">     v29 = v29_rx_init(NULL, 9600, v29_put_bit, NULL);
</span><span class="cx">     //v29 = v29_rx_init(NULL, 7200, v29_put_bit, NULL);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsfax_testerc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/fax_tester.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/fax_tester.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/fax_tester.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * License along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fax_tester.c,v 1.22 2009/02/12 12:38:39 steveu Exp $
</del><ins>+ * $Id: fax_tester.c,v 1.23 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -496,7 +496,7 @@
</span><span class="cx">     case T30_MODEM_V21:
</span><span class="cx">         if (s-&gt;flush_handler)
</span><span class="cx">             s-&gt;flush_handler(s, s-&gt;flush_user_data, 3);
</span><del>-        fsk_rx_init(&amp;t-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], TRUE, (put_bit_func_t) hdlc_rx_put_bit, put_bit_user_data);
</del><ins>+        fsk_rx_init(&amp;t-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, put_bit_user_data);
</ins><span class="cx">         fsk_rx_signal_cutoff(&amp;t-&gt;v21_rx, -45.5);
</span><span class="cx">         t-&gt;rx_handler = (span_rx_handler_t *) &amp;fsk_rx;
</span><span class="cx">         t-&gt;rx_user_data = &amp;t-&gt;v21_rx;
</span><span class="lines">@@ -670,7 +670,7 @@
</span><span class="cx"> 
</span><span class="cx">     hdlc_rx_init(&amp;s-&gt;hdlc_rx, FALSE, FALSE, HDLC_FRAMING_OK_THRESHOLD, hdlc_accept, user_data);
</span><span class="cx">     hdlc_tx_init(&amp;s-&gt;hdlc_tx, FALSE, 2, FALSE, hdlc_underflow_handler, user_data);
</span><del>-    fsk_rx_init(&amp;s-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], TRUE, (put_bit_func_t) hdlc_rx_put_bit, &amp;s-&gt;hdlc_rx);
</del><ins>+    fsk_rx_init(&amp;s-&gt;v21_rx, &amp;preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, &amp;s-&gt;hdlc_rx);
</ins><span class="cx">     fsk_rx_signal_cutoff(&amp;s-&gt;v21_rx, -45.5);
</span><span class="cx">     fsk_tx_init(&amp;s-&gt;v21_tx, &amp;preset_fsk_specs[FSK_V21CH2], (get_bit_func_t) hdlc_tx_get_bit, &amp;s-&gt;hdlc_tx);
</span><span class="cx">     fsk_tx_set_modem_status_handler(&amp;s-&gt;v21_tx, modem_tx_status, user_data);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsfax_testssh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/fax_tests.sh (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/fax_tests.sh        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/fax_tests.sh        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-#!/bin/sh
</del><ins>+#!/bin/bash
</ins><span class="cx"> #
</span><span class="cx"> # spandsp fax tests
</span><span class="cx"> #
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsfax_utilsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/fax_utils.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/fax_utils.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/fax_utils.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fax_utils.c,v 1.3 2009/05/16 03:34:45 steveu Exp $
</del><ins>+ * $Id: fax_utils.c,v 1.3.4.1 2009/12/19 09:47:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> #if defined(HAVE_CONFIG_H)
</span><span class="lines">@@ -95,8 +95,8 @@
</span><span class="cx">     printf(&quot;%s: ECM %s\n&quot;, tag, (t.error_correcting_mode)  ?  &quot;on&quot;  :  &quot;off&quot;);
</span><span class="cx">     printf(&quot;%s: tx pages %d, rx pages %d\n&quot;, tag, t.pages_tx, t.pages_rx);
</span><span class="cx">     printf(&quot;%s: pages in the file %d\n&quot;, tag, t.pages_in_file);
</span><del>-    printf(&quot;%s: image size %d x %d\n&quot;, tag, t.width, t.length);
-    printf(&quot;%s: image resolution %d x %d\n&quot;, tag, t.x_resolution, t.y_resolution);
</del><ins>+    printf(&quot;%s: image size %d pels x %d pels\n&quot;, tag, t.width, t.length);
+    printf(&quot;%s: image resolution %d pels/m x %d pels/m\n&quot;, tag, t.x_resolution, t.y_resolution);
</ins><span class="cx">     printf(&quot;%s: bad rows %d, longest bad row run %d\n&quot;, tag, t.bad_rows, t.longest_bad_row_run);
</span><span class="cx">     printf(&quot;%s: bad ECM frames %d\n&quot;, tag, t.error_correcting_mode_retries);
</span><span class="cx">     printf(&quot;%s: compression type %d\n&quot;, tag, t.encoding);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsfsk_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/fsk_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/fsk_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/fsk_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: fsk_tests.c,v 1.58 2009/07/09 13:52:09 steveu Exp $
</del><ins>+ * $Id: fsk_tests.c,v 1.59 2009/11/02 13:25:20 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \page fsk_tests_page FSK modem tests
</span><span class="lines">@@ -283,7 +283,7 @@
</span><span class="cx">             fprintf(stderr, &quot;    Cannot open audio file '%s'\n&quot;, decode_test_file);
</span><span class="cx">             exit(2);
</span><span class="cx">         }
</span><del>-        caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], TRUE, put_bit, NULL);
</del><ins>+        caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], FSK_FRAME_MODE_SYNC, put_bit, NULL);
</ins><span class="cx">         fsk_rx_set_modem_status_handler(caller_rx, rx_status, (void *) &amp;caller_rx);
</span><span class="cx">         test_bps = preset_fsk_specs[modem_under_test_1].baud_rate;
</span><span class="cx"> 
</span><span class="lines">@@ -306,7 +306,7 @@
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="cx">         printf(&quot;Test cutoff level\n&quot;);
</span><del>-        caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], TRUE, cutoff_test_put_bit, NULL);
</del><ins>+        caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], FSK_FRAME_MODE_SYNC, cutoff_test_put_bit, NULL);
</ins><span class="cx">         fsk_rx_signal_cutoff(caller_rx, -30.0f);
</span><span class="cx">         fsk_rx_set_modem_status_handler(caller_rx, cutoff_test_rx_status, (void *) &amp;caller_rx);
</span><span class="cx">         on_at = 0;
</span><span class="lines">@@ -370,14 +370,14 @@
</span><span class="cx">         {
</span><span class="cx">             caller_tx = fsk_tx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], (get_bit_func_t) bert_get_bit, &amp;caller_bert);
</span><span class="cx">             fsk_tx_set_modem_status_handler(caller_tx, tx_status, (void *) &amp;caller_tx);
</span><del>-            answerer_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], TRUE, (put_bit_func_t) bert_put_bit, &amp;answerer_bert);
</del><ins>+            answerer_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], FSK_FRAME_MODE_SYNC, (put_bit_func_t) bert_put_bit, &amp;answerer_bert);
</ins><span class="cx">             fsk_rx_set_modem_status_handler(answerer_rx, rx_status, (void *) &amp;answerer_rx);
</span><span class="cx">         }
</span><span class="cx">         if (modem_under_test_2 &gt;= 0)
</span><span class="cx">         {
</span><span class="cx">             answerer_tx = fsk_tx_init(NULL, &amp;preset_fsk_specs[modem_under_test_2], (get_bit_func_t) bert_get_bit, &amp;answerer_bert);
</span><span class="cx">             fsk_tx_set_modem_status_handler(answerer_tx, tx_status, (void *) &amp;answerer_tx);
</span><del>-            caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_2], TRUE, (put_bit_func_t) bert_put_bit, &amp;caller_bert);
</del><ins>+            caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) bert_put_bit, &amp;caller_bert);
</ins><span class="cx">             fsk_rx_set_modem_status_handler(caller_rx, rx_status, (void *) &amp;caller_rx);
</span><span class="cx">         }
</span><span class="cx">         test_bps = preset_fsk_specs[modem_under_test_1].baud_rate;
</span><span class="lines">@@ -477,14 +477,14 @@
</span><span class="cx">                 {
</span><span class="cx">                     caller_tx = fsk_tx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], (get_bit_func_t) bert_get_bit, &amp;caller_bert);
</span><span class="cx">                     fsk_tx_set_modem_status_handler(caller_tx, tx_status, (void *) &amp;caller_tx);
</span><del>-                    answerer_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], TRUE, (put_bit_func_t) bert_put_bit, &amp;answerer_bert);
</del><ins>+                    answerer_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_1], FSK_FRAME_MODE_SYNC, (put_bit_func_t) bert_put_bit, &amp;answerer_bert);
</ins><span class="cx">                     fsk_rx_set_modem_status_handler(answerer_rx, rx_status, (void *) &amp;answerer_rx);
</span><span class="cx">                 }
</span><span class="cx">                 if (modem_under_test_2 &gt;= 0)
</span><span class="cx">                 {
</span><span class="cx">                     answerer_tx = fsk_tx_init(NULL, &amp;preset_fsk_specs[modem_under_test_2], (get_bit_func_t) bert_get_bit, &amp;answerer_bert);
</span><span class="cx">                     fsk_tx_set_modem_status_handler(answerer_tx, tx_status, (void *) &amp;answerer_tx);
</span><del>-                    caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_2], TRUE, (put_bit_func_t) bert_put_bit, &amp;caller_bert);
</del><ins>+                    caller_rx = fsk_rx_init(NULL, &amp;preset_fsk_specs[modem_under_test_2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) bert_put_bit, &amp;caller_bert);
</ins><span class="cx">                     fsk_rx_set_modem_status_handler(caller_rx, rx_status, (void *) &amp;caller_rx);
</span><span class="cx">                 }
</span><span class="cx">                 noise_level++;
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsmodem_connect_tones_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/modem_connect_tones_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/modem_connect_tones_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/modem_connect_tones_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: modem_connect_tones_tests.c,v 1.30 2009/05/30 15:23:14 steveu Exp $
</del><ins>+ * $Id: modem_connect_tones_tests.c,v 1.32 2009/11/02 15:04:15 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \page modem_connect_tones_tests_page Modem connect tones tests
</span><span class="lines">@@ -61,11 +61,21 @@
</span><span class="cx"> #define FALSE 0
</span><span class="cx"> #define TRUE (!FALSE)
</span><span class="cx"> 
</span><del>-#define LEVEL_MAX                   0
</del><ins>+#define LEVEL_MAX                   -5
</ins><span class="cx"> #define LEVEL_MIN                   -48
</span><span class="cx"> #define LEVEL_MIN_ACCEPT            -43
</span><span class="cx"> #define LEVEL_MIN_REJECT            -44
</span><span class="cx"> 
</span><ins>+/* The 1100Hz tone is supposed to be within 38Hz, according to T.30. Allow another 8Hz for FDM, even though
+   you rarely see that used today. */
+#define CED_FREQ_TOLERANCE          (38 + 8)
+#define CED_FREQ_BLACKOUT           (80)
+/* The 2100Hz tone is supposed to be within 15Hz, according to T.30. Allow another 8Hz for FDM, even though
+   you rarely see that used today. */
+#define CNG_FREQ_TOLERANCE          (15 + 8)
+#define CNG_FREQ_BLACKOUT           (80)
+#define AM_FREQ_TOLERANCE           (1)
+
</ins><span class="cx"> const char *bellcore_files[] =
</span><span class="cx"> {
</span><span class="cx">     MITEL_DIR    &quot;mitel-cm7291-talkoff.wav&quot;,
</span><span class="lines">@@ -88,13 +98,21 @@
</span><span class="cx">     PERFORM_TEST_2A = (1 &lt;&lt; 6),
</span><span class="cx">     PERFORM_TEST_2B = (1 &lt;&lt; 7),
</span><span class="cx">     PERFORM_TEST_2C = (1 &lt;&lt; 8),
</span><del>-    PERFORM_TEST_3A = (1 &lt;&lt; 9),
-    PERFORM_TEST_3B = (1 &lt;&lt; 10),
-    PERFORM_TEST_3C = (1 &lt;&lt; 11),
-    PERFORM_TEST_4 = (1 &lt;&lt; 12),
-    PERFORM_TEST_5A = (1 &lt;&lt; 13),
-    PERFORM_TEST_5B = (1 &lt;&lt; 14),
-    PERFORM_TEST_6 = (1 &lt;&lt; 15)
</del><ins>+    PERFORM_TEST_2D = (1 &lt;&lt; 9),
+    PERFORM_TEST_2E = (1 &lt;&lt; 10),
+    PERFORM_TEST_3A = (1 &lt;&lt; 11),
+    PERFORM_TEST_3B = (1 &lt;&lt; 12),
+    PERFORM_TEST_3C = (1 &lt;&lt; 13),
+    PERFORM_TEST_3D = (1 &lt;&lt; 14),
+    PERFORM_TEST_3E = (1 &lt;&lt; 15),
+    PERFORM_TEST_4 = (1 &lt;&lt; 16),
+    PERFORM_TEST_5A = (1 &lt;&lt; 17),
+    PERFORM_TEST_5B = (1 &lt;&lt; 18),
+    PERFORM_TEST_6A = (1 &lt;&lt; 19),
+    PERFORM_TEST_6B = (1 &lt;&lt; 20),
+    PERFORM_TEST_7A = (1 &lt;&lt; 21),
+    PERFORM_TEST_7B = (1 &lt;&lt; 22),
+    PERFORM_TEST_8 = (1 &lt;&lt; 23)
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> int preamble_count = 0;
</span><span class="lines">@@ -129,45 +147,41 @@
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void preamble_detected(void *user_data, int on, int level, int delay)
</del><ins>+static void cng_detected(void *user_data, int tone, int level, int delay)
</ins><span class="cx"> {
</span><del>-    printf(&quot;%s (%d) declared at bit %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(on), on, preamble_count, level);
-    if (on)
-        preamble_on_at = preamble_count;
-    else
-        preamble_off_at = preamble_count;
-    /*endif*/
-}
-/*- End of function --------------------------------------------------------*/
-
-static void ced_detected(void *user_data, int on, int level, int delay)
-{
-    printf(&quot;%s (%d) declared at %fs, delay %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(on), on, (float) when/SAMPLE_RATE, delay, level);
-    if (on)
</del><ins>+    printf(&quot;%s (%d) declared at %fs, delay %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(tone), tone, (float) when/SAMPLE_RATE, delay, level);
+    if (tone == MODEM_CONNECT_TONES_FAX_CNG)
</ins><span class="cx">         hits++;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void ans_pr_detected(void *user_data, int on, int level, int delay)
</del><ins>+static void preamble_detected(void *user_data, int tone, int level, int delay)
</ins><span class="cx"> {
</span><del>-    printf(&quot;%s (%d) declared at %fs, delay %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(on), on, (float) when/SAMPLE_RATE, delay, level);
-    if (on == MODEM_CONNECT_TONES_ANS_PR)
-        hits++;
</del><ins>+    printf(&quot;%s (%d) declared at bit %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(tone), tone, preamble_count, level);
+    if (tone == MODEM_CONNECT_TONES_FAX_PREAMBLE)
+        preamble_on_at = preamble_count;
+    else
+        preamble_off_at = preamble_count;
+    /*endif*/
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void cng_detected(void *user_data, int on, int level, int delay)
</del><ins>+static void ced_detected(void *user_data, int tone, int level, int delay)
</ins><span class="cx"> {
</span><del>-    printf(&quot;%s (%d) declared at %fs, delay %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(on), on, (float) when/SAMPLE_RATE, delay, level);
-    if (on)
</del><ins>+    printf(&quot;%s (%d) declared at %fs, delay %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(tone), tone, (float) when/SAMPLE_RATE, delay, level);
+    if (tone == MODEM_CONNECT_TONES_FAX_PREAMBLE
+        ||
+        tone == MODEM_CONNECT_TONES_ANS)
+    {
</ins><span class="cx">         hits++;
</span><ins>+    }
</ins><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> 
</span><del>-static void ec_dis_detected(void *user_data, int on, int level, int delay)
</del><ins>+static void ans_pr_detected(void *user_data, int tone, int level, int delay)
</ins><span class="cx"> {
</span><del>-    printf(&quot;%s (%d) declared at %fs, delay %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(on), on, (float) when/SAMPLE_RATE, delay, level);
-    if (on)
</del><ins>+    printf(&quot;%s (%d) declared at %fs, delay %d (%ddBm0)\n&quot;, modem_connect_tone_to_str(tone), tone, (float) when/SAMPLE_RATE, delay, level);
+    if (tone == MODEM_CONNECT_TONES_ANS_PR)
</ins><span class="cx">         hits++;
</span><span class="cx"> }
</span><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="lines">@@ -177,6 +191,7 @@
</span><span class="cx">     int i;
</span><span class="cx">     int j;
</span><span class="cx">     int pitch;
</span><ins>+    int depth;
</ins><span class="cx">     int level;
</span><span class="cx">     int interval;
</span><span class="cx">     int cycle;
</span><span class="lines">@@ -194,13 +209,12 @@
</span><span class="cx">     int hit;
</span><span class="cx">     int false_hit;
</span><span class="cx">     int false_miss;
</span><del>-    tone_gen_descriptor_t tone_desc;
-    tone_gen_state_t tone_tx;
</del><span class="cx">     power_meter_t power_state;
</span><span class="cx">     int power;
</span><span class="cx">     int max_power;
</span><span class="cx">     int level2;
</span><span class="cx">     int max_level2;
</span><ins>+    int tone_type;
</ins><span class="cx">     int test_list;
</span><span class="cx">     int opt;
</span><span class="cx">     char *decode_test_file;
</span><span class="lines">@@ -241,20 +255,36 @@
</span><span class="cx">             test_list |= PERFORM_TEST_2B;
</span><span class="cx">         else if (strcasecmp(argv[i], &quot;2c&quot;) == 0)
</span><span class="cx">             test_list |= PERFORM_TEST_2C;
</span><ins>+        else if (strcasecmp(argv[i], &quot;2d&quot;) == 0)
+            test_list |= PERFORM_TEST_2D;
+        else if (strcasecmp(argv[i], &quot;2e&quot;) == 0)
+            test_list |= PERFORM_TEST_2E;
</ins><span class="cx">         else if (strcasecmp(argv[i], &quot;3a&quot;) == 0)
</span><span class="cx">             test_list |= PERFORM_TEST_3A;
</span><span class="cx">         else if (strcasecmp(argv[i], &quot;3b&quot;) == 0)
</span><span class="cx">             test_list |= PERFORM_TEST_3B;
</span><span class="cx">         else if (strcasecmp(argv[i], &quot;3c&quot;) == 0)
</span><span class="cx">             test_list |= PERFORM_TEST_3C;
</span><ins>+        else if (strcasecmp(argv[i], &quot;3d&quot;) == 0)
+            test_list |= PERFORM_TEST_3D;
+        else if (strcasecmp(argv[i], &quot;3e&quot;) == 0)
+            test_list |= PERFORM_TEST_3E;
</ins><span class="cx">         else if (strcasecmp(argv[i], &quot;4&quot;) == 0)
</span><span class="cx">             test_list |= PERFORM_TEST_4;
</span><span class="cx">         else if (strcasecmp(argv[i], &quot;5a&quot;) == 0)
</span><span class="cx">             test_list |= PERFORM_TEST_5A;
</span><span class="cx">         else if (strcasecmp(argv[i], &quot;5b&quot;) == 0)
</span><span class="cx">             test_list |= PERFORM_TEST_5B;
</span><del>-        else if (strcasecmp(argv[i], &quot;6&quot;) == 0)
-            test_list |= PERFORM_TEST_6;
</del><ins>+        else if (strcasecmp(argv[i], &quot;6a&quot;) == 0)
+            test_list |= PERFORM_TEST_6A;
+        else if (strcasecmp(argv[i], &quot;6b&quot;) == 0)
+            test_list |= PERFORM_TEST_6B;
+        else if (strcasecmp(argv[i], &quot;7a&quot;) == 0)
+            test_list |= PERFORM_TEST_7A;
+        else if (strcasecmp(argv[i], &quot;7b&quot;) == 0)
+            test_list |= PERFORM_TEST_7B;
+        else if (strcasecmp(argv[i], &quot;8&quot;) == 0)
+            test_list |= PERFORM_TEST_8;
</ins><span class="cx">         else
</span><span class="cx">         {
</span><span class="cx">             fprintf(stderr, &quot;Unknown test '%s' specified\n&quot;, argv[i]);
</span><span class="lines">@@ -310,7 +340,7 @@
</span><span class="cx"> 
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_1C))
</span><span class="cx">     {
</span><del>-        printf(&quot;Test 1c: ANSAM (Modulated ANS) generation to a file\n&quot;);
</del><ins>+        printf(&quot;Test 1c: ANSam (Modulated ANS) generation to a file\n&quot;);
</ins><span class="cx">         /* Some with modulation */
</span><span class="cx">         modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANSAM);
</span><span class="cx">         for (i = 0;  i &lt; 20*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="lines">@@ -330,8 +360,8 @@
</span><span class="cx"> 
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_1D))
</span><span class="cx">     {
</span><del>-        printf(&quot;Test 1d: ANS PR (EC-disable) generation to a file\n&quot;);
-        /* Some without modulation */
</del><ins>+        printf(&quot;Test 1d: ANS/ (EC-disable) generation to a file\n&quot;);
+        /* Some without modulation, but with phase reversals */
</ins><span class="cx">         modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANS_PR);
</span><span class="cx">         for (i = 0;  i &lt; 20*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">         {
</span><span class="lines">@@ -350,8 +380,8 @@
</span><span class="cx">     
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_1E))
</span><span class="cx">     {
</span><del>-        printf(&quot;Test 1e: ANSAM PR (Modulated EC-disable) generation to a file\n&quot;);
-        /* Some with modulation */
</del><ins>+        printf(&quot;Test 1e: ANSam/ (Modulated EC-disable) generation to a file\n&quot;);
+        /* Some with modulation and phase reversals */
</ins><span class="cx">         modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANSAM_PR);
</span><span class="cx">         for (i = 0;  i &lt; 20*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">         {
</span><span class="lines">@@ -378,24 +408,17 @@
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_2A))
</span><span class="cx">     {
</span><span class="cx">         printf(&quot;Test 2a: CNG detection with frequency\n&quot;);
</span><ins>+        tone_type = MODEM_CONNECT_TONES_FAX_CNG;
</ins><span class="cx">         awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
</span><span class="cx">         false_hit = FALSE;
</span><span class="cx">         false_miss = FALSE;
</span><del>-        for (pitch = 600;  pitch &lt; 1600;  pitch++)
</del><ins>+        for (pitch = 600;  pitch &lt;= 1600;  pitch++)
</ins><span class="cx">         {
</span><del>-            make_tone_gen_descriptor(&amp;tone_desc,
-                                     pitch,
-                                     -11,
-                                     0,
-                                     0,
-                                     425,
-                                     3000,
-                                     0,
-                                     0,
-                                     TRUE);
-            tone_gen_init(&amp;tone_tx, &amp;tone_desc);
-
-            modem_connect_tones_rx_init(&amp;cng_rx, MODEM_CONNECT_TONES_FAX_CNG, NULL, NULL);
</del><ins>+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            /* Fudge things for the test */
+            modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
+            modem_connect_tones_rx_init(&amp;cng_rx, tone_type, NULL, NULL);
</ins><span class="cx">             power_meter_init(&amp;power_state, 5);
</span><span class="cx">             power = 0;
</span><span class="cx">             max_power = 0;
</span><span class="lines">@@ -403,7 +426,7 @@
</span><span class="cx">             max_level2 = 0;
</span><span class="cx">             for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">             {
</span><del>-                samples = tone_gen(&amp;tone_tx, amp, SAMPLES_PER_CHUNK);
</del><ins>+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
</ins><span class="cx">                 for (j = 0;  j &lt; samples;  j++)
</span><span class="cx">                 {
</span><span class="cx">                     amp[j] += awgn(&amp;chan_noise_source);
</span><span class="lines">@@ -420,21 +443,21 @@
</span><span class="cx">             }
</span><span class="cx">             /*endfor*/
</span><span class="cx">             hit = modem_connect_tones_rx_get(&amp;cng_rx);
</span><del>-            if (pitch &lt; (1100 - 70)  ||  pitch &gt; (1100 + 70))
</del><ins>+            if (pitch &lt; (1100 - CED_FREQ_BLACKOUT)  ||  pitch &gt; (1100 + CED_FREQ_BLACKOUT))
</ins><span class="cx">             {
</span><del>-                if (hit == MODEM_CONNECT_TONES_FAX_CNG)
</del><ins>+                if (hit != MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">                     false_hit = TRUE;
</span><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><del>-            else if (pitch &gt; (1100 - 50)  &amp;&amp;  pitch &lt; (1100 + 50))
</del><ins>+            else if (pitch &gt; (1100 - CED_FREQ_TOLERANCE)  &amp;&amp;  pitch &lt; (1100 + CED_FREQ_TOLERANCE))
</ins><span class="cx">             {
</span><del>-                if (hit != MODEM_CONNECT_TONES_FAX_CNG)
</del><ins>+                if (hit != tone_type)
</ins><span class="cx">                     false_miss = TRUE;
</span><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             /*endif*/
</span><del>-            if (hit)
-                printf(&quot;Detected at %5dHz %12d %12d %d\n&quot;, pitch, cng_rx.channel_level, cng_rx.notch_level, hit);
</del><ins>+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, cng_rx.channel_level, cng_rx.notch_level, hit);
</ins><span class="cx">             /*endif*/
</span><span class="cx">         }
</span><span class="cx">         /*endfor*/
</span><span class="lines">@@ -447,7 +470,7 @@
</span><span class="cx">         printf(&quot;Test passed.\n&quot;);
</span><span class="cx">     }
</span><span class="cx">     /*endif*/
</span><del>-    
</del><ins>+
</ins><span class="cx">     if ((test_list &amp; PERFORM_TEST_2B))
</span><span class="cx">     {
</span><span class="cx">         printf(&quot;Test 2b: CED/ANS detection with frequency\n&quot;);
</span><span class="lines">@@ -456,22 +479,14 @@
</span><span class="cx">         false_miss = FALSE;
</span><span class="cx">         for (pitch = 1600;  pitch &lt; 2600;  pitch++)
</span><span class="cx">         {
</span><del>-            make_tone_gen_descriptor(&amp;tone_desc,
-                                     pitch,
-                                     -11,
-                                     0,
-                                     0,
-                                     2600,
-                                     0,
-                                     0,
-                                     0,
-                                     FALSE);
-            tone_gen_init(&amp;tone_tx, &amp;tone_desc);
-
</del><ins>+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANS);
+            /* Fudge things for the test */
+            modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
</ins><span class="cx">             modem_connect_tones_rx_init(&amp;ced_rx, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, NULL, NULL);
</span><span class="cx">             for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">             {
</span><del>-                samples = tone_gen(&amp;tone_tx, amp, SAMPLES_PER_CHUNK);
</del><ins>+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
</ins><span class="cx">                 for (j = 0;  j &lt; samples;  j++)
</span><span class="cx">                     amp[j] += awgn(&amp;chan_noise_source);
</span><span class="cx">                 /*endfor*/
</span><span class="lines">@@ -479,19 +494,21 @@
</span><span class="cx">             }
</span><span class="cx">             /*endfor*/
</span><span class="cx">             hit = modem_connect_tones_rx_get(&amp;ced_rx);
</span><del>-            if (pitch &lt; (2100 - 70)  ||  pitch &gt; (2100 + 70))
</del><ins>+            if (pitch &lt; (2100 - CNG_FREQ_BLACKOUT)  ||  pitch &gt; (2100 + CNG_FREQ_BLACKOUT))
</ins><span class="cx">             {
</span><del>-                if (hit == MODEM_CONNECT_TONES_FAX_CED)
</del><ins>+                if (hit != MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">                     false_hit = TRUE;
</span><ins>+                /*endif*/
</ins><span class="cx">             }
</span><del>-            else if (pitch &gt; (2100 - 50)  &amp;&amp;  pitch &lt; (2100 + 50))
</del><ins>+            else if (pitch &gt; (2100 - CNG_FREQ_TOLERANCE)  &amp;&amp;  pitch &lt; (2100 + CNG_FREQ_TOLERANCE))
</ins><span class="cx">             {
</span><span class="cx">                 if (hit != MODEM_CONNECT_TONES_FAX_CED)
</span><span class="cx">                     false_miss = TRUE;
</span><ins>+                /*endif*/
</ins><span class="cx">             }
</span><span class="cx">             /*endif*/
</span><del>-            if (hit)
-                printf(&quot;Detected at %5dHz %12d %12d %d\n&quot;, pitch, ced_rx.channel_level, ced_rx.notch_level, hit);
</del><ins>+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ced_rx.channel_level, ced_rx.notch_level, hit);
</ins><span class="cx">             /*endif*/
</span><span class="cx">         }
</span><span class="cx">         if (false_hit  ||  false_miss)
</span><span class="lines">@@ -506,18 +523,18 @@
</span><span class="cx"> 
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_2C))
</span><span class="cx">     {
</span><del>-        printf(&quot;Test 2c: EC disable detection with frequency\n&quot;);
</del><ins>+        printf(&quot;Test 2c: ANSam detection with frequency\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM;
</ins><span class="cx">         awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
</span><span class="cx">         false_hit = FALSE;
</span><span class="cx">         false_miss = FALSE;
</span><del>-        for (pitch = 2000;  pitch &lt; 2200;  pitch++)
</del><ins>+        for (pitch = 2000;  pitch &lt;= 2200;  pitch++)
</ins><span class="cx">         {
</span><span class="cx">             /* Use the transmitter to test the receiver */
</span><del>-            modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANS_PR);
</del><ins>+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
</ins><span class="cx">             /* Fudge things for the test */
</span><span class="cx">             modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
</span><del>-            modem_tone_tx.level = dds_scaling_dbm0(-25);
-            modem_connect_tones_rx_init(&amp;ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
</del><ins>+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
</ins><span class="cx">             for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">             {
</span><span class="cx">                 samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
</span><span class="lines">@@ -528,21 +545,21 @@
</span><span class="cx">             }
</span><span class="cx">             /*endfor*/
</span><span class="cx">             hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
</span><del>-            if (pitch &lt; (2100 - 70)  ||  pitch &gt; (2100 + 70))
</del><ins>+            if (pitch &lt; (2100 - CNG_FREQ_BLACKOUT)  ||  pitch &gt; (2100 + CNG_FREQ_BLACKOUT))
</ins><span class="cx">             {
</span><del>-                if (hit == MODEM_CONNECT_TONES_ANS_PR)
</del><ins>+                if (hit != MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">                     false_hit = TRUE;
</span><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><del>-            else if (pitch &gt; (2100 - 50)  &amp;&amp;  pitch &lt; (2100 + 50))
</del><ins>+            else if (pitch &gt; (2100 - CNG_FREQ_TOLERANCE)  &amp;&amp;  pitch &lt; (2100 + CNG_FREQ_TOLERANCE))
</ins><span class="cx">             {
</span><del>-                if (hit != MODEM_CONNECT_TONES_ANS_PR)
</del><ins>+                if (hit != tone_type)
</ins><span class="cx">                     false_miss = TRUE;
</span><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             /*endif*/
</span><del>-            if (hit)
-                printf(&quot;Detected at %5dHz %12d %12d %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
</del><ins>+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
</ins><span class="cx">             /*endif*/
</span><span class="cx">         }
</span><span class="cx">         /*endfor*/
</span><span class="lines">@@ -556,32 +573,130 @@
</span><span class="cx">     }
</span><span class="cx">     /*endif*/
</span><span class="cx"> 
</span><ins>+    if ((test_list &amp; PERFORM_TEST_2D))
+    {
+        printf(&quot;Test 2d: ANS/ (EC-disable) detection with frequency\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANS_PR;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (pitch = 2000;  pitch &lt;= 2200;  pitch++)
+        {
+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            /* Fudge things for the test */
+            modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+            for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+            {
+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                for (j = 0;  j &lt; samples;  j++)
+                    amp[j] += awgn(&amp;chan_noise_source);
+                /*endfor*/
+                modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+            }
+            /*endfor*/
+            hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+            if (pitch &lt; (2100 - CNG_FREQ_BLACKOUT)  ||  pitch &gt; (2100 + CNG_FREQ_BLACKOUT))
+            {
+                if (hit != MODEM_CONNECT_TONES_NONE)
+                    false_hit = TRUE;
+                /*endif*/
+            }
+            else if (pitch &gt; (2100 - CNG_FREQ_TOLERANCE)  &amp;&amp;  pitch &lt; (2100 + CNG_FREQ_TOLERANCE))
+            {
+                if (hit != tone_type)
+                    false_miss = TRUE;
+                /*endif*/
+            }
+            /*endif*/
+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+            /*endif*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
+    if ((test_list &amp; PERFORM_TEST_2E))
+    {
+        printf(&quot;Test 2e: ANSam/ (Modulated EC-disable) detection with frequency\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM_PR;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (pitch = 2000;  pitch &lt;= 2200;  pitch++)
+        {
+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            /* Fudge things for the test */
+            modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+            for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+            {
+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                for (j = 0;  j &lt; samples;  j++)
+                    amp[j] += awgn(&amp;chan_noise_source);
+                /*endfor*/
+                modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+            }
+            /*endfor*/
+            hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+            if (pitch &lt; (2100 - CNG_FREQ_BLACKOUT)  ||  pitch &gt; (2100 + CNG_FREQ_BLACKOUT))
+            {
+                if (hit != MODEM_CONNECT_TONES_NONE)
+                    false_hit = TRUE;
+                /*endif*/
+            }
+            else if (pitch &gt; (2100 - CNG_FREQ_TOLERANCE)  &amp;&amp;  pitch &lt; (2100 + CNG_FREQ_TOLERANCE))
+            {
+                if (hit != tone_type)
+                    false_miss = TRUE;
+                /*endif*/
+            }
+            /*endif*/
+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+            /*endif*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
</ins><span class="cx">     if ((test_list &amp; PERFORM_TEST_3A))
</span><span class="cx">     {
</span><span class="cx">         printf(&quot;Test 3a: CNG detection with level\n&quot;);
</span><ins>+        tone_type = MODEM_CONNECT_TONES_FAX_CNG;
</ins><span class="cx">         awgn_init_dbm0(&amp;chan_noise_source, 7162534, -60.0f);
</span><span class="cx">         false_hit = FALSE;
</span><span class="cx">         false_miss = FALSE;
</span><del>-        for (pitch = 1062;  pitch &lt;= 1138;  pitch += 2*38)
</del><ins>+        for (pitch = 1100 - CED_FREQ_TOLERANCE;  pitch &lt;= 1100 + CED_FREQ_TOLERANCE;  pitch += 2*CED_FREQ_TOLERANCE)
</ins><span class="cx">         {
</span><span class="cx">             for (level = LEVEL_MAX;  level &gt;= LEVEL_MIN;  level--)
</span><span class="cx">             {
</span><del>-                make_tone_gen_descriptor(&amp;tone_desc,
-                                         pitch,
-                                         level,
-                                         0,
-                                         0,
-                                         500,
-                                         3000,
-                                         0,
-                                         0,
-                                         TRUE);
-                tone_gen_init(&amp;tone_tx, &amp;tone_desc);
-
-                modem_connect_tones_rx_init(&amp;cng_rx, MODEM_CONNECT_TONES_FAX_CNG, NULL, NULL);
</del><ins>+                /* Use the transmitter to test the receiver */
+                modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+                /* Fudge things for the test */
+                modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
+                modem_tone_tx.level = dds_scaling_dbm0(level);
+                modem_connect_tones_rx_init(&amp;cng_rx, tone_type, NULL, NULL);
</ins><span class="cx">                 for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">                 {
</span><del>-                    samples = tone_gen(&amp;tone_tx, amp, SAMPLES_PER_CHUNK);
</del><ins>+                    samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
</ins><span class="cx">                     for (j = 0;  j &lt; samples;  j++)
</span><span class="cx">                         amp[j] += awgn(&amp;chan_noise_source);
</span><span class="cx">                     /*endfor*/
</span><span class="lines">@@ -591,25 +706,19 @@
</span><span class="cx">                 hit = modem_connect_tones_rx_get(&amp;cng_rx);
</span><span class="cx">                 if (level &lt; LEVEL_MIN_REJECT)
</span><span class="cx">                 {
</span><del>-                    if (hit == MODEM_CONNECT_TONES_FAX_CNG)
-                    {
-                        printf(&quot;False hit %d at %ddB\n&quot;, hit, level);
</del><ins>+                    if (hit != MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">                         false_hit = TRUE;
</span><del>-                    }
</del><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><span class="cx">                 else if (level &gt; LEVEL_MIN_ACCEPT)
</span><span class="cx">                 {
</span><del>-                    if (hit != MODEM_CONNECT_TONES_FAX_CNG)
-                    {
-                        printf(&quot;False miss %d at %ddB\n&quot;, hit, level);
</del><ins>+                    if (hit != tone_type)
</ins><span class="cx">                         false_miss = TRUE;
</span><del>-                    }
</del><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><span class="cx">                 /*endif*/
</span><del>-                if (hit)
-                    printf(&quot;Detected at %5dHz %4ddB %12d %12d %d\n&quot;, pitch, level, cng_rx.channel_level, cng_rx.notch_level, hit);
</del><ins>+                if (hit != MODEM_CONNECT_TONES_NONE)
+                    printf(&quot;Detected at %5dHz %4ddB %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, level, cng_rx.channel_level, cng_rx.notch_level, hit);
</ins><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             /*endfor*/
</span><span class="lines">@@ -628,28 +737,23 @@
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_3B))
</span><span class="cx">     {
</span><span class="cx">         printf(&quot;Test 3b: CED/ANS detection with level\n&quot;);
</span><ins>+        tone_type = MODEM_CONNECT_TONES_ANS;
</ins><span class="cx">         awgn_init_dbm0(&amp;chan_noise_source, 7162534, -60.0f);
</span><span class="cx">         false_hit = FALSE;
</span><span class="cx">         false_miss = FALSE;
</span><del>-        for (pitch = 2062;  pitch &lt;= 2138;  pitch += 2*38)
</del><ins>+        for (pitch = 2100 - CNG_FREQ_TOLERANCE;  pitch &lt;= 2100 + CNG_FREQ_TOLERANCE;  pitch += 2*CNG_FREQ_TOLERANCE)
</ins><span class="cx">         {
</span><span class="cx">             for (level = LEVEL_MAX;  level &gt;= LEVEL_MIN;  level--)
</span><span class="cx">             {
</span><del>-                make_tone_gen_descriptor(&amp;tone_desc,
-                                         pitch,
-                                         level,
-                                         0,
-                                         0,
-                                         2600,
-                                         0,
-                                         0,
-                                         0,
-                                         FALSE);
-                tone_gen_init(&amp;tone_tx, &amp;tone_desc);
</del><ins>+                /* Use the transmitter to test the receiver */
+                modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+                /* Fudge things for the test */
+                modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
+                modem_tone_tx.level = dds_scaling_dbm0(level);
</ins><span class="cx">                 modem_connect_tones_rx_init(&amp;ced_rx, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, NULL, NULL);
</span><span class="cx">                 for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">                 {
</span><del>-                    samples = tone_gen(&amp;tone_tx, amp, SAMPLES_PER_CHUNK);
</del><ins>+                    samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
</ins><span class="cx">                     for (j = 0;  j &lt; samples;  j++)
</span><span class="cx">                         amp[j] += awgn(&amp;chan_noise_source);
</span><span class="cx">                     /*endfor*/
</span><span class="lines">@@ -659,19 +763,19 @@
</span><span class="cx">                 hit = modem_connect_tones_rx_get(&amp;ced_rx);
</span><span class="cx">                 if (level &lt; LEVEL_MIN_REJECT)
</span><span class="cx">                 {
</span><del>-                    if (hit == MODEM_CONNECT_TONES_FAX_CED)
</del><ins>+                    if (hit != MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">                         false_hit = TRUE;
</span><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><span class="cx">                 else if (level &gt; LEVEL_MIN_ACCEPT)
</span><span class="cx">                 {
</span><del>-                    if (hit != MODEM_CONNECT_TONES_FAX_CED)
</del><ins>+                    if (hit != tone_type)
</ins><span class="cx">                         false_miss = TRUE;
</span><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><span class="cx">                 /*endif*/
</span><del>-                if (hit)
-                    printf(&quot;Detected at %5dHz %4ddB %12d %12d %d\n&quot;, pitch, level, ced_rx.channel_level, ced_rx.notch_level, hit);
</del><ins>+                if (hit != MODEM_CONNECT_TONES_NONE)
+                    printf(&quot;Detected at %5dHz %4ddB %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, level, ced_rx.channel_level, ced_rx.notch_level, hit);
</ins><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             /*endfor*/
</span><span class="lines">@@ -689,20 +793,80 @@
</span><span class="cx"> 
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_3C))
</span><span class="cx">     {
</span><del>-        printf(&quot;Test 3c: EC disable detection with level\n&quot;);
</del><ins>+        printf(&quot;Test 3c: ANSam detection with level\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM;
</ins><span class="cx">         awgn_init_dbm0(&amp;chan_noise_source, 7162534, -60.0f);
</span><span class="cx">         false_hit = FALSE;
</span><span class="cx">         false_miss = FALSE;
</span><del>-        for (pitch = 2062;  pitch &lt;= 2138;  pitch += 2*38)
</del><ins>+        for (pitch = 2100 - CNG_FREQ_TOLERANCE;  pitch &lt;= 2100 + CNG_FREQ_TOLERANCE;  pitch += 2*CNG_FREQ_TOLERANCE)
</ins><span class="cx">         {
</span><ins>+            //for (level = LEVEL_MAX;  level &gt;= LEVEL_MIN;  level--)
+            for (level = -26;  level &gt;= -26;  level--)
+            {
+                /* Use the transmitter to test the receiver */
+                modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+                /* Fudge things for the test */
+                modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
+                modem_tone_tx.level = dds_scaling_dbm0(level);
+                modem_tone_tx.mod_level = modem_tone_tx.level*20/100;
+                modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+                for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+                {
+                    samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                    for (j = 0;  j &lt; samples;  j++)
+                        amp[j] += awgn(&amp;chan_noise_source);
+                    /*endfor*/
+                    modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+                }
+                /*endfor*/
+                hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+                if (level &lt; LEVEL_MIN_REJECT)
+                {
+                    if (hit != MODEM_CONNECT_TONES_NONE)
+                        false_hit = TRUE;
+                    /*endif*/
+                }
+                else if (level &gt; LEVEL_MIN_ACCEPT)
+                {
+                    if (hit != tone_type)
+                        false_miss = TRUE;
+                    /*endif*/
+                }
+                /*endif*/
+                //if (hit != MODEM_CONNECT_TONES_NONE)
+                    printf(&quot;Detected at %5dHz %4ddB %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+                /*endif*/
+            }
+            /*endfor*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
+    if ((test_list &amp; PERFORM_TEST_3D))
+    {
+        printf(&quot;Test 3d: ANS/ (EC-disable) detection with level\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANS_PR;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -60.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (pitch = 2100 - CNG_FREQ_TOLERANCE;  pitch &lt;= 2100 + CNG_FREQ_TOLERANCE;  pitch += 2*CNG_FREQ_TOLERANCE)
+        {
</ins><span class="cx">             for (level = LEVEL_MAX;  level &gt;= LEVEL_MIN;  level--)
</span><span class="cx">             {
</span><span class="cx">                 /* Use the transmitter to test the receiver */
</span><del>-                modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANS_PR);
</del><ins>+                modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
</ins><span class="cx">                 /* Fudge things for the test */
</span><span class="cx">                 modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
</span><span class="cx">                 modem_tone_tx.level = dds_scaling_dbm0(level);
</span><del>-                modem_connect_tones_rx_init(&amp;ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
</del><ins>+                modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
</ins><span class="cx">                 for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">                 {
</span><span class="cx">                     samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
</span><span class="lines">@@ -715,19 +879,19 @@
</span><span class="cx">                 hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
</span><span class="cx">                 if (level &lt; LEVEL_MIN_REJECT)
</span><span class="cx">                 {
</span><del>-                    if (hit == MODEM_CONNECT_TONES_ANS_PR)
</del><ins>+                    if (hit != MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">                         false_hit = TRUE;
</span><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><span class="cx">                 else if (level &gt; LEVEL_MIN_ACCEPT)
</span><span class="cx">                 {
</span><del>-                    if (hit != MODEM_CONNECT_TONES_ANS_PR)
</del><ins>+                    if (hit != tone_type)
</ins><span class="cx">                         false_miss = TRUE;
</span><span class="cx">                     /*endif*/
</span><span class="cx">                 }
</span><span class="cx">                 /*endif*/
</span><del>-                if (hit)
-                    printf(&quot;Detected at %5dHz %4ddB %12d %12d %d\n&quot;, pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
</del><ins>+                if (hit != MODEM_CONNECT_TONES_NONE)
+                    printf(&quot;Detected at %5dHz %4ddB %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
</ins><span class="cx">                 /*endif*/
</span><span class="cx">             }
</span><span class="cx">             /*endfor*/
</span><span class="lines">@@ -743,6 +907,64 @@
</span><span class="cx">     }
</span><span class="cx">     /*endif*/
</span><span class="cx"> 
</span><ins>+    if ((test_list &amp; PERFORM_TEST_3E))
+    {
+        printf(&quot;Test 3e: ANSam/ (Modulated EC-disable) detection with level\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM_PR;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -60.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (pitch = 2100 - CNG_FREQ_TOLERANCE;  pitch &lt;= 2100 + CNG_FREQ_TOLERANCE;  pitch += 2*CNG_FREQ_TOLERANCE)
+        {
+            for (level = LEVEL_MAX;  level &gt;= LEVEL_MIN;  level--)
+            {
+                /* Use the transmitter to test the receiver */
+                modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+                /* Fudge things for the test */
+                modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
+                modem_tone_tx.level = dds_scaling_dbm0(level);
+                modem_tone_tx.mod_level = modem_tone_tx.level*20/100;
+                modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+                for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+                {
+                    samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                    for (j = 0;  j &lt; samples;  j++)
+                        amp[j] += awgn(&amp;chan_noise_source);
+                    /*endfor*/
+                    modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+                }
+                /*endfor*/
+                hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+                if (level &lt; LEVEL_MIN_REJECT)
+                {
+                    if (hit != MODEM_CONNECT_TONES_NONE)
+                        false_hit = TRUE;
+                    /*endif*/
+                }
+                else if (level &gt; LEVEL_MIN_ACCEPT)
+                {
+                    if (hit != tone_type)
+                        false_miss = TRUE;
+                    /*endif*/
+                }
+                /*endif*/
+                if (hit != MODEM_CONNECT_TONES_NONE)
+                    printf(&quot;Detected at %5dHz %4ddB %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, level, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+                /*endif*/
+            }
+            /*endfor*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
</ins><span class="cx">     if ((test_list &amp; PERFORM_TEST_4))
</span><span class="cx">     {
</span><span class="cx">         printf(&quot;Test 4: CED detection, when stimulated with V.21 preamble\n&quot;);
</span><span class="lines">@@ -779,21 +1001,17 @@
</span><span class="cx"> 
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_5A))
</span><span class="cx">     {
</span><del>-        printf(&quot;Test 5A: ANS/ANS PR detection with reversal interval\n&quot;);
</del><ins>+        printf(&quot;Test 5A: ANS and ANS/ detection with reversal interval\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANS_PR;
</ins><span class="cx">         awgn_init_dbm0(&amp;chan_noise_source, 7162534, -60.0f);
</span><span class="cx">         false_hit = FALSE;
</span><span class="cx">         false_miss = FALSE;
</span><del>-        pitch = 2100;
-        level = -15;
</del><span class="cx">         for (interval = 400;  interval &lt; 800;  interval++)
</span><span class="cx">         {
</span><span class="cx">             printf(&quot;Reversal interval = %d\n&quot;, interval);
</span><span class="cx">             /* Use the transmitter to test the receiver */
</span><del>-            modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANS_PR);
-            /* Fudge things for the test */
-            modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
-            modem_tone_tx.level = dds_scaling_dbm0(level);
-            modem_connect_tones_rx_init(&amp;ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, ans_pr_detected, NULL);
</del><ins>+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, ans_pr_detected, NULL);
</ins><span class="cx">             hits = 0;
</span><span class="cx">             for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">             {
</span><span class="lines">@@ -829,7 +1047,7 @@
</span><span class="cx">             }
</span><span class="cx">             /*endif*/
</span><span class="cx">             if (hits)
</span><del>-                printf(&quot;Detected at %5dHz %4ddB %dms %12d %12d %d\n&quot;, pitch, level, interval, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hits);
</del><ins>+                printf(&quot;Detected at %5dHz %4ddB %dms %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, 2100, -11, interval, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hits);
</ins><span class="cx">             /*endif*/
</span><span class="cx">         }
</span><span class="cx">         /*endfor*/
</span><span class="lines">@@ -845,22 +1063,18 @@
</span><span class="cx"> 
</span><span class="cx">     if ((test_list &amp; PERFORM_TEST_5B))
</span><span class="cx">     {
</span><del>-        printf(&quot;Test 5B: ANS/ANS PR detection with mixed reversal intervals\n&quot;);
</del><ins>+        printf(&quot;Test 5B: ANS and ANS/ detection with mixed reversal intervals\n&quot;);
</ins><span class="cx">         awgn_init_dbm0(&amp;chan_noise_source, 7162534, -60.0f);
</span><ins>+        tone_type = MODEM_CONNECT_TONES_ANS_PR;
</ins><span class="cx">         false_hit = FALSE;
</span><span class="cx">         false_miss = FALSE;
</span><del>-        pitch = 2100;
-        level = -15;
</del><span class="cx">         interval = 450;
</span><span class="cx">         printf(&quot;Reversal interval = %d\n&quot;, interval);
</span><span class="cx">         /* Use the transmitter to test the receiver */
</span><del>-        modem_connect_tones_tx_init(&amp;modem_tone_tx, MODEM_CONNECT_TONES_ANS_PR);
-        /* Fudge things for the test */
-        modem_tone_tx.tone_phase_rate = dds_phase_rate(pitch);
-        modem_tone_tx.level = dds_scaling_dbm0(level);
-        modem_connect_tones_rx_init(&amp;ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, ans_pr_detected, NULL);
</del><ins>+        modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+        modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, ans_pr_detected, NULL);
+        cycle = 0;
</ins><span class="cx">         hits = 0;
</span><del>-        cycle = 0;
</del><span class="cx">         for (i = 0;  i &lt; 60*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
</span><span class="cx">         {
</span><span class="cx">             when = i;
</span><span class="lines">@@ -883,6 +1097,7 @@
</span><span class="cx">                 amp[j] += awgn(&amp;chan_noise_source);
</span><span class="cx">             /*endfor*/
</span><span class="cx">             modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
</span><ins>+            /* TODO: Add test result detection logic. */
</ins><span class="cx">         }
</span><span class="cx">         /*endfor*/
</span><span class="cx">         if (false_hit  ||  false_miss)
</span><span class="lines">@@ -895,8 +1110,218 @@
</span><span class="cx">     }
</span><span class="cx">     /*endif*/
</span><span class="cx"> 
</span><del>-    if ((test_list &amp; PERFORM_TEST_6))
</del><ins>+    if ((test_list &amp; PERFORM_TEST_6A))
</ins><span class="cx">     {
</span><ins>+        printf(&quot;Test 6a: ANSam detection with AM pitch\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (pitch = 5;  pitch &lt; 25;  pitch++)
+        {
+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            /* Fudge things for the test */
+            modem_tone_tx.mod_phase_rate = dds_phase_rate(pitch);
+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+            for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+            {
+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                for (j = 0;  j &lt; samples;  j++)
+                    amp[j] += awgn(&amp;chan_noise_source);
+                /*endfor*/
+                modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+            }
+            /*endfor*/
+            hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+            if (pitch &lt; (15 - 10)  ||  pitch &gt; (15 + 10))
+            {
+                if (hit == tone_type)
+                    false_hit = TRUE;
+                /*endif*/
+            }
+            else if (pitch &gt; (15 - AM_FREQ_TOLERANCE)  &amp;&amp;  pitch &lt; (15 + AM_FREQ_TOLERANCE))
+            {
+                if (hit != tone_type)
+                    false_miss = TRUE;
+                /*endif*/
+            }
+            /*endif*/
+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+            /*endif*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
+    if ((test_list &amp; PERFORM_TEST_6B))
+    {
+        printf(&quot;Test 6b: ANSam/ (Modulated EC-disable) detection with AM pitch\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM_PR;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (pitch = 5;  pitch &lt; 25;  pitch++)
+        {
+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            /* Fudge things for the test */
+            modem_tone_tx.mod_phase_rate = dds_phase_rate(pitch);
+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+            for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+            {
+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                for (j = 0;  j &lt; samples;  j++)
+                    amp[j] += awgn(&amp;chan_noise_source);
+                /*endfor*/
+                modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+            }
+            /*endfor*/
+            hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+            if (pitch &lt; (15 - 10)  ||  pitch &gt; (15 + 10))
+            {
+                if (hit == tone_type)
+                    false_hit = TRUE;
+                /*endif*/
+            }
+            else if (pitch &gt; (15 - AM_FREQ_TOLERANCE)  &amp;&amp;  pitch &lt; (15 + AM_FREQ_TOLERANCE))
+            {
+                if (hit != tone_type)
+                    false_miss = TRUE;
+                /*endif*/
+            }
+            /*endif*/
+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+            /*endif*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
+    if ((test_list &amp; PERFORM_TEST_7A))
+    {
+        printf(&quot;Test 7a: ANSam detection with AM depth\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM;
+        pitch = 2100;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (depth = 0;  depth &lt; 40;  depth++)
+        {
+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            /* Fudge things for the test */
+            modem_tone_tx.mod_level = modem_tone_tx.level*depth/100;
+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+            for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+            {
+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                for (j = 0;  j &lt; samples;  j++)
+                    amp[j] += awgn(&amp;chan_noise_source);
+                /*endfor*/
+                modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+            }
+            /*endfor*/
+            hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+            if (depth &lt; 10)
+            {
+                if (hit == tone_type)
+                    false_hit = TRUE;
+                /*endif*/
+            }
+            else if (depth &gt; 15)
+            {
+                if (hit != tone_type)
+                    false_miss = TRUE;
+                /*endif*/
+            }
+            /*endif*/
+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+            /*endif*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
+    if ((test_list &amp; PERFORM_TEST_7B))
+    {
+        printf(&quot;Test 7b: ANSam/ (Modulated EC-disable) detection with AM depth\n&quot;);
+        tone_type = MODEM_CONNECT_TONES_ANSAM_PR;
+        pitch = 2100;
+        awgn_init_dbm0(&amp;chan_noise_source, 7162534, -50.0f);
+        false_hit = FALSE;
+        false_miss = FALSE;
+        for (depth = 0;  depth &lt; 40;  depth++)
+        {
+            /* Use the transmitter to test the receiver */
+            modem_connect_tones_tx_init(&amp;modem_tone_tx, tone_type);
+            /* Fudge things for the test */
+            modem_tone_tx.mod_level = modem_tone_tx.level*depth/100;
+            modem_connect_tones_rx_init(&amp;ans_pr_rx, tone_type, NULL, NULL);
+            for (i = 0;  i &lt; 10*SAMPLE_RATE;  i += SAMPLES_PER_CHUNK)
+            {
+                samples = modem_connect_tones_tx(&amp;modem_tone_tx, amp, SAMPLES_PER_CHUNK);
+                for (j = 0;  j &lt; samples;  j++)
+                    amp[j] += awgn(&amp;chan_noise_source);
+                /*endfor*/
+                modem_connect_tones_rx(&amp;ans_pr_rx, amp, samples);
+            }
+            /*endfor*/
+            hit = modem_connect_tones_rx_get(&amp;ans_pr_rx);
+            if (depth &lt; 10)
+            {
+                if (hit == tone_type)
+                    false_hit = TRUE;
+                /*endif*/
+            }
+            else if (depth &gt; 15)
+            {
+                if (hit != tone_type)
+                    false_miss = TRUE;
+                /*endif*/
+            }
+            /*endif*/
+            if (hit != MODEM_CONNECT_TONES_NONE)
+                printf(&quot;Detected at %5dHz %12&quot; PRId32 &quot; %12&quot; PRId32 &quot; %d\n&quot;, pitch, ans_pr_rx.channel_level, ans_pr_rx.notch_level, hit);
+            /*endif*/
+        }
+        /*endfor*/
+        if (false_hit  ||  false_miss)
+        {
+            printf(&quot;Test failed.\n&quot;);
+            exit(2);
+        }
+        /*endif*/
+        printf(&quot;Test passed.\n&quot;);
+    }
+    /*endif*/
+
+    if ((test_list &amp; PERFORM_TEST_8))
+    {
</ins><span class="cx">         /* Talk-off test */
</span><span class="cx">         /* Here we use the BellCore and Mitel talk off test tapes, intended for DTMF
</span><span class="cx">            detector testing. Presumably they should also have value here, but I am not
</span><span class="lines">@@ -904,11 +1329,10 @@
</span><span class="cx">            might go easy on detectors looking for different pitches. However, the
</span><span class="cx">            Mitel DTMF test tape is known (the hard way) to exercise 2280Hz tone
</span><span class="cx">            detectors quite well. */
</span><del>-        printf(&quot;Test 6: Talk-off test\n&quot;);
</del><ins>+        printf(&quot;Test 8: Talk-off test\n&quot;);
</ins><span class="cx">         modem_connect_tones_rx_init(&amp;cng_rx, MODEM_CONNECT_TONES_FAX_CNG, NULL, NULL);
</span><span class="cx">         modem_connect_tones_rx_init(&amp;ced_rx, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, NULL, NULL);
</span><span class="cx">         modem_connect_tones_rx_init(&amp;ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
</span><del>-        hits = 0;
</del><span class="cx">         for (j = 0;  bellcore_files[j][0];  j++)
</span><span class="cx">         {
</span><span class="cx">             if ((inhandle = sf_open_telephony_read(bellcore_files[j], 1)) == NULL)
</span><span class="lines">@@ -976,7 +1400,7 @@
</span><span class="cx">         printf(&quot;Decode file '%s'\n&quot;, decode_test_file);
</span><span class="cx">         modem_connect_tones_rx_init(&amp;cng_rx, MODEM_CONNECT_TONES_FAX_CNG, cng_detected, NULL);
</span><span class="cx">         modem_connect_tones_rx_init(&amp;ced_rx, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, ced_detected, NULL);
</span><del>-        modem_connect_tones_rx_init(&amp;ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, ec_dis_detected, NULL);
</del><ins>+        modem_connect_tones_rx_init(&amp;ans_pr_rx, MODEM_CONNECT_TONES_ANS_PR, ans_pr_detected, NULL);
</ins><span class="cx">         hits = 0;
</span><span class="cx">         if ((inhandle = sf_open_telephony_read(decode_test_file, 1)) == NULL)
</span><span class="cx">         {
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestst38_gateway_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/t38_gateway_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/t38_gateway_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/t38_gateway_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_gateway_tests.c,v 1.82 2009/05/30 15:23:14 steveu Exp $
</del><ins>+ * $Id: t38_gateway_tests.c,v 1.82.4.1 2009/12/19 09:47:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -99,7 +99,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase B:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase B&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase B handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_rx_parameters(s, tag);
</span><span class="cx">     return T30_ERR_OK;
</span><span class="lines">@@ -112,7 +112,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase D:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase D&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase D handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span><span class="lines">@@ -128,7 +128,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx">     
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase E:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase E&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase E handler on channel %c - (%d) %s\n&quot;, i, i, result, t30_completion_code_to_str(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestst38_gateway_to_terminal_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/t38_gateway_to_terminal_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/t38_gateway_to_terminal_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/t38_gateway_to_terminal_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_gateway_to_terminal_tests.c,v 1.66 2009/05/30 15:23:14 steveu Exp $
</del><ins>+ * $Id: t38_gateway_to_terminal_tests.c,v 1.66.4.1 2009/12/19 09:47:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase B:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase B&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase B handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_rx_parameters(s, tag);
</span><span class="cx">     return T30_ERR_OK;
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase D:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase D&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase D handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx">     
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase E:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase E&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase E handler on channel %c - (%d) %s\n&quot;, i, i, result, t30_completion_code_to_str(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestst38_non_ecm_buffer_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/t38_non_ecm_buffer_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/t38_non_ecm_buffer_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/t38_non_ecm_buffer_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_non_ecm_buffer_tests.c,v 1.5 2009/04/25 14:17:47 steveu Exp $
</del><ins>+ * $Id: t38_non_ecm_buffer_tests.c,v 1.5.4.1 2009/12/19 06:43:28 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -50,6 +50,88 @@
</span><span class="cx"> 
</span><span class="cx"> #include &quot;spandsp.h&quot;
</span><span class="cx"> 
</span><ins>+/* A pattern of widening gaps between ones, until at 11 apart an
+   EOL should be registered */
+static const uint8_t spreader[] =
+{
+    0x55,
+    0x55,
+    0x55,
+    0x55,
+    0x55,
+    0x55,
+    0x55,
+    0x55,       /* 1 apart */
+    0x22,       /* 2 and 3 apart */
+    0x10,       /* 4 apart */
+    0x40,       /* 5 apart */
+    0x80,       /* 6 apart */
+    0x80,       /* 7 apart */
+    0x40,       /* 8 apart */
+    0x10,       /* 9 apart */
+    0x02,       /* 10 apart */
+    0x00,
+    0x25        /* 11 apart */
+};
+
+static int bit_no;
+
+static int xxx(t38_non_ecm_buffer_state_t *s, logging_state_t *l, int log_bits, int n, int expected)
+{
+    int i;
+    int j;
+    int bit;
+
+    t38_non_ecm_buffer_inject(s, &amp;spreader[n], 1);
+    if (expected &gt;= 0)
+    {
+        for (i = 0;  i &lt; 128;  i++)
+        {
+            bit = t38_non_ecm_buffer_get_bit((void *) s);
+            if (log_bits)
+                printf(&quot;Rx bit %d - %d\n&quot;, bit_no, bit);
+            if (bit != expected)
+            {
+                printf(&quot;Tests failed - %d %d %d\n&quot;, bit_no, bit, expected);
+                exit(2);
+            }
+            bit_no++;
+        }
+    }
+    else
+    {
+        j = -1;
+        for (i = 0;  i &lt; 256;  i++)
+        {
+            bit = t38_non_ecm_buffer_get_bit((void *) s);
+            if (log_bits)
+                printf(&quot;Rx bit %d - %d\n&quot;, bit_no, bit);
+            if (j &lt; 0)
+            {
+                if (bit == 1)
+                    j = 18*8 - 5;
+            }
+            else
+            {
+                expected = (spreader[j &gt;&gt; 3] &gt;&gt; (7 - (j &amp; 7))) &amp; 1;
+                if (bit != expected)
+                {
+                    printf(&quot;Tests failed - %d %d %d\n&quot;, bit_no, bit, expected);
+                    exit(2);
+                }
+                j++;
+                if (j &gt;= 18*8)
+                    j = 0;
+            }
+            bit_no++;
+            if (j == 17*8)
+                return 0;
+        }
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
</ins><span class="cx"> int main(int argc, char *argv[])
</span><span class="cx"> {
</span><span class="cx">     t38_non_ecm_buffer_state_t buffer;
</span><span class="lines">@@ -60,65 +142,170 @@
</span><span class="cx">     int log_bits;
</span><span class="cx">     int i;
</span><span class="cx"> 
</span><del>-    log_bits = FALSE;
</del><ins>+    log_bits = (argc &gt; 1);
+    printf(&quot;T.38 non-ECM rate adapting buffer tests.\n&quot;);
</ins><span class="cx">     span_log_init(&amp;logging, SPAN_LOG_FLOW, NULL);
</span><span class="cx">     span_log_set_protocol(&amp;logging, &quot;Buffer&quot;);
</span><span class="cx"> 
</span><ins>+    printf(&quot;1 - Impose no minimum for the bits per row\n&quot;);
</ins><span class="cx">     t38_non_ecm_buffer_init(&amp;buffer, TRUE, 0);
</span><del>-    memset(buf, 0, sizeof(buf));
-    memset(buf + 10, 0x55, 10);
-    buf[25] = 0x80;
-    memset(buf + 30, 0x55, 10);
-    t38_non_ecm_buffer_inject(&amp;buffer, buf, 50);
-    t38_non_ecm_buffer_push(&amp;buffer);
</del><span class="cx">     n = 0;
</span><del>-    do
-    {
-        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
-        if (log_bits)
-            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
-    }
-    while (bit &gt;= 0);
</del><ins>+    bit_no = 0;
+    /* We should get ones until the buffers recognises an EOL */
+    printf(&quot;    We should get ones here\n&quot;);
+    for (i = 0;  i &lt; 17;  i++)
+        xxx(&amp;buffer, &amp;logging, log_bits, i, 1);
+    printf(&quot;    We should change to zeros here\n&quot;);
+    xxx(&amp;buffer, &amp;logging, log_bits, i, 0);
+    for (i = 0;  i &lt; 17;  i++)
+        xxx(&amp;buffer, &amp;logging, log_bits, i, 0);
+    printf(&quot;    We should get the first row here\n&quot;);
+    xxx(&amp;buffer, &amp;logging, log_bits, i, -1);
+    for (i = 0;  i &lt; 17;  i++)
+        xxx(&amp;buffer, &amp;logging, log_bits, i, 0);
+    printf(&quot;    We should get the second row here\n&quot;);
+    xxx(&amp;buffer, &amp;logging, log_bits, i, -1);
+    for (i = 0;  i &lt; 17;  i++)
+        xxx(&amp;buffer, &amp;logging, log_bits, i, 0);
+    printf(&quot;    We should get the third row here\n&quot;);
+    xxx(&amp;buffer, &amp;logging, log_bits, i, -1);
+    printf(&quot;    Done\n&quot;);
</ins><span class="cx">     t38_non_ecm_buffer_report_input_status(&amp;buffer, &amp;logging);
</span><span class="cx">     t38_non_ecm_buffer_report_output_status(&amp;buffer, &amp;logging);
</span><span class="cx"> 
</span><ins>+    printf(&quot;2 - Impose no minimum for the bits per row, different alignment\n&quot;);
</ins><span class="cx">     t38_non_ecm_buffer_init(&amp;buffer, TRUE, 0);
</span><ins>+    n = 0;
</ins><span class="cx">     memset(buf, 0, sizeof(buf));
</span><ins>+    /* The first one in this should be seen as the first EOL */
</ins><span class="cx">     memset(buf + 10, 0x55, 10);
</span><del>-    buf[25] = 0x40;
</del><ins>+    /* EOL 2 */
+    buf[25] = 0x20;
+    /* EOL 3 */
</ins><span class="cx">     memset(buf + 30, 0x55, 10);
</span><ins>+    /* EOL 4 */
+    buf[45] = 0x10;
</ins><span class="cx">     t38_non_ecm_buffer_inject(&amp;buffer, buf, 50);
</span><span class="cx">     t38_non_ecm_buffer_push(&amp;buffer);
</span><del>-    n = 0;
-    do
</del><ins>+    for (;;)
</ins><span class="cx">     {
</span><span class="cx">         bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
</span><span class="cx">         if (log_bits)
</span><del>-            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
</del><ins>+            printf(&quot;Rx bit %d - %d\n&quot;, n, bit);
+        n++;
+        if (bit == SIG_STATUS_END_OF_DATA)
+        {
+            if (n != 337)
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+            break;
+        }
+        if (n &gt;= 18  &amp;&amp;  n &lt;= 96)
+        {
+            if (bit == (n &amp; 1))
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
+        else if (n &gt;= 178  &amp;&amp;  n &lt;= 256)
+        {
+            if (bit == (n &amp; 1))
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
+        else if (n == 139  ||  n == 300)
+        {
+            if (bit != 1)
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
+        else
+        {
+            if (bit != 0)
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
</ins><span class="cx">     }
</span><del>-    while (bit &gt;= 0);
</del><span class="cx">     t38_non_ecm_buffer_report_input_status(&amp;buffer, &amp;logging);
</span><span class="cx">     t38_non_ecm_buffer_report_output_status(&amp;buffer, &amp;logging);
</span><span class="cx"> 
</span><ins>+    printf(&quot;3 - Demand a fairly high minimum for the bits per row\n&quot;);
</ins><span class="cx">     t38_non_ecm_buffer_init(&amp;buffer, TRUE, 400);
</span><ins>+    n = 0;
</ins><span class="cx">     memset(buf, 0, sizeof(buf));
</span><ins>+    /* The first one in this should be seen as the first EOL */
</ins><span class="cx">     memset(buf + 10, 0x55, 10);
</span><del>-    buf[25] = 0x01;
</del><ins>+    /* EOL 2 */
+    buf[25] = 0x08;
+    /* EOL 3 */
</ins><span class="cx">     memset(buf + 30, 0x55, 10);
</span><ins>+    /* EOL 4 */
+    buf[45] = 0x04;
</ins><span class="cx">     t38_non_ecm_buffer_inject(&amp;buffer, buf, 50);
</span><span class="cx">     t38_non_ecm_buffer_push(&amp;buffer);
</span><del>-    n = 0;
-    do
</del><ins>+    for (;;)
</ins><span class="cx">     {
</span><span class="cx">         bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
</span><span class="cx">         if (log_bits)
</span><del>-            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
</del><ins>+            printf(&quot;Rx bit %d - %d\n&quot;, n, bit);
+        n++;
+        if (bit == SIG_STATUS_END_OF_DATA)
+        {
+            if (n != 1273)
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+            break;
+        }
+        if (n &gt;= 18  &amp;&amp;  n &lt;= 96)
+        {
+            if (bit == (n &amp; 1))
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
+        else if (n &gt;= 834  &amp;&amp;  n &lt;= 912)
+        {
+            if (bit == (n &amp; 1))
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
+        else if (n == 429  ||  n == 1238)
+        {
+            if (bit != 1)
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
+        else
+        {
+            if (bit != 0)
+            {
+                printf(&quot;Tests failed\n&quot;);
+                exit(2);
+            }
+        }
</ins><span class="cx">     }
</span><del>-    while (bit &gt;= 0);
</del><span class="cx">     t38_non_ecm_buffer_report_input_status(&amp;buffer, &amp;logging);
</span><span class="cx">     t38_non_ecm_buffer_report_output_status(&amp;buffer, &amp;logging);
</span><span class="cx"> 
</span><ins>+    printf(&quot;4 - Take some time to get to the first row of the image, output ahead\n&quot;);
</ins><span class="cx">     t38_non_ecm_buffer_init(&amp;buffer, TRUE, 400);
</span><ins>+    n = 0;
</ins><span class="cx">     /* Get some initial bits from an empty buffer. These should be ones */
</span><span class="cx">     for (i = 0;  i &lt; 1000;  i++)
</span><span class="cx">     {
</span><span class="lines">@@ -131,6 +318,7 @@
</span><span class="cx">             exit(2);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    printf(&quot;    Initial ones OK\n&quot;);
</ins><span class="cx">     /* Now put some zeros into the buffer, but no EOL. We should continue
</span><span class="cx">        getting ones out. */
</span><span class="cx">     memset(buf, 0, sizeof(buf));
</span><span class="lines">@@ -146,6 +334,7 @@
</span><span class="cx">             exit(2);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    printf(&quot;    Continuing initial ones OK\n&quot;);
</ins><span class="cx">     /* Now add a one, to make an EOL. We should see the zeros come out. */
</span><span class="cx">     buf[0] = 0x01;
</span><span class="cx">     t38_non_ecm_buffer_inject(&amp;buffer, buf, 1);
</span><span class="lines">@@ -160,8 +349,9 @@
</span><span class="cx">             exit(2);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    printf(&quot;    First EOL caused zeros to output OK\n&quot;);
</ins><span class="cx">     /* Now add another line. We should see the first line come out. This means just the
</span><del>-       eighth bit from now will be a one. */
</del><ins>+       23rd bit from now will be a one. */
</ins><span class="cx">     buf[0] = 0x00;
</span><span class="cx">     buf[4] = 0x01;
</span><span class="cx">     t38_non_ecm_buffer_inject(&amp;buffer, buf, 5);
</span><span class="lines">@@ -170,15 +360,346 @@
</span><span class="cx">         bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
</span><span class="cx">         if (log_bits)
</span><span class="cx">             printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
</span><del>-        if (i != 7  &amp;&amp;  bit != 0)
</del><ins>+        if ((i == 23  &amp;&amp;  bit == 0)  ||  (i != 23  &amp;&amp;  bit != 0))
</ins><span class="cx">         {
</span><span class="cx">             printf(&quot;Tests failed (%d)\n&quot;, i);
</span><span class="cx">             exit(2);
</span><span class="cx">         }
</span><span class="cx">     }
</span><ins>+    printf(&quot;    Second EOL caused the first row to output OK\n&quot;);
+    /* Now inject an RTC - 6 EOLs */
+    memset(buf, 0, sizeof(buf));
+    /* T.4 1D style */
+    for (i = 10;  i &lt; 19;  i += 3)
+    {
+        buf[i] = 0x00;
+        buf[i + 1] = 0x10;
+        buf[i + 2] = 0x01;
+    }
+    /* T.4 2D style */
+    buf[25 + 0] = 0x00;
+    buf[25 + 1] = 0x18;
+    buf[25 + 2] = 0x00;
+    buf[25 + 3] = 0xC0;
+    buf[25 + 4] = 0x06;
+    buf[25 + 5] = 0x00;
+    buf[25 + 6] = 0x30;
+    buf[25 + 7] = 0x01;
+    buf[25 + 8] = 0x80;
+    buf[25 + 9] = 0x0C;
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 50);
+    t38_non_ecm_buffer_push(&amp;buffer);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (i == 7
+            ||
+            i == 400 + 11 + 0*12
+            ||
+            i == 400 + 11 + 1*12
+            ||
+            i == 400 + 11 + 2*12
+            ||
+            i == 400 + 11 + 3*12
+            ||
+            i == 400 + 11 + 4*12
+            ||
+            i == 400 + 11 + 5*12
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 0*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 0*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 1*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 1*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 2*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 2*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 3*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 3*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 4*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 4*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 5*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 5*13 + 1)
+        {
+            if (bit == 0)
+            {
+                printf(&quot;Tests failed (%d)\n&quot;, i);
+                exit(2);
+            }
+        }
+        else
+        {
+            if (bit == 1)
+            {
+                printf(&quot;Tests failed (%d)\n&quot;, i);
+                exit(2);
+            }
+        }
+    }
+    printf(&quot;    RTC output OK\n&quot;);
</ins><span class="cx">     t38_non_ecm_buffer_report_input_status(&amp;buffer, &amp;logging);
</span><span class="cx">     t38_non_ecm_buffer_report_output_status(&amp;buffer, &amp;logging);
</span><span class="cx"> 
</span><ins>+    printf(&quot;5 - Take some time to get to the first row of the image, output behind\n&quot;);
+    t38_non_ecm_buffer_init(&amp;buffer, TRUE, 400);
+    n = 0;
+    /* Inject some ones. */
+    memset(buf, 0xFF, 100);
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 100);
+    /* Inject some zeros */
+    memset(buf, 0, sizeof(buf));
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 100);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (bit != 1)
+        {
+            printf(&quot;Tests failed\n&quot;);
+            exit(2);
+        }
+    }
+    printf(&quot;    Initial ones OK\n&quot;);
+    /* Now add a one, to make an EOL. We should see the zeros come out. */
+    buf[0] = 0x01;
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 1);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (bit != 0)
+        {
+            printf(&quot;Tests failed\n&quot;);
+            exit(2);
+        }
+    }
+    printf(&quot;    First EOL caused zeros to output OK\n&quot;);
+    /* Now add another line. We should see the first line come out. This means just the
+       23rd bit from now will be a one. */
+    buf[0] = 0x00;
+    buf[4] = 0x01;
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 5);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if ((i == 23  &amp;&amp;  bit == 0)  ||  (i != 23  &amp;&amp;  bit != 0))
+        {
+            printf(&quot;Tests failed (%d)\n&quot;, i);
+            exit(2);
+        }
+    }
+    printf(&quot;    Second EOL caused the first row to output OK\n&quot;);
+    /* Now inject an RTC - 6 EOLs */
+    memset(buf, 0, sizeof(buf));
+    /* T.4 1D style */
+    for (i = 10;  i &lt; 19;  i += 3)
+    {
+        buf[i] = 0x00;
+        buf[i + 1] = 0x10;
+        buf[i + 2] = 0x01;
+    }
+    /* T.4 2D style */
+    buf[25 + 0] = 0x00;
+    buf[25 + 1] = 0x18;
+    buf[25 + 2] = 0x00;
+    buf[25 + 3] = 0xC0;
+    buf[25 + 4] = 0x06;
+    buf[25 + 5] = 0x00;
+    buf[25 + 6] = 0x30;
+    buf[25 + 7] = 0x01;
+    buf[25 + 8] = 0x80;
+    buf[25 + 9] = 0x0C;
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 50);
+    t38_non_ecm_buffer_push(&amp;buffer);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (i == 7
+            ||
+            i == 400 + 11 + 0*12
+            ||
+            i == 400 + 11 + 1*12
+            ||
+            i == 400 + 11 + 2*12
+            ||
+            i == 400 + 11 + 3*12
+            ||
+            i == 400 + 11 + 4*12
+            ||
+            i == 400 + 11 + 5*12
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 0*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 0*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 1*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 1*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 2*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 2*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 3*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 3*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 4*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 4*13 + 1
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 5*13
+            ||
+            i == 400 + 11 + 60 + 400 + 4 + 5*13 + 1)
+        {
+            if (bit == 0)
+            {
+                printf(&quot;Tests failed (%d)\n&quot;, i);
+                exit(2);
+            }
+        }
+        else
+        {
+            if (bit == 1)
+            {
+                printf(&quot;Tests failed (%d)\n&quot;, i);
+                exit(2);
+            }
+        }
+    }
+    printf(&quot;    RTC output OK\n&quot;);
+    t38_non_ecm_buffer_report_input_status(&amp;buffer, &amp;logging);
+    t38_non_ecm_buffer_report_output_status(&amp;buffer, &amp;logging);
+
+    printf(&quot;6 - TCF without leading ones\n&quot;);
+    t38_non_ecm_buffer_init(&amp;buffer, FALSE, 400);
+    n = 0;
+    /* Get some initial bits from an empty buffer. These should be ones */
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (bit != 1)
+        {
+            printf(&quot;Tests failed\n&quot;);
+            exit(2);
+        }
+    }
+    printf(&quot;    Initial ones from an empty TCF buffer OK\n&quot;);
+    /* Now send some TCF through, and see that it comes out */
+    memset(buf, 0x00, sizeof(buf));
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 500);
+    t38_non_ecm_buffer_push(&amp;buffer);
+    for (i = 0;  i &lt; 500*8;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (bit != 0)
+        {
+            printf(&quot;Tests failed\n&quot;);
+            exit(2);
+        }
+    }
+    printf(&quot;    Passthrough of TCF OK\n&quot;);
+    /* Check the right number of bits was buffered */
+    bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+    if (log_bits)
+        printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+    if (bit != SIG_STATUS_END_OF_DATA)
+    {
+        printf(&quot;Tests failed\n&quot;);
+        exit(2);
+    }
+    printf(&quot;    End of data seen OK\n&quot;);
+    t38_non_ecm_buffer_report_input_status(&amp;buffer, &amp;logging);
+    t38_non_ecm_buffer_report_output_status(&amp;buffer, &amp;logging);
+
+    printf(&quot;7 - TCF with leading ones\n&quot;);
+    t38_non_ecm_buffer_init(&amp;buffer, FALSE, 400);
+    n = 0;
+    /* Get some initial bits from an empty buffer. These should be ones */
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (bit != 1)
+        {
+            printf(&quot;Tests failed\n&quot;);
+            exit(2);
+        }
+    }
+    printf(&quot;    Initial ones from an empty TCF buffer OK\n&quot;);
+    
+    /* Now send some initial ones, and see that we continue to get all ones
+       as the stuffing. */
+    memset(buf, 0xFF, 500);
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 500);
+    for (i = 0;  i &lt; 500*8;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if (bit != 1)
+        {
+            printf(&quot;Tests failed\n&quot;);
+            exit(2);
+        }
+    }
+    printf(&quot;    Sustaining ones OK\n&quot;);
+
+    /* Now send some initial ones, and some TCF through, and see that only
+       the TCF comes out */
+    memset(buf, 0x00, sizeof(buf));
+    memset(buf, 0xFF, 100);
+    /* End the ones mid byte */
+    buf[100] = 0xF0;
+    t38_non_ecm_buffer_inject(&amp;buffer, buf, 500);
+    t38_non_ecm_buffer_push(&amp;buffer);
+    for (i = 0;  i &lt; 400*8;  i++)
+    {
+        bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+        if (log_bits)
+            printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+        if ((i &lt; 4  &amp;&amp;  bit == 0)  ||  (i &gt;= 4  &amp;&amp;  bit != 0))
+        {
+            printf(&quot;Tests failed\n&quot;);
+            exit(2);
+        }
+    }
+    printf(&quot;    Passthrough of TCF OK\n&quot;);
+    /* Check the right number of bits was buffered */
+    bit = t38_non_ecm_buffer_get_bit((void *) &amp;buffer);
+    if (log_bits)
+        printf(&quot;Rx bit %d - %d\n&quot;, n++, bit);
+    if (bit != SIG_STATUS_END_OF_DATA)
+    {
+        printf(&quot;Tests failed\n&quot;);
+        exit(2);
+    }
+    printf(&quot;    End of data seen OK\n&quot;);
+    t38_non_ecm_buffer_report_input_status(&amp;buffer, &amp;logging);
+    t38_non_ecm_buffer_report_output_status(&amp;buffer, &amp;logging);
+
</ins><span class="cx">     printf(&quot;Tests passed\n&quot;);
</span><span class="cx">     return  0;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestst38_terminal_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/t38_terminal_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/t38_terminal_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/t38_terminal_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_terminal_tests.c,v 1.67 2009/04/25 14:34:45 steveu Exp $
</del><ins>+ * $Id: t38_terminal_tests.c,v 1.67.4.1 2009/12/19 09:47:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase B:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase B&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase B handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_rx_parameters(s, tag);
</span><span class="cx">     return T30_ERR_OK;
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase D:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase D&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase D handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase E:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase E&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase E handler on channel %c - (%d) %s\n&quot;, i, i, result, t30_completion_code_to_str(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestst38_terminal_to_gateway_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/t38_terminal_to_gateway_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/t38_terminal_to_gateway_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/t38_terminal_to_gateway_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t38_terminal_to_gateway_tests.c,v 1.65 2009/05/30 15:23:14 steveu Exp $
</del><ins>+ * $Id: t38_terminal_to_gateway_tests.c,v 1.65.4.1 2009/12/19 09:47:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase B:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase B&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase B handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_rx_parameters(s, tag);
</span><span class="cx">     return T30_ERR_OK;
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx"> 
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase D:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase D&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase D handler on channel %c - (0x%X) %s\n&quot;, i, i, result, t30_frametype(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx">     char tag[20];
</span><span class="cx">     
</span><span class="cx">     i = (int) (intptr_t) user_data;
</span><del>-    snprintf(tag, sizeof(tag), &quot;%c: Phase E:&quot;, i);
</del><ins>+    snprintf(tag, sizeof(tag), &quot;%c: Phase E&quot;, i);
</ins><span class="cx">     printf(&quot;%c: Phase E handler on channel %c - (%d) %s\n&quot;, i, i, result, t30_completion_code_to_str(result));
</span><span class="cx">     log_transfer_statistics(s, tag);
</span><span class="cx">     log_tx_parameters(s, tag);
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestst4_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/t4_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/t4_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/t4_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: t4_tests.c,v 1.69 2009/05/16 03:34:45 steveu Exp $
</del><ins>+ * $Id: t4_tests.c,v 1.69.4.1 2009/12/19 09:47:57 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \file */
</span><span class="lines">@@ -129,8 +129,8 @@
</span><span class="cx"> 
</span><span class="cx">     t4_get_transfer_statistics(s, &amp;stats);
</span><span class="cx">     printf(&quot;Pages = %d\n&quot;, stats.pages_transferred);
</span><del>-    printf(&quot;Image size = %d x %d pixels\n&quot;, stats.width, stats.length);
-    printf(&quot;Image resolution = %d/m x %d/m\n&quot;, stats.x_resolution, stats.y_resolution);
</del><ins>+    printf(&quot;Image size = %d pels x %d pels\n&quot;, stats.width, stats.length);
+    printf(&quot;Image resolution = %d pels/m x %d pels/m\n&quot;, stats.x_resolution, stats.y_resolution);
</ins><span class="cx">     printf(&quot;Bad rows = %d\n&quot;, stats.bad_rows);
</span><span class="cx">     printf(&quot;Longest bad row run = %d\n&quot;, stats.longest_bad_row_run);
</span><span class="cx">     printf(&quot;Bits per row - min %d, max %d\n&quot;, s-&gt;min_row_bits, s-&gt;max_row_bits);
</span><span class="lines">@@ -144,6 +144,7 @@
</span><span class="cx">     const char *s;
</span><span class="cx">     static int row = 0;
</span><span class="cx"> 
</span><ins>+    /* Send the test pattern. */
</ins><span class="cx">     s = t4_test_patterns[row++];
</span><span class="cx">     if (row &gt;= 16)
</span><span class="cx">         return 0;
</span><span class="lines">@@ -170,6 +171,7 @@
</span><span class="cx">     static int row = 0;
</span><span class="cx">     uint8_t ref[8192];
</span><span class="cx"> 
</span><ins>+    /* Verify that what is received matches the test pattern. */
</ins><span class="cx">     if (len == 0)
</span><span class="cx">         return 0;
</span><span class="cx">     s = t4_test_patterns[row++];
</span><span class="lines">@@ -280,9 +282,15 @@
</span><span class="cx"> {
</span><span class="cx">     static const int compression_sequence[] =
</span><span class="cx">     {
</span><ins>+        //T4_COMPRESSION_NONE,
</ins><span class="cx">         T4_COMPRESSION_ITU_T4_1D,
</span><span class="cx">         T4_COMPRESSION_ITU_T4_2D,
</span><del>-        T4_COMPRESSION_ITU_T6
</del><ins>+        T4_COMPRESSION_ITU_T6,
+        //T4_COMPRESSION_ITU_T85,
+        //T4_COMPRESSION_ITU_T43,
+        //T4_COMPRESSION_ITU_T45,
+        //T4_COMPRESSION_ITU_T81,
+        //T4_COMPRESSION_ITU_SYCC_T81
</ins><span class="cx">     };
</span><span class="cx">     int sends;
</span><span class="cx">     int page_no;
</span><span class="lines">@@ -486,11 +494,11 @@
</span><span class="cx">         }
</span><span class="cx">         span_log_set_level(&amp;receive_state.logging, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME | SPAN_LOG_FLOW);
</span><span class="cx">         t4_rx_set_row_write_handler(&amp;receive_state, row_write_handler, NULL);
</span><ins>+        t4_rx_set_image_width(&amp;receive_state, t4_tx_get_image_width(&amp;send_state));
</ins><span class="cx">         t4_rx_set_x_resolution(&amp;receive_state, t4_tx_get_x_resolution(&amp;send_state));
</span><span class="cx">         t4_rx_set_y_resolution(&amp;receive_state, t4_tx_get_y_resolution(&amp;send_state));
</span><del>-        t4_rx_set_image_width(&amp;receive_state, t4_tx_get_image_width(&amp;send_state));
</del><span class="cx"> 
</span><del>-        /* Now send and receive all the pages in the source TIFF file */
</del><ins>+        /* Now send and receive the test data with all compression modes. */
</ins><span class="cx">         page_no = 1;
</span><span class="cx">         /* If we are stepping around the compression schemes, reset to the start of the sequence. */
</span><span class="cx">         if (compression_step &gt; 0)
</span></span></pre></div>
<a id="freeswitchtrunklibsspandspteststsb85_testssh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/tsb85_tests.sh (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/tsb85_tests.sh        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/tsb85_tests.sh        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-#!/bin/sh
</del><ins>+#!/bin/bash
</ins><span class="cx"> #
</span><span class="cx"> # spandsp fax tests
</span><span class="cx"> #
</span></span></pre></div>
<a id="freeswitchtrunklibsspandsptestsv8_testsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/libs/spandsp/tests/v8_tests.c (16034 => 16035)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/libs/spandsp/tests/v8_tests.c        2009-12-23 01:24:36 UTC (rev 16034)
+++ freeswitch/trunk/libs/spandsp/tests/v8_tests.c        2009-12-23 01:38:36 UTC (rev 16035)
</span><span class="lines">@@ -22,7 +22,7 @@
</span><span class="cx">  * along with this program; if not, write to the Free Software
</span><span class="cx">  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
</span><span class="cx">  *
</span><del>- * $Id: v8_tests.c,v 1.33 2009/05/30 15:23:14 steveu Exp $
</del><ins>+ * $Id: v8_tests.c,v 1.36 2009/11/04 16:10:14 steveu Exp $
</ins><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /*! \page v8_tests_page V.8 tests
</span><span class="lines">@@ -70,31 +70,304 @@
</span><span class="cx">         printf(&quot;%s V.8 negotiation failed\n&quot;, s);
</span><span class="cx">         return;
</span><span class="cx">     }
</span><del>-    printf(&quot;%s V.8 negotiation result:\n&quot;, s);
-    printf(&quot;  Call function '%s'\n&quot;, v8_call_function_to_str(result-&gt;call_function));
-    printf(&quot;  Negotiated modulation '%s'\n&quot;, v8_modulation_to_str(result-&gt;negotiated_modulation));
-    printf(&quot;  Protocol '%s'\n&quot;, v8_protocol_to_str(result-&gt;protocol));
-    printf(&quot;  PSTN access '%s'\n&quot;, v8_pstn_access_to_str(result-&gt;pstn_access));
-    printf(&quot;  PCM modem availability '%s'\n&quot;, v8_pcm_modem_availability_to_str(result-&gt;pcm_modem_availability));
-    if (result-&gt;call_function == V8_CALL_V_SERIES
-        &amp;&amp;
-        result-&gt;negotiated_modulation == V8_MOD_V90
-        &amp;&amp;
-        result-&gt;protocol == V8_PROTOCOL_LAPM_V42)
</del><ins>+    if (result-&gt;modem_connect_tone_detected == MODEM_CONNECT_TONES_ANSAM
+        ||
+        result-&gt;modem_connect_tone_detected == MODEM_CONNECT_TONES_ANSAM_PR
+        ||
+        result-&gt;modem_connect_tone_detected == MODEM_CONNECT_TONES_NONE)
</ins><span class="cx">     {
</span><del>-        negotiations_ok++;
</del><ins>+        printf(&quot;%s V.8 negotiation result:\n&quot;, s);
+        printf(&quot;  Modem connect tone '%s'\n&quot;, modem_connect_tone_to_str(result-&gt;modem_connect_tone_detected));
+        printf(&quot;  Call function '%s'\n&quot;, v8_call_function_to_str(result-&gt;call_function));
+        printf(&quot;  Negotiated modulation '%s'\n&quot;, v8_modulation_to_str(result-&gt;negotiated_modulation));
+        printf(&quot;  Protocol '%s'\n&quot;, v8_protocol_to_str(result-&gt;protocol));
+        printf(&quot;  PSTN access '%s'\n&quot;, v8_pstn_access_to_str(result-&gt;pstn_access));
+        printf(&quot;  NSF %d %d\n&quot;, result-&gt;nsf_seen, result-&gt;nsf);
+        printf(&quot;  PCM modem availability '%s'\n&quot;, v8_pcm_modem_availability_to_str(result-&gt;pcm_modem_availability));
+        printf(&quot;  T.66 %d %d\n&quot;, result-&gt;t66_seen, result-&gt;t66);
+        if (result-&gt;call_function == V8_CALL_V_SERIES
+            &amp;&amp;
+            result-&gt;negotiated_modulation == V8_MOD_V90
+            &amp;&amp;
+            result-&gt;protocol == V8_PROTOCOL_LAPM_V42)
+        {
+            negotiations_ok++;
+        }
</ins><span class="cx">     }
</span><ins>+    else
+    {
+        printf(&quot;%s V.8 negotiation result:\n&quot;, s);
+        printf(&quot;  Modem connect tone '%s'\n&quot;, modem_connect_tone_to_str(result-&gt;modem_connect_tone_detected));
+    }
</ins><span class="cx"> }
</span><ins>+/*- End of function --------------------------------------------------------*/
</ins><span class="cx"> 
</span><del>-int main(int argc, char *argv[])
</del><ins>+static int v8_calls_v8_tests(SNDFILE *outhandle)
</ins><span class="cx"> {
</span><ins>+    v8_state_t *v8_caller;
+    v8_state_t *v8_answerer;
+    logging_state_t *caller_logging;
+    logging_state_t *answerer_logging;
+    int caller_available_modulations;
+    int answerer_available_modulations;
</ins><span class="cx">     int i;
</span><ins>+    int samples;
+    int remnant;
+    int outframes;
</ins><span class="cx">     int16_t amp[SAMPLES_PER_CHUNK];
</span><span class="cx">     int16_t out_amp[2*SAMPLES_PER_CHUNK];
</span><del>-    v8_state_t *v8_caller;
</del><ins>+
+    caller_available_modulations = V8_MOD_V17
+                                 | V8_MOD_V21
+                                 | V8_MOD_V22
+                                 | V8_MOD_V23HALF
+                                 | V8_MOD_V23
+                                 | V8_MOD_V26BIS
+                                 | V8_MOD_V26TER
+                                 | V8_MOD_V27TER
+                                 | V8_MOD_V29
+                                 | V8_MOD_V32
+                                 | V8_MOD_V34HALF
+                                 | V8_MOD_V34
+                                 | V8_MOD_V90
+                                 | V8_MOD_V92;
+    answerer_available_modulations = V8_MOD_V17
+                                   | V8_MOD_V21
+                                   | V8_MOD_V22
+                                   | V8_MOD_V23HALF
+                                   | V8_MOD_V23
+                                   | V8_MOD_V26BIS
+                                   | V8_MOD_V26TER
+                                   | V8_MOD_V27TER
+                                   | V8_MOD_V29
+                                   | V8_MOD_V32
+                                   | V8_MOD_V34HALF
+                                   | V8_MOD_V34
+                                   | V8_MOD_V90
+                                   | V8_MOD_V92;
+    negotiations_ok = 0;
+
+    v8_caller = v8_init(NULL, TRUE, TRUE, caller_available_modulations, handler, (void *) &quot;caller&quot;);
+    v8_answerer = v8_init(NULL, FALSE, TRUE, answerer_available_modulations, handler, (void *) &quot;answerer&quot;);
+    caller_logging = v8_get_logging_state(v8_caller);
+    span_log_set_level(caller_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+    span_log_set_tag(caller_logging, &quot;caller&quot;);
+    answerer_logging = v8_get_logging_state(v8_answerer);
+    span_log_set_level(answerer_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+    span_log_set_tag(answerer_logging, &quot;answerer&quot;);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        samples = v8_tx(v8_caller, amp, SAMPLES_PER_CHUNK);
+        if (samples &lt; SAMPLES_PER_CHUNK)
+        {
+            memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+            samples = SAMPLES_PER_CHUNK;
+        }
+        span_log_bump_samples(caller_logging, samples);
+        remnant = v8_rx(v8_answerer, amp, samples);
+        for (i = 0;  i &lt; samples;  i++)
+            out_amp[2*i] = amp[i];
+        
+        samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK);
+        if (samples &lt; SAMPLES_PER_CHUNK)
+        {
+            memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+            samples = SAMPLES_PER_CHUNK;
+        }
+        span_log_bump_samples(answerer_logging, samples);
+        if (v8_rx(v8_caller, amp, samples)  &amp;&amp;  remnant)
+            break;
+        for (i = 0;  i &lt; samples;  i++)
+            out_amp[2*i + 1] = amp[i];
+
+        outframes = sf_writef_short(outhandle, out_amp, samples);
+        if (outframes != samples)
+        {
+            fprintf(stderr, &quot;    Error writing audio file\n&quot;);
+            exit(2);
+        }
+    }
+    v8_free(v8_caller);
+    v8_free(v8_answerer);
+
+    if (negotiations_ok != 2)
+    {
+        printf(&quot;Tests failed.\n&quot;);
+        exit(2);
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int non_v8_calls_v8_tests(SNDFILE *outhandle)
+{
+    silence_gen_state_t *non_v8_caller_tx;
+    modem_connect_tones_rx_state_t *non_v8_caller_rx;
</ins><span class="cx">     v8_state_t *v8_answerer;
</span><ins>+    logging_state_t *answerer_logging;
+    int answerer_available_modulations;
+    int i;
+    int samples;
+    int remnant;
</ins><span class="cx">     int outframes;
</span><ins>+    int tone;
+    int16_t amp[SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+
+    answerer_available_modulations = V8_MOD_V17
+                                   | V8_MOD_V21
+                                   | V8_MOD_V22
+                                   | V8_MOD_V23HALF
+                                   | V8_MOD_V23
+                                   | V8_MOD_V26BIS
+                                   | V8_MOD_V26TER
+                                   | V8_MOD_V27TER
+                                   | V8_MOD_V29
+                                   | V8_MOD_V32
+                                   | V8_MOD_V34HALF
+                                   | V8_MOD_V34
+                                   | V8_MOD_V90
+                                   | V8_MOD_V92;
+    negotiations_ok = 0;
+
+    non_v8_caller_tx = silence_gen_init(NULL, 10*SAMPLE_RATE);
+    non_v8_caller_rx = modem_connect_tones_rx_init(NULL, MODEM_CONNECT_TONES_ANS_PR, NULL, NULL);
+    v8_answerer = v8_init(NULL, FALSE, TRUE, answerer_available_modulations, handler, (void *) &quot;answerer&quot;);
+    answerer_logging = v8_get_logging_state(v8_answerer);
+    span_log_set_level(answerer_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+    span_log_set_tag(answerer_logging, &quot;answerer&quot;);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        samples = silence_gen(non_v8_caller_tx, amp, SAMPLES_PER_CHUNK);
+        if (samples &lt; SAMPLES_PER_CHUNK)
+        {
+            memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+            samples = SAMPLES_PER_CHUNK;
+        }
+        remnant = v8_rx(v8_answerer, amp, samples);
+        if (remnant)
+            break;
+        for (i = 0;  i &lt; samples;  i++)
+            out_amp[2*i] = amp[i];
+        
+        samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK);
+        if (samples &lt; SAMPLES_PER_CHUNK)
+        {
+            memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+            samples = SAMPLES_PER_CHUNK;
+        }
+        span_log_bump_samples(answerer_logging, samples);
+        modem_connect_tones_rx(non_v8_caller_rx, amp, samples);
+        if ((tone = modem_connect_tones_rx_get(non_v8_caller_rx)) != MODEM_CONNECT_TONES_NONE)
+        {
+            printf(&quot;Detected %s (%d)\n&quot;, modem_connect_tone_to_str(tone), tone);
+            if (tone == MODEM_CONNECT_TONES_ANSAM_PR)
+                negotiations_ok++;
+        }
+        for (i = 0;  i &lt; samples;  i++)
+            out_amp[2*i + 1] = amp[i];
+
+        outframes = sf_writef_short(outhandle, out_amp, samples);
+        if (outframes != samples)
+        {
+            fprintf(stderr, &quot;    Error writing audio file\n&quot;);
+            exit(2);
+        }
+    }
+    silence_gen_free(non_v8_caller_tx);
+    modem_connect_tones_rx_free(non_v8_caller_rx);
+    v8_free(v8_answerer);
+
+    if (negotiations_ok != 1)
+    {
+        printf(&quot;Tests failed.\n&quot;);
+        exit(2);
+    }
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int v8_calls_non_v8_tests(SNDFILE *outhandle)
+{
+    v8_state_t *v8_caller;
+    modem_connect_tones_tx_state_t *non_v8_answerer_tx;
+    logging_state_t *caller_logging;
+    int caller_available_modulations;
+    int i;
</ins><span class="cx">     int samples;
</span><ins>+    int outframes;
+    int16_t amp[SAMPLES_PER_CHUNK];
+    int16_t out_amp[2*SAMPLES_PER_CHUNK];
+
+    caller_available_modulations = V8_MOD_V17
+                                 | V8_MOD_V21
+                                 | V8_MOD_V22
+                                 | V8_MOD_V23HALF
+                                 | V8_MOD_V23
+                                 | V8_MOD_V26BIS
+                                 | V8_MOD_V26TER
+                                 | V8_MOD_V27TER
+                                 | V8_MOD_V29
+                                 | V8_MOD_V32
+                                 | V8_MOD_V34HALF
+                                 | V8_MOD_V34
+                                 | V8_MOD_V90
+                                 | V8_MOD_V92;
+    negotiations_ok = 0;
+
+    v8_caller = v8_init(NULL, TRUE, TRUE, caller_available_modulations, handler, (void *) &quot;caller&quot;);
+    non_v8_answerer_tx = modem_connect_tones_tx_init(NULL, MODEM_CONNECT_TONES_ANS_PR);
+    caller_logging = v8_get_logging_state(v8_caller);
+    span_log_set_level(caller_logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG | SPAN_LOG_SHOW_SAMPLE_TIME);
+    span_log_set_tag(caller_logging, &quot;caller&quot;);
+    for (i = 0;  i &lt; 1000;  i++)
+    {
+        samples = v8_tx(v8_caller, amp, SAMPLES_PER_CHUNK);
+        if (samples &lt; SAMPLES_PER_CHUNK)
+        {
+            memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+            samples = SAMPLES_PER_CHUNK;
+        }
+        span_log_bump_samples(caller_logging, samples);
+        for (i = 0;  i &lt; samples;  i++)
+            out_amp[2*i] = amp[i];
+        
+        samples = modem_connect_tones_tx(non_v8_answerer_tx, amp, SAMPLES_PER_CHUNK);
+        if (samples &lt; SAMPLES_PER_CHUNK)
+        {
+            memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
+            samples = SAMPLES_PER_CHUNK;
+        }
+        if (v8_rx(v8_caller, amp, samples))
+            break;
+        for (i = 0;  i &lt; samples;  i++)
+            out_amp[2*i + 1] = amp[i];
+
+        outframes = sf_writef_short(outhandle, out_amp, samples);
+        if (outframes != samples)
+        {
+            fprintf(stderr, &quot;    Error writing audio file\n&quot;);
+            exit(2);
+        }
+    }
+    v8_free(v8_caller);
+    modem_connect_tones_tx_free(non_v8_answerer_tx);
+
+#if 0
+    if (negotiations_ok != 1)
+    {
+        printf(&quot;Tests failed.\n&quot;);
+        exit(2);
+    }
+#endif
+    return 0;
+}
+/*- End of function --------------------------------------------------------*/
+
+int main(int argc, char *argv[])
+{
+    int16_t amp[SAMPLES_PER_CHUNK];
+    int samples;
</ins><span class="cx">     int remnant;
</span><span class="cx">     int caller_available_modulations;
</span><span class="cx">     int answerer_available_modulations;
</span><span class="lines">@@ -102,6 +375,7 @@
</span><span class="cx">     SNDFILE *outhandle;
</span><span class="cx">     int opt;
</span><span class="cx">     char *decode_test_file;
</span><ins>+    v8_state_t *v8_answerer;
</ins><span class="cx">     logging_state_t *logging;
</span><span class="cx"> 
</span><span class="cx">     decode_test_file = NULL;
</span><span class="lines">@@ -155,65 +429,28 @@
</span><span class="cx">             fprintf(stderr, &quot;    Cannot create audio file '%s'\n&quot;, OUTPUT_FILE_NAME);
</span><span class="cx">             exit(2);
</span><span class="cx">         }
</span><del>-    
-        v8_caller = v8_init(NULL, TRUE, caller_available_modulations, handler, (void *) &quot;caller&quot;);
-        v8_answerer = v8_init(NULL, FALSE, answerer_available_modulations, handler, (void *) &quot;answerer&quot;);
-        logging = v8_get_logging_state(v8_caller);
-        span_log_set_level(logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG);
-        span_log_set_tag(logging, &quot;caller&quot;);
-        logging = v8_get_logging_state(v8_answerer);
-        span_log_set_level(logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG);
-        span_log_set_tag(logging, &quot;answerer&quot;);
-        for (i = 0;  i &lt; 1000;  i++)
-        {
-            samples = v8_tx(v8_caller, amp, SAMPLES_PER_CHUNK);
-            if (samples &lt; SAMPLES_PER_CHUNK)
-            {
-                memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
-                samples = SAMPLES_PER_CHUNK;
-            }
-            remnant = v8_rx(v8_answerer, amp, samples);
-            for (i = 0;  i &lt; samples;  i++)
-                out_amp[2*i] = amp[i];
-            
-            samples = v8_tx(v8_answerer, amp, SAMPLES_PER_CHUNK);
-            if (samples &lt; SAMPLES_PER_CHUNK)
-            {
-                memset(amp + samples, 0, sizeof(int16_t)*(SAMPLES_PER_CHUNK - samples));
-                samples = SAMPLES_PER_CHUNK;
-            }
-            if (v8_rx(v8_caller, amp, samples)  &amp;&amp;  remnant)
-                break;
-            for (i = 0;  i &lt; samples;  i++)
-                out_amp[2*i + 1] = amp[i];
-    
-            outframes = sf_writef_short(outhandle, out_amp, samples);
-            if (outframes != samples)
-            {
-                fprintf(stderr, &quot;    Error writing audio file\n&quot;);
-                exit(2);
-            }
-        }
</del><ins>+
+        printf(&quot;Test 1: V.8 terminal calls V.8 terminal\n&quot;);
+        v8_calls_v8_tests(outhandle);
+
+        printf(&quot;Test 2: non-V.8 terminal calls V.8 terminal\n&quot;);
+        non_v8_calls_v8_tests(outhandle);
+
+        printf(&quot;Test 3: V.8 terminal calls non-V.8 terminal\n&quot;);
+        v8_calls_non_v8_tests(outhandle);
+
</ins><span class="cx">         if (sf_close(outhandle))
</span><span class="cx">         {
</span><span class="cx">             fprintf(stderr, &quot;    Cannot close audio file '%s'\n&quot;, OUTPUT_FILE_NAME);
</span><span class="cx">             exit(2);
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        v8_free(v8_caller);
-        v8_free(v8_answerer);
-        
-        if (negotiations_ok != 2)
-        {
-            printf(&quot;Tests failed.\n&quot;);
-            exit(2);
-        }
</del><span class="cx">         printf(&quot;Tests passed.\n&quot;);
</span><span class="cx">     }
</span><span class="cx">     else
</span><span class="cx">     {
</span><span class="cx">         printf(&quot;Decode file '%s'\n&quot;, decode_test_file);
</span><del>-        v8_answerer = v8_init(NULL, FALSE, answerer_available_modulations, handler, (void *) &quot;answerer&quot;);
</del><ins>+        v8_answerer = v8_init(NULL, FALSE, TRUE, answerer_available_modulations, handler, (void *) &quot;answerer&quot;);
</ins><span class="cx">         logging = v8_get_logging_state(v8_answerer);
</span><span class="cx">         span_log_set_level(logging, SPAN_LOG_FLOW | SPAN_LOG_SHOW_TAG);
</span><span class="cx">         span_log_set_tag(logging, &quot;decoder&quot;);
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>