[MN-dev] [mndiff]: r148 - in trunk/noe: ldpc.c ldpc.h test_ldpc.c
michael
subversion at mplayerhq.hu
Sat Apr 11 23:42:47 CEST 2009
Author: michael
Date: Sat Apr 11 23:42:47 2009
New Revision: 148
Log:
Work with 32bits at a time for GF(2) LDPC, 4x faster.
Modified:
trunk/noe/ldpc.c
trunk/noe/ldpc.h
trunk/noe/test_ldpc.c
Modified: trunk/noe/ldpc.c
==============================================================================
--- trunk/noe/ldpc.c Sat Apr 11 23:19:18 2009 (r147)
+++ trunk/noe/ldpc.c Sat Apr 11 23:42:47 2009 (r148)
@@ -35,7 +35,7 @@
typedef struct LDPCContext{
unsigned int (*parity_matrix)[2][MAX_NZC];
- GFF4Element (*inv_matrix)[2];
+ int (*inv_matrix)[2];
int parity_len;
int data_len;
int nzc;
@@ -251,11 +251,11 @@ int EXT(init_matrixLDPC)(LDPCContext *c,
return rank - erasure_count;
}
-int EXT(decodeLDPC)(LDPCContext *c, uint8_t *code, int erasure_count, int erasure_pos[]){
+int EXT(decodeLDPC)(LDPCContext *c, LDPC_ELEM *code, int erasure_count, int erasure_pos[]){
int i,j;
int parity_len= c->parity_len;
int code_len= c->data_len + parity_len;
- GFF4Element syndrom[2*c->parity_len];
+ unsigned int syndrom[2*c->parity_len];
memset(syndrom, 0, sizeof(syndrom));
for(i=0; i<erasure_count; i++)
@@ -263,7 +263,7 @@ int EXT(decodeLDPC)(LDPCContext *c, uint
#if SIZE == 2
for(i=0; i<code_len; i++){
- GFF4Element v= code[i];
+ unsigned int 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]];
@@ -273,7 +273,7 @@ int EXT(decodeLDPC)(LDPCContext *c, uint
j=0;
for(i=erasure_count-1; i>=0; i--){
- GFF4Element v=0;
+ unsigned int v=0;
int idx= c->inv_matrix[j][0];
while(idx<2*parity_len){
v^= syndrom[idx] & c->inv_matrix[j++][1];
@@ -285,7 +285,7 @@ int EXT(decodeLDPC)(LDPCContext *c, uint
}
#else
for(i=0; i<code_len; i++){
- GFF4Element v= EXT(log)[ code[i] ];
+ 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;
int p= c->parity_matrix[i][1][j];
@@ -298,7 +298,7 @@ int EXT(decodeLDPC)(LDPCContext *c, uint
j=0;
for(i=erasure_count-1; i>=0; i--){
- GFF4Element v=0;
+ unsigned int v=0;
int idx= c->inv_matrix[j][0];
while(idx<2*parity_len){
v= sum(v, EXT(exp)[syndrom[idx] + c->inv_matrix[j++][1]]);
Modified: trunk/noe/ldpc.h
==============================================================================
--- trunk/noe/ldpc.h Sat Apr 11 23:19:18 2009 (r147)
+++ trunk/noe/ldpc.h Sat Apr 11 23:42:47 2009 (r148)
@@ -18,6 +18,12 @@
struct LDPCContext;
+#if SIZE==2
+ typedef uint32_t LDPC_ELEM;
+#else
+ typedef uint8_t LDPC_ELEM;
+#endif
+
/**
*
* @param nzc number of non zero elements per column, 0 means choose automatically.
@@ -38,6 +44,6 @@ int EXT(init_matrixLDPC)(struct LDPCCont
* @param erasure_count must match what has been passed to init_matrixLDPC
* @param erasure_pos must match what has been passed to init_matrixLDPC
*/
-int EXT(decodeLDPC)(struct LDPCContext *c, uint8_t *code, int erasure_count, int erasure_pos[]);
+int EXT(decodeLDPC)(struct LDPCContext *c, LDPC_ELEM *code, int erasure_count, int erasure_pos[]);
void EXT(freeLDPC)(struct LDPCContext *c);
Modified: trunk/noe/test_ldpc.c
==============================================================================
--- trunk/noe/test_ldpc.c Sat Apr 11 23:19:18 2009 (r147)
+++ trunk/noe/test_ldpc.c Sat Apr 11 23:42:47 2009 (r148)
@@ -61,13 +61,13 @@ int main(){
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];
+ LDPC_ELEM code[code_len], code_bak[code_len];
int erasure_pos[erasure_count];
for(i=0; i<data_len; i++)
code[i]= code_bak[i]= get_random(&kiss);
EXT(decodeLDPC)(enc, code, parity_len, parity_pos);
- memcpy(code_bak+data_len, code+data_len, parity_len);
+ memcpy(code_bak+data_len, code+data_len, parity_len * sizeof(*code));
for(i=0; i<code_len; i++)
if(code[i] != code_bak[i])
fprintf(stderr, "FATALXX error %X!= %X at %d\n", code[i], code_bak[i], i);
@@ -76,7 +76,7 @@ int main(){
do{
x= get_random(&kiss) % code_len;
}while(code[x] != code_bak[x]);
- code[x]+= get_random(&kiss)%255+1;
+ code[x]+= get_random(&kiss)%(8*sizeof(LDPC_ELEM)-1)+1;
erasure_pos[i]= x;
}
More information about the Mndiff-dev
mailing list