Menu

## ReedSolomonDecoder
in package

ReedSolomonDecoder.php : 35

Implements Reed-Solomon decoding, as the name implies.

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

decode() : array<string|int, mixed>
  Error-correct and copy data blocks together into a stream of bytes
correctErrors() : array<string|int, mixed>
  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.
findErrorLocations() : array<string|int, mixed>
findErrorMagnitudes() : array<string|int, mixed>
runEuclideanAlgorithm() : array<string|int, GenericGFPoly>

### Methods

#### decode()

ReedSolomonDecoder.php : 40

Error-correct and copy data blocks together into a stream of bytes

`public decode(array<string|int, mixed> $dataBlocks) : array<string|int, mixed>`

##### Parameters

$dataBlocks : array<string|int, mixed>

##### Return values

array<string|int, mixed> —

#### correctErrors()

ReedSolomonDecoder.php : 60

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, mixed> $codewordBytes, int $numDataCodewords) : array<string|int, mixed>`

##### Parameters

$codewordBytes : array<string|int, mixed>
$numDataCodewords : int

##### Return values

array<string|int, mixed> —

#### decodeWords()

ReedSolomonDecoder.php : 90

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, mixed> $received, int $numEccCodewords) : array<string|int, int>`

##### Parameters

$received : array<string|int, mixed>

  data and error-correction codewords

$numEccCodewords : int

  number of error-correction codewords available

##### Tags

throws
  QRCodeException

  if decoding fails for any reason

##### Return values

array<string|int, int> —

#### findErrorLocations()

ReedSolomonDecoder.php : 179
`private findErrorLocations(GenericGFPoly $errorLocator) : array<string|int, mixed>`

##### Parameters

$errorLocator : GenericGFPoly

##### Tags

throws
  QRCodeException

##### Return values

array<string|int, mixed> —

#### findErrorMagnitudes()

ReedSolomonDecoder.php : 207
`private findErrorMagnitudes(GenericGFPoly $errorEvaluator, array<string|int, mixed> $errorLocations) : array<string|int, mixed>`

##### Parameters

$errorEvaluator : GenericGFPoly
$errorLocations : array<string|int, mixed>

##### Return values

array<string|int, mixed> —

#### runEuclideanAlgorithm()

ReedSolomonDecoder.php : 135
`private runEuclideanAlgorithm(GenericGFPoly $a, GenericGFPoly $b, int $R) : array<string|int, GenericGFPoly>`

##### Parameters

$a : GenericGFPoly
$b : GenericGFPoly
$R : int

##### Tags

throws
  QRCodeException

##### Return values

array<string|int, GenericGFPoly> —

[sigma, omega]

## Search results