Implement PBM read file and display
This commit is contained in:
parent
8de8db41a6
commit
a32e1e3a9f
3 changed files with 168 additions and 17 deletions
28
crc16ccitt.c
28
crc16ccitt.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* derived from crctester.c
|
||||
* derived from crctester.c 2011 by Nils Faerber <nils.faerber@kernelconcepts.de>
|
||||
* original header:
|
||||
* ----------------------------------------------------------------------------
|
||||
* CRC tester v1.3 written on 4th of February 2003 by Sven Reifegerste (zorc/reflex)
|
||||
|
@ -100,12 +100,19 @@ static unsigned long crctablefast (unsigned char* p, unsigned long len)
|
|||
|
||||
unsigned long crc = crcinit_direct;
|
||||
|
||||
if (refin) crc = reflect(crc, order);
|
||||
if (refin)
|
||||
crc = reflect(crc, order);
|
||||
|
||||
if (!refin) while (len--) crc = (crc << 8) ^ crctab[ ((crc >> (order-8)) & 0xff) ^ *p++];
|
||||
else while (len--) crc = (crc >> 8) ^ crctab[ (crc & 0xff) ^ *p++];
|
||||
if (!refin)
|
||||
while (len--)
|
||||
crc = (crc << 8) ^ crctab[ ((crc >> (order-8)) & 0xff) ^ *p++];
|
||||
else
|
||||
while (len--)
|
||||
crc = (crc >> 8) ^ crctab[ (crc & 0xff) ^ *p++];
|
||||
|
||||
if (refout^refin)
|
||||
crc = reflect(crc, order);
|
||||
|
||||
if (refout^refin) crc = reflect(crc, order);
|
||||
crc^= crcxor;
|
||||
crc&= crcmask;
|
||||
|
||||
|
@ -114,8 +121,8 @@ static unsigned long crctablefast (unsigned char* p, unsigned long len)
|
|||
|
||||
static unsigned long crctable (unsigned char* p, unsigned long len)
|
||||
{
|
||||
// normal lookup table algorithm with augmented zero bytes.
|
||||
// only usable with polynom orders of 8, 16, 24 or 32.
|
||||
/* normal lookup table algorithm with augmented zero bytes. */
|
||||
/* only usable with polynom orders of 8, 16, 24 or 32. */
|
||||
|
||||
unsigned long crc = crcinit_nondirect;
|
||||
|
||||
|
@ -138,6 +145,7 @@ static unsigned long crctable (unsigned char* p, unsigned long len)
|
|||
|
||||
if (refout^refin)
|
||||
crc = reflect(crc, order);
|
||||
|
||||
crc^= crcxor;
|
||||
crc&= crcmask;
|
||||
|
||||
|
@ -148,8 +156,8 @@ static unsigned long crctable (unsigned char* p, unsigned long len)
|
|||
|
||||
unsigned long crcbitbybit(unsigned char* p, unsigned long len) {
|
||||
|
||||
// bit by bit algorithm with augmented zero bytes.
|
||||
// does not use lookup table, suited for polynom orders between 1...32.
|
||||
/* bit by bit algorithm with augmented zero bytes. */
|
||||
/* does not use lookup table, suited for polynom orders between 1...32. */
|
||||
|
||||
unsigned long i, j, c, bit;
|
||||
unsigned long crc = crcinit_nondirect;
|
||||
|
@ -179,6 +187,7 @@ unsigned long crcbitbybit(unsigned char* p, unsigned long len) {
|
|||
|
||||
if (refout)
|
||||
crc=reflect(crc, order);
|
||||
|
||||
crc ^= crcxor;
|
||||
crc &= crcmask;
|
||||
|
||||
|
@ -365,3 +374,4 @@ int main() {
|
|||
return(0);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue