Merge commit 'v3.3.0' into upstream
[debian/gnuradio] / gnuradio-core / src / lib / reed-solomon / decode_rs_ccsds.c
diff --git a/gnuradio-core/src/lib/reed-solomon/decode_rs_ccsds.c b/gnuradio-core/src/lib/reed-solomon/decode_rs_ccsds.c
new file mode 100644 (file)
index 0000000..2543d3a
--- /dev/null
@@ -0,0 +1,27 @@
+/* This function wraps around the fixed 8-bit decoder, performing the
+ * basis transformations necessary to meet the CCSDS standard
+ *
+ * Copyright 2002, Phil Karn, KA9Q
+ * May be used under the terms of the GNU General Public License (GPL)
+ */
+#define FIXED 1
+#include "fixed.h"
+#include "ccsds.h"
+
+int decode_rs_ccsds(unsigned char *data,int *eras_pos,int no_eras){
+  int i,r;
+  unsigned char cdata[NN];
+
+  /* Convert data from dual basis to conventional */
+  for(i=0;i<NN;i++)
+    cdata[i] = Tal1tab[data[i]];
+
+  r = decode_rs_8(cdata,eras_pos,no_eras);
+
+  if(r > 0){
+    /* Convert from conventional to dual basis */
+    for(i=0;i<NN;i++)
+      data[i] = Taltab[cdata[i]];
+  }
+  return r;
+}