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

$eccLevel : EccLevel
$version : Version
__construct() : mixed
  ReedSolomonDecoder constructor
decode() : BitBuffer
  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.
deinterleaveRawBytes() : array<string|int, mixed>
  When QR Codes use multiple data blocks, they are actually interleaved.
findErrorLocations() : array<string|int, mixed>
findErrorMagnitudes() : array<string|int, mixed>
runEuclideanAlgorithm() : array<string|int, GenericGFPoly>

### Properties

#### $eccLevel

ReedSolomonDecoder.php : 38
`private EccLevel $eccLevel`

#### $version

ReedSolomonDecoder.php : 37
`private Version $version`

### Methods

#### __construct()

ReedSolomonDecoder.php : 43

ReedSolomonDecoder constructor

`public __construct(Version $version, EccLevel $eccLevel) : mixed`

##### Parameters

$version : Version
$eccLevel : EccLevel

##### Return values

mixed —

#### decode()

ReedSolomonDecoder.php : 51

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

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

##### Parameters

$rawCodewords : array<string|int, mixed>

##### Return values

BitBuffer —

#### correctErrors()

ReedSolomonDecoder.php : 145

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 : 175

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> —

#### deinterleaveRawBytes()

ReedSolomonDecoder.php : 75

When QR Codes use multiple data blocks, they are actually interleaved.

`private deinterleaveRawBytes(array<string|int, mixed> $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, mixed>

##### Tags

throws
  QRCodeDecoderException

##### Return values

array<string|int, mixed> —

#### findErrorLocations()

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

##### Parameters

$errorLocator : GenericGFPoly

##### Tags

throws
  QRCodeException

##### Return values

array<string|int, mixed> —

#### findErrorMagnitudes()

ReedSolomonDecoder.php : 292
`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 : 220
`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