1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Fixed a problem with crc32 in SI handling on 64bit systems

This commit is contained in:
Klaus Schmidinger 2003-12-22 14:18:48 +01:00
parent 7ff59171e3
commit 0acb4dc6d0
4 changed files with 21 additions and 15 deletions

View File

@ -876,3 +876,6 @@ Emil Petersky <petersky@isr.uni-stuttgart.de>
Alessio Sangalli <alesan@manoweb.com> Alessio Sangalli <alesan@manoweb.com>
for providing the iso8859-1 small font for providing the iso8859-1 small font
Pedro Miguel Sequeira de Justo Teixeira <pedro.miguel.teixeira@bigfoot.com>
for reporting a problem with crc32 in SI handling on 64bit systems

View File

@ -2502,3 +2502,5 @@ Video Disk Recorder Revision History
- Added 'cRWlock' to 'thread.[hc]'. Note that all plugin Makefiles need to - Added 'cRWlock' to 'thread.[hc]'. Note that all plugin Makefiles need to
define _GNU_SOURCE for this to work (see the example plugin Makefiles and define _GNU_SOURCE for this to work (see the example plugin Makefiles and
'newplugin'). 'newplugin').
- Fixed a problem with crc32 in SI handling on 64bit systems (thanks to Pedro
Miguel Sequeira de Justo Teixeira for reportign this one).

View File

@ -6,7 +6,7 @@
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* $Id: util.c 1.2 2003/12/13 10:42:18 kls Exp $ * $Id: util.c 1.3 2003/12/22 14:03:03 kls Exp $
* * * *
***************************************************************************/ ***************************************************************************/
@ -186,7 +186,7 @@ void Parsable::CheckParse() {
//taken and adapted from libdtv, (c) Rolf Hakenes and VDR, (c) Klaus Schmidinger //taken and adapted from libdtv, (c) Rolf Hakenes and VDR, (c) Klaus Schmidinger
time_t DVBTime::getTime(unsigned char date_hi, unsigned char date_lo, unsigned char time_hour, unsigned char time_minute, unsigned char time_second) { time_t DVBTime::getTime(unsigned char date_hi, unsigned char date_lo, unsigned char time_hour, unsigned char time_minute, unsigned char time_second) {
unsigned short mjd = date_hi << 8 | date_lo; u_int16_t mjd = date_hi << 8 | date_lo;
struct tm t; struct tm t;
t.tm_sec = bcdToDec(time_second); t.tm_sec = bcdToDec(time_second);
@ -217,7 +217,7 @@ time_t DVBTime::getDuration(unsigned char time_hour, unsigned char time_minute,
//taken and adapted from libdtv, (c) Rolf Hakenes //taken and adapted from libdtv, (c) Rolf Hakenes
// CRC32 lookup table for polynomial 0x04c11db7 // CRC32 lookup table for polynomial 0x04c11db7
unsigned long CRC32::crc_table[256] = { u_int32_t CRC32::crc_table[256] = {
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b, 0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61, 0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7, 0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
@ -262,7 +262,7 @@ unsigned long CRC32::crc_table[256] = {
0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668, 0x933eb0bb, 0x97ffad0c, 0xafb010b1, 0xab710d06, 0xa6322bdf, 0xa2f33668,
0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4}; 0xbcb4666d, 0xb8757bda, 0xb5365d03, 0xb1f740b4};
unsigned long CRC32::crc32 (const char *d, int len, unsigned long crc) u_int32_t CRC32::crc32 (const char *d, int len, u_int32_t crc)
{ {
register int i; register int i;
@ -272,7 +272,7 @@ unsigned long CRC32::crc32 (const char *d, int len, unsigned long crc)
return crc; return crc;
} }
CRC32::CRC32(const char *d, int len, unsigned long CRCvalue) { CRC32::CRC32(const char *d, int len, u_int32_t CRCvalue) {
data=d; data=d;
length=len; length=len;
value=CRCvalue; value=CRCvalue;

View File

@ -6,7 +6,7 @@
* the Free Software Foundation; either version 2 of the License, or * * the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. * * (at your option) any later version. *
* * * *
* $Id: util.h 1.2 2003/12/13 10:42:20 kls Exp $ * $Id: util.h 1.3 2003/12/22 14:07:41 kls Exp $
* * * *
***************************************************************************/ ***************************************************************************/
@ -14,6 +14,7 @@
#define LIBSI_UTIL_H #define LIBSI_UTIL_H
#include <stdint.h> #include <stdint.h>
#include <sys/types.h>
#include <pthread.h> #include <pthread.h>
#include <time.h> #include <time.h>
@ -54,8 +55,8 @@ public:
template <typename T> void setPointerAndOffset(const T* &p, unsigned int &offset) const { p=(T*)getData(offset); offset+=sizeof(T); } template <typename T> void setPointerAndOffset(const T* &p, unsigned int &offset) const { p=(T*)getData(offset); offset+=sizeof(T); }
unsigned char operator[](const unsigned int index) const { return data_->data ? data_->data[off+index] : 0; } unsigned char operator[](const unsigned int index) const { return data_->data ? data_->data[off+index] : 0; }
int getLength() const { return data_->size; } int getLength() const { return data_->size; }
unsigned short TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; } u_int16_t TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; }
unsigned long FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; } u_int32_t FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; }
void addOffset(unsigned int offset) { off+=offset; } void addOffset(unsigned int offset) { off+=offset; }
private: private:
@ -67,9 +68,9 @@ private:
virtual void assign(const unsigned char*data, unsigned int size) = 0; virtual void assign(const unsigned char*data, unsigned int size) = 0;
virtual void Delete() = 0; virtual void Delete() = 0;
unsigned short TwoBytes(const unsigned int index) const u_int16_t TwoBytes(const unsigned int index) const
{ return (data[index] << 8) | data[index+1]; } { return (data[index] << 8) | data[index+1]; }
unsigned long FourBytes(const unsigned int index) const u_int32_t FourBytes(const unsigned int index) const
{ return (data[index] << 24) | (data[index+1] << 16) | (data[index+2] << 8) | data[index+3]; } { return (data[index] << 24) | (data[index+1] << 16) | (data[index+2] << 8) | data[index+3]; }
/*#ifdef CHARARRAY_THREADSAFE /*#ifdef CHARARRAY_THREADSAFE
void Lock(); void Lock();
@ -139,16 +140,16 @@ inline unsigned char bcdToDec(unsigned char b) { return ((b >> 4) & 0x0F) * 10 +
//taken and adapted from libdtv, (c) Rolf Hakenes //taken and adapted from libdtv, (c) Rolf Hakenes
class CRC32 { class CRC32 {
public: public:
CRC32(const char *d, int len, unsigned long CRCvalue=0xFFFFFFFF); CRC32(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF);
bool isValid() { return crc32(data, length, value) == 0; } bool isValid() { return crc32(data, length, value) == 0; }
static bool isValid(const char *d, int len, unsigned long CRCvalue=0xFFFFFFFF) { return crc32(d, len, CRCvalue) == 0; } static bool isValid(const char *d, int len, u_int32_t CRCvalue=0xFFFFFFFF) { return crc32(d, len, CRCvalue) == 0; }
protected: protected:
static unsigned long crc_table[256]; static u_int32_t crc_table[256];
static unsigned long crc32 (const char *d, int len, unsigned long CRCvalue); static u_int32_t crc32 (const char *d, int len, u_int32_t CRCvalue);
const char *data; const char *data;
int length; int length;
unsigned long value; u_int32_t value;
}; };
} //end of namespace } //end of namespace