]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 526: change Class1ECMDoCTC into Class1PersistentECM and apply it
authorLee Howard <faxguy@howardsilvan.com>
Wed, 7 Apr 2004 05:23:22 +0000 (05:23 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Wed, 7 Apr 2004 05:23:22 +0000 (05:23 +0000)
         to V.34-Fax also.

faxd/Class1Recv.c++
faxd/Class1Send.c++
faxd/ModemConfig.c++
faxd/ModemConfig.h
man/hylafax-config.4f

index 7d67aa9f2acdd42c97fa3d1d227241332ccee72b..8be26f1fb49e337890ce598708b2e5692724b8f2 100644 (file)
@@ -1004,7 +1004,7 @@ Class1Modem::recvPageECMData(TIFF* tif, const Class2Params& params, fxStr& emsg)
                            tracePPR("RECV send", FCF_PPR);
 
                            pprcnt++;
-                           if (pprcnt == 4) {
+                           if (pprcnt == 4 && (!useV34 || !conf.class1PersistentECM)) {
                                // expect sender to send CTC/EOR after every fourth PPR, not just the fourth
                                protoTrace("RECV sent fourth PPR");
                                pprcnt = 0;
index 27d80ef17a09c2ac6f0e689427a3054da921257b..3efe224d760316ff73faaf335a107bfecf6b9681 100644 (file)
@@ -1082,9 +1082,11 @@ Class1Modem::blockFrame(const u_char* bitrev, bool lastframe, u_int ppmcmd, fxSt
                        }
                    } while (!gotppr);          
                }
+               bool doctceor;
                switch (pprframe.getFCF()) {
                    case FCF_MCF:
                    case FCF_PIP:
+                       hadV34Trouble = false;
                        blockgood = true;
                        signalRcvd = pprframe.getFCF();
                        break;
@@ -1105,25 +1107,39 @@ Class1Modem::blockFrame(const u_char* bitrev, bool lastframe, u_int ppmcmd, fxSt
                                }
                            }
                        }
-                       if (useV34 && badframes && badframes >= (badframesbefore / 2) && pprcnt < 4) {
-                           /*
-                            * With V.34-Fax we cannot send CTC, but we can request 
-                            * to renegotiate the primary rate any time.  (T.31-A1 B.8.5)
-                            * In practice, if we do not constrain the rate then
-                            * we may likely speed up the rate; so we constrain it.
-                            */
-                           renegotiatePrimary(true);           // constrain
+                       doctceor = (pprcnt == 4);
+                       /*
+                        * T.30 Annex F prohibits CTC in V.34-Fax.  Per the spec our options
+                        * are to do EOR or DCN.  However, many receivers will allow us to
+                        * simply continue sending image blocks followed by PPS.  Coupled with
+                        * primary rate negotiations, this becomes a better-than-CTC solution.
+                        * Do this up to 12 attempts and only when something has gotten through.
+                        */
+                       if (useV34) {
+                           if (pprcnt >= 4 && badframes) hadV34Trouble = true; // problematic V.34?
+                           if (pprcnt == 8) doctceor = true;
+                           if (conf.class1PersistentECM && badframes && badframes != frameNumber) doctceor = false;
+                           if (pprcnt == 12) doctceor = true;
+                           if (!doctceor && badframes && badframes >= (badframesbefore / 2)) {
+                               /*
+                                * Request to renegotiate the primary rate.  (T.31-A1 B.8.5)
+                                * In practice, if we do not constrain the rate then
+                                * we may likely speed up the rate; so we constrain it.
+                                */
+                               renegotiatePrimary(true);               // constrain
+                           }
                        }
-                       if (pprcnt == 4) {
+                       if (doctceor) {
                            pprcnt = 0;
                            // Some receivers will ignorantly transmit PPR showing all frames good,
                            // so if that's the case then do EOR instead of CTC.
                            if (badframes == 0) {
+                               hadV34Trouble = false;
                                blockgood = true;
                                signalRcvd = FCF_MCF;
                            }
                            // There is no CTC with V.34-fax (T.30 Annex F.3.4.5 Note 1).
-                           if (conf.class1ECMDoCTC && !useV34 && (blockgood == false) && 
+                           if (conf.class1PersistentECM && !useV34 && (blockgood == false) && 
                                !((curcap->br == 0) && (badframes >= badframesbefore))) {
                                // send ctc even at 2400 baud if we're getting somewhere
                                if (curcap->br != 0) {
@@ -1187,10 +1203,6 @@ Class1Modem::blockFrame(const u_char* bitrev, bool lastframe, u_int ppmcmd, fxSt
                                 * disabling MMR to this destination would be advisable.
                                 */
                                if (blockgood == false && params.df == DF_2DMMR) {
-                                   if (useV34) {
-                                       // not using CTC seems to be a problem
-                                       hadV34Trouble = true;
-                                   }
                                    emsg = "Failure to transmit clean MMR image data.";
                                    protoTrace(emsg);
                                    return (false);
index c49c8ac3846c697e51be63fd344a00e43bc48f1b..6cb9a4dc8f7f836f29027b86ab2faf5faeef4c18 100644 (file)
@@ -237,7 +237,7 @@ ModemConfig::setupConfig()
     class2UseLineCount = false;                // don't trust firmware decoders
     class1ECMSupport   = true;                 // support for ECM
     class1ExtendedRes  = true;                 // support for extended resolutions
-    class1ECMDoCTC     = true;                 // continue to correct through all bitrates
+    class1PersistentECM        = true;                 // continue to correct
     class1TCFRecvHack  = false;                // historical behavior
     class1ValidateV21Frames = false;           // assume the modem does this
     setVolumeCmds("ATM0 ATL0M1 ATL1M1 ATL2M1 ATL3M1");
@@ -581,8 +581,8 @@ ModemConfig::setConfigItem(const char* tag, const char* value)
        class2SendRTC = getBoolean(value);
     else if (streq(tag, "class1ecmsupport"))
        class1ECMSupport = getBoolean(value);
-    else if (streq(tag, "class1ecmdoctc"))
-       class1ECMDoCTC = getBoolean(value);
+    else if (streq(tag, "class1persistentecm"))
+       class1PersistentECM = getBoolean(value);
     else if (streq(tag, "class1extendedres"))
        class1ExtendedRes = getBoolean(value);
     else if (streq(tag, "class1tcfrecvhack"))
index fafad9c28fdaedf3c4b9a78329c92c111d9cd021..1f7a1fabd87aec40043e40005d962c6eaad77595 100644 (file)
@@ -141,7 +141,7 @@ public:
     u_int      class1TMConnectDelay;   // delay (ms) after +FTM CONNECT
     u_int      class1ECMFrameSize;     // ECM frame size for transmission
     bool       class1ECMSupport;       // support T.30-A ECM
-    bool       class1ECMDoCTC;         // continue to correct
+    bool       class1PersistentECM;    // continue to correct
     bool       class1ExtendedRes;      // support for extended resolutions
     bool       class1TCFRecvHack;      // deliberately look for V.21 disconnect
     bool       class1ValidateV21Frames;// check received FCS values in V.21
index 79d752d1b0038a428543a63f19b29fe8abf84fd4..67c8fd5e0279cc3e7b5b5940ca7b68c749bb4895 100644 (file)
@@ -262,7 +262,7 @@ Class1Cmd   string  \s-1AT+FCLASS=1\s+1     Class 1: command to enter class 1
 Class1Cmd      string  \s-1AT+FCLASS=1.0\s+1   Class 1.0: command to enter class 1
 Class1EnableV34Cmd     string  \-      Class 1/1.0: command to enable V.34-fax support
 Class1ECMSupport       boolean \s-1Yes\s+1     Class 1/1.0: enable T.30-A ECM support
-Class1ECMDoCTC boolean \s-1Yes\s+1     Class 1/1.0: to perform CTC in ECM protocol
+Class1PersistentECM    boolean \s-1Yes\s+1     Class 1/1.0: to continue to correct while in ECM
 Class1ECMFrameSize     integer \s-1256\s+1     Class 1/1.0: image frame size in ECM protocol
 Class1ExtendedRes      boolean \s-1Yes\s+1     Class 1/1.0: enable extended resolution support
 Class1HFLOCmd  string  \-      Class 1/1.0: command to set hardware flow control
@@ -2044,10 +2044,10 @@ maximum primary channel rate.
 Whether or not to support T.30-A error correction protocol.  Use of
 ECM will require 64 kilobytes of free memory per modem in active use.
 .TP
-.B Class1ECMDoCTC
-Whether or not to continue to retransmit image data in ECM protocol 
-at a lower bitrate which is not accepted as valid after four successive
-attempts at the current bitrate.
+.B Class1PersistentECM
+Whether or not to continue to retransmit and allow to continue to 
+receive image data in ECM protocol 
+which is not accepted as valid after four successive attempts.
 .TP
 .B Class1ECMFrameSize
 The size in bytes of image frames to transmit during ECM protocol.