File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change 12
12
namespace chillerlan \QRCode \Common ;
13
13
14
14
use RuntimeException ;
15
- use function array_fill , count ;
15
+ use function array_fill , array_reverse , count ;
16
16
17
17
/**
18
18
* Implements Reed-Solomon decoding, as the name implies.
@@ -48,24 +48,23 @@ final class ReedSolomonDecoder{
48
48
public function decode (array $ received , int $ numEccCodewords ):array {
49
49
$ poly = new GenericGFPoly ($ received );
50
50
$ syndromeCoefficients = [];
51
- $ noError = true ;
51
+ $ error = false ;
52
52
53
- for ($ i = 0 , $ j = $ numEccCodewords - 1 ; $ i < $ numEccCodewords ; $ i ++, $ j --){
54
- $ eval = $ poly ->evaluateAt (GF256 ::exp ($ i ));
55
- $ syndromeCoefficients [$ j ] = $ eval ;
53
+ for ($ i = 0 ; $ i < $ numEccCodewords ; $ i ++){
54
+ $ syndromeCoefficients [$ i ] = $ poly ->evaluateAt (GF256 ::exp ($ i ));
56
55
57
- if ($ eval !== 0 ){
58
- $ noError = false ;
56
+ if ($ syndromeCoefficients [ $ i ] !== 0 ){
57
+ $ error = true ;
59
58
}
60
59
}
61
60
62
- if ($ noError ){
61
+ if (! $ error ){
63
62
return $ received ;
64
63
}
65
64
66
65
[$ sigma , $ omega ] = $ this ->runEuclideanAlgorithm (
67
66
GF256 ::buildMonomial ($ numEccCodewords , 1 ),
68
- new GenericGFPoly ($ syndromeCoefficients ),
67
+ new GenericGFPoly (array_reverse ( $ syndromeCoefficients) ),
69
68
$ numEccCodewords
70
69
);
71
70
You can’t perform that action at this time.
0 commit comments