paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Macros | Functions
fec.c File Reference

Forward error correction based on Vandermonde matrices. More...

#include <regex.h>
#include "para.h"
#include "error.h"
#include "portable_io.h"
#include "string.h"
#include "fec.h"

Macros

#define GF_BITS   8
 Code over GF(256). More...
 
#define GF_SIZE   ((1 << GF_BITS) - 1)
 The largest number in GF(256) More...
 
#define gf_mul(x, y)   gf_mul_table[x][y]
 Multiply two GF numbers. More...
 
#define UNROLL   16
 How often the loop is unrolled. More...
 
#define FEC_SWAP(a, b)   {typeof(a) tmp = a; a = b; b = tmp;}
 Swap two numbers. More...
 

Functions

void fec_free (struct fec_parms *p)
 Deallocate a fec params structure. More...
 
int fec_new (int k, int n, struct fec_parms **result)
 Create a new encoder and return an opaque descriptor to it. More...
 
void fec_encode (struct fec_parms *parms, const unsigned char *const *src, unsigned char *dst, int idx, int sz)
 Compute one encoded slice of the given input. More...
 
int fec_decode (struct fec_parms *parms, unsigned char **data, int *idx, int sz)
 Decode one slice from the group of received slices. More...
 

Detailed Description

Forward error correction based on Vandermonde matrices.

Macro Definition Documentation

◆ GF_BITS

#define GF_BITS   8

Code over GF(256).

◆ GF_SIZE

#define GF_SIZE   ((1 << GF_BITS) - 1)

The largest number in GF(256)

◆ gf_mul

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

Multiply two GF numbers.

◆ UNROLL

#define UNROLL   16

How often the loop is unrolled.

◆ FEC_SWAP

#define FEC_SWAP (   a,
 
)    {typeof(a) tmp = a; a = b; b = tmp;}

Swap two numbers.

Function Documentation

◆ fec_free()

void fec_free ( struct fec_parms *  p)

Deallocate a fec params structure.

Parameters
pThe structure to free.

◆ fec_new()

int fec_new ( int  k,
int  n,
struct fec_parms **  result 
)

Create a new encoder and return an opaque descriptor to it.

Parameters
kNumber of input slices.
nNumber of output slices.
resultOn success the Fec descriptor is returned here.
Returns
Standard.

This creates the k*n encoding matrix. It is computed starting with a Vandermonde matrix, and then transformed into a systematic matrix.

◆ fec_encode()

void fec_encode ( struct fec_parms *  parms,
const unsigned char *const *  src,
unsigned char *  dst,
int  idx,
int  sz 
)

Compute one encoded slice of the given input.

Parameters
parmsThe fec parameters returned earlier by fec_new().
srcThe k data slices to encode.
dstResult pointer.
idxThe index of the slice to compute.
szThe size of the input data packets.

Encode the k slices of size sz given by src and store the output slice number idx in dst.

◆ fec_decode()

int fec_decode ( struct fec_parms *  parms,
unsigned char **  data,
int *  idx,
int  sz 
)

Decode one slice from the group of received slices.

Parameters
parmsPointer to fec params structure.
dataPointers to received packets.
idxPointer to packet indices (gets modified).
szSize of each packet.
Returns
Zero on success, -1 on errors.

The data vector of received slices and the indices of slices are used to produce the correct output slice. The data slices are modified in-place.