]> Joshua Wise's Git repositories - netwatch.git/commitdiff
Modify crc32 users to behave better when crcing multiple things into one CRC.
authorJoshua Wise <joshua@rebirth.joshuawise.com>
Mon, 15 Dec 2008 00:25:18 +0000 (19:25 -0500)
committerJoshua Wise <joshua@rebirth.joshuawise.com>
Mon, 15 Dec 2008 00:25:18 +0000 (19:25 -0500)
include/crc32.h
lib/crc32.c
video/generic.c
video/text.c

index f7d568a2a4b4d4b5c232d6c534c1ac0ef2451dde..a384bcc93cc58524b029a0eb4426dc93c90ecb32 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <stdint.h>
 
-extern uint32_t crc32(unsigned char *buf, int len);
+extern uint32_t crc32(unsigned char *buf, int len, uint32_t crc0);
 extern void crc32_init();
 
 #endif
index fd7bd49dbac871ba0c81c019c0e88a80f9dec189..43f9d7a876ad1dee6818f4b85b56f7861d86af4d 100644 (file)
@@ -5,15 +5,15 @@
 
 uint32_t crc32_table[256];
 
-uint32_t crc32(uint8_t *buf, int len)
+uint32_t crc32(uint8_t *buf, int len, uint32_t crc0)
 {
        uint8_t *p;
        uint32_t crc;
 
-       crc = 0xffffffff;       /* preload shift register, per CRC-32 spec */
+       crc = crc0;
        for (p = buf; len > 0; ++p, --len)
                crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p];
-       return ~crc;        /* transmit complement, per CRC-32 spec */
+       return crc;
 }
 
 /*
index 8c6866d4bcad7ea9a65d1b4c8e13d95057ab5df4..95f564f470b3d9893dcefd27f1c2cf0c75c18eb0 100644 (file)
@@ -17,7 +17,7 @@ uint32_t checksum_rect_generic32(int x, int y, int width, int height) {
         for (i = 0; i < height; i++) {
                 lineaddr = fb->fbaddr + (i + y) * scanline + (4 * x);
 
-                sum ^= crc32(lineaddr, width * 4);
+                sum = crc32(lineaddr, width * 4, sum);
         }
 
         return sum;
index 25fe245dec4a551cb9d144cac9eb09f9b751afb9..7fe30c952e3a436ef0a01720c955450838dec2e0 100644 (file)
@@ -91,7 +91,7 @@ uint32_t text_checksum(int x, int y, int w, int h)
                cx = x;
                texty = cy / 14;
                textx = cx / 9;
-               cksm ^= crc32(video + texty * 160 + textx * 2, (w / 9 + 1) * 2);        /* Err on the side of 'too many'. */
+               cksm = crc32(video + texty * 160 + textx * 2, (w / 9) * 2 + 2, cksm);   /* Err on the side of 'too many'. */
        }
        
        smram_restore_state(old_state);
This page took 0.027355 seconds and 4 git commands to generate.