fec.c File Reference

Forward error correction based on Vandermonde matrices
980624
(C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it). More...

#include "defines.h"
#include "fec.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>

Include dependency graph for fec.c:

Go to the source code of this file.

Data Structures

struct  fec_parms

Defines

#define FEC
#define NEED_BCOPY
#define bcmp(a, b, n)   memcmp(a,b,n)
#define bcopy(s, d, siz)   memcpy((d), (s), (siz))
#define bzero(d, siz)   memset((d), '\0', (siz))
#define u_long   unsigned long
#define DEB(x)
#define DDB(x)
#define TICK(x)
#define TOCK(x)
#define SWAP(a, b, t)   {t tmp; tmp=a; a=b; b=tmp;}
#define gf_mul(x, y)   gf_mul_table[x][y]
#define USE_GF_MULC   register gf * __gf_mulc_
#define GF_MULC0(c)   __gf_mulc_ = gf_mul_table[c]
#define GF_ADDMULC(dst, x)   dst ^= __gf_mulc_[x]
#define NEW_GF_MATRIX(rows, cols)   (gf *)my_malloc(rows * cols * sizeof(gf), " ## __LINE__ ## " )
#define addmul(dst, src, c, sz)   if (c != 0) addmul1(dst, src, c, sz)
#define UNROLL   16
#define FEC_MAGIC   0xFECC0DEC
#define CPLUSPLUS_COMPATIBLE
#define CPLUSPLUS_COMPATIBLE
#define CPLUSPLUS_COMPATIBLE

Typedefs

typedef unsigned char gf

Functions

static gf modnn (int x)
static void init_mul_table ()
static void * my_malloc (int sz, char *err_string)
static void generate_gf (void)
static void addmul1 (gf *dst1, gf *src1, gf c, int sz)
static void matmul (gf *a, gf *b, gf *c, int n, int k, int m)
static int invert_mat (gf *src, int k)
int invert_vdm (gf *src, int k)
void init_fec ()
void fec_free (void *p_vp)
void * fec_new (int k, int n)
void fec_encode (void *code_vp, void **src_vp, void *fec_vp, int index, int sz)
static int shuffle (gf *pkt[], int index[], int k)
static gfbuild_decode_matrix (struct fec_parms *code, gf *pkt[], int index[])
int fec_decode (void *code_vp, void **pkt_vp, int index[], int sz)

Variables

static char * allPp []
static gf gf_exp [2 *GF_SIZE]
static int gf_log [GF_SIZE+1]
static gf inverse [GF_SIZE+1]
static gf gf_mul_table [GF_SIZE+1][GF_SIZE+1]
static int fec_initialized = 0


Detailed Description

Forward error correction based on Vandermonde matrices
980624
(C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it).

Author
peltotal
Date
2007/01/12 11:30:17
Revision
1.13

Portions derived from code by Phil Karn (karn@ka9q.ampr.org), Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and Hari Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file fec.c.


Define Documentation

#define addmul ( dst,
src,
c,
sz   )     if (c != 0) addmul1(dst, src, c, sz)

Definition at line 347 of file fec.c.

Referenced by fec_decode(), fec_encode(), and invert_mat().

#define bcmp ( a,
b,
 )     memcmp(a,b,n)

Definition at line 57 of file fec.c.

Referenced by invert_mat().

#define bcopy ( s,
d,
siz   )     memcpy((d), (s), (siz))

Definition at line 61 of file fec.c.

Referenced by build_decode_matrix(), fec_decode(), and fec_encode().

#define bzero ( d,
siz   )     memset((d), '\0', (siz))

Definition at line 62 of file fec.c.

Referenced by build_decode_matrix(), fec_decode(), fec_encode(), fec_new(), and invert_mat().

#define CPLUSPLUS_COMPATIBLE

Definition at line 879 of file fec.c.

#define CPLUSPLUS_COMPATIBLE

Definition at line 879 of file fec.c.

#define CPLUSPLUS_COMPATIBLE

Definition at line 879 of file fec.c.

#define DDB (  ) 

Definition at line 110 of file fec.c.

Referenced by fec_new(), and init_fec().

#define DEB (  ) 

Definition at line 109 of file fec.c.

Referenced by fec_new(), invert_mat(), and shuffle().

#define FEC

Definition at line 35 of file fec.c.

#define FEC_MAGIC   0xFECC0DEC

Definition at line 652 of file fec.c.

Referenced by fec_free(), and fec_new().

#define GF_ADDMULC ( dst,
 )     dst ^= __gf_mulc_[x]

Definition at line 211 of file fec.c.

Referenced by addmul1().

#define gf_mul ( x,
 )     gf_mul_table[x][y]

Definition at line 207 of file fec.c.

Referenced by invert_mat(), invert_vdm(), and matmul().

#define GF_MULC0 (  )     __gf_mulc_ = gf_mul_table[c]

Definition at line 210 of file fec.c.

Referenced by addmul1().

#define NEED_BCOPY

Definition at line 56 of file fec.c.

#define NEW_GF_MATRIX ( rows,
cols   )     (gf *)my_malloc(rows * cols * sizeof(gf), " ## __LINE__ ## " )

Definition at line 265 of file fec.c.

Referenced by build_decode_matrix(), fec_new(), invert_mat(), and invert_vdm().

#define SWAP ( a,
b,
 )     {t tmp; tmp=a; a=b; b=tmp;}

Definition at line 192 of file fec.c.

Referenced by invert_mat(), and shuffle().

#define TICK (  ) 

Definition at line 111 of file fec.c.

Referenced by build_decode_matrix(), fec_new(), and init_fec().

#define TOCK (  ) 

Definition at line 112 of file fec.c.

Referenced by fec_new(), and init_fec().

#define u_long   unsigned long

Definition at line 66 of file fec.c.

#define UNROLL   16

Definition at line 350 of file fec.c.

Referenced by addmul1().

#define USE_GF_MULC   register gf * __gf_mulc_

Definition at line 209 of file fec.c.

Referenced by addmul1().


Typedef Documentation

typedef unsigned char gf

Definition at line 131 of file fec.c.


Function Documentation

static void addmul1 ( gf dst1,
gf src1,
gf  c,
int  sz 
) [static]

Definition at line 352 of file fec.c.

References GF_ADDMULC, GF_MULC0, UNROLL, and USE_GF_MULC.

static gf* build_decode_matrix ( struct fec_parms code,
gf pkt[],
int  index[] 
) [static]

Definition at line 832 of file fec.c.

References bcopy, bzero, fec_parms::enc_matrix, fec_parms::k, fec_parms::n, NEW_GF_MATRIX, and TICK.

Referenced by fec_decode().

Here is the caller graph for this function:

int fec_decode ( void *  code_vp,
void **  pkt_vp,
int  index[],
int  sz 
)

Definition at line 882 of file fec.c.

References addmul, bcopy, build_decode_matrix(), bzero, GF_BITS, fec_parms::k, my_malloc(), and shuffle().

Referenced by rs_fec_decode_src_block().

Here is the call graph for this function:

Here is the caller graph for this function:

void fec_encode ( void *  code_vp,
void **  src_vp,
void *  fec_vp,
int  index,
int  sz 
)

Definition at line 760 of file fec.c.

References addmul, bcopy, bzero, fec_parms::enc_matrix, GF_BITS, fec_parms::k, and fec_parms::n.

Referenced by rs_fec_encode_src_block().

Here is the caller graph for this function:

void fec_free ( void *  p_vp  ) 

Definition at line 663 of file fec.c.

References fec_parms::enc_matrix, FEC_MAGIC, fec_parms::k, fec_parms::magic, and fec_parms::n.

Referenced by rs_fec_decode_src_block(), and rs_fec_encode_src_block().

Here is the caller graph for this function:

void* fec_new ( int  k,
int  n 
)

Definition at line 689 of file fec.c.

References bzero, DDB, DEB, fec_parms::enc_matrix, FEC_MAGIC, gf_exp, GF_SIZE, init_fec(), invert_vdm(), fec_parms::k, fec_parms::magic, matmul(), modnn(), my_malloc(), fec_parms::n, NEW_GF_MATRIX, TICK, and TOCK.

Referenced by rs_fec_decode_src_block(), and rs_fec_encode_src_block().

Here is the call graph for this function:

Here is the caller graph for this function:

static void generate_gf ( void   )  [static]

Definition at line 272 of file fec.c.

References allPp, GF_BITS, gf_exp, gf_log, GF_SIZE, and inverse.

Referenced by init_fec().

Here is the caller graph for this function:

void init_fec ( void   ) 

Definition at line 633 of file fec.c.

References DDB, generate_gf(), init_mul_table(), TICK, and TOCK.

Referenced by fec_new().

Here is the call graph for this function:

Here is the caller graph for this function:

static void init_mul_table (  )  [static]

Definition at line 214 of file fec.c.

References gf_exp, gf_log, gf_mul_table, GF_SIZE, and modnn().

Referenced by init_fec().

Here is the call graph for this function:

Here is the caller graph for this function:

static int invert_mat ( gf src,
int  k 
) [static]

Definition at line 438 of file fec.c.

References addmul, bcmp, bzero, DEB, gf_mul, inverse, my_malloc(), NEW_GF_MATRIX, and SWAP.

Here is the call graph for this function:

int invert_vdm ( gf src,
int  k 
)

Definition at line 576 of file fec.c.

References gf_mul, inverse, and NEW_GF_MATRIX.

Referenced by fec_new().

Here is the caller graph for this function:

static void matmul ( gf a,
gf b,
gf c,
int  n,
int  k,
int  m 
) [static]

Definition at line 393 of file fec.c.

References gf_mul.

Referenced by fec_new().

Here is the caller graph for this function:

static gf modnn ( int  x  )  [static]

Definition at line 183 of file fec.c.

References GF_BITS, and GF_SIZE.

Referenced by fec_new(), and init_mul_table().

Here is the caller graph for this function:

static void* my_malloc ( int  sz,
char *  err_string 
) [static]

Definition at line 255 of file fec.c.

Referenced by fec_decode(), fec_new(), and invert_mat().

Here is the caller graph for this function:

static int shuffle ( gf pkt[],
int  index[],
int  k 
) [static]

Definition at line 792 of file fec.c.

References DEB, and SWAP.

Referenced by fec_decode().

Here is the caller graph for this function:


Variable Documentation

char* allPp[] [static]

Initial value:

 {    
    NULL,                   
    NULL,                   
    "111",                  
    "1101",                 
    "11001",                
    "101001",               
    "1100001",              
    "10010001",             
    "101110001",            
    "1000100001",           
    "10010000001",          
    "101000000001",         
    "1100101000001",        
    "11011000000001",       
    "110000100010001",      
    "1100000000000001",     
    "11010000000010001"     
}

Definition at line 143 of file fec.c.

Referenced by generate_gf().

int fec_initialized = 0 [static]

Definition at line 631 of file fec.c.

gf gf_exp[2 *GF_SIZE] [static]

Definition at line 173 of file fec.c.

Referenced by fec_new(), generate_gf(), and init_mul_table().

int gf_log[GF_SIZE+1] [static]

Definition at line 174 of file fec.c.

Referenced by generate_gf(), and init_mul_table().

gf gf_mul_table[GF_SIZE+1][GF_SIZE+1] [static]

Definition at line 205 of file fec.c.

Referenced by init_mul_table().

gf inverse[GF_SIZE+1] [static]

Definition at line 175 of file fec.c.

Referenced by generate_gf(), invert_mat(), and invert_vdm().


Generated on Fri Mar 9 20:00:57 2007 for MAD-FCL by  doxygen 1.5.0