This file describes the VDMFEC file format.

Output blocks have the format:

	u_char[packlen] data    output packet of length packlen
	u_char          blkid   block id [0..N-1]
	u_char          K       the FEC K parameter
	u_char[16]      hash    MD5 hash of packet + blkid

Output blocks are usually a multiple of the media block or sector
size (e.g., 512, 1024, 18K, etc.) and packlen = blocksize - 18.
We store K because small K syndromes on decoding can result in
false positives (file decoded with no error messages but bad data).
There's really no good way to store N and the blocksize, you need
those values to be able to read the file at all.

Note that GF_BITS must be 8 or the block id and K fields will overflow.

A packet, prior to encoding, has one of the following formats, either:

	u_int32_t       clen    number of data bytes in this chunk
	u_int32_t       chkid   chunk id or CHUNK_FINAL for the last one
	u_char[dlen]    data    packet data

for the first packet in a chunk, where dlen = packlen - 8, or

	u_char[packlen] data    packet data

for the other K - 1 input packets in a chunk.  These K packets are encoded
(expanded) and output as N output blocks.  clen and chkid are written in
network byte order.

A chkid of CHUNK_FINAL marks the end of the file.  This is useful when
reading from raw devices that don't have an explicit EOF indication, and
also for detecting file truncation.  Since CHUNK_FINAL is -1, the output
stream can have at most 2^32 chunks.  Since chunks can be very large this
isn't a problem.

The maximum size of a chunk is (blocksize - 18) * K - 8.  Chunks with less
data than this are padded with zero prior to encoding.
