From kde-commits Tue Nov 30 22:12:39 2010 From: Christoph Pfister Date: Tue, 30 Nov 2010 22:12:39 +0000 To: kde-commits Subject: extragear/multimedia/kaffeine/src/dvb Message-Id: <20101130221239.6C549AC8A3 () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=129115520932461 SVN commit 1202443 by pfister: again calculate crc sum for dvb sec sections - got removed during restructuring M +13 -16 dvbdevice.cpp M +4 -3 dvbsi.cpp M +1 -2 dvbsi.h --- trunk/extragear/multimedia/kaffeine/src/dvb/dvbdevice.cpp #1202442:1202443 @@ -133,31 +133,27 @@ void DvbSectionFilterInternal::processSections(bool force) { - const char *data = buffer.constBegin(); + const char *it = buffer.constBegin(); const char *end = buffer.constEnd(); - while (true) { - if (data >= end) { - break; - } - - if (static_cast(data[0]) == 0xff) { + while (it != end) { + if (static_cast(it[0]) == 0xff) { // table id == 0xff means padding - data = end; + it = end; break; } - if ((end - data) < 3) { + if ((end - it) < 3) { if (force) { kDebug() << "stray data"; - data = end; + it = end; } break; } - const char *sectionEnd = ((((static_cast(data[1]) & 0x0f) << 8) | - static_cast(data[2])) + 3 + data); + const char *sectionEnd = (it + (((static_cast(it[1]) & 0x0f) << 8) | + static_cast(it[2])) + 3); if (force && (sectionEnd > end)) { kDebug() << "short section"; @@ -165,20 +161,21 @@ } if (sectionEnd <= end) { - int size = (sectionEnd - data); + int size = (sectionEnd - it); + int crc = DvbStandardSection::verifyCrc32(it, size); for (int i = 0; i < sectionFilters.size(); ++i) { - sectionFilters.at(i)->processSection(data, size, 0); // FIXME + sectionFilters.at(i)->processSection(it, size, crc); } - data = sectionEnd; + it = sectionEnd; continue; } break; } - buffer.remove(0, buffer.size() - (end - data)); + buffer.remove(0, it - buffer.constBegin()); } class DvbDataDumper : public QFile, public DvbPidFilter --- trunk/extragear/multimedia/kaffeine/src/dvb/dvbsi.cpp #1202442:1202443 @@ -39,12 +39,13 @@ } } -int DvbStandardSection::verifyCrc32() const +int DvbStandardSection::verifyCrc32(const char *data, int size) { unsigned int crc32 = 0xffffffff; - for (int i = 0; i < length; ++i) { - crc32 = (crc32 << 8) ^ crc32Table[(crc32 >> 24) ^ at(i)]; + for (int i = 0; i < size; ++i) { + crc32 = ((crc32 << 8) ^ + crc32Table[(crc32 >> 24) ^ static_cast(data[i])]); } return crc32; --- trunk/extragear/multimedia/kaffeine/src/dvb/dvbsi.h #1202442:1202443 @@ -142,8 +142,7 @@ return at(7); } - int verifyCrc32() const; - + static int verifyCrc32(const char *data, int size); static const unsigned int crc32Table[]; };