[NUT-devel] [NUT] (ods15): r111 - /trunk/libnut/priv.h

syncmail at mplayerhq.hu syncmail at mplayerhq.hu
Fri Mar 17 12:55:46 CET 2006


Author: ods15
Date: Fri Mar 17 12:55:46 2006
New Revision: 111

Log:
use a small LUT crc, probably faster, doesn't really matter

Modified:
    trunk/libnut/priv.h

Modified: trunk/libnut/priv.h
==============================================================================
--- trunk/libnut/priv.h (original)
+++ trunk/libnut/priv.h Fri Mar 17 12:55:46 2006
@@ -159,11 +159,17 @@
 };
 
 static inline uint32_t crc32(uint8_t * buf, int len){
-	int32_t crc = 0;
-	int i;
+	static const uint32_t table[16] = {
+		0x00000000, 0x04C11DB7, 0x09823B6E, 0x0D4326D9,
+		0x130476DC, 0x17C56B6B, 0x1A864DB2, 0x1E475005,
+		0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6, 0x2B4BCB61,
+		0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,
+	};
+	uint32_t crc = 0;
 	while (len--) {
 		crc ^= *buf++ << 24;
-		for(i = 0; i < 8; i++) crc = (crc<<1) ^ (0x04C11DB7 & (crc>>31));
+		crc = (crc<<4) ^ table[crc>>28];
+		crc = (crc<<4) ^ table[crc>>28];
 	}
 	return crc;
 }




More information about the NUT-devel mailing list