int32_t CBC_DecodedBitStreamPaser::decodeMacroBlock( CFX_Int32Array& codewords, int32_t codeIndex, CBC_PDF417ResultMetadata* resultMetadata, int32_t& e) { if (codeIndex + NUMBER_OF_SEQUENCE_CODEWORDS > codewords[0]) { e = BCExceptionFormatInstance; return -1; } CFX_Int32Array segmentIndexArray; segmentIndexArray.SetSize(NUMBER_OF_SEQUENCE_CODEWORDS); for (int32_t i = 0; i < NUMBER_OF_SEQUENCE_CODEWORDS; i++, codeIndex++) { segmentIndexArray.SetAt(i, codewords[codeIndex]); } CFX_ByteString str = decodeBase900toBase10(segmentIndexArray, NUMBER_OF_SEQUENCE_CODEWORDS, e); BC_EXCEPTION_CHECK_ReturnValue(e, -1); resultMetadata->setSegmentIndex(atoi(str.GetBuffer(str.GetLength()))); CFX_ByteString fileId; codeIndex = textCompaction(codewords, codeIndex, fileId); resultMetadata->setFileId(fileId); if (codewords[codeIndex] == BEGIN_MACRO_PDF417_OPTIONAL_FIELD) { codeIndex++; CFX_Int32Array additionalOptionCodeWords; additionalOptionCodeWords.SetSize(codewords[0] - codeIndex); int32_t additionalOptionCodeWordsIndex = 0; FX_BOOL end = FALSE; while ((codeIndex < codewords[0]) && !end) { int32_t code = codewords[codeIndex++]; if (code < TEXT_COMPACTION_MODE_LATCH) { additionalOptionCodeWords[additionalOptionCodeWordsIndex++] = code; } else { switch (code) { case MACRO_PDF417_TERMINATOR: resultMetadata->setLastSegment(TRUE); codeIndex++; end = TRUE; break; default: e = BCExceptionFormatInstance; return -1; } } } CFX_Int32Array array; array.SetSize(additionalOptionCodeWordsIndex); array.Copy(additionalOptionCodeWords); resultMetadata->setOptionalData(array); } else if (codewords[codeIndex] == MACRO_PDF417_TERMINATOR) { resultMetadata->setLastSegment(TRUE); codeIndex++; } return codeIndex; }
CFX_Int32Array* CBC_DetectionResultRowIndicatorColumn::getRowHeights( int32_t& e) { CBC_BarcodeMetadata* barcodeMetadata = getBarcodeMetadata(); if (barcodeMetadata == NULL) { e = BCExceptionCannotMetadata; return NULL; } adjustIncompleteIndicatorColumnRowNumbers(*barcodeMetadata); CFX_Int32Array* result = new CFX_Int32Array; result->SetSize(barcodeMetadata->getRowCount()); for (int32_t i = 0; i < getCodewords()->GetSize(); i++) { CBC_Codeword* codeword = (CBC_Codeword*)getCodewords()->GetAt(i); if (codeword != NULL) { result->SetAt(codeword->getRowNumber(), result->GetAt(codeword->getRowNumber()) + 1); } } return result; }
CFX_Int32Array* CBC_PDF417CodewordDecoder::sampleBitCounts( CFX_Int32Array& moduleBitCount) { FX_FLOAT bitCountSum = (FX_FLOAT)CBC_PDF417Common::getBitCountSum(moduleBitCount); CFX_Int32Array* bitCount = new CFX_Int32Array(); bitCount->SetSize(CBC_PDF417Common::BARS_IN_MODULE); int32_t bitCountIndex = 0; int32_t sumPreviousBits = 0; for (int32_t i = 0; i < CBC_PDF417Common::MODULES_IN_CODEWORD; i++) { FX_FLOAT sampleIndex = bitCountSum / (2 * CBC_PDF417Common::MODULES_IN_CODEWORD) + (i * bitCountSum) / CBC_PDF417Common::MODULES_IN_CODEWORD; if (sumPreviousBits + moduleBitCount.GetAt(bitCountIndex) <= sampleIndex) { sumPreviousBits += moduleBitCount.GetAt(bitCountIndex); bitCountIndex++; } bitCount->SetAt(bitCountIndex, bitCount->GetAt(bitCountIndex) + 1); } return bitCount; }