| 28 | static const int ODD = 2; |
| 29 | |
| 30 | static bool CorrectErrors(ByteArray& codewordBytes, int start, int dataCodewords, int ecCodewords, int mode) |
| 31 | { |
| 32 | int codewords = dataCodewords + ecCodewords; |
| 33 | |
| 34 | // in EVEN or ODD mode only half the codewords |
| 35 | int divisor = mode == ALL ? 1 : 2; |
| 36 | |
| 37 | // First read into an array of ints |
| 38 | std::vector<int> codewordsInts(codewords / divisor, 0); |
| 39 | for (int i = 0; i < codewords; i++) { |
| 40 | if ((mode == ALL) || (i % 2 == (mode - 1))) |
| 41 | codewordsInts[i / divisor] = codewordBytes[i + start]; |
| 42 | } |
| 43 | |
| 44 | if (!ReedSolomonDecode(GenericGF::MaxiCodeField64(), codewordsInts, ecCodewords / divisor)) |
| 45 | return false; |
| 46 | |
| 47 | // Copy back into array of bytes -- only need to worry about the bytes that were data |
| 48 | // We don't care about errors in the error-correction codewords |
| 49 | for (int i = 0; i < dataCodewords; i++) { |
| 50 | if ((mode == ALL) || (i % 2 == (mode - 1))) |
| 51 | codewordBytes[i + start] = narrow_cast<uint8_t>(codewordsInts[i / divisor]); |
| 52 | } |
| 53 | |
| 54 | return true; |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * <p>MaxiCodes can encode text or structured information as bits in one of several modes, |
no test coverage detected