added error counting to golay
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 22 Mar 2013 22:36:24 +0000 (22:36 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Fri, 22 Mar 2013 22:36:24 +0000 (22:36 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@1222 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/src/golay23.c
codec2-dev/src/golay23.h

index e325786a1c5f0f2eab792d803383bd64e867e347..84d4c28151e3ef2156745024df19fd903d0d6799 100644 (file)
@@ -267,6 +267,21 @@ int golay23_decode(int received_codeword) {
     return received_codeword ^= decoding_table[get_syndrome(received_codeword)];
 }
 
+int golay23_count_errors(int recd_codeword, int corrected_codeword)
+{
+    int errors = 0;
+    int diff, i;
+
+    diff = recd_codeword ^ corrected_codeword;
+    for(i=0; i<23; i++) {
+        if (diff & 0x1)
+            errors++;
+        diff >>= 1;
+    }
+
+    return errors;
+}
+
 #ifdef GOLAY23_UNITTEST
 
 static int golay23_test(int error_pattern) {
index 8ea6f80eaeb6feb39f4fbed5802523d3a817736c..a916d29f0fd48ca92e73163671af2274a2c2677c 100644 (file)
@@ -35,6 +35,7 @@ extern "C" {
 void golay23_init(void);
 int  golay23_encode(int data);
 int  golay23_decode(int received_codeword);
+int  golay23_count_errors(int recd_codeword, int corrected_codeword);
 
 #ifdef __cplusplus
 }