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

Function Decode

czxing/src/main/cpp/zxing/src/maxicode/MCDecoder.cpp:298–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

296} // DecodedBitStreamParser
297
298DecoderResult Decode(const BitMatrix& bits)
299{
300 ByteArray codewords = BitMatrixParser::ReadCodewords(bits);
301
302 if (!CorrectErrors(codewords, 0, 10, 10, ALL))
303 return ChecksumError();
304
305 int mode = codewords[0] & 0x0F;
306 ByteArray datawords;
307 switch (mode) {
308 case 2: // Structured Carrier Message (numeric postcode)
309 case 3: // Structured Carrier Message (alphanumeric postcode)
310 case 4: // Standard Symbol
311 case 6: // Reader Programming
312 if (CorrectErrors(codewords, 20, 84, 40, EVEN) && CorrectErrors(codewords, 20, 84, 40, ODD))
313 datawords.resize(94, 0);
314 else
315 return ChecksumError();
316 break;
317 case 5: // Full ECC
318 if (CorrectErrors(codewords, 20, 68, 56, EVEN) && CorrectErrors(codewords, 20, 68, 56, ODD))
319 datawords.resize(78, 0);
320 else
321 return ChecksumError();
322 break;
323 default: return FormatError("Invalid mode");
324 }
325
326 std::copy_n(codewords.begin(), 10, datawords.begin());
327 std::copy_n(codewords.begin() + 20, datawords.size() - 10, datawords.begin() + 10);
328
329 return DecodedBitStreamParser::Decode(std::move(datawords), mode);
330}
331
332} // namespace ZXing::MaxiCode

Callers 1

decodeMethod · 0.70

Calls 6

ReadCodewordsFunction · 0.85
moveFunction · 0.85
CorrectErrorsFunction · 0.70
resizeMethod · 0.45
beginMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected