[mndiff]: r149 - in trunk/noe: ldpc.c ldpc.h
Author: michael Date: Sun Apr 12 05:22:04 2009 New Revision: 149 Log: Optional support for fast to encode matrixes. Modified: trunk/noe/ldpc.c trunk/noe/ldpc.h Modified: trunk/noe/ldpc.c ============================================================================== --- trunk/noe/ldpc.c Sat Apr 11 23:42:47 2009 (r148) +++ trunk/noe/ldpc.c Sun Apr 12 05:22:04 2009 (r149) @@ -34,7 +34,7 @@ #define MAX_NZC 32 typedef struct LDPCContext{ - unsigned int (*parity_matrix)[2][MAX_NZC]; + int (*parity_matrix)[2][MAX_NZC]; int (*inv_matrix)[2]; int parity_len; int data_len; @@ -151,6 +151,8 @@ LDPCContext *EXT(initLDPC)(int data_len, memset(tab, 0, parity_len); for(j=0; j<nzc; j++){ int minrow=999999; + + if(i<data_len || seed>0){ for(y=0; y<parity_len; y++){ if(row[y] < minrow) minrow= row[y]; @@ -158,6 +160,13 @@ LDPCContext *EXT(initLDPC)(int data_len, do{ y= get_random(&kiss)%parity_len; }while(tab[y] || (row[y] > minrow + (SIZE == 2))); + }else{ + y= i + j - data_len; + if(y >= parity_len){ + c->parity_matrix[i][0][j] = -1; + continue; + } + } tab[y]=1; c->parity_matrix[i][0][j] = y; c->parity_matrix[i][1][j] = EXT(log)[get_random(&kiss)%(SIZE-1)+1]; @@ -222,8 +231,10 @@ int EXT(init_matrixLDPC)(LDPCContext *c, x= erasure_pos[i]; for(j=0; j<nzc; j++){ y= c->parity_matrix[x][0][j]; + if(y>=0){ inv_matrix[i + y*2*parity_len]= EXT(exp)[c->parity_matrix[x][1][j]]; row_weight[y]++; + } } col_weight[i]= nzc; } @@ -266,8 +277,10 @@ int EXT(decodeLDPC)(LDPCContext *c, LDPC unsigned int v= code[i]; for(j=0; j<c->nzc; j++){ int y= c->parity_matrix[i][0][j] + c->parity_len; + if(y>=c->parity_len){ int p= -EXT(exp)[c->parity_matrix[i][1][j]]; syndrom[y]^= p & v; + } } } @@ -288,8 +301,10 @@ int EXT(decodeLDPC)(LDPCContext *c, LDPC unsigned int v= EXT(log)[ code[i] ]; for(j=0; j<c->nzc; j++){ int y= c->parity_matrix[i][0][j] + c->parity_len; + if(y>=c->parity_len){ int p= c->parity_matrix[i][1][j]; syndrom[y]= sum(syndrom[y], EXT(exp)[p + v]); + } } } Modified: trunk/noe/ldpc.h ============================================================================== --- trunk/noe/ldpc.h Sat Apr 11 23:42:47 2009 (r148) +++ trunk/noe/ldpc.h Sun Apr 12 05:22:04 2009 (r149) @@ -26,6 +26,8 @@ struct LDPCContext; /** * + * @param seed if 0 then a matrix will be generated that can be encoded quicker + * at the expense of worse error recovery capabilities. * @param nzc number of non zero elements per column, 0 means choose automatically. */ struct LDPCContext *EXT(initLDPC)(int data_len, int parity_len, uint32_t seed, int nzc);
participants (1)
-
michael