FireBirdLib - Topfield TMS PVR TAP Programming Library
CRC32.c
Go to the documentation of this file.
1
#include "
libFireBird.h
"
2
3
dword
CRC32Table
[256];
4
bool
CRCTableOK
= FALSE;
5
6
void
make_crc_table
(
void
);
7
8
void
make_crc_table
(
void
)
9
{
10
TRACEENTER
();
11
12
dword dwCRC;
13
dword CRCPOLY = 0;
14
dword i, j;
15
bool
topbit;
16
byte
poly[15] = { 0, 1, 2, 4, 5, 7, 8, 10, 11, 12, 16, 22, 23, 26 };
17
18
for
(i = 0; i < 15; ++i)
19
CRCPOLY |= (1 << poly[i]);
20
21
for
(i = 0; i < 256; i++)
22
{
23
dwCRC = i << 24;
24
for
(j = 0; j < 8; ++j)
25
{
26
topbit = (dwCRC >> 31);
27
dwCRC <<= 1;
28
if
(topbit) dwCRC ^= CRCPOLY;
29
}
30
CRC32Table
[i] = dwCRC;
31
}
32
CRCTableOK
= TRUE;
33
34
TRACEEXIT
();
35
}
36
37
38
dword
CRC32
(dword StartValue,
void
*StartAddress, dword Length)
39
{
40
TRACEENTER
();
41
42
volatile
byte
*pData;
43
dword crc = StartValue;
//Normaly 0xffffffff
44
45
if
(!StartAddress)
46
{
47
TRACEEXIT
();
48
return
crc;
49
}
50
51
if
(!
CRCTableOK
)
make_crc_table
();
52
53
for
(pData = StartAddress; pData < (
byte
*) StartAddress + Length; pData++)
54
crc = (crc << 8) ^
CRC32Table
[((crc >> 24) ^ *pData) & 0xff];
55
56
TRACEEXIT
();
57
return
crc;
58
}
CRC32
dword CRC32(dword StartValue, void *StartAddress, dword Length)
Definition:
CRC32.c:38
make_crc_table
void make_crc_table(void)
Definition:
CRC32.c:8
CRCTableOK
bool CRCTableOK
Definition:
CRC32.c:4
CRC32Table
dword CRC32Table[256]
Definition:
CRC32.c:3
libFireBird.h
TRACEEXIT
#define TRACEEXIT()
Definition:
libFireBird.h:1244
TRACEENTER
#define TRACEENTER()
Definition:
libFireBird.h:1243
compression
CRC32.c
Generated on Fri Apr 29 2022 13:34:00 for FireBirdLib - Topfield TMS PVR TAP Programming Library by
1.9.3