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

Function CorrectErrors

czxing/src/main/cpp/zxing/src/datamatrix/DMDecoder.cpp:371–386  ·  view source on GitHub ↗

* Given data and error-correction codewords received, possibly corrupted by errors, attempts to * correct the errors in-place using Reed-Solomon error correction. * * @param codewordBytes data and error correction codewords * @param numDataCodewords number of codewords that are data bytes * @return false if error correction fails */

Source from the content-addressed store, hash-verified

369* @return false if error correction fails
370*/
371static bool
372CorrectErrors(ByteArray& codewordBytes, int numDataCodewords)
373{
374 // First read into an array of ints
375 std::vector<int> codewordsInts(codewordBytes.begin(), codewordBytes.end());
376 int numECCodewords = Size(codewordBytes) - numDataCodewords;
377
378 if (!ReedSolomonDecode(GenericGF::DataMatrixField256(), codewordsInts, numECCodewords))
379 return false;
380
381 // Copy back into array of bytes -- only need to worry about the bytes that were data
382 // We don't care about errors in the error-correction codewords
383 std::copy_n(codewordsInts.begin(), numDataCodewords, codewordBytes.begin());
384
385 return true;
386}
387
388static DecoderResult DoDecode(const BitMatrix& bits)
389{

Callers 1

DoDecodeFunction · 0.70

Calls 4

ReedSolomonDecodeFunction · 0.85
SizeFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected