[hamradio-commits] [dump1090] 93/389: Speed up Squawk Decode
Matthew Ernisse
mernisse-guest at moszumanska.debian.org
Wed Nov 5 00:19:44 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 96afd52cb072431a084f4bd14f3f32abf68a28e2
Author: Malcolm Robb <Support at ATTAvionics.com>
Date: Mon Apr 15 22:12:40 2013 +0100
Speed up Squawk Decode
Re-write to avoid multiple reads of the same memory variable.
---
dump1090.c | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/dump1090.c b/dump1090.c
index 1b2138c..b89c743 100644
--- a/dump1090.c
+++ b/dump1090.c
@@ -1112,21 +1112,26 @@ void decodeModesMessage(struct modesMessage *mm, unsigned char *msg) {
*
* For more info: http://en.wikipedia.org/wiki/Gillham_code */
{
- int a,b,c,d;
-
- a = ((msg[3] & 0x80) >> 5) |
- ((msg[2] & 0x02) >> 0) |
- ((msg[2] & 0x08) >> 3);
- b = ((msg[3] & 0x02) << 1) |
- ((msg[3] & 0x08) >> 2) |
- ((msg[3] & 0x20) >> 5);
- c = ((msg[2] & 0x01) << 2) |
- ((msg[2] & 0x04) >> 1) |
- ((msg[2] & 0x10) >> 4);
- d = ((msg[3] & 0x01) << 2) |
- ((msg[3] & 0x04) >> 1) |
- ((msg[3] & 0x10) >> 4);
- mm->identity = a*1000 + b*100 + c*10 + d;
+ int decIdentity = 0;
+ unsigned char rawIdentity;
+
+ rawIdentity = msg[2];
+ if (rawIdentity & 0x01) {decIdentity += 40;} // C4
+ if (rawIdentity & 0x02) {decIdentity += 2000;} // A2
+ if (rawIdentity & 0x04) {decIdentity += 20;} // C2
+ if (rawIdentity & 0x08) {decIdentity += 1000;} // A1
+ if (rawIdentity & 0x10) {decIdentity += 10;} // C1
+
+ rawIdentity = msg[3];
+ if (rawIdentity & 0x01) {decIdentity += 4;} // D4
+ if (rawIdentity & 0x02) {decIdentity += 400;} // B4
+ if (rawIdentity & 0x04) {decIdentity += 2;} // D2
+ if (rawIdentity & 0x08) {decIdentity += 200;} // B2
+ if (rawIdentity & 0x10) {decIdentity += 1;} // D1
+ if (rawIdentity & 0x20) {decIdentity += 100;} // B1
+ if (rawIdentity & 0x80) {decIdentity += 4000;} // A4
+
+ mm->identity = decIdentity;
}
/* DF 11 & 17: try to populate our ICAO addresses whitelist.
--
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