ReedSolomonDecoder
in package
Implements Reed-Solomon decoding
The algorithm will not be explained here, but the following references were helpful in creating this implementation:
- Bruce Maggs "Decoding Reed-Solomon Codes" (see discussion of Forney's Formula) http://www.cs.cmu.edu/afs/cs.cmu.edu/project/pscico-guyb/realworld/www/rs_decode.ps
- J.I. Hall. "Chapter 5. Generalized Reed-Solomon Codes" (see discussion of Euclidean algorithm) https://users.math.msu.edu/users/halljo/classes/codenotes/GRS.pdf
Much credit is due to William Rucklidge since portions of this code are an indirect port of his C++ Reed-Solomon implementation.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- ReedSolomonDecoder constructor
- decode() : BitBuffer
- Error-correct and copy data blocks together into a stream of bytes
- correctErrors() : array<string|int, int>
- Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
- decodeWords() : array<string|int, int>
- Decodes given set of received codewords, which include both data and error-correction codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, in the input.
- deinterleaveRawBytes() : array<string|int, mixed>
- When QR Codes use multiple data blocks, they are actually interleaved.
- findErrorLocations() : array<string|int, int>
- findErrorMagnitudes() : array<string|int, int>
- runEuclideanAlgorithm() : array<string|int, GenericGFPoly>
Properties
$eccLevel
private
EccLevel
$eccLevel
$version
private
Version
$version
Methods
__construct()
ReedSolomonDecoder constructor
public
__construct(Version $version, EccLevel $eccLevel) : mixed
Parameters
decode()
Error-correct and copy data blocks together into a stream of bytes
public
decode(array<string|int, int> $rawCodewords) : BitBuffer
Parameters
- $rawCodewords : array<string|int, int>
Return values
BitBuffercorrectErrors()
Given data and error-correction codewords received, possibly corrupted by errors, attempts to correct the errors in-place using Reed-Solomon error correction.
private
correctErrors(array<string|int, int> $codewordBytes, int $numDataCodewords) : array<string|int, int>
Parameters
- $codewordBytes : array<string|int, int>
- $numDataCodewords : int
Return values
array<string|int, int>decodeWords()
Decodes given set of received codewords, which include both data and error-correction codewords. Really, this means it uses Reed-Solomon to detect and correct errors, in-place, in the input.
private
decodeWords(array<string|int, int> $received, int $numEccCodewords) : array<string|int, int>
Parameters
- $received : array<string|int, int>
-
data and error-correction codewords
- $numEccCodewords : int
-
number of error-correction codewords available
Tags
Return values
array<string|int, int>deinterleaveRawBytes()
When QR Codes use multiple data blocks, they are actually interleaved.
private
deinterleaveRawBytes(array<string|int, int> $rawCodewords) : array<string|int, mixed>
That is, the first byte of data block 1 to n is written, then the second bytes, and so on. This method will separate the data into original blocks.
Parameters
- $rawCodewords : array<string|int, int>
Tags
Return values
array<string|int, mixed>findErrorLocations()
private
findErrorLocations(GenericGFPoly $errorLocator) : array<string|int, int>
Parameters
- $errorLocator : GenericGFPoly
Tags
Return values
array<string|int, int>findErrorMagnitudes()
private
findErrorMagnitudes(GenericGFPoly $errorEvaluator, array<string|int, int> $errorLocations) : array<string|int, int>
Parameters
- $errorEvaluator : GenericGFPoly
- $errorLocations : array<string|int, int>
Return values
array<string|int, int>runEuclideanAlgorithm()
private
runEuclideanAlgorithm(GenericGFPoly $a, GenericGFPoly $b, int $z) : array<string|int, GenericGFPoly>
Parameters
- $a : GenericGFPoly
- $b : GenericGFPoly
- $z : int
Tags
Return values
array<string|int, GenericGFPoly> —[sigma, omega]