Algorithm-FEC

 view release on metacpan or  search on metacpan

FEC.pm  view on Meta::CPAN

The encoded block is returned as a perl scalar (so the blocks should fit
into memory. If this is a problem for you mail me and I'll make it a file.

=item $fec->set_decode_blocks ([array_of_blocks], [array_of_indices])

Prepares to decode C<data_blocks> of blocks (see C<set_encode_blocks> for
the C<array_of_blocks> parameter).

Since these are not usually the original data blocks, an array of
indices (ranging from C<0> to C<encoded_blocks-1>) must be supplied as
the second arrayref.

Both arrays must have exactly C<data_blocks> entries.

This method also reorders the blocks and index array in place (if
necessary) to reflect the order the blocks will have in the decoded
result.

The index array represents the decoded ordering, in that the n-th entry
in the indices array corresponds to the n-th data block of the decoded
result. The value stored in the n-th place in the array will contain the

README  view on Meta::CPAN

        The encoded block is returned as a perl scalar (so the blocks should
        fit into memory. If this is a problem for you mail me and I'll make
        it a file.

    $fec->set_decode_blocks ([array_of_blocks], [array_of_indices])
        Prepares to decode "data_blocks" of blocks (see "set_encode_blocks"
        for the "array_of_blocks" parameter).

        Since these are not usually the original data blocks, an array of
        indices (ranging from 0 to "encoded_blocks-1") must be supplied as
        the second arrayref.

        Both arrays must have exactly "data_blocks" entries.

        This method also reorders the blocks and index array in place (if
        necessary) to reflect the order the blocks will have in the decoded
        result.

        The index array represents the decoded ordering, in that the n-th
        entry in the indices array corresponds to the n-th data block of the
        decoded result. The value stored in the n-th place in the array will

fec_imp.h  view on Meta::CPAN

struct timeval {
    unsigned long ticks;
};
#define gettimeofday(x, dummy) { (x)->ticks = clock() ; }
#define DIFF_T(a,b) (1+ 1000000*(a.ticks - b.ticks) / CLOCKS_PER_SEC )
typedef unsigned long u_long ;
typedef unsigned short u_short ;
#else /* typically, unix systems */
#include <sys/time.h>
#define DIFF_T(a,b) \
	(1+ 1000000*(a.tv_sec - b.tv_sec) + (a.tv_usec - b.tv_usec) )
#endif

#define TICK(t) \
	{struct timeval x ; \
	gettimeofday(&x, NULL) ; \
	t = x.tv_usec + 1000000* (x.tv_sec & 0xff ) ; \
	}
#define TOCK(t) \
	{ u_long t1 ; TICK(t1) ; \
	  if (t1 < t) t = 256000000 + t1 - t ; \
	  else t = t1 - t ; \
	  if (t == 0) t = 1 ;}
	
u_long ticks[10];	/* vars for timekeeping */
#else
#define DEB(x)

fec_imp.h  view on Meta::CPAN

    free(ipiv);
    free(id_row);
    free(temp_row);
    return error ;
}

/*
 * fast code for inverting a vandermonde matrix.
 * XXX NOTE: It assumes that the matrix
 * is not singular and _IS_ a vandermonde matrix. Only uses
 * the second column of the matrix, containing the p_i's.
 *
 * Algorithm borrowed from "Numerical recipes in C" -- sec.2.8, but
 * largely revised for my purposes.
 * p = coefficients of the matrix (p_i)
 * q = values of the polynomial (known)
 */

static int
invert_vdm(gf *src, int k)
{
    int i, j, row, col ;
    gf *b, *c, *p;

fec_imp.h  view on Meta::CPAN

    TOCK(ticks[0]);
    DDB(fprintf(stderr, "generate_gf took %ldus\n", ticks[0]);)
    TICK(ticks[0]);
    init_mul_table();
    TOCK(ticks[0]);
    DDB(fprintf(stderr, "init_mul_table took %ldus\n", ticks[0]);)
    fec_initialized = 1 ;
}

/*
 * This section contains the proper FEC encoding/decoding routines.
 * The encoding matrix is computed starting with a Vandermonde matrix,
 * and then transforming it into a systematic matrix.
 */

struct fec_parms {
    int k, n ;		/* parameters of the code */
    gf *enc_matrix ;
} ;

void



( run in 0.740 second using v1.01-cache-2.11-cpan-39bf76dae61 )