TODO: replace this duplicated code with ReedSolomonEncoder
| 98 | |
| 99 | //TODO: replace this duplicated code with ReedSolomonEncoder |
| 100 | static 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 | |
| 120 | void EncodeECC200(ByteArray& codewords, const SymbolInfo& symbolInfo) |
| 121 | { |