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

michael subversion at mplayerhq.hu
Fri Apr 24 21:54:49 CEST 2009


Author: michael
Date: Fri Apr 24 21:54:49 2009
New Revision: 155

Log:
Calculate min_weight without scaning row_weight.

Modified:
   trunk/noe/ldpc.c

Modified: trunk/noe/ldpc.c
==============================================================================
--- trunk/noe/ldpc.c	Fri Apr 24 21:34:11 2009	(r154)
+++ trunk/noe/ldpc.c	Fri Apr 24 21:54:49 2009	(r155)
@@ -121,9 +121,10 @@ LDPCContext *EXT(initLDPC)(int data_len,
     LDPCContext *c= malloc(sizeof(LDPCContext));
     int row_weight[parity_len];
     KISSState kiss;
-    int i, j, y;
+    int i, j, y, min_weight;
     int code_len= data_len + parity_len;
     uint8_t tab[parity_len];
+    int weight_hist[16];
 
     if(nzc==0){
 #if SIZE==2
@@ -149,15 +150,15 @@ LDPCContext *EXT(initLDPC)(int data_len,
 
     memset(row_weight, 0, sizeof(row_weight));
     memset(tab, 0, parity_len);
+    memset(weight_hist, 0, sizeof(weight_hist));
+    weight_hist[0]= parity_len;
+    min_weight    = 0;
+
     for(i=0; i<code_len; i++){
         for(j=0; j<nzc; j++){
-            int min_weight=999999;
-
             if(i<data_len || seed>0){
-                for(y=0; y<parity_len; y++){
-                    if(row_weight[y] < min_weight)
-                        min_weight= row_weight[y];
-                }
+                while(!weight_hist[min_weight&15])
+                    min_weight++;
             do{
                 y= get_random(&kiss)%parity_len;
             }while(tab[y] || (row_weight[y] > min_weight + (SIZE == 2)));
@@ -171,7 +172,9 @@ LDPCContext *EXT(initLDPC)(int data_len,
             tab[y]=1;
             c->parity_matrix[i][0][j] = y;
             c->parity_matrix[i][1][j] = EXT(log)[get_random(&kiss)%(SIZE-1)+1];
+            weight_hist[ row_weight[y]&15 ]--;
             row_weight[y]++;
+            weight_hist[ row_weight[y]&15 ]++;
         }
         for(j=0; j<nzc; j++)
             tab[ c->parity_matrix[i][0][j] ]= 0;



More information about the Mndiff-dev mailing list