[hamradio-commits] [dump1090] 186/389: VK1ET: Shorten CRC calculation
Matthew Ernisse
mernisse-guest at moszumanska.debian.org
Wed Nov 5 00:19:53 UTC 2014
This is an automated email from the git hooks/post-receive script.
mernisse-guest pushed a commit to branch master
in repository dump1090.
commit 640d63a0d1472a3965f6f11dba70423dc5fb1f2b
Author: Malcolm Robb <Support at ATTAvionics.com>
Date: Tue May 21 12:54:34 2013 +0100
VK1ET: Shorten CRC calculation
We don't need to include the CRC itself one bit at a time. This shortens
the loop count by 24 iterations, so should be much faster
---
dump1090.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dump1090.c b/dump1090.c
index 9098987..55c5baf 100644
--- a/dump1090.c
+++ b/dump1090.c
@@ -1115,16 +1115,19 @@ uint32_t modesChecksum(unsigned char *msg, int bits) {
uint32_t * pCRCTable = &modes_checksum_table[offset];
int j;
+ // We don't really need to include the checksum itself
+ bits -= 24;
for(j = 0; j < bits; j++) {
if ((j & 7) == 0)
- {theByte = *msg++; rem = (rem << 8) | theByte;}
+ theByte = *msg++;
// If bit is set, xor with corresponding table entry.
if (theByte & 0x80) {crc ^= *pCRCTable;}
pCRCTable++;
theByte = theByte << 1;
}
- return ((crc ^ rem) & 0x00FFFFFF); // 24 bit checksum.
+ rem = (msg[0] << 16) | (msg[1] << 8) | msg[2]; // message checksum
+ return ((crc ^ rem) & 0x00FFFFFF); // 24 bit checksum syndrome.
}
//
// Given the Downlink Format (DF) of the message, return the message length in bits.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-hamradio/dump1090.git
More information about the pkg-hamradio-commits
mailing list