From 263a8b61bef7eda295def324beccfa53b22b44d1 Mon Sep 17 00:00:00 2001 From: Nikolaos Ftylitakis Date: Sat, 7 Aug 2021 13:28:11 +0300 Subject: [PATCH] fixing compilation issues --- .../zxing/aztec/decoder/AztecDecoder.cpp | 12 +- .../zxing/aztec/detector/AztecDetector.cpp | 29 ++--- .../decoder/DataMatrixBitMatrixParser.cpp | 16 +-- .../decoder/DataMatrixDataBlock.cpp | 8 +- .../datamatrix/decoder/DataMatrixDecoder.cpp | 10 +- .../pdf417/decoder/DecodedBitStreamParser.h | 4 +- .../pdf417/decoder/PDF417BitMatrixParser.cpp | 16 +-- .../decoder/PDF417DecodedBitStreamParser.cpp | 94 +++++++------- .../pdf417/decoder/ec/ErrorCorrection.cpp | 20 +-- .../zxing/pdf417/decoder/ec/ModulusGF.cpp | 25 ++-- .../zxing/pdf417/decoder/ec/ModulusPoly.cpp | 30 ++--- .../zxing/pdf417/detector/PDF417Detector.cpp | 120 +++++++++--------- .../zxing/qrcode/decoder/QRDataBlock.cpp | 10 +- .../decoder/QRDecodedBitStreamParser.cpp | 8 +- src/zxing/zxing/qrcode/decoder/QRDecoder.cpp | 10 +- .../qrcode/detector/AlignmentPatternFinder.h | 2 +- .../detector/QRAlignmentPatternFinder.cpp | 7 +- src/zxing/zxing/qrcode/encoder/BlockPair.h | 4 +- src/zxing/zxing/qrcode/encoder/QRCode.cpp | 2 +- 19 files changed, 213 insertions(+), 214 deletions(-) diff --git a/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp b/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp index 7561511..d5ab14c 100644 --- a/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp +++ b/src/zxing/zxing/aztec/decoder/AztecDecoder.cpp @@ -170,10 +170,10 @@ QSharedPointer Decoder::decode(QSharedPointer result = getEncodedData(aCorrectedBits); // std::printf("constructing array\n"); - QSharedPointer> arrayOut(aCorrectedBits->getSize()); - for (size_t i = 0; i < aCorrectedBits->count(); i++) + QSharedPointer> arrayOut(new std::vector(aCorrectedBits->getSize())); + for (size_t i = 0; i < aCorrectedBits->getSize(); i++) { - arrayOut[i] = (zxing::byte)aCorrectedBits->get(i); + (*arrayOut)[i] = (zxing::byte)aCorrectedBits->get(i); } // std::printf("returning\n"); @@ -352,7 +352,7 @@ QSharedPointer Decoder::correctBits(QSharedPointer ra numECCodewords = NB_DATABLOCK[ddata_->getNBLayers()] - numDataCodewords; } - QSharedPointer> dataWords(numCodewords_); + QSharedPointer> dataWords(new std::vector(numCodewords_)); for (int i = 0; i < numCodewords_; i++) { @@ -361,7 +361,7 @@ QSharedPointer Decoder::correctBits(QSharedPointer ra { if (rawbits->get(codewordSize_ * i + codewordSize_ - j + offset)) { - dataWords[i] += flag; + (*dataWords)[i] += flag; } flag <<= 1; } @@ -402,7 +402,7 @@ QSharedPointer Decoder::correctBits(QSharedPointer ra for (int j = 0; j < codewordSize_; j++) { - bool color = (dataWords[i] & flag) == flag; + bool color = ((*dataWords)[i] & flag) == flag; if (seriesCount == codewordSize_ - 1) { diff --git a/src/zxing/zxing/aztec/detector/AztecDetector.cpp b/src/zxing/zxing/aztec/detector/AztecDetector.cpp index f45c571..5c6cb52 100644 --- a/src/zxing/zxing/aztec/detector/AztecDetector.cpp +++ b/src/zxing/zxing/aztec/detector/AztecDetector.cpp @@ -59,10 +59,10 @@ QSharedPointer Detector::detect() { QSharedPointer bits = sampleGrid(image_, - corners[shift_%4], - corners[(shift_+3)%4], - corners[(shift_+2)%4], - corners[(shift_+1)%4]); + (*corners)[shift_%4], + (*corners)[(shift_+3)%4], + (*corners)[(shift_+2)%4], + (*corners)[(shift_+1)%4]); // std::printf("------------\ndetected: compact:%s, nbDataBlocks:%d, nbLayers:%d\n------------\n",compact_?"YES":"NO", nbDataBlocks_, nbLayers_); @@ -168,11 +168,10 @@ Detector::getMatrixCornerPoints(std::vector > bullEyeCorne throw ReaderException("matrix extends over image bounds"); } std::vector< QSharedPointer >* array = new std::vector< QSharedPointer >(); - vector< QSharedPointer >& returnValue (array->values()); - returnValue.push_back(QSharedPointer(new ResultPoint(float(targetax), float(targetay)))); - returnValue.push_back(QSharedPointer(new ResultPoint(float(targetbx), float(targetby)))); - returnValue.push_back(QSharedPointer(new ResultPoint(float(targetcx), float(targetcy)))); - returnValue.push_back(QSharedPointer(new ResultPoint(float(targetdx), float(targetdy)))); + array->push_back(QSharedPointer(new ResultPoint(float(targetax), float(targetay)))); + array->push_back(QSharedPointer(new ResultPoint(float(targetbx), float(targetby)))); + array->push_back(QSharedPointer(new ResultPoint(float(targetcx), float(targetcy)))); + array->push_back(QSharedPointer(new ResultPoint(float(targetdx), float(targetdy)))); return QSharedPointer> >(array); } @@ -197,7 +196,7 @@ void Detector::correctParameterData(QSharedPointer parameterDat int flag = 1; for (int j = 1; j <= codewordSize; j++) { if (parameterData->get(codewordSize*i + codewordSize - j)) { - parameterWords[i] += flag; + (*parameterWords)[i] += flag; } flag <<= 1; } @@ -217,7 +216,7 @@ void Detector::correctParameterData(QSharedPointer parameterDat for (int i = 0; i < numDataCodewords; i++) { int flag = 1; for (int j = 1; j <= codewordSize; j++) { - if ((parameterWords[i] & flag) == flag) { + if (((*parameterWords)[i] & flag) == flag) { parameterData->set(i*codewordSize+codewordSize-j); } flag <<= 1; @@ -449,10 +448,10 @@ bool Detector::isWhiteOrBlackRectangle(QSharedPointer p1, QSharedPointer p4) { int corr = 3; - p1 = new Point(p1->getX() - corr, p1->getY() + corr); - p2 = new Point(p2->getX() - corr, p2->getY() - corr); - p3 = new Point(p3->getX() + corr, p3->getY() - corr); - p4 = new Point(p4->getX() + corr, p4->getY() + corr); + p1.reset(new Point(p1->getX() - corr, p1->getY() + corr)); + p2.reset(new Point(p2->getX() - corr, p2->getY() - corr)); + p3.reset(new Point(p3->getX() + corr, p3->getY() - corr)); + p4.reset(new Point(p4->getX() + corr, p4->getY() + corr)); int cInit = getColor(p4, p1); diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp index e0727ab..b60ee70 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixBitMatrixParser.cpp @@ -39,7 +39,7 @@ BitMatrixParser::BitMatrixParser(QSharedPointer bitMatrix) : bitMatri parsedVersion_ = readVersion(bitMatrix); bitMatrix_ = extractDataRegion(bitMatrix); - readBitMatrix_ = new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight()); + readBitMatrix_.reset(new BitMatrix(bitMatrix_->getWidth(), bitMatrix_->getHeight())); } QSharedPointer BitMatrixParser::readVersion(QSharedPointer bitMatrix) { @@ -58,7 +58,7 @@ QSharedPointer BitMatrixParser::readVersion(QSharedPointer b } QSharedPointer> BitMatrixParser::readCodewords() { - QSharedPointer> result(parsedVersion_->getTotalCodewords()); + QSharedPointer> result(new std::vector(parsedVersion_->getTotalCodewords())); int resultOffset = 0; int row = 4; int column = 0; @@ -75,22 +75,22 @@ QSharedPointer> BitMatrixParser::readCodewords() { do { // Check the four corner cases if ((row == numRows) && (column == 0) && !corner1Read) { - result[resultOffset++] = (zxing::byte) readCorner1(numRows, numColumns); + (*result)[resultOffset++] = (zxing::byte) readCorner1(numRows, numColumns); row -= 2; column +=2; corner1Read = true; } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) { - result[resultOffset++] = (zxing::byte) readCorner2(numRows, numColumns); + (*result)[resultOffset++] = (zxing::byte) readCorner2(numRows, numColumns); row -= 2; column +=2; corner2Read = true; } else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) { - result[resultOffset++] = (zxing::byte) readCorner3(numRows, numColumns); + (*result)[resultOffset++] = (zxing::byte) readCorner3(numRows, numColumns); row -= 2; column +=2; corner3Read = true; } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) { - result[resultOffset++] = (zxing::byte) readCorner4(numRows, numColumns); + (*result)[resultOffset++] = (zxing::byte) readCorner4(numRows, numColumns); row -= 2; column +=2; corner4Read = true; @@ -98,7 +98,7 @@ QSharedPointer> BitMatrixParser::readCodewords() { // Sweep upward diagonally to the right do { if ((row < numRows) && (column >= 0) && !readBitMatrix_->get(column, row)) { - result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns); + (*result)[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns); } row -= 2; column +=2; @@ -109,7 +109,7 @@ QSharedPointer> BitMatrixParser::readCodewords() { // Sweep downward diagonally to the left do { if ((row >= 0) && (column < numColumns) && !readBitMatrix_->get(column, row)) { - result[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns); + (*result)[resultOffset++] = (zxing::byte) readUtah(row, column, numRows, numColumns); } row += 2; column -=2; diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp index 4a7cfcf..ec82daf 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDataBlock.cpp @@ -58,7 +58,7 @@ std::vector > DataBlock::getDataBlocks(QSharedPointer< for (int i = 0; i < ecBlock->getCount(); i++) { int numDataCodewords = ecBlock->getDataCodewords(); int numBlockCodewords = ecBlocks->getECCodewords() + numDataCodewords; - QSharedPointer> buffer(numBlockCodewords); + QSharedPointer> buffer(new std::vector(numBlockCodewords)); QSharedPointer blockRef(new DataBlock(numDataCodewords, buffer)); result[numResultBlocks++] = blockRef; } @@ -86,19 +86,19 @@ std::vector > DataBlock::getDataBlocks(QSharedPointer< int rawCodewordsOffset = 0; for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { for (int j = 0; j < numResultBlocks; j++) { - result[j]->codewords_[i] = rawCodewords[rawCodewordsOffset++]; + (*result[j]->codewords_)[i] = (*rawCodewords)[rawCodewordsOffset++]; } } // Fill out the last data block in the longer ones for (int j = longerBlocksStartAt; j < numResultBlocks; j++) { - result[j]->codewords_[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; + (*result[j]->codewords_)[shorterBlocksNumDataCodewords] = (*rawCodewords)[rawCodewordsOffset++]; } // Now add in error correction blocks int max = result[0]->codewords_->size(); for (int i = shorterBlocksNumDataCodewords; i < max; i++) { for (int j = 0; j < numResultBlocks; j++) { int iOffset = j < longerBlocksStartAt ? i : i + 1; - result[j]->codewords_[iOffset] = rawCodewords[rawCodewordsOffset++]; + (*result[j]->codewords_)[iOffset] = (*rawCodewords)[rawCodewordsOffset++]; } } diff --git a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp index a0311bb..e36f7fe 100644 --- a/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp +++ b/src/zxing/zxing/datamatrix/decoder/DataMatrixDecoder.cpp @@ -44,9 +44,9 @@ Decoder::Decoder() : rsDecoder_(GenericGF::DATA_MATRIX_FIELD_256) {} void Decoder::correctErrors(QSharedPointer> codewordBytes, int numDataCodewords) { int numCodewords = codewordBytes->size(); - QSharedPointer> codewordInts(numCodewords); + QSharedPointer> codewordInts(new std::vector(numCodewords)); for (int i = 0; i < numCodewords; i++) { - codewordInts[i] = codewordBytes[i] & 0xff; + (*codewordInts)[i] = (*codewordBytes)[i] & 0xff; } int numECCodewords = numCodewords - numDataCodewords; try { @@ -58,7 +58,7 @@ void Decoder::correctErrors(QSharedPointer> codewordByt // Copy back into array of bytes -- only need to worry about the bytes that were data // We don't care about errors in the error-correction codewords for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (zxing::byte)codewordInts[i]; + (*codewordBytes)[i] = (zxing::byte)(*codewordInts)[i]; } } @@ -79,7 +79,7 @@ QSharedPointer Decoder::decode(QSharedPointer bits) { for (int i = 0; i < dataBlocksCount; i++) { totalBytes += dataBlocks[i]->getNumDataCodewords(); } - QSharedPointer> resultBytes(totalBytes); + QSharedPointer> resultBytes(new std::vector(totalBytes)); // Error-correct and copy data blocks together into a stream of bytes for (int j = 0; j < dataBlocksCount; j++) { @@ -89,7 +89,7 @@ QSharedPointer Decoder::decode(QSharedPointer bits) { correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { // De-interlace data blocks. - resultBytes[i * dataBlocksCount + j] = codewordBytes[i]; + (*resultBytes)[i * dataBlocksCount + j] = (*codewordBytes)[i]; } } // Decode the contents of that stream of bytes diff --git a/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h b/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h index 30a40bf..1e8f8bc 100644 --- a/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h +++ b/src/zxing/zxing/pdf417/decoder/DecodedBitStreamParser.h @@ -61,8 +61,8 @@ class DecodedBitStreamParser { static const char PUNCT_CHARS[]; static const char MIXED_CHARS[]; - static QSharedPointer EXP900; - static QSharedPointer initEXP900(); + static QSharedPointer> EXP900; + static QSharedPointer> initEXP900(); static int textCompaction(QSharedPointer> codewords, int codeIndex, QSharedPointer result); static void decodeTextCompaction(QSharedPointer> textCompactionData, diff --git a/src/zxing/zxing/pdf417/decoder/PDF417BitMatrixParser.cpp b/src/zxing/zxing/pdf417/decoder/PDF417BitMatrixParser.cpp index 130d692..482f20b 100644 --- a/src/zxing/zxing/pdf417/decoder/PDF417BitMatrixParser.cpp +++ b/src/zxing/zxing/pdf417/decoder/PDF417BitMatrixParser.cpp @@ -72,7 +72,7 @@ QSharedPointer> BitMatrixParser::readCodewords() //int width = bitMatrix_->getWidth(); int height = bitMatrix_->getHeight(); - erasures_ = new std::vector(MAX_CW_CAPACITY); + erasures_.reset(new std::vector(MAX_CW_CAPACITY)); QSharedPointer> codewords (new std::vector(MAX_CW_CAPACITY)); int next = 0; @@ -129,14 +129,14 @@ int BitMatrixParser::processRow(int rowNumber, QSharedPointer> if (eraseCount_ >= (int)erasures_->size()) { throw FormatException("BitMatrixParser::processRow(PDF417): eraseCount too big!"); } - erasures_[eraseCount_] = next; + (*erasures_)[eraseCount_] = next; next++; eraseCount_++; } else { if (next >= codewords->size()) { throw FormatException("BitMatrixParser::processRow(PDF417): codewords index out of bound."); } - codewords[next++] = cw; + (*codewords)[next++] = cw; } } else { // Left row indicator column @@ -154,10 +154,10 @@ int BitMatrixParser::processRow(int rowNumber, QSharedPointer> // Right row indicator column is in codeword[next] // Overwrite the last codeword i.e. Right Row Indicator --next; - aRightColumnTriple_[rowNumber % 3] = codewords[next]; /* added 2012-06-22 hfn */ + aRightColumnTriple_[rowNumber % 3] = (*codewords)[next]; /* added 2012-06-22 hfn */ if (rowNumber % 3 == 2) { if (ecLevel_ < 0) { - rightColumnECData_ = codewords[next]; + rightColumnECData_ = (*codewords)[next]; if (rightColumnECData_ == leftColumnECData_ && (int)leftColumnECData_ > 0) { /* leftColumnECData_ != 0 */ ecLevel_ = ((rightColumnECData_ % 30) - rows_ % 3) / 3; } @@ -167,7 +167,7 @@ int BitMatrixParser::processRow(int rowNumber, QSharedPointer> throw FormatException("BitMatrixParser::processRow(PDF417): outer columns corrupted!"); } } - codewords[next] = 0; + (*codewords)[next] = 0; } return next; } @@ -187,9 +187,9 @@ QSharedPointer> BitMatrixParser::trimArray(QSharedPointer> a = new std::vector(size); + QSharedPointer> a(new std::vector(size)); for (int i = 0; i < size; i++) { - a[i] = array[i]; + (*a)[i] = (*array)[i]; } return a; } diff --git a/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp b/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp index ff1dd76..494e128 100644 --- a/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp +++ b/src/zxing/zxing/pdf417/decoder/PDF417DecodedBitStreamParser.cpp @@ -61,18 +61,18 @@ const char DecodedBitStreamParser::MIXED_CHARS[] = { '\r', '\t', ',', ':', '#', '-', '.', '$', '/', '+', '%', '*', '=', '^'}; -QSharedPointer DecodedBitStreamParser::initEXP900() { - QSharedPointer EXP900 (16); - EXP900[0] = BigInteger(1); +QSharedPointer> DecodedBitStreamParser::initEXP900() { + QSharedPointer> EXP900 (new std::vector(16)); + (*EXP900)[0] = BigInteger(1); BigInteger nineHundred (900); - EXP900[1] = nineHundred; + (*EXP900)[1] = nineHundred; for (int i = 2; i < EXP900->size(); i++) { - EXP900[i] = EXP900[i - 1] * nineHundred; + (*EXP900)[i] = (*EXP900)[i - 1] * nineHundred; } return EXP900; } -QSharedPointer DecodedBitStreamParser::EXP900 = initEXP900(); +QSharedPointer> DecodedBitStreamParser::EXP900 = initEXP900(); DecodedBitStreamParser::DecodedBitStreamParser(){} @@ -84,8 +84,8 @@ QSharedPointer DecodedBitStreamParser::decode(QSharedPointer result (new String(100)); // Get compaction mode int codeIndex = 1; - int code = codewords[codeIndex++]; - while (codeIndex < codewords[0]) { + int code = (*codewords)[codeIndex++]; + while (codeIndex < (*codewords)[0]) { switch (code) { case TEXT_COMPACTION_MODE_LATCH: codeIndex = textCompaction(codewords, codeIndex, result); @@ -111,7 +111,7 @@ QSharedPointer DecodedBitStreamParser::decode(QSharedPointersize()) { - code = codewords[codeIndex++]; + code = (*codewords)[codeIndex++]; } else { throw FormatException(); } @@ -133,22 +133,22 @@ int DecodedBitStreamParser::textCompaction(QSharedPointer> code int codeIndex, QSharedPointer result) { // 2 character per codeword - QSharedPointer> textCompactionData (codewords[0] << 1); + QSharedPointer> textCompactionData (new std::vector((*codewords)[0] << 1)); // Used to hold the byte compaction value if there is a mode shift - QSharedPointer> byteCompactionData (codewords[0] << 1); + QSharedPointer> byteCompactionData (new std::vector((*codewords)[0] << 1)); int index = 0; bool end = false; - while ((codeIndex < codewords[0]) && !end) { - int code = codewords[codeIndex++]; + while ((codeIndex < (*codewords)[0]) && !end) { + int code = (*codewords)[codeIndex++]; if (code < TEXT_COMPACTION_MODE_LATCH) { - textCompactionData[index] = code / 30; - textCompactionData[index + 1] = code % 30; + (*textCompactionData)[index] = code / 30; + (*textCompactionData)[index + 1] = code % 30; index += 2; } else { switch (code) { case TEXT_COMPACTION_MODE_LATCH: - textCompactionData[index++] = TEXT_COMPACTION_MODE_LATCH; + (*textCompactionData)[index++] = TEXT_COMPACTION_MODE_LATCH; break; case BYTE_COMPACTION_MODE_LATCH: codeIndex--; @@ -165,9 +165,9 @@ int DecodedBitStreamParser::textCompaction(QSharedPointer> code // after which the mode shall revert to the prevailing sub-mode // of the Text Compaction mode. Codeword 913 is only available // in Text Compaction mode; its use is described in 5.4.2.4. - textCompactionData[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; - code = codewords[codeIndex++]; - byteCompactionData[index] = code; //Integer.toHexString(code); + (*textCompactionData)[index] = MODE_SHIFT_TO_BYTE_COMPACTION_MODE; + code = (*codewords)[codeIndex++]; + (*byteCompactionData)[index] = code; //Integer.toHexString(code); index++; break; case BYTE_COMPACTION_MODE_LATCH_6: @@ -210,7 +210,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointerappend((zxing::byte) byteCompactionData[i]); + result->append((zxing::byte) (*byteCompactionData)[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -255,7 +255,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointerappend((zxing::byte) byteCompactionData[i]); + result->append((zxing::byte) (*byteCompactionData)[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -280,7 +280,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointerappend((zxing::byte) byteCompactionData[i]); + result->append((zxing::byte) (*byteCompactionData)[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -295,7 +295,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointerappend((zxing::byte) byteCompactionData[i]); + result->append((zxing::byte) (*byteCompactionData)[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -332,7 +332,7 @@ void DecodedBitStreamParser::decodeTextCompaction(QSharedPointerappend((zxing::byte) byteCompactionData[i]); + result->append((zxing::byte) (*byteCompactionData)[i]); } else if (subModeCh == TEXT_COMPACTION_MODE_LATCH) { subMode = ALPHA; } @@ -366,15 +366,15 @@ int DecodedBitStreamParser::byteCompaction(int mode, // is not a multiple of 6 int count = 0; int64_t value = 0; - QSharedPointer> decodedData = new std::vector(6); - QSharedPointer> byteCompactedCodewords = new std::vector(6); + QSharedPointer> decodedData(new std::vector(6)); + QSharedPointer> byteCompactedCodewords(new std::vector(6)); bool end = false; - int nextCode = codewords[codeIndex++]; - while ((codeIndex < codewords[0]) && !end) { - byteCompactedCodewords[count++] = nextCode; + int nextCode = (*codewords)[codeIndex++]; + while ((codeIndex < (*codewords)[0]) && !end) { + (*byteCompactedCodewords)[count++] = nextCode; // Base 900 value = 900 * value + nextCode; - nextCode = codewords[codeIndex++]; + nextCode = (*codewords)[codeIndex++]; // perhaps it should be ok to check only nextCode >= TEXT_COMPACTION_MODE_LATCH if (nextCode == TEXT_COMPACTION_MODE_LATCH || nextCode == BYTE_COMPACTION_MODE_LATCH || @@ -394,25 +394,25 @@ int DecodedBitStreamParser::byteCompaction(int mode, // Convert to Base 256 for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (zxing::byte) (value%256); + (*decodedData)[5 - j] = (zxing::byte) (value%256); value >>= 8; } - result->append(string((char*)&(decodedData->values()[0]), decodedData->values().size())); + result->append(string((char*)&((*decodedData)[0]), decodedData->size())); count = 0; } } } // if the end of all codewords is reached the last codeword needs to be added - if (codeIndex == codewords[0] && nextCode < TEXT_COMPACTION_MODE_LATCH) - byteCompactedCodewords[count++] = nextCode; + if (codeIndex == (*codewords)[0] && nextCode < TEXT_COMPACTION_MODE_LATCH) + (*byteCompactedCodewords)[count++] = nextCode; // If Byte Compaction mode is invoked with codeword 901, // the last group of codewords is interpreted directly // as one byte per codeword, without compaction. for (int i = 0; i < count; i++) { - result->append((zxing::byte)byteCompactedCodewords[i]); + result->append((zxing::byte)(*byteCompactedCodewords)[i]); } } else if (mode == BYTE_COMPACTION_MODE_LATCH_6) { @@ -421,8 +421,8 @@ int DecodedBitStreamParser::byteCompaction(int mode, int count = 0; int64_t value = 0; bool end = false; - while (codeIndex < codewords[0] && !end) { - int code = codewords[codeIndex++]; + while (codeIndex < (*codewords)[0] && !end) { + int code = (*codewords)[codeIndex++]; if (code < TEXT_COMPACTION_MODE_LATCH) { count++; // Base 900 @@ -442,12 +442,12 @@ int DecodedBitStreamParser::byteCompaction(int mode, if ((count % 5 == 0) && (count > 0)) { // Decode every 5 codewords // Convert to Base 256 - QSharedPointer> decodedData = new std::vector(6); + QSharedPointer> decodedData(new std::vector(6)); for (int j = 0; j < 6; ++j) { - decodedData[5 - j] = (zxing::byte) (value & 0xFF); + (*decodedData)[5 - j] = (zxing::byte) (value & 0xFF); value >>= 8; } - result->append(string((char*)&decodedData[0],6)); + result->append(string((char*)&(*decodedData)[0],6)); // 2012-11-27 hfn after recent java code/fix by srowen count = 0; } @@ -470,15 +470,15 @@ int DecodedBitStreamParser::numericCompaction(QSharedPointer> c int count = 0; bool end = false; - QSharedPointer> numericCodewords = new std::vector(MAX_NUMERIC_CODEWORDS); + QSharedPointer> numericCodewords(new std::vector(MAX_NUMERIC_CODEWORDS)); - while (codeIndex < codewords[0] && !end) { - int code = codewords[codeIndex++]; - if (codeIndex == codewords[0]) { + while (codeIndex < (*codewords)[0] && !end) { + int code = (*codewords)[codeIndex++]; + if (codeIndex == (*codewords)[0]) { end = true; } if (code < TEXT_COMPACTION_MODE_LATCH) { - numericCodewords[count] = code; + (*numericCodewords)[count] = code; count++; } else { if (code == TEXT_COMPACTION_MODE_LATCH || @@ -553,7 +553,7 @@ QSharedPointer DecodedBitStreamParser::decodeBase900toBase10(QSharedPoin { BigInteger result = BigInteger(0); for (int i = 0; i < count; i++) { - result = result + (EXP900[count - i - 1] * BigInteger(codewords[i])); + result = result + ((*EXP900)[count - i - 1] * BigInteger((*codewords)[i])); } string resultString = bigIntegerToString(result); if (resultString[0] != '1') { diff --git a/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp b/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp index 3566d23..b5a8461 100644 --- a/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp +++ b/src/zxing/zxing/pdf417/decoder/ec/ErrorCorrection.cpp @@ -53,7 +53,7 @@ void ErrorCorrection::decode(QSharedPointer> received, bool error = false; for (int i = numECCodewords; i > 0; i--) { int eval = poly->evaluateAt(field_.exp(i)); - S[numECCodewords - i] = eval; + (*S)[numECCodewords - i] = eval; if (eval != 0) { error = true; } @@ -63,11 +63,11 @@ void ErrorCorrection::decode(QSharedPointer> received, QSharedPointer knownErrors = field_.getOne(); for (int i=0;isize();i++) { - int b = field_.exp(received->size() - 1 - erasures[i]); + int b = field_.exp(received->size() - 1 - (*erasures)[i]); // Add (1 - bx) term: QSharedPointer> one_minus_b_x(new std::vector(2)); - one_minus_b_x[1]=field_.subtract(0,b); - one_minus_b_x[0]=1; + (*one_minus_b_x)[1]=field_.subtract(0,b); + (*one_minus_b_x)[0]=1; QSharedPointer term (new ModulusPoly(field_,one_minus_b_x)); knownErrors = knownErrors->multiply(term); } @@ -86,11 +86,11 @@ void ErrorCorrection::decode(QSharedPointer> received, QSharedPointer> errorMagnitudes = findErrorMagnitudes(omega, sigma, errorLocations); for (int i = 0; i < errorLocations->size(); i++) { - int position = received->size() - 1 - field_.log(errorLocations[i]); + int position = received->size() - 1 - field_.log((*errorLocations)[i]); if (position < 0) { throw ReedSolomonException("Bad error location!"); } - received[position] = field_.subtract(received[position], errorMagnitudes[i]); + (*received)[position] = field_.subtract((*received)[position], (*errorMagnitudes)[i]); #if (defined (DEBUG) && defined _WIN32) { WCHAR szmsg[256]; @@ -164,7 +164,7 @@ QSharedPointer> ErrorCorrection::findErrorLocations(QSharedPoin int e = 0; for (int i = 1; i < field_.getSize() && e < numErrors; i++) { if (errorLocator->evaluateAt(i) == 0) { - result[e] = field_.inverse(i); + (*result)[e] = field_.inverse(i); e++; } } @@ -195,7 +195,7 @@ QSharedPointer> ErrorCorrection::findErrorMagnitudes(QSharedPoi int errorLocatorDegree = errorLocator->getDegree(); QSharedPointer> formalDerivativeCoefficients (new std::vector(errorLocatorDegree)); for (i = 1; i <= errorLocatorDegree; i++) { - formalDerivativeCoefficients[errorLocatorDegree - i] = + (*formalDerivativeCoefficients)[errorLocatorDegree - i] = field_.multiply(i, errorLocator->getCoefficient(i)); } QSharedPointer formalDerivative (new ModulusPoly(field_, formalDerivativeCoefficients)); @@ -204,10 +204,10 @@ QSharedPointer> ErrorCorrection::findErrorMagnitudes(QSharedPoi int s = errorLocations->size(); QSharedPointer> result ( new std::vector(s)); for (i = 0; i < s; i++) { - int xiInverse = field_.inverse(errorLocations[i]); + int xiInverse = field_.inverse((*errorLocations)[i]); int numerator = field_.subtract(0, errorEvaluator->evaluateAt(xiInverse)); int denominator = field_.inverse(formalDerivative->evaluateAt(xiInverse)); - result[i] = field_.multiply(numerator, denominator); + (*result)[i] = field_.multiply(numerator, denominator); } return result; } diff --git a/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp b/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp index 5d808b7..818811d 100644 --- a/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp +++ b/src/zxing/zxing/pdf417/decoder/ec/ModulusGF.cpp @@ -40,21 +40,22 @@ ModulusGF ModulusGF::PDF417_GF(929,3); ModulusGF::ModulusGF(int modulus, int generator) : modulus_(modulus) { - expTable_ = new std::vector(modulus_); - logTable_ = new std::vector(modulus_); + expTable_.reset(new std::vector(modulus_)); + logTable_.reset(new std::vector(modulus_)); int x = 1,i; for (i = 0; i < modulus_; i++) { - expTable_[i] = x; + (*expTable_)[i] = x; x = (x * generator) % modulus_; } for (i = 0; i < modulus_-1; i++) { - logTable_[expTable_[i]] = i; + (*logTable_)[(*expTable_)[i]] = i; } // logTable[0] == 0 but this should never be used QSharedPointer>aZero(new std::vector(1)),aOne(new std::vector(1)); - aZero[0]=0;aOne[0]=1; - zero_ = new ModulusPoly(*this, aZero); - one_ = new ModulusPoly(*this, aOne); + (*aZero)[0]=0; + (*aOne)[0]=1; + zero_.reset(new ModulusPoly(*this, aZero)); + one_.reset(new ModulusPoly(*this, aOne)); } QSharedPointer ModulusGF::getZero() { @@ -75,7 +76,7 @@ QSharedPointer ModulusGF::buildMonomial(int degree, int coefficient } int nCoefficients = degree + 1; QSharedPointer> coefficients (new std::vector(nCoefficients)); - coefficients[0] = coefficient; + (*coefficients)[0] = coefficient; QSharedPointer result(new ModulusPoly(*this,coefficients)); return result; } @@ -91,28 +92,28 @@ int ModulusGF::subtract(int a, int b) { } int ModulusGF::exp(int a) { - return expTable_[a]; + return (*expTable_)[a]; } int ModulusGF::log(int a) { if (a == 0) { throw IllegalArgumentException("log of zero!"); } - return logTable_[a]; + return (*logTable_)[a]; } int ModulusGF::inverse(int a) { if (a == 0) { throw IllegalArgumentException("inverse of zero!");; } - return expTable_[modulus_ - logTable_[a] - 1]; + return (*expTable_)[modulus_ - (*logTable_)[a] - 1]; } int ModulusGF::multiply(int a, int b) { if (a == 0 || b == 0) { return 0; } - return expTable_[(logTable_[a] + logTable_[b]) % (modulus_ - 1)]; + return (*expTable_)[((*logTable_)[a] + (*logTable_)[b]) % (modulus_ - 1)]; } int ModulusGF::getSize() { diff --git a/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp b/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp index 754fdaf..5ac87a0 100644 --- a/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp +++ b/src/zxing/zxing/pdf417/decoder/ec/ModulusPoly.cpp @@ -37,11 +37,11 @@ ModulusPoly::ModulusPoly(ModulusGF &field, QSharedPointer> coef throw IllegalArgumentException("no coefficients!"); } int coefficientsLength = coefficients->size(); - if (coefficientsLength > 1 && coefficients[0] == 0) + if (coefficientsLength > 1 && (*coefficients)[0] == 0) { // Leading term must be non-zero for anything except the constant polynomial "0" int firstNonZero = 1; - while (firstNonZero < coefficientsLength && coefficients[firstNonZero] == 0) + while (firstNonZero < coefficientsLength && (*coefficients)[firstNonZero] == 0) { firstNonZero++; } @@ -58,7 +58,7 @@ ModulusPoly::ModulusPoly(ModulusGF &field, QSharedPointer> coef coefficients_.reset(new std::vector(coefficientsLength)); for (int i = 0; i < coefficientsLength; i++) { - coefficients_[i] = c[i + firstNonZero]; + (*coefficients_)[i] = (*c)[i + firstNonZero]; } /* coefficientsLength -= firstNonZero; @@ -93,7 +93,7 @@ int ModulusPoly::getDegree() */ bool ModulusPoly::isZero() { - return coefficients_[0] == 0; + return (*coefficients_)[0] == 0; } /** @@ -101,7 +101,7 @@ bool ModulusPoly::isZero() */ int ModulusPoly::getCoefficient(int degree) { - return coefficients_[coefficients_->size() - 1 - degree]; + return (*coefficients_)[coefficients_->size() - 1 - degree]; } /** @@ -122,14 +122,14 @@ int ModulusPoly::evaluateAt(int a) int result = 0; for (i = 0; i < size; i++) { - result = field_.add(result, coefficients_[i]); + result = field_.add(result, (*coefficients_)[i]); } return result; } - int result = coefficients_[0]; + int result = (*coefficients_)[0]; for (i = 1; i < size; i++) { - result = field_.add(field_.multiply(a, result), coefficients_[i]); + result = field_.add(field_.multiply(a, result), (*coefficients_)[i]); } return result; } @@ -162,12 +162,12 @@ QSharedPointer ModulusPoly::add(QSharedPointer other) // Copy high-order terms only found in higher-degree polynomial's coefficients for (int i = 0; i < lengthDiff; i++) { - sumDiff[i] = largerCoefficients[i]; + (*sumDiff)[i] = (*largerCoefficients)[i]; } for (int i = lengthDiff; i < largerCoefficients->size(); i++) { - sumDiff[i] = field_.add(smallerCoefficients[i - lengthDiff], largerCoefficients[i]); + (*sumDiff)[i] = field_.add((*smallerCoefficients)[i - lengthDiff], (*largerCoefficients)[i]); } return QSharedPointer(new ModulusPoly(field_, sumDiff)); @@ -204,10 +204,10 @@ QSharedPointer ModulusPoly::multiply(QSharedPointer ot QSharedPointer> product(new std::vector(aLength + bLength - 1)); for (i = 0; i < aLength; i++) { - int aCoeff = aCoefficients[i]; + int aCoeff = (*aCoefficients)[i]; for (j = 0; j < bLength; j++) { - product[i + j] = field_.add(product[i + j], field_.multiply(aCoeff, bCoefficients[j])); + (*product)[i + j] = field_.add((*product)[i + j], field_.multiply(aCoeff, (*bCoefficients)[j])); } } return QSharedPointer(new ModulusPoly(field_, product)); @@ -219,7 +219,7 @@ QSharedPointer ModulusPoly::negative() QSharedPointer> negativeCoefficients(new std::vector(size)); for (int i = 0; i < size; i++) { - negativeCoefficients[i] = field_.subtract(0, coefficients_[i]); + (*negativeCoefficients)[i] = field_.subtract(0, (*coefficients_)[i]); } return QSharedPointer(new ModulusPoly(field_, negativeCoefficients)); } @@ -238,7 +238,7 @@ QSharedPointer ModulusPoly::multiply(int scalar) QSharedPointer> product(new std::vector(size)); for (int i = 0; i < size; i++) { - product[i] = field_.multiply(coefficients_[i], scalar); + (*product)[i] = field_.multiply((*coefficients_)[i], scalar); } return QSharedPointer(new ModulusPoly(field_, product)); } @@ -257,7 +257,7 @@ QSharedPointer ModulusPoly::multiplyByMonomial(int degree, int coef QSharedPointer> product(new std::vector(size + degree)); for (int i = 0; i < size; i++) { - product[i] = field_.multiply(coefficients_[i], coefficient); + (*product)[i] = field_.multiply((*coefficients_)[i], coefficient); } return QSharedPointer(new ModulusPoly(field_, product)); } diff --git a/src/zxing/zxing/pdf417/detector/PDF417Detector.cpp b/src/zxing/zxing/pdf417/detector/PDF417Detector.cpp index 9b0ab97..ca849ec 100644 --- a/src/zxing/zxing/pdf417/detector/PDF417Detector.cpp +++ b/src/zxing/zxing/pdf417/detector/PDF417Detector.cpp @@ -106,24 +106,24 @@ QSharedPointer Detector::detect(DecodeHints const& hints) { throw NotFoundException("Bad module width."); } - int dimension = computeDimension(vertices[12], vertices[14], - vertices[13], vertices[15], moduleWidth); + int dimension = computeDimension((*vertices)[12], (*vertices)[14], + (*vertices)[13], (*vertices)[15], moduleWidth); if (dimension < 1) { throw NotFoundException("Bad dimension."); } - int yDimension = max(computeYDimension(vertices[12], vertices[14], - vertices[13], vertices[15], moduleWidth), dimension); + int yDimension = max(computeYDimension((*vertices)[12], (*vertices)[14], + (*vertices)[13], (*vertices)[15], moduleWidth), dimension); // Deskew and sample lines from image. QSharedPointer linesMatrix = sampleLines(vertices, dimension, yDimension); QSharedPointer linesGrid(LinesSampler(linesMatrix, dimension).sample()); - QSharedPointer> > points(4); - points[0] = vertices[5]; - points[1] = vertices[4]; - points[2] = vertices[6]; - points[3] = vertices[7]; + QSharedPointer>> points(new std::vector>(4)); + (*points)[0] = (*vertices)[5]; + (*points)[1] = (*vertices)[4]; + (*points)[2] = (*vertices)[6]; + (*points)[3] = (*vertices)[7]; return QSharedPointer(new DetectorResult(linesGrid, points)); } @@ -148,7 +148,7 @@ QSharedPointer> > Detector::findVertices const int height = matrix->getHeight(); const int width = matrix->getWidth(); - QSharedPointer> > result(16); + QSharedPointer>> result(new std::vector>(16)); bool found = false; QSharedPointer> counters(new std::vector(START_PATTERN_LENGTH)); @@ -158,8 +158,8 @@ QSharedPointer> > Detector::findVertices QSharedPointer> loc = findGuardPattern(matrix, 0, i, width, false, START_PATTERN, START_PATTERN_LENGTH, counters); if (loc) { - result[0] = new ResultPoint((float)loc[0], (float)i); - result[4] = new ResultPoint((float)loc[1], (float)i); + (*result)[0].reset(new ResultPoint((float)(*loc)[0], (float)i)); + (*result)[4].reset(new ResultPoint((float)(*loc)[1], (float)i)); found = true; break; } @@ -171,15 +171,15 @@ QSharedPointer> > Detector::findVertices QSharedPointer> loc = findGuardPattern(matrix, 0, i, width, false, START_PATTERN, START_PATTERN_LENGTH, counters); if (loc) { - result[1] = new ResultPoint((float)loc[0], (float)i); - result[5] = new ResultPoint((float)loc[1], (float)i); + (*result)[1].reset(new ResultPoint((float)(*loc)[0], (float)i)); + (*result)[5].reset(new ResultPoint((float)(*loc)[1], (float)i)); found = true; break; } } } - counters = new std::vector(STOP_PATTERN_LENGTH); + counters.reset(new std::vector(STOP_PATTERN_LENGTH)); // Top right if (found) { // Found the Bottom Left vertex @@ -188,8 +188,8 @@ QSharedPointer> > Detector::findVertices QSharedPointer> loc = findGuardPattern(matrix, 0, i, width, false, STOP_PATTERN, STOP_PATTERN_LENGTH, counters); if (loc) { - result[2] = new ResultPoint((float)loc[1], (float)i); - result[6] = new ResultPoint((float)loc[0], (float)i); + (*result)[2].reset(new ResultPoint((float)(*loc)[1], (float)i)); + (*result)[6].reset(new ResultPoint((float)(*loc)[0], (float)i)); found = true; break; } @@ -202,8 +202,8 @@ QSharedPointer> > Detector::findVertices QSharedPointer> loc = findGuardPattern(matrix, 0, i, width, false, STOP_PATTERN, STOP_PATTERN_LENGTH, counters); if (loc) { - result[3] = new ResultPoint((float)loc[1], (float)i); - result[7] = new ResultPoint((float)loc[0], (float)i); + (*result)[3].reset(new ResultPoint((float)(*loc)[1], (float)i)); + (*result)[7].reset(new ResultPoint((float)(*loc)[0], (float)i)); found = true; break; } @@ -218,10 +218,10 @@ QSharedPointer> > Detector::findVertices const int width = matrix->getWidth(); const int halfWidth = width >> 1; - QSharedPointer> > result(16); + QSharedPointer>> result(new std::vector>(16)); bool found = false; - QSharedPointer> counters = new std::vector(START_PATTERN_REVERSE_LENGTH); + QSharedPointer> counters(new std::vector(START_PATTERN_REVERSE_LENGTH)); // Top Left for (int i = height - 1; i > 0; i -= rowStep) { @@ -229,8 +229,8 @@ QSharedPointer> > Detector::findVertices findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE, START_PATTERN_REVERSE_LENGTH, counters); if (loc) { - result[0] = new ResultPoint((float)loc[1], (float)i); - result[4] = new ResultPoint((float)loc[0], (float)i); + (*result)[0].reset(new ResultPoint((float)(*loc)[1], (float)i)); + (*result)[4].reset(new ResultPoint((float)(*loc)[0], (float)i)); found = true; break; } @@ -243,15 +243,15 @@ QSharedPointer> > Detector::findVertices findGuardPattern(matrix, halfWidth, i, halfWidth, true, START_PATTERN_REVERSE, START_PATTERN_REVERSE_LENGTH, counters); if (loc) { - result[1] = new ResultPoint((float)loc[1], (float)i); - result[5] = new ResultPoint((float)loc[0], (float)i); + (*result)[1].reset(new ResultPoint((float)(*loc)[1], (float)i)); + (*result)[5].reset(new ResultPoint((float)(*loc)[0], (float)i)); found = true; break; } } } - counters = new std::vector(STOP_PATTERN_REVERSE_LENGTH); + counters.reset(new std::vector(STOP_PATTERN_REVERSE_LENGTH)); // Top Right if (found) { // Found the Bottom Left vertex @@ -260,8 +260,8 @@ QSharedPointer> > Detector::findVertices QSharedPointer> loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE, STOP_PATTERN_REVERSE_LENGTH, counters); if (loc) { - result[2] = new ResultPoint((float)loc[0], (float)i); - result[6] = new ResultPoint((float)loc[1], (float)i); + (*result)[2].reset(new ResultPoint((float)(*loc)[0], (float)i)); + (*result)[6].reset(new ResultPoint((float)(*loc)[1], (float)i)); found = true; break; } @@ -274,8 +274,8 @@ QSharedPointer> > Detector::findVertices QSharedPointer> loc = findGuardPattern(matrix, 0, i, halfWidth, false, STOP_PATTERN_REVERSE, STOP_PATTERN_REVERSE_LENGTH, counters); if (loc) { - result[3] = new ResultPoint((float)loc[0], (float)i); - result[7] = new ResultPoint((float)loc[1], (float)i); + (*result)[3].reset(new ResultPoint((float)(*loc)[0], (float)i)); + (*result)[7].reset(new ResultPoint((float)(*loc)[1], (float)i)); found = true; break; } @@ -303,7 +303,7 @@ QSharedPointer> Detector::findGuardPattern(QSharedPointer>& counters) { - counters->values().assign(counters->size(), 0); + counters->assign(counters->size(), 0); int patternLength = patternSize; bool isWhite = whiteFirst; @@ -312,26 +312,26 @@ QSharedPointer> Detector::findGuardPattern(QSharedPointerget(x, row); if (pixel ^ isWhite) { - counters[counterPosition]++; + (*counters)[counterPosition]++; } else { if (counterPosition == patternLength - 1) { if (patternMatchVariance(counters, pattern, MAX_INDIVIDUAL_VARIANCE) < MAX_AVG_VARIANCE) { - QSharedPointer> result = new std::vector(2); - result[0] = patternStart; - result[1] = x; + QSharedPointer> result(new std::vector(2)); + (*result)[0] = patternStart; + (*result)[1] = x; return result; } - patternStart += counters[0] + counters[1]; + patternStart += (*counters)[0] + (*counters)[1]; for(int i = 0; i < patternLength - 2; ++i) - counters[i] = counters[ i + 2]; - counters[patternLength - 2] = 0; - counters[patternLength - 1] = 0; + (*counters)[i] = (*counters)[ i + 2]; + (*counters)[patternLength - 2] = 0; + (*counters)[patternLength - 1] = 0; counterPosition--; } else { counterPosition++; } - counters[counterPosition] = 1; + (*counters)[counterPosition] = 1; isWhite = !isWhite; } } @@ -361,7 +361,7 @@ int Detector::patternMatchVariance(QSharedPointer>& counters, int total = 0; int patternLength = 0; for (int i = 0; i < numCounters; i++) { - total += counters[i]; + total += (*counters)[i]; patternLength += pattern[i]; } if (total < patternLength) { @@ -377,7 +377,7 @@ int Detector::patternMatchVariance(QSharedPointer>& counters, int totalVariance = 0; for (int x = 0; x < numCounters; x++) { - int counter = counters[x] << 8; + int counter = (*counters)[x] << 8; int scaledPattern = pattern[x] * unitBarWidth; int variance = counter > scaledPattern ? counter - scaledPattern : scaledPattern - counter; if (variance > maxIndividualVariance) { @@ -409,8 +409,8 @@ void Detector::correctVertices(QSharedPointer matrix, QSharedPointer> >& vertices, bool upsideDown) { - bool isLowLeft = abs(vertices[4]->getY() - vertices[5]->getY()) < 20.0; - bool isLowRight = abs(vertices[6]->getY() - vertices[7]->getY()) < 20.0; + bool isLowLeft = abs((*vertices)[4]->getY() - (*vertices)[5]->getY()) < 20.0; + bool isLowRight = abs((*vertices)[6]->getY() - (*vertices)[7]->getY()) < 20.0; if (isLowLeft || isLowRight) { throw NotFoundException("Cannot find enough PDF417 guard patterns!"); } else { @@ -449,8 +449,8 @@ void Detector::findWideBarTopBottom(QSharedPointer matrix, int lenPattern, int rowStep) { - QSharedPointer verticeStart(vertices[offsetVertice]); - QSharedPointer verticeEnd(vertices[offsetVertice + 4]); + QSharedPointer verticeStart((*vertices)[offsetVertice]); + QSharedPointer verticeEnd((*vertices)[offsetVertice + 4]); // Start horizontally at the middle of the bar. int endWideBar = startWideBar + lenWideBar; @@ -496,7 +496,7 @@ void Detector::findWideBarTopBottom(QSharedPointer matrix, } } - vertices[offsetVertice + 8] = new ResultPoint((float)x, (float)y); + (*vertices)[offsetVertice + 8].reset(new ResultPoint((float)x, (float)y)); } /** @@ -518,10 +518,10 @@ void Detector::findCrossingPoint(QSharedPointer& matrix) { - Point p1(vertices[idxLineA1]->getX(), vertices[idxLineA1]->getY()); - Point p2(vertices[idxLineA2]->getX(), vertices[idxLineA2]->getY()); - Point p3(vertices[idxLineB1]->getX(), vertices[idxLineB1]->getY()); - Point p4(vertices[idxLineB2]->getX(), vertices[idxLineB2]->getY()); + Point p1((*vertices)[idxLineA1]->getX(), (*vertices)[idxLineA1]->getY()); + Point p2((*vertices)[idxLineA2]->getX(), (*vertices)[idxLineA2]->getY()); + Point p3((*vertices)[idxLineB1]->getX(), (*vertices)[idxLineB1]->getY()); + Point p4((*vertices)[idxLineB2]->getX(), (*vertices)[idxLineB2]->getY()); Point result(intersection(Line(p1, p2), Line(p3, p4))); if (result.x == numeric_limits::infinity() || @@ -535,7 +535,7 @@ void Detector::findCrossingPoint(QSharedPointer(new ResultPoint(result.x, result.y)); + (*vertices)[idxResult] = QSharedPointer(new ResultPoint(result.x, result.y)); } /** @@ -576,11 +576,11 @@ Point Detector::intersection(Line a, Line b) { * @return the module size. */ float Detector::computeModuleWidth(QSharedPointer> >& vertices) { - float pixels1 = ResultPoint::distance(vertices[0], vertices[4]); - float pixels2 = ResultPoint::distance(vertices[1], vertices[5]); + float pixels1 = ResultPoint::distance((*vertices)[0], (*vertices)[4]); + float pixels2 = ResultPoint::distance((*vertices)[1], (*vertices)[5]); float moduleWidth1 = (pixels1 + pixels2) / (17 * 2.0f); - float pixels3 = ResultPoint::distance(vertices[6], vertices[2]); - float pixels4 = ResultPoint::distance(vertices[7], vertices[3]); + float pixels3 = ResultPoint::distance((*vertices)[6], (*vertices)[2]); + float pixels4 = ResultPoint::distance((*vertices)[7], (*vertices)[3]); float moduleWidth2 = (pixels3 + pixels4) / (18 * 2.0f); return (moduleWidth1 + moduleWidth2) / 2.0f; } @@ -651,10 +651,10 @@ QSharedPointer Detector::sampleLines(QSharedPointergetX(), vertices[12]->getY(), - vertices[14]->getX(), vertices[14]->getY(), - vertices[13]->getX(), vertices[13]->getY(), - vertices[15]->getX(), vertices[15]->getY())); + (*vertices)[12]->getX(), (*vertices)[12]->getY(), + (*vertices)[14]->getX(), (*vertices)[14]->getY(), + (*vertices)[13]->getX(), (*vertices)[13]->getY(), + (*vertices)[15]->getX(), (*vertices)[15]->getY())); QSharedPointer linesMatrix = GridSampler::getInstance().sampleGrid( image_->getBlackMatrix(), sampleDimensionX, sampleDimensionY, transform); diff --git a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp index 48e43fe..e493629 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDataBlock.cpp @@ -53,14 +53,14 @@ std::vector > DataBlock::getDataBlocks(QSharedPointer< vector ecBlockArray = ecBlocks.getECBlocks(); // Now establish DataBlocks of the appropriate size and number of data codewords - std::vector > result(totalBlocks); + std::vector> result(totalBlocks); int numResultBlocks = 0; for (size_t j = 0; j < ecBlockArray.size(); j++) { ECB *ecBlock = ecBlockArray[j]; for (int i = 0; i < ecBlock->getCount(); i++) { int numDataCodewords = ecBlock->getDataCodewords(); int numBlockCodewords = ecBlocks.getECCodewordsPerBloc() + numDataCodewords; - QSharedPointer> buffer(numBlockCodewords); + QSharedPointer> buffer(new std::vector(numBlockCodewords)); QSharedPointer blockRef(new DataBlock(numDataCodewords, buffer)); result[numResultBlocks++] = blockRef; } @@ -88,19 +88,19 @@ std::vector > DataBlock::getDataBlocks(QSharedPointer< int rawCodewordsOffset = 0; for (int i = 0; i < shorterBlocksNumDataCodewords; i++) { for (int j = 0; j < numResultBlocks; j++) { - result[j]->codewords_[i] = rawCodewords[rawCodewordsOffset++]; + (*result[j]->codewords_)[i] = (*rawCodewords)[rawCodewordsOffset++]; } } // Fill out the last data block in the longer ones for (int j = longerBlocksStartAt; j < numResultBlocks; j++) { - result[j]->codewords_[shorterBlocksNumDataCodewords] = rawCodewords[rawCodewordsOffset++]; + (*result[j]->codewords_)[shorterBlocksNumDataCodewords] = (*rawCodewords)[rawCodewordsOffset++]; } // Now add in error correction blocks int max = result[0]->codewords_->size(); for (int i = shorterBlocksNumDataCodewords; i < max; i++) { for (int j = 0; j < numResultBlocks; j++) { int iOffset = j < longerBlocksStartAt ? i : i + 1; - result[j]->codewords_[iOffset] = rawCodewords[rawCodewordsOffset++]; + (*result[j]->codewords_)[iOffset] = (*rawCodewords)[rawCodewordsOffset++]; } } diff --git a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp index 0535194..645725f 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDecodedBitStreamParser.cpp @@ -186,7 +186,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(QSharedPointer string& result, int count, CharacterSetECI const * currentCharacterSetECI, - QSharedPointer> >& byteSegments, + QSharedPointer>>>& byteSegments, Hashtable const& hints) { int nBytes = count; BitSource& bits (*bits_); @@ -195,7 +195,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(QSharedPointer throw FormatException(); } - QSharedPointer> bytes_ (count); + QSharedPointer> bytes_ (new std::vector(count)); byte* readBytes = &(*bytes_)[0]; for (int i = 0; i < count; i++) { readBytes[i] = (zxing::byte) bits.readBits(8); @@ -217,7 +217,7 @@ std::string DecodedBitStreamParser::decodeByteSegment(QSharedPointer (void)ignored; throw FormatException(); } - byteSegments->values().push_back(bytes_); + byteSegments->push_back(bytes_); return encoding; } @@ -359,7 +359,7 @@ DecodedBitStreamParser::decode(QSharedPointer> bytes, BitSource& bits (*bits_); string result; result.reserve(50); - QSharedPointer> > byteSegments (0); + QSharedPointer>>> byteSegments (0); const CharacterSetECI* currentCharacterSetECI = 0; string charSet = ""; try { diff --git a/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp b/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp index 70b1905..79e8bd5 100644 --- a/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp +++ b/src/zxing/zxing/qrcode/decoder/QRDecoder.cpp @@ -47,10 +47,10 @@ namespace zxing void Decoder::correctErrors(QSharedPointer> codewordBytes, int numDataCodewords) { int numCodewords = codewordBytes->size(); - QSharedPointer> codewordInts(numCodewords); + QSharedPointer> codewordInts(new std::vector(numCodewords)); for (int i = 0; i < numCodewords; i++) { - codewordInts[i] = codewordBytes[i] & 0xff; + (*codewordInts)[i] = (*codewordBytes)[i] & 0xff; } int numECCodewords = numCodewords - numDataCodewords; @@ -66,7 +66,7 @@ namespace zxing for (int i = 0; i < numDataCodewords; i++) { - codewordBytes[i] = (zxing::byte)codewordInts[i]; + (*codewordBytes)[i] = (zxing::byte)(*codewordInts)[i]; } } @@ -92,7 +92,7 @@ namespace zxing { totalBytes += dataBlocks[i]->getNumDataCodewords(); } - QSharedPointer> resultBytes(totalBytes); + QSharedPointer> resultBytes(new std::vector(totalBytes)); int resultOffset = 0; // Error-correct and copy data blocks together into a stream of bytes @@ -104,7 +104,7 @@ namespace zxing correctErrors(codewordBytes, numDataCodewords); for (int i = 0; i < numDataCodewords; i++) { - resultBytes[resultOffset++] = (zxing::byte)codewordBytes[i]; + (*resultBytes)[resultOffset++] = (zxing::byte)(*codewordBytes)[i]; } } diff --git a/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h b/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h index 0b6b617..d3eb506 100644 --- a/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h +++ b/src/zxing/zxing/qrcode/detector/AlignmentPatternFinder.h @@ -36,7 +36,7 @@ private: static int MAX_MODULES; QSharedPointer image_; - std::vector *possibleCenters_; + std::vector> *possibleCenters_; int startX_; int startY_; int width_; diff --git a/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp b/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp index 3fe940f..49af8cc 100644 --- a/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp +++ b/src/zxing/zxing/qrcode/detector/QRAlignmentPatternFinder.cpp @@ -127,9 +127,8 @@ QSharedPointer AlignmentPatternFinder::handlePossibleCenter(ve return center->combineEstimate(centerI, centerJ, estimatedModuleSize); } } - AlignmentPattern *tmp = new AlignmentPattern(centerJ, centerI, estimatedModuleSize); + QSharedPointer tmp(new AlignmentPattern(centerJ, centerI, estimatedModuleSize)); // Hadn't found this before; save it - tmp->retain(); possibleCenters_->push_back(tmp); if (callback_ != 0) { @@ -142,7 +141,7 @@ QSharedPointer AlignmentPatternFinder::handlePossibleCenter(ve AlignmentPatternFinder::AlignmentPatternFinder(QSharedPointer image, int startX, int startY, int width, int height, float moduleSize, - QSharedPointer const &callback) : image_(image), possibleCenters_(new vector()), startX_(startX), startY_(startY), + QSharedPointer const &callback) : image_(image), possibleCenters_(new vector>()), startX_(startX), startY_(startY), width_(width), height_(height), moduleSize_(moduleSize), callback_(callback) { } @@ -151,7 +150,7 @@ AlignmentPatternFinder::~AlignmentPatternFinder() { for (int i = 0; i < int(possibleCenters_->size()); i++) { - (*possibleCenters_)[i]->release(); + (*possibleCenters_)[i].clear(); (*possibleCenters_)[i] = 0; } delete possibleCenters_; diff --git a/src/zxing/zxing/qrcode/encoder/BlockPair.h b/src/zxing/zxing/qrcode/encoder/BlockPair.h index 8f02c96..ea37411 100644 --- a/src/zxing/zxing/qrcode/encoder/BlockPair.h +++ b/src/zxing/zxing/qrcode/encoder/BlockPair.h @@ -27,8 +27,8 @@ public: QSharedPointer> getErrorCorrectionBytes() { return errorCorrection_; } BlockPair& operator=(const BlockPair &other) { - data_->release(); - errorCorrection_->release(); + data_->clear(); + errorCorrection_->clear(); data_ = other.data_; errorCorrection_ = other.errorCorrection_; diff --git a/src/zxing/zxing/qrcode/encoder/QRCode.cpp b/src/zxing/zxing/qrcode/encoder/QRCode.cpp index 752b26a..236d6f3 100644 --- a/src/zxing/zxing/qrcode/encoder/QRCode.cpp +++ b/src/zxing/zxing/qrcode/encoder/QRCode.cpp @@ -49,7 +49,7 @@ std::string QRCode::toString() const result << mode_.getName(); result << "\n ecLevel: "; - if(!ecLevel_ptr_.empty()) + if(!ecLevel_ptr_.isNull()) result << ecLevel_ptr_->name(); else result << "null";