aboutsummaryrefslogtreecommitdiff
path: root/rs-common.h
diff options
context:
space:
mode:
authorBill Yi <byi@google.com>2015-06-23 13:53:11 -0700
committerBill Yi <byi@google.com>2015-06-23 13:53:11 -0700
commit4e213d510f437769f8a28578dd4f786fb7d16c44 (patch)
tree0d5cbd5a7eee87b3dca5820d282ef618a7e25991 /rs-common.h
downloadfec-4e213d510f437769f8a28578dd4f786fb7d16c44.tar.gz
Initial codenougat-mr1-arc
Diffstat (limited to 'rs-common.h')
-rw-r--r--rs-common.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/rs-common.h b/rs-common.h
new file mode 100644
index 0000000..e64eb39
--- /dev/null
+++ b/rs-common.h
@@ -0,0 +1,26 @@
+/* Stuff common to all the general-purpose Reed-Solomon codecs
+ * Copyright 2004 Phil Karn, KA9Q
+ * May be used under the terms of the GNU Lesser General Public License (LGPL)
+ */
+
+/* Reed-Solomon codec control block */
+struct rs {
+ int mm; /* Bits per symbol */
+ int nn; /* Symbols per block (= (1<<mm)-1) */
+ data_t *alpha_to; /* log lookup table */
+ data_t *index_of; /* Antilog lookup table */
+ data_t *genpoly; /* Generator polynomial */
+ int nroots; /* Number of generator roots = number of parity symbols */
+ int fcr; /* First consecutive root, index form */
+ int prim; /* Primitive element, index form */
+ int iprim; /* prim-th root of 1, index form */
+ int pad; /* Padding bytes in shortened block */
+};
+
+static inline int modnn(struct rs *rs,int x){
+ while (x >= rs->nn) {
+ x -= rs->nn;
+ x = (x >> rs->mm) + (x & rs->nn);
+ }
+ return x;
+}