[MN-dev] [mndiff]: r126 - trunk/noe/ldpc.c

michael subversion at mplayerhq.hu
Tue Nov 25 13:11:48 CET 2008


Author: michael
Date: Tue Nov 25 13:11:48 2008
New Revision: 126

Log:
Better parity matrix construction.


Modified:
   trunk/noe/ldpc.c

Modified: trunk/noe/ldpc.c
==============================================================================
--- trunk/noe/ldpc.c	(original)
+++ trunk/noe/ldpc.c	Tue Nov 25 13:11:48 2008
@@ -75,11 +75,17 @@ int inverse(ELEM *matrix, int width, int
 
 LDPCContext *EXT(initLDPC)(int data_len, int parity_len, uint32_t seed){
     LDPCContext *c= malloc(sizeof(LDPCContext));
+    int row[parity_len];
     KISSState kiss;
-    int i, j, y;
-    int nzc= noe_log2(parity_len)+1;
+    int i, j, y, nzc;
     int code_len= data_len + parity_len;
 
+    if     (parity_len < 16) nzc=3;
+    else if(parity_len < 32) nzc=4;
+    else if(parity_len < 64) nzc=5;
+    else if(parity_len <256) nzc=6;
+    else                     nzc=7;
+
     if(nzc > MAX_NZC)
         goto fail;
     assert(nzc <= parity_len);
@@ -89,16 +95,23 @@ LDPCContext *EXT(initLDPC)(int data_len,
     c->parity_matrix= malloc(code_len * sizeof(*c->parity_matrix));
     c->   inv_matrix= malloc(parity_len*parity_len * sizeof(*c->inv_matrix));
 
+    memset(row, 0, sizeof(row));
     for(i=0; i<code_len; i++){
         uint8_t tab[parity_len];
         memset(tab, 0, parity_len);
         for(j=0; j<nzc; j++){
+            int minrow=999999;
+            for(y=0; y<parity_len; y++){
+                if(row[y] < minrow)
+                    minrow= row[y];
+            }
             do{
                 y= get_random(&kiss)%parity_len;
-            }while(tab[y]);
+            }while(tab[y] || (row[y] > minrow));
             tab[y]=1;
             c->parity_matrix[i][0][j] = y;
             c->parity_matrix[i][1][j] = EXT(log)[get_random(&kiss)%(SIZE-1)+1];
+            row[y]++;
         }
     }
 #if 0



More information about the Mndiff-dev mailing list