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

Function DecoderResult Decode

czxing/src/main/cpp/zxing/src/aztec/AZDecoder.cpp:301–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

299}
300
301ZXING_EXPORT_TEST_ONLY
302DecoderResult Decode(const BitArray& bits)
303{
304 Content res;
305 res.symbology = {'z', '0', 3};
306
307 try {
308 DecodeContent(bits, res);
309 } catch (const std::exception&) { // see BitArrayView::readBits
310 return FormatError();
311 }
312
313 if (res.bytes.empty())
314 return FormatError("Empty symbol content");
315
316 // Check for Structured Append - need 4 5-bit words, beginning with ML UL, ending with index and count
317 bool haveStructuredAppend = Size(bits) > 20 && ToInt(bits, 0, 5) == 29 // latch to MIXED (from UPPER)
318 && ToInt(bits, 5, 5) == 29; // latch back to UPPER (from MIXED)
319
320 StructuredAppendInfo sai = haveStructuredAppend ? ParseStructuredAppend(res.bytes) : StructuredAppendInfo();
321
322 // As converting character set ECIs ourselves and ignoring/skipping non-character ECIs, not using
323 // modifiers that indicate ECI protocol (ISO/IEC 24778:2008 Annex F Table F.1)
324 if (res.bytes[0] == 29) {
325 res.symbology.modifier = '1'; // GS1
326 res.symbology.aiFlag = AIFlag::GS1;
327 res.erase(0, 1); // Remove FNC1
328 } else if (res.bytes.size() > 2 && std::isupper(res.bytes[0]) && res.bytes[1] == 29) {
329 // FNC1 following single uppercase letter (the AIM Application Indicator)
330 res.symbology.modifier = '2'; // AIM
331 res.symbology.aiFlag = AIFlag::AIM;
332 res.erase(1, 1); // Remove FNC1,
333 // The AIM Application Indicator character "A"-"Z" is left in the stream (ISO/IEC 24778:2008 16.2)
334 } else if (res.bytes.size() > 3 && std::isdigit(res.bytes[0]) && std::isdigit(res.bytes[1]) && res.bytes[2] == 29) {
335 // FNC1 following 2 digits (the AIM Application Indicator)
336 res.symbology.modifier = '2'; // AIM
337 res.symbology.aiFlag = AIFlag::AIM;
338 res.erase(2, 1); // Remove FNC1
339 // The AIM Application Indicator characters "00"-"99" are left in the stream (ISO/IEC 24778:2008 16.2)
340 }
341
342 if (sai.index != -1)
343 res.symbology.modifier += 6; // TODO: this is wrong as long as we remove the sai info from the content in ParseStructuredAppend
344
345 return DecoderResult(std::move(res)).setStructuredAppend(sai);
346}
347
348DecoderResult Decode(const DetectorResult& detectorResult)
349{

Callers

nothing calls this directly

Calls 10

DecodeContentFunction · 0.85
moveFunction · 0.85
ParseStructuredAppendFunction · 0.70
DecoderResultClass · 0.70
SizeFunction · 0.50
ToIntFunction · 0.50
emptyMethod · 0.45
eraseMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected