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

Function CorrectErrors

czxing/src/main/cpp/zxing/src/qrcode/QRDecoder.cpp:39–52  ·  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

37* @return false if error correction fails
38*/
39static bool CorrectErrors(ByteArray& codewordBytes, int numDataCodewords)
40{
41 // First read into an array of ints
42 std::vector<int> codewordsInts(codewordBytes.begin(), codewordBytes.end());
43
44 int numECCodewords = Size(codewordBytes) - numDataCodewords;
45 if (!ReedSolomonDecode(GenericGF::QRCodeField256(), codewordsInts, numECCodewords))
46 return false;
47
48 // Copy back into array of bytes -- only need to worry about the bytes that were data
49 // We don't care about errors in the error-correction codewords
50 std::copy_n(codewordsInts.begin(), numDataCodewords, codewordBytes.begin());
51 return true;
52}
53
54
55/**

Callers 1

DecodeFunction · 0.70

Calls 4

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

Tested by

no test coverage detected