commit c4505ee877c604be5bbac6c8756c2ecc2d606937
Author: Gregorio Gervasio, Jr <ggervasio@yahoo.com>
Date:   Tue Jun 7 02:45:10 2011 -0700

    Improved XDS check for SCTE field inversion.

diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
index 4a66e86..34ac965 100644
--- a/mythtv/libs/libmythtv/avformatdecoder.cpp
+++ b/mythtv/libs/libmythtv/avformatdecoder.cpp
@@ -2435,21 +2435,25 @@ void AvFormatDecoder::DecodeDTVCC(const uint8_t *buf, uint len, bool scte)
                 field = cc_type ^ invert_scte_field;
             }
 
-            // in film mode, we may start at the wrong field;
-            // correct if XDS is detected (must be field 2)
-            if (scte && field == 0 && data1 == 0x01)
+            if (cc608_good_parity(cc608_parity_table, data))
             {
-                if (cc_type == 1)
-                    invert_scte_field = 0;
-                field = 1;
-            }
+                // in film mode, we may start at the wrong field;
+                // correct if XDS start/cont/end code is detected (must be field 2)
+                if (scte && field == 0 &&
+                    (data1 & 0x7f) <= 0x0f && (data1 & 0x7f) != 0x00)
+                {
+                    if (cc_type == 1)
+                        invert_scte_field = 0;
+                    field = 1;
 
-            last_scte_field = field;
+                    // flush decoder
+                    ccd608->FormatCC(0, -1, -1);
+                }
 
-            if (cc608_good_parity(cc608_parity_table, data))
-            {
                 had_608 = true;
                 ccd608->FormatCCField(lastccptsu / 1000, field, data);
+
+                last_scte_field = field;
             }
         }
         else
