mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 06:51:47 +00:00
break the loop from CRC_Block into CRC_ProcessBlock so that crcs can be
caclulated over multiple blocks.
This commit is contained in:
parent
21b6e68a8c
commit
6f29bcb238
2 changed files with 12 additions and 4 deletions
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
void CRC_Init(unsigned short *crcvalue);
|
void CRC_Init(unsigned short *crcvalue);
|
||||||
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
|
void CRC_ProcessByte(unsigned short *crcvalue, byte data);
|
||||||
|
void CRC_ProcessBlock (byte *start, unsigned short *crcvalue, int count);
|
||||||
unsigned short CRC_Value(unsigned short crcvalue);
|
unsigned short CRC_Value(unsigned short crcvalue);
|
||||||
unsigned short CRC_Block (byte *start, int count);
|
unsigned short CRC_Block (byte *start, int count);
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,15 @@ CRC_ProcessByte (unsigned short *crcvalue, byte data)
|
||||||
*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
|
*crcvalue = (*crcvalue << 8) ^ crctable[(*crcvalue >> 8) ^ data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CRC_ProcessBlock (byte *start, unsigned short *crcvalue, int count)
|
||||||
|
{
|
||||||
|
unsigned short crc = *crcvalue;
|
||||||
|
while (count--)
|
||||||
|
crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
|
||||||
|
*crcvalue = crc;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned short
|
unsigned short
|
||||||
CRC_Value (unsigned short crcvalue)
|
CRC_Value (unsigned short crcvalue)
|
||||||
{
|
{
|
||||||
|
@ -95,13 +104,11 @@ CRC_Value (unsigned short crcvalue)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned short
|
unsigned short
|
||||||
CRC_Block (byte * start, int count)
|
CRC_Block (byte *start, int count)
|
||||||
{
|
{
|
||||||
unsigned short crc;
|
unsigned short crc;
|
||||||
|
|
||||||
CRC_Init (&crc);
|
CRC_Init (&crc);
|
||||||
while (count--)
|
CRC_ProcessBlock (start, &crc, count);
|
||||||
crc = (crc << 8) ^ crctable[(crc >> 8) ^ *start++];
|
|
||||||
|
|
||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue