Paraslash Audio Streaming | |
About News Download Documentation Development |
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... | |
Forward error correction based on Vandermonde matrices.
#define GF_BITS 8 |
Code over GF(256).
#define GF_SIZE ((1 << GF_BITS) - 1) |
The largest number in GF(256)
#define gf_mul | ( | x, | |
y | |||
) | gf_mul_table[x][y] |
Multiply two GF numbers.
#define UNROLL 16 |
How often the loop is unrolled.
#define FEC_SWAP | ( | a, | |
b | |||
) | {typeof(a) tmp = a; a = b; b = tmp;} |
Swap two numbers.
void fec_free | ( | struct fec_parms * | p | ) |
Deallocate a fec params structure.
p | The structure to free. |
int fec_new | ( | int | k, |
int | n, | ||
struct fec_parms ** | result | ||
) |
Create a new encoder and return an opaque descriptor to it.
k | Number of input slices. |
n | Number of output slices. |
result | On success the Fec descriptor is returned here. |
This creates the k*n encoding matrix. It is computed starting with a Vandermonde matrix, and then transformed into a systematic matrix.
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.
parms | The fec parameters returned earlier by fec_new(). |
src | The k data slices to encode. |
dst | Result pointer. |
idx | The index of the slice to compute. |
sz | The 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.
int fec_decode | ( | struct fec_parms * | parms, |
unsigned char ** | data, | ||
int * | idx, | ||
int | sz | ||
) |
Decode one slice from the group of received slices.
parms | Pointer to fec params structure. |
data | Pointers to received packets. |
idx | Pointer to packet indices (gets modified). |
sz | Size of each packet. |
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.