[linux-dvb] CRC 32 information for MPEG checksum

w-thiel at gmx.net w-thiel at gmx.net
Wed Mar 14 14:00:34 CET 2007


On Wed, Mar 14, 2007 at 12:37:15PM +0100, Paolo Pasquali wrote:
> Hi to all,
> I'm doing an application to off-line analyze and edit a generic DVB TS.  I
> have a lot og problems with CRC32 calculation on PSI/SI tables.
> I'm using a fast calculation CRC32:
> 
> poly: 0x04c11db7
> 
> table:  0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc,
> 0x17c56b6b, etc.............
> 
> algorithm:
> 
> public long CRC(byte[] by)
>        {
>            ulong ulCRC = 0xFFFFFFFF;
>            long len;
>            len = by.Length;
>            for(long i = 0; i < len; i++)
>            {
> 
> 
>                ulCRC = (ulCRC >> 8) ^ crcLookup[by[i]  ^ (ulCRC & 0xFF) ];
>                }
>            return Convert.ToInt64( ulCRC ^ 0xFFFFFFFF);
>        }
> 
Try this:

for (i = 0; i < len; ++i)
        CRC = (CRC<<8) ^ crc_tab[((CRC>>24)^*p++) &0xff];

Wolfgang



More information about the linux-dvb mailing list