[MN-dev] [mndiff]: r194 - trunk/noe/ldpc.c
michael
subversion at mplayerhq.hu
Tue Jul 13 11:31:46 CEST 2010
Author: michael
Date: Tue Jul 13 11:31:45 2010
New Revision: 194
Log:
get rid of VLAs in ldpc.c
Modified:
trunk/noe/ldpc.c
Modified: trunk/noe/ldpc.c
==============================================================================
--- trunk/noe/ldpc.c Tue Jul 13 11:31:44 2010 (r193)
+++ trunk/noe/ldpc.c Tue Jul 13 11:31:45 2010 (r194)
@@ -41,6 +41,7 @@ typedef struct LDPCContext{
int data_len;
int nzc;
int (*op_table)[2];
+ int *temp;
}LDPCContext;
typedef uint8_t ELEM;
@@ -130,13 +131,17 @@ static int inverse(ELEM *matrix, int wid
LDPCContext *EXT(initLDPC)(int data_len, int parity_len, uint32_t seed, int nzc){
LDPCContext *c= malloc(sizeof(LDPCContext));
- int row_weight[parity_len];
+ int *row_weight;
KISSState kiss;
int i, j, y, min_weight;
int code_len= data_len + parity_len;
- uint8_t tab[parity_len];
+ uint8_t *tab;
int weight_hist[16];
+ c->temp= malloc(sizeof(*c->temp)*parity_len*2);
+ row_weight= c->temp;
+ tab = c->temp + parity_len;
+
if(nzc==0){
#if SIZE==2
if (parity_len < 16) nzc=3;
@@ -160,7 +165,7 @@ LDPCContext *EXT(initLDPC)(int data_len,
c->op_table = malloc(parity_len*(parity_len+1)/2 * sizeof(*c->op_table));
//FIXME could we in theory need more space?
- memset(row_weight, 0, sizeof(row_weight));
+ memset(row_weight, 0, sizeof(*row_weight)*parity_len);
memset(tab, 0, parity_len);
memset(weight_hist, 0, sizeof(weight_hist));
weight_hist[0]= parity_len;
@@ -240,10 +245,10 @@ int EXT(init_matrixLDPC)(LDPCContext *c,
int nzc= c->nzc;
int parity_len= c->parity_len;
ELEM *inv_matrix= calloc(parity_len*parity_len, sizeof(ELEM));
- unsigned int row_weight[parity_len];
- unsigned int col_weight[2*parity_len];
+ unsigned int *row_weight= c->temp;
+ unsigned int *col_weight= c->temp + parity_len;
- memset(row_weight, 0, sizeof(row_weight));
+ memset(row_weight, 0, sizeof(*row_weight)*parity_len);
for(i=0; i<erasure_count; i++){
x= erasure_pos[i];
@@ -281,9 +286,9 @@ int EXT(decodeLDPC)(LDPCContext *c, LDPC
int i,j;
int parity_len= c->parity_len;
int code_len= c->data_len + parity_len;
- unsigned int syndrom[2*c->parity_len];
+ unsigned int *syndrom= c->temp;
unsigned int *sp= &syndrom[c->parity_len];
- memset(syndrom, 0, sizeof(syndrom));
+ memset(syndrom, 0, sizeof(*syndrom)*parity_len*2);
for(i=0; i<erasure_count; i++)
code[ erasure_pos[i] ]= 0;
@@ -378,5 +383,6 @@ void EXT(freeLDPC)(LDPCContext *c){
free(c->parity_matrix);
free(c->inv_matrix);
free(c->op_table);
+ free(c->temp);
free(c);
}
More information about the Mndiff-dev
mailing list