Documentation

ReedSolomonDecoder
in package

FinalYes

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
author

Sean Owen

author

William Rucklidge

author

sanfordsquires

Table of Contents

Properties

$eccLevel  : EccLevel
$version  : Version

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

Methods

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
BitBuffer

correctErrors()

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
throws
QRCodeDecoderException

if decoding fails for any reason

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
throws
QRCodeDecoderException
Return values
array<string|int, mixed>

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>

        
On this page

Search results