Reed-Solomon codec for 8-bit characters.
Based on libfec by Phil Karn, KA9Q.
- Full name:
\BaconQrCode\Common\ReedSolomonCodec
- This class is marked as final and can't be subclassed
- This class is a Final class
Symbol size in bits.
private int $symbolSize
Block size in symbols.
private int $blockSize
First root of RS code generator polynomial, index form.
private int $firstRoot
Primitive element to generate polynomial roots, index form.
private int $primitive
Prim-th root of 1, index form.
private int $iPrimitive
RS code generator polynomial degree (number of roots).
private int $numRoots
Padding bytes at front of shortened block.
private int $padding
Log lookup table.
private \SplFixedArray $alphaTo
Anti-Log lookup table.
private \SplFixedArray $indexOf
Generator polynomial.
private \SplFixedArray $generatorPoly
public __construct(int $symbolSize, int $gfPoly, int $firstRoot, int $primitive, int $numRoots, int $padding): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$symbolSize |
int | |
$gfPoly |
int | |
$firstRoot |
int | |
$primitive |
int | |
$numRoots |
int | |
$padding |
int |
Encodes data and writes result back into parity array.
public encode(\SplFixedArray $data, \SplFixedArray $parity): void
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
\SplFixedArray | |
$parity |
\SplFixedArray |
Decodes received data.
public decode(\SplFixedArray $data, \SplFixedArray $erasures = null): ?int
Parameters:
Parameter | Type | Description |
---|---|---|
$data |
\SplFixedArray | |
$erasures |
\SplFixedArray |
Computes $x % GF_SIZE, where GF_SIZE is 2**GF_BITS - 1, without a slow divide.
private modNn(int $x): int
Parameters:
Parameter | Type | Description |
---|---|---|
$x |
int |