[MN-dev] [mndiff]: r101 - in trunk/noe: galois.c galois.h galois_internal.h gfft.c mina.c noe.c rs.c rs.h test.c

michael subversion at mplayerhq.hu
Wed Oct 22 03:02:15 CEST 2008


Author: michael
Date: Wed Oct 22 03:02:15 2008
New Revision: 101

Log:
Split public from private headers and their innards a little clearer.


Added:
   trunk/noe/galois_internal.h
      - copied, changed from r100, /trunk/noe/galois.h
Modified:
   trunk/noe/galois.c
   trunk/noe/galois.h
   trunk/noe/gfft.c
   trunk/noe/mina.c
   trunk/noe/noe.c
   trunk/noe/rs.c
   trunk/noe/rs.h
   trunk/noe/test.c

Modified: trunk/noe/galois.c
==============================================================================
--- trunk/noe/galois.c	(original)
+++ trunk/noe/galois.c	Wed Oct 22 03:02:15 2008
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include "noe_internal.h"
-#include "galois.h"
+#include "galois_internal.h"
 #include "gfft.h"
 
 GFF4Element EXT(exp)[4*SIZE];

Modified: trunk/noe/galois.h
==============================================================================
--- trunk/noe/galois.h	(original)
+++ trunk/noe/galois.h	Wed Oct 22 03:02:15 2008
@@ -1,5 +1,5 @@
 /*
- *   Copyright (C) 2002 Michael Niedermayer <michaelni at gmx.at>
+ *   Copyright (C) 2002-2008 Michael Niedermayer <michaelni at gmx.at>
  *
  *   This program is free software; you can redistribute it and/or modify
  *   it under the terms of the GNU General Public License as published by
@@ -16,95 +16,13 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#if SIZE == 0x100
-#define PRIMITIVE_ELEMENT 2
-#define SHIFT 8
-#define M 0x11D
-#define EXT(name) noe_ ## name ## _100
-#define ADD_OP ^=
-#elif SIZE == 0x10001
-#define PRIMITIVE_ELEMENT 3
-#define SHIFT 16
-#define M 0
-#define EXT(name) noe_ ## name ## _10001
-#define ADD_OP +=
-#elif SIZE == 0x101
-#define PRIMITIVE_ELEMENT 3
-#define SHIFT 8
-#define M 0
-#define EXT(name) noe_ ## name ## _101
-#define ADD_OP +=
-#else
-#error wrong SIZE
-#endif
-
-#define MINUS1 (SIZE-1)
-#define MASK ((1<<SHIFT)-1)
+#ifndef NOE_GALOIS_H
 
 typedef unsigned int GFF4Element;
 
-extern GFF4Element EXT(exp)[4*SIZE];
-extern GFF4Element EXT(log)[SIZE];
-
-void EXT(prodPoly)(GFF4Element *dst, GFF4Element *src1, GFF4Element *src2);
-void EXT(partialProdPoly)(GFF4Element *dst, GFF4Element *src1, GFF4Element *src2, int order);
-void EXT(init)();
-void EXT(printPoly)(GFF4Element *src);
-void EXT(getDerivative)(GFF4Element *dst, GFF4Element *src);
-GFF4Element EXT(evalPoly)(GFF4Element *src, GFF4Element x);
-void EXT(synthPoly)(GFF4Element *dst, int *src, int count);
-#ifdef ALTERNATIVE_SOLVERS
-void EXT(divPoly)(GFF4Element *quot, GFF4Element *rem, GFF4Element *nom, GFF4Element *denom);
-void EXT(diffPoly)(GFF4Element *dst, GFF4Element *src1, GFF4Element *src2);
-void EXT(sumPoly)(GFF4Element *dst, GFF4Element *src1, GFF4Element *src2);
-#endif
-void EXT(getOrder)(GFF4Element *src);
-#ifdef ALTERNATIVE_SOLVERS
-void EXT(scaledSumPoly)(GFF4Element *dst, GFF4Element *src1, GFF4Element *src2, GFF4Element f, int s);
-void EXT(prodMatrix)(GFF4Element *d1[2], GFF4Element *d2[2], GFF4Element *s1[2], GFF4Element *s2[2]);
-#endif
-int noe_log2(unsigned int v);
-
-static inline GFF4Element reduce(GFF4Element a){
-#if M==0
-    a = (a&MASK) - (a>>SHIFT);
-    a += (((int)a)>>31)&SIZE;
-#endif
-    return a;
-}
-
-static inline GFF4Element prod(GFF4Element a, GFF4Element b){
-#if M!=0 || SIZE < 0x500
-    return EXT(exp)[EXT(log)[a] + EXT(log)[b]];
-#else
-    if(a==MINUS1)  return -b + ((((int)-b)>>31)&SIZE);
-    else           return reduce(a*b);
-#endif
-}
-
-static inline GFF4Element diff(GFF4Element a, GFF4Element b){
-#if M!=0
-    return a^b;
-#else
-    a -= b;
-    return a + ((((int)a)>>31)&SIZE);
-#endif
-}
-
-#if M!=0
-#define neg(a) (a)
-#else
-#define neg(a) (SIZE - (a))
-#endif
-
-#define sum(a,b) diff(a,neg(b))
-
-static inline GFF4Element inv(GFF4Element a){
-    assert(a!=0);
-
-    return (EXT(exp)+MINUS1)[- (signed)EXT(log)[a]];
-}
+void noe_init_100();
+void noe_init_101();
+void noe_init_10001();
 
-#define SET_POLY0(dst, coeff0) (dst)[0]=0; (dst)[1]=coeff0;
-#define SET_POLY1(dst, coeff0, coeff1) (dst)[0]=1; (dst)[1]=coeff0; (dst)[2]=coeff1;
-#define SET_POLY2(dst, coeff0, coeff1, coeff2) (dst)[0]=2; (dst)[1]=coeff0; (dst)[2]=coeff1; (dst)[3]=coeff2;
+#define NOE_GALOIS_H
+#endif
\ No newline at end of file

Copied: trunk/noe/galois_internal.h (from r100, /trunk/noe/galois.h)
==============================================================================
--- /trunk/noe/galois.h	(original)
+++ trunk/noe/galois_internal.h	Wed Oct 22 03:02:15 2008
@@ -16,6 +16,8 @@
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
+#include "galois.h"
+
 #if SIZE == 0x100
 #define PRIMITIVE_ELEMENT 2
 #define SHIFT 8
@@ -41,14 +43,11 @@
 #define MINUS1 (SIZE-1)
 #define MASK ((1<<SHIFT)-1)
 
-typedef unsigned int GFF4Element;
-
 extern GFF4Element EXT(exp)[4*SIZE];
 extern GFF4Element EXT(log)[SIZE];
 
 void EXT(prodPoly)(GFF4Element *dst, GFF4Element *src1, GFF4Element *src2);
 void EXT(partialProdPoly)(GFF4Element *dst, GFF4Element *src1, GFF4Element *src2, int order);
-void EXT(init)();
 void EXT(printPoly)(GFF4Element *src);
 void EXT(getDerivative)(GFF4Element *dst, GFF4Element *src);
 GFF4Element EXT(evalPoly)(GFF4Element *src, GFF4Element x);

Modified: trunk/noe/gfft.c
==============================================================================
--- trunk/noe/gfft.c	(original)
+++ trunk/noe/gfft.c	Wed Oct 22 03:02:15 2008
@@ -22,7 +22,7 @@
 #include <string.h>
 
 #include "noe_internal.h"
-#include "galois.h"
+#include "galois_internal.h"
 #include "gfft.h"
 
 uint8_t noe_revTable[256];

Modified: trunk/noe/mina.c
==============================================================================
--- trunk/noe/mina.c	(original)
+++ trunk/noe/mina.c	Wed Oct 22 03:02:15 2008
@@ -23,6 +23,7 @@
 #include <assert.h>
 
 #define SIZE 0x10001
+#define SHIFT 16
 #include "galois.h"
 #include "rs.h"
 
@@ -129,7 +130,7 @@ int main(int argc, char* argv[]){
     int erasure_list_len=0;
     int verbose= 0;
 
-    EXT(init)();
+    noe_init_10001();
 
     if(argc < 2 || argc > 3)
         help();
@@ -261,7 +262,7 @@ printf("%d %d %d\n", n, k, n-k);
                     }
                 }
 
-                e= EXT(rsDecode)(code, erased, erasureLocator, erasedCount, n-k, SHIFT);
+                e= noe_rsDecode_10001(code, erased, erasureLocator, erasedCount, n-k, SHIFT);
                 if(e<0){
                     fprintf(stderr, "reed solomon decoding error\n");
                     return 9;
@@ -270,10 +271,10 @@ printf("%d %d %d\n", n, k, n-k);
                 }
             }else{
                 code[k-1]=0;
-                EXT(rsEncode)(code, parityLocator, n-k, SHIFT);
+                noe_rsEncode_10001(code, parityLocator, n-k, SHIFT);
             }
 
-            if(EXT(rsTransform)(code, parityLocator, n-k, tPoly, k-1, !decode, SHIFT) < 0){
+            if(noe_rsTransform_10001(code, parityLocator, n-k, tPoly, k-1, !decode, SHIFT) < 0){
                 fprintf(stderr, "transform failure\n");
                 return 6;
             }

Modified: trunk/noe/noe.c
==============================================================================
--- trunk/noe/noe.c	(original)
+++ trunk/noe/noe.c	Wed Oct 22 03:02:15 2008
@@ -25,6 +25,10 @@
 #include "rw.h"
 #include "bytestream.h"
 
+#define SIZE 0x10001
+#define SHIFT 16
+
+
 static const uint8_t startcode[8]={0xAB, 0x2C, 0xE2, 0x47, 0x15, 'N', 'O', 'E'};
 //#define STARTCODE (0xAB2CE24715000000ULL + ('N'<<16) + ('O'<<8) + 'E')
 #define STARTCODE_THRESHOLD 6
@@ -146,7 +150,7 @@ static int decode_header(NoeContext *n, 
         code[k+i]= get_c(&bs, 2);
     }
 
-    if(EXT(rsDecode)(code, erased, erasedCount, HEADER_PARITY_LENGTH) < 0)
+    if(noe_rsDecode_10001(code, erased, erasedCount, HEADER_PARITY_LENGTH) < 0)
         return -1;
 
     for(i=HEADER_DATA_LENGTH; i<k; i++){
@@ -388,7 +392,7 @@ static int correct(NoeContext *n, noe_Rw
                 code[cw_id - first_cw][cw_pos]= 256*buffer[pos] + buffer[pos+1];
             }
         }
-        if(EXT(rsDecode)(code, NULL/*erased*/, erasedCount, n->parityCount) < 0)
+        if(noe_rsDecode_10001(code, NULL/*erased*/, erasedCount, n->parityCount) < 0)
             uncorrectable++;
 
 //        write data

Modified: trunk/noe/rs.c
==============================================================================
--- trunk/noe/rs.c	(original)
+++ trunk/noe/rs.c	Wed Oct 22 03:02:15 2008
@@ -23,7 +23,7 @@
 #include <string.h>
 
 #include "noe_internal.h"
-#include "galois.h"
+#include "galois_internal.h"
 #include "rs.h"
 #include "gfft.h"
 

Modified: trunk/noe/rs.h
==============================================================================
--- trunk/noe/rs.h	(original)
+++ trunk/noe/rs.h	Wed Oct 22 03:02:15 2008
@@ -17,8 +17,8 @@
  */
 
 /**
- *
- * @Note, EXT(init)() has to be called before using any functions from this file.
+ * Public header for reed solomon decoding.
+ * @Note, noe_init_*() has to be called before using any functions from this file.
  */
 
 /**
@@ -27,7 +27,9 @@
  * @param syn the syndrom polynom will be stored here
  * @param codeBits log2(codeSize)
  */
-void EXT(getSyndrom)(GFF4Element *syn, GFF4Element *src, int order, int codeBits);
+void noe_getSyndrom_100(GFF4Element *syn, GFF4Element *src, int order, int codeBits);
+void noe_getSyndrom_101(GFF4Element *syn, GFF4Element *src, int order, int codeBits);
+void noe_getSyndrom_10001(GFF4Element *syn, GFF4Element *src, int order, int codeBits);
 
 /**
  * Appends parity symbols to data to make the whole a Reed Solomon codeword.
@@ -41,7 +43,9 @@ void EXT(getSyndrom)(GFF4Element *syn, G
  * @param codeBits log2(codeSize), must be equal to n for GF(2^n) based codes currently,
  *        this may change though.
  */
-void EXT(rsEncode)(GFF4Element *data, GFF4Element *parityLocator, int parityCount, int codeBits);
+void noe_rsEncode_100(GFF4Element *data, GFF4Element *parityLocator, int parityCount, int codeBits);
+void noe_rsEncode_101(GFF4Element *data, GFF4Element *parityLocator, int parityCount, int codeBits);
+void noe_rsEncode_10001(GFF4Element *data, GFF4Element *parityLocator, int parityCount, int codeBits);
 
 /**
  * Corrects some data using a Reed Solomon code.
@@ -57,7 +61,9 @@ void EXT(rsEncode)(GFF4Element *data, GF
  *        this may change though.
  * @returns the number of corrected symbols or a negative value in case of a uncorrectable error.
  */
-int EXT(rsDecode)(GFF4Element *data, int *erased, GFF4Element *erassureLocator, int erasedCount, int parityCount, int codeBits);
+int noe_rsDecode_100(GFF4Element *data, int *erased, GFF4Element *erassureLocator, int erasedCount, int parityCount, int codeBits);
+int noe_rsDecode_101(GFF4Element *data, int *erased, GFF4Element *erassureLocator, int erasedCount, int parityCount, int codeBits);
+int noe_rsDecode_10001(GFF4Element *data, int *erased, GFF4Element *erassureLocator, int erasedCount, int parityCount, int codeBits);
 
 /**
  * Transforms (or inverse transforms) a Reed Solomon code based on GF(fermat prime) so that
@@ -82,4 +88,4 @@ int EXT(rsDecode)(GFF4Element *data, int
  * @param encode 1 for the transform to avoid the largest symbols, 0 to reverse it.
  * @returns 0 if success or a negative value in case of an error.
  */
-int EXT(rsTransform)(GFF4Element *data, GFF4Element *parityLocator, int parityCount, GFF4Element *tPoly, int tLocation, int encode, int codeBits);
+int noe_rsTransform_10001(GFF4Element *data, GFF4Element *parityLocator, int parityCount, GFF4Element *tPoly, int tLocation, int encode, int codeBits);

Modified: trunk/noe/test.c
==============================================================================
--- trunk/noe/test.c	(original)
+++ trunk/noe/test.c	Wed Oct 22 03:02:15 2008
@@ -24,7 +24,7 @@
 #include <string.h>
 
 #include "noe_internal.h"
-#include "galois.h"
+#include "galois_internal.h"
 #include "gfft.h"
 #include "rs.h"
 #include "bytestream.h"



More information about the Mndiff-dev mailing list