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

Function CreateECCBlock

czxing/src/main/cpp/zxing/src/datamatrix/DMECEncoder.cpp:100–118  ·  view source on GitHub ↗

TODO: replace this duplicated code with ReedSolomonEncoder

Source from the content-addressed store, hash-verified

98
99//TODO: replace this duplicated code with ReedSolomonEncoder
100static void CreateECCBlock(ByteArray& data, int codeOffset, int codeLength, int eccOffset, int eccLength, int stride)
101{
102 // binary search for the poly vector with length numECWords
103 auto iter = std::lower_bound(FACTORS.begin(), FACTORS.end(), eccLength,
104 [](const ByteArray& vec, size_t size) { return vec.size() < size; });
105 if (iter == FACTORS.end())
106 throw std::invalid_argument("Illegal number of error correction codewords specified: " + std::to_string(eccLength));
107
108 auto& poly = *iter;
109 ByteArray ecc(eccLength);
110 for (int i = 0; i < codeLength; ++i) {
111 const auto m = ecc.back() ^ data[codeOffset + i * stride];
112 for (size_t k = ecc.size() - 1; k > 0; k--)
113 ecc[k] = ecc[k - 1] ^ mult(m, poly[k]);
114 ecc[0] = mult(m, poly[0]);
115 }
116 for (int i = 0; i < eccLength; ++i)
117 data[eccOffset + i * stride] = ecc[eccLength - 1 - i];
118}
119
120void EncodeECC200(ByteArray& codewords, const SymbolInfo& symbolInfo)
121{

Callers 1

EncodeECC200Function · 0.85

Calls 5

multFunction · 0.85
backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected