MCPcopy Create free account
hub / github.com/devilsen/CZXing / ReedSolomonDecode

Function ReedSolomonDecode

czxing/src/main/cpp/zxing/src/ReedSolomonDecoder.cpp:108–141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108bool
109ReedSolomonDecode(const GenericGF& field, std::vector<int>& message, int numECCodeWords)
110{
111 GenericGFPoly poly(field, message);
112
113 std::vector<int> syndromes(numECCodeWords);
114 for (int i = 0; i < numECCodeWords; i++)
115 syndromes[numECCodeWords - 1 - i] = poly.evaluateAt(field.exp(i + field.generatorBase()));
116
117 // if all syndromes are 0 there is no error to correct
118 if (std::all_of(syndromes.begin(), syndromes.end(), [](int c) { return c == 0; }))
119 return true;
120
121 ZX_THREAD_LOCAL GenericGFPoly sigma, omega;
122
123 if (!RunEuclideanAlgorithm(field, std::move(syndromes), sigma, omega))
124 return false;
125
126 auto errorLocations = FindErrorLocations(field, sigma);
127 if (errorLocations.empty())
128 return false;
129
130 auto errorMagnitudes = FindErrorMagnitudes(field, omega, errorLocations);
131
132 int msgLen = Size(message);
133 for (int i = 0; i < Size(errorLocations); ++i) {
134 int position = msgLen - 1 - field.log(errorLocations[i]);
135 if (position < 0)
136 return false;
137
138 message[position] ^= errorMagnitudes[i];
139 }
140 return true;
141}
142
143} // namespace ZXing

Callers 5

CorrectErrorsFunction · 0.85
CorrectErrorsFunction · 0.85
CorrectErrorsFunction · 0.85
ModeMessageFunction · 0.85
CorrectBitsFunction · 0.85

Calls 12

moveFunction · 0.85
generatorBaseMethod · 0.80
RunEuclideanAlgorithmFunction · 0.70
FindErrorLocationsFunction · 0.70
FindErrorMagnitudesFunction · 0.70
SizeFunction · 0.70
evaluateAtMethod · 0.45
expMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected