[MN-dev] [mndiff]: r147 - in trunk/noe: Makefile ldpc.c test_ldpc.c

michael subversion at mplayerhq.hu
Sat Apr 11 23:19:18 CEST 2009


Author: michael
Date: Sat Apr 11 23:19:18 2009
New Revision: 147

Log:
First try of LDPC over GF(2)

Modified:
   trunk/noe/Makefile
   trunk/noe/ldpc.c
   trunk/noe/test_ldpc.c

Modified: trunk/noe/Makefile
==============================================================================
--- trunk/noe/Makefile	Sat Apr 11 20:40:24 2009	(r146)
+++ trunk/noe/Makefile	Sat Apr 11 23:19:18 2009	(r147)
@@ -20,12 +20,16 @@ CFLAGS  = -g -Wall -O4 $(OPTFLAGS) -I. $
 %_10001.o: %.c
 	$(CC) $(CFLAGS) -c -DSIZE=0x10001 -o $@ $<
 
-all: test_100 test_101 test_10001 mina test_ldpc_100
+%_2.o: %.c
+	$(CC) $(CFLAGS) -c -DSIZE=2 -o $@ $<
+
+all: test_100 test_101 test_10001 mina test_ldpc_100 test_ldpc_2
 
 libnoe_100.a: $(LIBOBJS:.o=_100.o) ldpc_100.o
 libnoe_101.a: $(LIBOBJS:.o=_101.o) gfft_101.o
 libnoe_10001.a: $(LIBOBJS:.o=_10001.o) gfft_10001.o
-libnoe_100.a libnoe_101.a libnoe_10001.a:
+libnoe_2.a: galois_2.o ldpc_2.o
+libnoe_100.a libnoe_101.a libnoe_10001.a libnoe_2.a:
 	$(AR) rc $@ $^
 
 mina: mina.o libnoe_10001.a

Modified: trunk/noe/ldpc.c
==============================================================================
--- trunk/noe/ldpc.c	Sat Apr 11 20:40:24 2009	(r146)
+++ trunk/noe/ldpc.c	Sat Apr 11 23:19:18 2009	(r147)
@@ -124,11 +124,16 @@ LDPCContext *EXT(initLDPC)(int data_len,
     int code_len= data_len + parity_len;
 
     if(nzc==0){
+#if SIZE==2
+        if     (parity_len < 16) nzc=3;
+        else                     nzc=5;
+#else
         if     (parity_len < 16) nzc=4;
         else if(parity_len < 32) nzc=5;
         else if(parity_len < 64) nzc=5;
         else if(parity_len <256) nzc=6;
         else                     nzc=6;
+#endif
     }
 
     if(nzc > MAX_NZC || nzc > parity_len)
@@ -152,7 +157,7 @@ LDPCContext *EXT(initLDPC)(int data_len,
             }
             do{
                 y= get_random(&kiss)%parity_len;
-            }while(tab[y] || (row[y] > minrow));
+            }while(tab[y] || (row[y] > minrow + (SIZE == 2)));
             tab[y]=1;
             c->parity_matrix[i][0][j] = y;
             c->parity_matrix[i][1][j] = EXT(log)[get_random(&kiss)%(SIZE-1)+1];
@@ -232,7 +237,11 @@ int EXT(init_matrixLDPC)(LDPCContext *c,
         for(i=0; i<parity_len*2; i++){
             if(i != j && inv_matrix[i + j*2*parity_len]){
                 c->inv_matrix[x  ][0]= i;
+#if SIZE == 2
+                c->inv_matrix[x++][1]= -inv_matrix[i + j*2*parity_len];
+#else
                 c->inv_matrix[x++][1]= EXT(log)[inv_matrix[i + j*2*parity_len]];
+#endif
             }
         }
         c->inv_matrix[x++][0]= 2*parity_len;
@@ -252,6 +261,29 @@ int EXT(decodeLDPC)(LDPCContext *c, uint
     for(i=0; i<erasure_count; i++)
         code[ erasure_pos[i] ]= 0;
 
+#if SIZE == 2
+    for(i=0; i<code_len; i++){
+        GFF4Element v= code[i];
+        for(j=0; j<c->nzc; j++){
+            int y= c->parity_matrix[i][0][j] + c->parity_len;
+            int p= -EXT(exp)[c->parity_matrix[i][1][j]];
+            syndrom[y]^= p & v;
+        }
+    }
+
+    j=0;
+    for(i=erasure_count-1; i>=0; i--){
+        GFF4Element v=0;
+        int idx= c->inv_matrix[j][0];
+        while(idx<2*parity_len){
+            v^= syndrom[idx] & c->inv_matrix[j++][1];
+            idx= c->inv_matrix[j][0];
+        }
+        j++;
+        syndrom[i] = v;
+        code[ erasure_pos[i] ]= v;
+    }
+#else
     for(i=0; i<code_len; i++){
         GFF4Element v= EXT(log)[ code[i] ];
         for(j=0; j<c->nzc; j++){
@@ -276,6 +308,7 @@ int EXT(decodeLDPC)(LDPCContext *c, uint
         syndrom[i] = EXT(log)[ v ];
         code[ erasure_pos[i] ]= v;
     }
+#endif
 
     return 0;
 }

Modified: trunk/noe/test_ldpc.c
==============================================================================
--- trunk/noe/test_ldpc.c	Sat Apr 11 20:40:24 2009	(r146)
+++ trunk/noe/test_ldpc.c	Sat Apr 11 23:19:18 2009	(r147)
@@ -58,7 +58,7 @@ int main(){
 
             dec= EXT(initLDPC)(data_len, parity_len, seed, reliable ? 0 : 3);
 
-            for(erasure_count= reliable ? parity_len-1 : parity_len*3/4; ; erasure_count--){
+            for(erasure_count= reliable ? parity_len-(SIZE==2 ? 4 : 1) : parity_len*3/4; ; erasure_count--){
                 int fail=0;
                 for(try=0; try<10; try++){
                     uint8_t code[code_len], code_bak[code_len];



More information about the Mndiff-dev mailing list