Package org.yamcs.rs
Class ReedSolomon
- java.lang.Object
-
- org.yamcs.rs.ReedSolomon
-
public class ReedSolomon extends Object
Reed-Solomon encoder/decoder. Works with up to 7 bits per symbol (due to the byte in Java being signed)
-
-
Constructor Summary
Constructors Constructor Description ReedSolomon(int nroots, int symsize, int fcr, int prim, int gfpoly, int pad)
Constructs a new encoder/decoder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
decode(byte[] data, int[] eras_pos)
Corrects in place data and returns the number of error corrected.void
encode(byte[] data, byte[] parity)
-
-
-
Constructor Detail
-
ReedSolomon
public ReedSolomon(int nroots, int symsize, int fcr, int prim, int gfpoly, int pad)
Constructs a new encoder/decoder.- Parameters:
nroots
- the number of roots in the Reed Solomon code generator polynomial. This equals the number of parity symbols per code block.symsize
- the symbol size in bits, up to 8fcr
- in index form, the first consecutive root of the Reed Solomon code generator polynomial.prim
- in index form, the primitive element in the Galois field used to generate the Reed Solomon code generator polynomial.gfpoly
- the extended Galois field generator polynomial coefficients, with the 0th coefficient in the low order bit. The polynomial must be primitive; if not, an IllegalArgumentException will be thrown.pad
- the number of leading symbols in the codeword that are implicitly padded to zero in a shortened code block
-
-
Method Detail
-
encode
public void encode(byte[] data, byte[] parity)
-
decode
public int decode(byte[] data, int[] eras_pos) throws ReedSolomonException
Corrects in place data and returns the number of error corrected.- Parameters:
data
- - data to be correctederas_pos
- - erasures positions (can be null)- Returns:
- Throws:
ReedSolomonException
- - thrown if the data cannot be corrected
-
-