fix vc1 streamtype detection
[enigma2.git] / lib / dvb / pesparse.cpp
index d96477be0fb6a67709d29a4f0e81773b8c65b63d..b0352fe60faa7f20e72bab1b8c881fe0dc04f320 100644 (file)
@@ -12,16 +12,14 @@ ePESParser::ePESParser()
        setStreamID(0); /* must be overridden */
 }
 
-void ePESParser::setStreamID(unsigned char id)
+void ePESParser::setStreamID(unsigned char id, unsigned char id_mask)
 {
        m_header[3] = id;
+       m_stream_id_mask = id_mask;
 }
 
 void ePESParser::processData(const __u8 *p, int len)
 {
-       int i;
-       eDebug("process %d bytes of pes data, %02x, %02x, %02x, %02x, %02x, %02x", len, p[0], p[1], p[2], p[3], p[4], p[5]);
-#if 0
                /* this is a state machine, handling arbitary amounts of pes-formatted data. */
        while (len)
        {
@@ -44,23 +42,26 @@ void ePESParser::processData(const __u8 *p, int len)
                } else
                {
                        if (m_pes_position < 4)
-                               if (*p != m_header[m_pes_position])
+                       {
+                               unsigned char ch = *p;
+                               if (m_pes_position == 3)
+                                       ch &= m_stream_id_mask;
+                               if (ch != m_header[m_pes_position])
                                {
-                                       eDebug("sync lost at %d (%02x)", m_pes_position, *p);
+//                                     eDebug("sync lost at %d (%02x)", m_pes_position, *p);
                                        m_pes_position = 0;
-                                       while (m_header[m_pes_position] == *p) /* guaranteed to stop at the old m_pes_position */
+                                       while (m_header[m_pes_position] == ch) /* guaranteed to stop at the old m_pes_position */
                                                m_pes_position++;
                                        p++;
                                        len--;
                                        continue;
                                }
+                       }
                        m_pes_buffer[m_pes_position++] = *p++; len--;
                        if (m_pes_position == 6)
                        {
                                m_pes_length = ((m_pes_buffer[4] << 8) | m_pes_buffer[5]) + 6;
-                               eDebug("pes length: %d", m_pes_length);
                        }
                }
        }
-#endif
 }