summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/qrcode
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode/qrcode')
-rw-r--r--xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp46
-rw-r--r--xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h30
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp49
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h29
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp199
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h47
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp183
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h34
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp104
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCodeReader.h45
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp15
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp125
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h37
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp111
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h30
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp23
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp109
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDataBlock.h33
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDataMask.cpp164
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDataMask.h29
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp273
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h59
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetector.cpp278
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetector.h63
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp43
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDetectorResult.h32
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp68
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRFinderPattern.h33
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp481
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h59
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp139
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRGridSampler.h48
32 files changed, 31 insertions, 2987 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp b/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp
deleted file mode 100644
index 63b3ab790d..0000000000
--- a/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h"
-#include "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h"
-
-CBC_QRFinderPatternInfo::CBC_QRFinderPatternInfo(
- CFX_ArrayTemplate<CBC_QRFinderPattern*>* patternCenters) {
- m_bottomLeft = (*patternCenters)[0];
- m_topLeft = (*patternCenters)[1];
- m_topRight = (*patternCenters)[2];
-}
-
-CBC_QRFinderPatternInfo::~CBC_QRFinderPatternInfo() {}
-
-CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetBottomLeft() const {
- return m_bottomLeft;
-}
-
-CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopLeft() const {
- return m_topLeft;
-}
-
-CBC_QRFinderPattern* CBC_QRFinderPatternInfo::GetTopRight() const {
- return m_topRight;
-}
diff --git a/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h b/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h
deleted file mode 100644
index 6d0cb60f2f..0000000000
--- a/xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_
-#define XFA_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_QRFinderPattern;
-
-class CBC_QRFinderPatternInfo {
- public:
- explicit CBC_QRFinderPatternInfo(
- CFX_ArrayTemplate<CBC_QRFinderPattern*>* patternCenters);
- ~CBC_QRFinderPatternInfo();
-
- CBC_QRFinderPattern* GetBottomLeft() const;
- CBC_QRFinderPattern* GetTopLeft() const;
- CBC_QRFinderPattern* GetTopRight() const;
-
- private:
- CBC_QRFinderPattern* m_bottomLeft;
- CBC_QRFinderPattern* m_topLeft;
- CBC_QRFinderPattern* m_topRight;
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_FINDERPATTERNINFO_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp b/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp
deleted file mode 100644
index 4d5a36e250..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.cpp
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h"
-
-CBC_QRAlignmentPattern::CBC_QRAlignmentPattern(FX_FLOAT posX,
- FX_FLOAT posY,
- FX_FLOAT estimateModuleSize)
- : CBC_ResultPoint(posX, posY), m_moduleSize(estimateModuleSize) {}
-CBC_QRAlignmentPattern::~CBC_QRAlignmentPattern() {}
-FX_FLOAT CBC_QRAlignmentPattern::GetX() {
- return m_x;
-}
-FX_FLOAT CBC_QRAlignmentPattern::GetY() {
- return m_y;
-}
-FX_BOOL CBC_QRAlignmentPattern::AboutEquals(FX_FLOAT moduleSize,
- FX_FLOAT i,
- FX_FLOAT j) {
- if ((FXSYS_fabs(i - GetY()) <= moduleSize) &&
- (FXSYS_fabs(j - GetX()) <= moduleSize)) {
- FX_FLOAT moduleSizeDiff = FXSYS_fabs(moduleSize - m_moduleSize);
- return (moduleSizeDiff <= 1.0f) || (moduleSizeDiff / m_moduleSize <= 1.0f);
- }
- return FALSE;
-}
-CBC_QRAlignmentPattern* CBC_QRAlignmentPattern::Clone() {
- return new CBC_QRAlignmentPattern(m_x, m_y, m_moduleSize);
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h b/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h
deleted file mode 100644
index 7006b72c9c..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_
-class CBC_ResultPoint;
-class CBC_QRAlignmentPattern : public CBC_ResultPoint {
- private:
- FX_FLOAT m_moduleSize;
-
- public:
- CBC_QRAlignmentPattern(FX_FLOAT posX,
- FX_FLOAT posY,
- FX_FLOAT estimateModuleSize);
- ~CBC_QRAlignmentPattern() override;
-
- // CBC_ResultPoint
- FX_FLOAT GetX() override;
- FX_FLOAT GetY() override;
-
- FX_BOOL AboutEquals(FX_FLOAT moduleSize, FX_FLOAT i, FX_FLOAT j);
-
- CBC_QRAlignmentPattern* Clone();
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERN_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp b/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp
deleted file mode 100644
index efc1014188..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.cpp
+++ /dev/null
@@ -1,199 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h"
-#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h"
-
-CBC_QRAlignmentPatternFinder::CBC_QRAlignmentPatternFinder(
- CBC_CommonBitMatrix* image,
- int32_t startX,
- int32_t startY,
- int32_t width,
- int32_t height,
- FX_FLOAT moduleSize)
- : m_image(image),
- m_startX(startX),
- m_startY(startY),
- m_width(width),
- m_height(height),
- m_moduleSize(moduleSize) {
- m_crossCheckStateCount.SetSize(3);
-}
-
-CBC_QRAlignmentPatternFinder::~CBC_QRAlignmentPatternFinder() {
- for (int32_t i = 0; i < m_possibleCenters.GetSize(); i++)
- delete m_possibleCenters[i];
-}
-
-CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::Find(int32_t& e) {
- int32_t startX = m_startX;
- int32_t height = m_height;
- int32_t maxJ = startX + m_width;
- int32_t middleI = m_startY + (height >> 1);
- CFX_Int32Array stateCount;
- stateCount.SetSize(3);
- for (int32_t iGen = 0; iGen < height; iGen++) {
- int32_t i =
- middleI + ((iGen & 0x01) == 0 ? ((iGen + 1) >> 1) : -((iGen + 1) >> 1));
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
- int32_t j = startX;
- while (j < maxJ && !m_image->Get(j, i)) {
- j++;
- }
- int32_t currentState = 0;
- while (j < maxJ) {
- if (m_image->Get(j, i)) {
- if (currentState == 1) {
- stateCount[currentState]++;
- } else {
- if (currentState == 2) {
- if (FoundPatternCross(stateCount)) {
- CBC_QRAlignmentPattern* confirmed =
- HandlePossibleCenter(stateCount, i, j);
- if (confirmed) {
- return confirmed;
- }
- }
- stateCount[0] = stateCount[2];
- stateCount[1] = 1;
- stateCount[2] = 0;
- currentState = 1;
- } else {
- stateCount[++currentState]++;
- }
- }
- } else {
- if (currentState == 1) {
- currentState++;
- }
- stateCount[currentState]++;
- }
- j++;
- }
- if (FoundPatternCross(stateCount)) {
- CBC_QRAlignmentPattern* confirmed =
- HandlePossibleCenter(stateCount, i, maxJ);
- if (confirmed) {
- return confirmed;
- }
- }
- }
- if (m_possibleCenters.GetSize() != 0) {
- return m_possibleCenters[0]->Clone();
- }
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return nullptr;
-}
-FX_FLOAT CBC_QRAlignmentPatternFinder::CenterFromEnd(
- const CFX_Int32Array& stateCount,
- int32_t end) {
- return (FX_FLOAT)(end - stateCount[2]) - stateCount[1] / 2.0f;
-}
-FX_BOOL CBC_QRAlignmentPatternFinder::FoundPatternCross(
- const CFX_Int32Array& stateCount) {
- FX_FLOAT moduleSize = m_moduleSize;
- FX_FLOAT maxVariance = moduleSize / 2.0f;
- for (int32_t i = 0; i < 3; i++) {
- if (fabs(moduleSize - stateCount[i]) >= maxVariance) {
- return false;
- }
- }
- return TRUE;
-}
-FX_FLOAT CBC_QRAlignmentPatternFinder::CrossCheckVertical(
- int32_t startI,
- int32_t centerJ,
- int32_t maxCount,
- int32_t originalStateCountTotal) {
- int32_t maxI = m_image->GetHeight();
- CFX_Int32Array stateCount;
- stateCount.Copy(m_crossCheckStateCount);
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
- int32_t i = startI;
- while (i >= 0 && m_image->Get(centerJ, i) && stateCount[1] <= maxCount) {
- stateCount[1]++;
- i--;
- }
- if (i < 0 || stateCount[1] > maxCount) {
- return FXSYS_nan();
- }
- while (i >= 0 && !m_image->Get(centerJ, i) && stateCount[0] <= maxCount) {
- stateCount[0]++;
- i--;
- }
- if (stateCount[0] > maxCount) {
- return FXSYS_nan();
- }
- i = startI + 1;
- while (i < maxI && m_image->Get(centerJ, i) && stateCount[1] <= maxCount) {
- stateCount[1]++;
- i++;
- }
- if (i == maxI || stateCount[1] > maxCount) {
- return FXSYS_nan();
- }
- while (i < maxI && !m_image->Get(centerJ, i) && stateCount[2] <= maxCount) {
- stateCount[2]++;
- i++;
- }
- if (stateCount[2] > maxCount) {
- return FXSYS_nan();
- }
- int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
- if (5 * abs(stateCountTotal - originalStateCountTotal) >=
- originalStateCountTotal) {
- return FXSYS_nan();
- }
- return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, i)
- : FXSYS_nan();
-}
-CBC_QRAlignmentPattern* CBC_QRAlignmentPatternFinder::HandlePossibleCenter(
- const CFX_Int32Array& stateCount,
- int32_t i,
- int32_t j) {
- int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2];
- FX_FLOAT centerJ = CenterFromEnd(stateCount, j);
- FX_FLOAT centerI = CrossCheckVertical(i, (int32_t)centerJ, 2 * stateCount[1],
- stateCountTotal);
- if (!FXSYS_isnan(centerI)) {
- FX_FLOAT estimatedModuleSize =
- (FX_FLOAT)(stateCount[0] + stateCount[1] + stateCount[2]) / 3.0f;
- int32_t max = m_possibleCenters.GetSize();
- for (int32_t index = 0; index < max; index++) {
- CBC_QRAlignmentPattern* center = m_possibleCenters[index];
- if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) {
- return new CBC_QRAlignmentPattern(centerJ, centerI,
- estimatedModuleSize);
- }
- }
- m_possibleCenters.Add(
- new CBC_QRAlignmentPattern(centerJ, centerI, estimatedModuleSize));
- }
- return nullptr;
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h b/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h
deleted file mode 100644
index e524c4bdaf..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fxbarcode/utils.h"
-
-class CBC_CommonBitMatrix;
-class CBC_QRAlignmentPattern;
-
-class CBC_QRAlignmentPatternFinder {
- public:
- CBC_QRAlignmentPatternFinder(CBC_CommonBitMatrix* image,
- int32_t startX,
- int32_t startY,
- int32_t width,
- int32_t height,
- FX_FLOAT moduleSize);
- virtual ~CBC_QRAlignmentPatternFinder();
- FX_BOOL FoundPatternCross(const CFX_Int32Array& stateCount);
- FX_FLOAT CrossCheckVertical(int32_t startI,
- int32_t startJ,
- int32_t maxCount,
- int32_t originalStateCountTotal);
- CBC_QRAlignmentPattern* Find(int32_t& e);
- CBC_QRAlignmentPattern* HandlePossibleCenter(const CFX_Int32Array& stateCount,
- int32_t i,
- int32_t j);
- static FX_FLOAT CenterFromEnd(const CFX_Int32Array& stateCount, int32_t end);
-
- private:
- CBC_CommonBitMatrix* m_image;
- CFX_ArrayTemplate<CBC_QRAlignmentPattern*> m_possibleCenters;
- int32_t m_startX;
- int32_t m_startY;
- int32_t m_width;
- int32_t m_height;
- FX_FLOAT m_moduleSize;
- CFX_Int32Array m_crossCheckStateCount;
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRALIGNMENTPATTERNFINDER_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp b/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp
deleted file mode 100644
index 81d27538bf..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h"
-
-#include <memory>
-
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDataMask.h"
-#include "xfa/fxbarcode/utils.h"
-
-CBC_QRBitMatrixParser::CBC_QRBitMatrixParser() {}
-void CBC_QRBitMatrixParser::Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e) {
- m_dimension = bitMatrix->GetDimension(e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- m_tempBitMatrix = bitMatrix;
- if (m_dimension < 21 || (m_dimension & 0x03) != 1) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- m_bitMatrix = m_tempBitMatrix;
- m_parsedFormatInfo = nullptr;
- m_version = nullptr;
-}
-CBC_QRBitMatrixParser::~CBC_QRBitMatrixParser() {
- delete m_parsedFormatInfo;
-}
-CBC_QRCoderFormatInformation* CBC_QRBitMatrixParser::ReadFormatInformation(
- int32_t& e) {
- if (m_parsedFormatInfo) {
- return m_parsedFormatInfo;
- }
- int32_t formatInfoBits = 0;
- int32_t j;
- for (j = 0; j < 6; j++) {
- formatInfoBits = CopyBit(8, j, formatInfoBits);
- }
- formatInfoBits = CopyBit(8, 7, formatInfoBits);
- formatInfoBits = CopyBit(8, 8, formatInfoBits);
- formatInfoBits = CopyBit(7, 8, formatInfoBits);
- for (int32_t i = 5; i >= 0; i--) {
- formatInfoBits = CopyBit(i, 8, formatInfoBits);
- }
- m_parsedFormatInfo =
- CBC_QRCoderFormatInformation::DecodeFormatInformation(formatInfoBits);
- if (m_parsedFormatInfo) {
- return m_parsedFormatInfo;
- }
- int32_t dimension = m_bitMatrix->GetDimension(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- formatInfoBits = 0;
- int32_t iMin = dimension - 8;
- for (j = dimension - 1; j >= iMin; j--) {
- formatInfoBits = CopyBit(j, 8, formatInfoBits);
- }
- for (int32_t k = dimension - 7; k < dimension; k++) {
- formatInfoBits = CopyBit(8, k, formatInfoBits);
- }
- m_parsedFormatInfo =
- CBC_QRCoderFormatInformation::DecodeFormatInformation(formatInfoBits);
- if (m_parsedFormatInfo) {
- return m_parsedFormatInfo;
- }
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return nullptr;
-}
-CBC_QRCoderVersion* CBC_QRBitMatrixParser::ReadVersion(int32_t& e) {
- if (m_version) {
- return m_version;
- }
- int32_t dimension = m_bitMatrix->GetDimension(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- int32_t provisionVersion = (dimension - 17) >> 2;
- if (provisionVersion <= 6) {
- CBC_QRCoderVersion* qrv =
- CBC_QRCoderVersion::GetVersionForNumber(provisionVersion, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return qrv;
- }
- int32_t versionBits = 0;
- for (int32_t i = 5; i >= 0; i--) {
- int32_t jMin = dimension - 11;
- for (int32_t j = dimension - 9; j >= jMin; j--) {
- versionBits = CopyBit(i, j, versionBits);
- }
- }
- m_version = CBC_QRCoderVersion::DecodeVersionInformation(versionBits, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- if (m_version && m_version->GetDimensionForVersion() == dimension) {
- return m_version;
- }
- versionBits = 0;
- for (int32_t j = 5; j >= 0; j--) {
- int32_t iMin = dimension - 11;
- for (int32_t i = dimension - 9; i >= iMin; i--) {
- versionBits = CopyBit(i, j, versionBits);
- }
- }
- m_version = CBC_QRCoderVersion::DecodeVersionInformation(versionBits, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- if (m_version && m_version->GetDimensionForVersion() == dimension) {
- return m_version;
- }
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return nullptr;
-}
-int32_t CBC_QRBitMatrixParser::CopyBit(int32_t i,
- int32_t j,
- int32_t versionBits) {
- return m_bitMatrix->Get(j, i) ? (versionBits << 1) | 0x1 : versionBits << 1;
-}
-CFX_ByteArray* CBC_QRBitMatrixParser::ReadCodewords(int32_t& e) {
- CBC_QRCoderFormatInformation* formatInfo = ReadFormatInformation(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr) CBC_QRCoderVersion* version =
- ReadVersion(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- CBC_QRDataMask* dataMask =
- CBC_QRDataMask::ForReference((int32_t)(formatInfo->GetDataMask()), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- int32_t dimension = m_bitMatrix->GetDimension(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- dataMask->UnmaskBitMatrix(m_bitMatrix, dimension);
- std::unique_ptr<CBC_CommonBitMatrix> functionPattern(
- version->BuildFunctionPattern(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- FX_BOOL readingUp = TRUE;
- std::unique_ptr<CFX_ByteArray> result(new CFX_ByteArray);
- result->SetSize(version->GetTotalCodeWords());
- int32_t resultOffset = 0;
- int32_t currentByte = 0;
- int32_t bitsRead = 0;
- for (int32_t j = dimension - 1; j > 0; j -= 2) {
- if (j == 6) {
- j--;
- }
- for (int32_t count = 0; count < dimension; count++) {
- int32_t i = readingUp ? dimension - 1 - count : count;
- for (int32_t col = 0; col < 2; col++) {
- if (!functionPattern->Get(j - col, i)) {
- bitsRead++;
- currentByte <<= 1;
- if (m_bitMatrix->Get(j - col, i)) {
- currentByte |= 1;
- }
- if (bitsRead == 8) {
- (*result)[resultOffset++] = (uint8_t)currentByte;
- bitsRead = 0;
- currentByte = 0;
- }
- }
- }
- }
- readingUp ^= TRUE;
- }
- if (resultOffset != version->GetTotalCodeWords()) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- return result.release();
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h b/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h
deleted file mode 100644
index 66b28d924b..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_CommonBitMatrix;
-class CBC_QRCoderVersion;
-class CBC_QRCoderFormatInformation;
-
-class CBC_QRBitMatrixParser {
- private:
- CBC_CommonBitMatrix* m_bitMatrix;
- CBC_CommonBitMatrix* m_tempBitMatrix;
- CBC_QRCoderVersion* m_version;
- CBC_QRCoderFormatInformation* m_parsedFormatInfo;
- int32_t m_dimension;
-
- public:
- CBC_QRBitMatrixParser();
- virtual ~CBC_QRBitMatrixParser();
- CBC_QRCoderFormatInformation* ReadFormatInformation(int32_t& e);
- CBC_QRCoderVersion* ReadVersion(int32_t& e);
- int32_t CopyBit(int32_t i, int32_t j, int32_t versionBits);
- CFX_ByteArray* ReadCodewords(int32_t& e);
- virtual void Init(CBC_CommonBitMatrix* bitMatrix, int32_t& e);
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRBITMATRIXPARSER_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
deleted file mode 100644
index 0f9c44f0c5..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRCodeReader.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRCodeReader.h"
-
-#include <memory>
-
-#include "xfa/fxbarcode/BC_Binarizer.h"
-#include "xfa/fxbarcode/BC_BinaryBitmap.h"
-#include "xfa/fxbarcode/BC_BufferedImageLuminanceSource.h"
-#include "xfa/fxbarcode/BC_LuminanceSource.h"
-#include "xfa/fxbarcode/BC_Reader.h"
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h"
-#include "xfa/fxbarcode/common/BC_GlobalHistogramBinarizer.h"
-#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDataMask.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDetector.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
-
-CBC_QRCodeReader::CBC_QRCodeReader() : m_decoder(nullptr) {}
-void CBC_QRCodeReader::Init() {
- m_decoder = new CBC_QRCoderDecoder;
- m_decoder->Init();
-}
-CBC_QRCodeReader::~CBC_QRCodeReader() {
- delete m_decoder;
-}
-CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image,
- int32_t hints,
- int32_t& e) {
- CBC_CommonBitMatrix* matrix = image->GetMatrix(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, "");
- CBC_QRDetector detector(matrix);
- std::unique_ptr<CBC_QRDetectorResult> detectorResult(
- detector.Detect(hints, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, "");
- std::unique_ptr<CBC_CommonDecoderResult> decodeResult(
- m_decoder->Decode(detectorResult->GetBits(), 0, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, "");
- return (decodeResult->GetText());
-}
-CFX_ByteString CBC_QRCodeReader::Decode(const CFX_WideString& filename,
- int32_t hints,
- int32_t byteModeDecode,
- int32_t& e) {
- CBC_BufferedImageLuminanceSource source(filename);
- source.Init(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, "");
- CBC_GlobalHistogramBinarizer binarizer(&source);
- CBC_BinaryBitmap bitmap(&binarizer);
- CFX_ByteString bs = Decode(&bitmap, hints, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, "");
- return bs;
-}
-CFX_ByteString CBC_QRCodeReader::Decode(CFX_DIBitmap* pBitmap,
- int32_t hints,
- int32_t byteModeDecode,
- int32_t& e) {
- CBC_BufferedImageLuminanceSource source(pBitmap);
- CBC_GlobalHistogramBinarizer binarizer(&source);
- CBC_BinaryBitmap bitmap(&binarizer);
- CFX_ByteString bs = Decode(&bitmap, hints, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, "");
- return bs;
-}
-CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, int32_t& e) {
- CFX_ByteString bs = Decode(image, 0, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, "");
- return bs;
-}
-void CBC_QRCodeReader::ReleaseAll() {
- delete CBC_ReedSolomonGF256::QRCodeFild;
- CBC_ReedSolomonGF256::QRCodeFild = nullptr;
- delete CBC_ReedSolomonGF256::DataMatrixField;
- CBC_ReedSolomonGF256::DataMatrixField = nullptr;
- CBC_QRCoderMode::Destroy();
- CBC_QRCoderErrorCorrectionLevel::Destroy();
- CBC_QRDataMask::Destroy();
- CBC_QRCoderVersion::Destroy();
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeReader.h b/xfa/fxbarcode/qrcode/BC_QRCodeReader.h
deleted file mode 100644
index b3a72b4d18..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRCodeReader.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRCODEREADER_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRCODEREADER_H_
-
-#include <stdint.h>
-
-#include "core/fxcrt/include/fx_string.h"
-#include "xfa/fxbarcode/BC_Reader.h"
-
-class CBC_BinaryBitmap;
-class CBC_QRCoderDecoder;
-class CFX_DIBitmap;
-
-class CBC_QRCodeReader : public CBC_Reader {
- private:
- CBC_QRCoderDecoder* m_decoder;
-
- public:
- CBC_QRCodeReader();
- ~CBC_QRCodeReader() override;
-
- CFX_ByteString Decode(CFX_DIBitmap* pBitmap,
- int32_t hints,
- int32_t byteModeDecode,
- int32_t& e);
- CFX_ByteString Decode(const CFX_WideString& filename,
- int32_t hints,
- int32_t byteModeDecode,
- int32_t& e);
- static void ReleaseAll();
-
- // CBC_Reader
- CFX_ByteString Decode(CBC_BinaryBitmap* image,
- int32_t hints,
- int32_t& e) override;
- CFX_ByteString Decode(CBC_BinaryBitmap* image, int32_t& e) override;
- virtual void Init();
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRCODEREADER_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
index 8e1d6edb70..c9f16cafd1 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCodeWriter.cpp
@@ -20,14 +20,15 @@
* limitations under the License.
*/
-#include "xfa/fxbarcode/BC_Reader.h"
#include "xfa/fxbarcode/BC_TwoDimWriter.h"
#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCodeReader.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h"
+#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoder.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderEncoder.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
+#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h"
+#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
+#include "xfa/fxbarcode/qrcode/BC_QRCodeWriter.h"
CBC_QRCodeWriter::CBC_QRCodeWriter() {
m_bFixedSize = TRUE;
@@ -36,7 +37,13 @@ CBC_QRCodeWriter::CBC_QRCodeWriter() {
}
CBC_QRCodeWriter::~CBC_QRCodeWriter() {}
void CBC_QRCodeWriter::ReleaseAll() {
- CBC_QRCodeReader::ReleaseAll();
+ delete CBC_ReedSolomonGF256::QRCodeFild;
+ CBC_ReedSolomonGF256::QRCodeFild = nullptr;
+ delete CBC_ReedSolomonGF256::DataMatrixField;
+ CBC_ReedSolomonGF256::DataMatrixField = nullptr;
+ CBC_QRCoderMode::Destroy();
+ CBC_QRCoderErrorCorrectionLevel::Destroy();
+ CBC_QRCoderVersion::Destroy();
}
FX_BOOL CBC_QRCodeWriter::SetVersion(int32_t version) {
if (version < 0 || version > 40) {
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp
deleted file mode 100644
index 97219ddd72..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h"
-
-#include <memory>
-
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h"
-#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h"
-#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h"
-#include "xfa/fxbarcode/qrcode/BC_QRBitMatrixParser.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDataBlock.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h"
-
-CBC_QRCoderDecoder::CBC_QRCoderDecoder() {
- m_rsDecoder = nullptr;
-}
-
-void CBC_QRCoderDecoder::Init() {
- m_rsDecoder = new CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256::QRCodeFild);
-}
-CBC_QRCoderDecoder::~CBC_QRCoderDecoder() {
- delete m_rsDecoder;
-}
-CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(FX_BOOL* image,
- int32_t width,
- int32_t height,
- int32_t& e) {
- CBC_CommonBitMatrix bits;
- bits.Init(width);
- for (int32_t i = 0; i < width; i++) {
- for (int32_t j = 0; j < height; j++) {
- if (image[i * width + j]) {
- bits.Set(j, i);
- }
- }
- }
- CBC_CommonDecoderResult* cdr = Decode(&bits, height, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return cdr;
-}
-CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(CBC_CommonBitMatrix* bits,
- int32_t byteModeDecode,
- int32_t& e) {
- CBC_QRBitMatrixParser parser;
- parser.Init(bits, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- CBC_QRCoderVersion* version = parser.ReadVersion(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- CBC_QRCoderFormatInformation* temp = parser.ReadFormatInformation(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- CBC_QRCoderErrorCorrectionLevel* ecLevel = temp->GetErrorCorrectionLevel();
- std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- CFX_ArrayTemplate<CBC_QRDataBlock*>* dataBlocks =
- CBC_QRDataBlock::GetDataBlocks(codewords.get(), version, ecLevel, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- int32_t totalBytes = 0;
- for (int32_t i = 0; i < dataBlocks->GetSize(); i++) {
- totalBytes += (*dataBlocks)[i]->GetNumDataCodewords();
- }
- CFX_ByteArray resultBytes;
- for (int32_t j = 0; j < dataBlocks->GetSize(); j++) {
- CBC_QRDataBlock* dataBlock = (*dataBlocks)[j];
- CFX_ByteArray* codewordBytes = dataBlock->GetCodewords();
- int32_t numDataCodewords = dataBlock->GetNumDataCodewords();
- CorrectErrors(codewordBytes, numDataCodewords, e);
- if (e != BCExceptionNO) {
- for (int32_t k = 0; k < dataBlocks->GetSize(); k++) {
- delete (*dataBlocks)[k];
- }
- delete dataBlocks;
- return nullptr;
- }
- for (int32_t i = 0; i < numDataCodewords; i++) {
- resultBytes.Add((*codewordBytes)[i]);
- }
- }
- for (int32_t k = 0; k < dataBlocks->GetSize(); k++) {
- delete (*dataBlocks)[k];
- }
- delete dataBlocks;
- CBC_CommonDecoderResult* cdr = CBC_QRDecodedBitStreamParser::Decode(
- &resultBytes, version, ecLevel, byteModeDecode, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return cdr;
-}
-void CBC_QRCoderDecoder::CorrectErrors(CFX_ByteArray* codewordBytes,
- int32_t numDataCodewords,
- int32_t& e) {
- int32_t numCodewords = codewordBytes->GetSize();
- CFX_Int32Array codewordsInts;
- codewordsInts.SetSize(numCodewords);
- for (int32_t i = 0; i < numCodewords; i++) {
- codewordsInts[i] = (int32_t)((*codewordBytes)[i] & 0xff);
- }
- int32_t numECCodewords = codewordBytes->GetSize() - numDataCodewords;
- m_rsDecoder->Decode(&codewordsInts, numECCodewords, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- for (int32_t k = 0; k < numDataCodewords; k++) {
- (*codewordBytes)[k] = (uint8_t)codewordsInts[k];
- }
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h b/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h
deleted file mode 100644
index 3a588b6293..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRCoderDecoder.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_CommonBitMatrix;
-class CBC_ReedSolomonDecoder;
-class CBC_CommonDecoderResult;
-
-class CBC_QRCoderDecoder {
- private:
- CBC_ReedSolomonDecoder* m_rsDecoder;
-
- public:
- CBC_QRCoderDecoder();
- virtual ~CBC_QRCoderDecoder();
-
- CBC_CommonDecoderResult* Decode(FX_BOOL* image,
- int32_t width,
- int32_t height,
- int32_t& e);
- CBC_CommonDecoderResult* Decode(CBC_CommonBitMatrix* bits,
- int32_t byteModeDecode,
- int32_t& e);
- void CorrectErrors(CFX_ByteArray* codewordBytes,
- int32_t numDataCodewords,
- int32_t& e);
- virtual void Init();
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp
deleted file mode 100644
index 1c85aa16d7..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h"
-
-#include <limits>
-
-#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
-#include "xfa/fxbarcode/utils.h"
-
-namespace {
-
-const uint16_t FORMAT_INFO_MASK_QR = 0X5412;
-
-struct DecodeInfo {
- uint16_t target;
- uint16_t format;
-};
-const DecodeInfo FORMAT_INFO_DECODE_LOOKUP[32] = {
- {0x5412, 0x00}, {0x5125, 0x01}, {0x5E7C, 0x02}, {0x5B4B, 0x03},
- {0x45F9, 0x04}, {0x40CE, 0x05}, {0x4F97, 0x06}, {0x4AA0, 0x07},
- {0x77C4, 0x08}, {0x72F3, 0x09}, {0x7DAA, 0x0A}, {0x789D, 0x0B},
- {0x662F, 0x0C}, {0x6318, 0x0D}, {0x6C41, 0x0E}, {0x6976, 0x0F},
- {0x1689, 0x10}, {0x13BE, 0x11}, {0x1CE7, 0x12}, {0x19D0, 0x13},
- {0x0762, 0x14}, {0x0255, 0x15}, {0x0D0C, 0x16}, {0x083B, 0x17},
- {0x355F, 0x18}, {0x3068, 0x19}, {0x3F31, 0x1A}, {0x3A06, 0x1B},
- {0x24B4, 0x1C}, {0x2183, 0x1D}, {0x2EDA, 0x1E}, {0x2BED, 0x1F},
-};
-const uint8_t BITS_SET_IN_HALF_BYTE[] = {0, 1, 1, 2, 1, 2, 2, 3,
- 1, 2, 2, 3, 2, 3, 3, 4};
-
-CBC_QRCoderFormatInformation* DoDecodeFormatInformation(
- int32_t maskedFormatInfo) {
- int32_t bestDifference = std::numeric_limits<int32_t>::max();
- int32_t bestFormatInfo = 0;
- for (int32_t i = 0; i < 32; ++i) {
- const DecodeInfo& decodeInfo = FORMAT_INFO_DECODE_LOOKUP[i];
- if (decodeInfo.target == maskedFormatInfo)
- return new CBC_QRCoderFormatInformation(decodeInfo.format);
-
- int32_t bitsDifference = CBC_QRCoderFormatInformation::NumBitsDiffering(
- maskedFormatInfo, decodeInfo.target);
- if (bitsDifference < bestDifference) {
- bestFormatInfo = decodeInfo.format;
- bestDifference = bitsDifference;
- }
- }
- if (bestDifference > 3)
- return nullptr;
- return new CBC_QRCoderFormatInformation(bestFormatInfo);
-}
-
-} // namespace
-
-CBC_QRCoderFormatInformation::CBC_QRCoderFormatInformation(int32_t formatInfo)
- : m_dataMask(static_cast<uint8_t>(formatInfo & 0x07)) {
- m_errorCorrectLevel =
- CBC_QRCoderErrorCorrectionLevel::ForBits((formatInfo >> 3) & 0x03);
-}
-
-CBC_QRCoderFormatInformation::~CBC_QRCoderFormatInformation() {}
-int32_t CBC_QRCoderFormatInformation::NumBitsDiffering(int32_t a, int32_t b) {
- a ^= b;
- return BITS_SET_IN_HALF_BYTE[a & 0x0F] +
- BITS_SET_IN_HALF_BYTE[(a >> 4) & 0x0F] +
- BITS_SET_IN_HALF_BYTE[(a >> 8) & 0x0F] +
- BITS_SET_IN_HALF_BYTE[(a >> 12) & 0x0F] +
- BITS_SET_IN_HALF_BYTE[(a >> 16) & 0x0F] +
- BITS_SET_IN_HALF_BYTE[(a >> 20) & 0x0F] +
- BITS_SET_IN_HALF_BYTE[(a >> 24) & 0x0F] +
- BITS_SET_IN_HALF_BYTE[(a >> 28) & 0x0F];
-}
-uint8_t CBC_QRCoderFormatInformation::GetDataMask() const {
- return m_dataMask;
-}
-
-// static
-CBC_QRCoderErrorCorrectionLevel*
-CBC_QRCoderFormatInformation::GetErrorCorrectionLevel() {
- return m_errorCorrectLevel;
-}
-
-// static
-CBC_QRCoderFormatInformation*
-CBC_QRCoderFormatInformation::DecodeFormatInformation(
- int32_t maskedFormatInfo) {
- CBC_QRCoderFormatInformation* formatInfo =
- DoDecodeFormatInformation(maskedFormatInfo);
- if (formatInfo)
- return formatInfo;
- return DoDecodeFormatInformation(maskedFormatInfo ^ FORMAT_INFO_MASK_QR);
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h
deleted file mode 100644
index b069795ce1..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_
-
-#include <stdint.h>
-
-class CBC_QRCoderErrorCorrectionLevel;
-class CBC_QRCoderFormatInformation {
- public:
- explicit CBC_QRCoderFormatInformation(int32_t formatInfo);
- ~CBC_QRCoderFormatInformation();
-
- uint8_t GetDataMask() const;
- CBC_QRCoderErrorCorrectionLevel* GetErrorCorrectionLevel();
-
- static int32_t NumBitsDiffering(int32_t a, int32_t b);
- static CBC_QRCoderFormatInformation* DecodeFormatInformation(
- int32_t maskedFormatInfo);
-
- private:
- CBC_QRCoderErrorCorrectionLevel* m_errorCorrectLevel;
- const uint8_t m_dataMask;
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERFORMATINFORMATION_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
index cae0d54c7c..b0b445bede 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
@@ -25,10 +25,28 @@
#include "xfa/fxbarcode/qrcode/BC_QRCoderECB.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h"
#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
#include "xfa/fxbarcode/utils.h"
+namespace {
+
+const uint8_t BITS_SET_IN_HALF_BYTE[] = {0, 1, 1, 2, 1, 2, 2, 3,
+ 1, 2, 2, 3, 2, 3, 3, 4};
+
+int32_t NumBitsDiffering(int32_t a, int32_t b) {
+ a ^= b;
+ return BITS_SET_IN_HALF_BYTE[a & 0x0F] +
+ BITS_SET_IN_HALF_BYTE[(a >> 4) & 0x0F] +
+ BITS_SET_IN_HALF_BYTE[(a >> 8) & 0x0F] +
+ BITS_SET_IN_HALF_BYTE[(a >> 12) & 0x0F] +
+ BITS_SET_IN_HALF_BYTE[(a >> 16) & 0x0F] +
+ BITS_SET_IN_HALF_BYTE[(a >> 20) & 0x0F] +
+ BITS_SET_IN_HALF_BYTE[(a >> 24) & 0x0F] +
+ BITS_SET_IN_HALF_BYTE[(a >> 28) & 0x0F];
+}
+
+} // namespace
+
const int32_t CBC_QRCoderVersion::VERSION_DECODE_INFO[] = {
0x07C94, 0x085BC, 0x09A99, 0x0A4D3, 0x0BBF6, 0x0C762, 0x0D847,
0x0E60D, 0x0F928, 0x10B78, 0x1145D, 0x12A17, 0x13532, 0x149A6,
@@ -372,8 +390,7 @@ CBC_QRCoderVersion* CBC_QRCoderVersion::DecodeVersionInformation(
BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
return qcv;
}
- int32_t bitsDifference = CBC_QRCoderFormatInformation::NumBitsDiffering(
- versionBits, targetVersion);
+ int32_t bitsDifference = NumBitsDiffering(versionBits, targetVersion);
if (bitsDifference < bestDifference) {
bestVersion = i + 7;
bestDifference = bitsDifference;
diff --git a/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp b/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
deleted file mode 100644
index 0be3c8d61e..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRDataBlock.h"
-
-#include <memory>
-
-#include "xfa/fxbarcode/qrcode/BC_QRCoderECB.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
-#include "xfa/fxbarcode/utils.h"
-
-CBC_QRDataBlock::CBC_QRDataBlock(int32_t numDataCodewords,
- CFX_ByteArray* codewords)
- : m_numDataCodewords(numDataCodewords), m_codewords(codewords) {}
-CBC_QRDataBlock::~CBC_QRDataBlock() {
- delete m_codewords;
-}
-int32_t CBC_QRDataBlock::GetNumDataCodewords() {
- return m_numDataCodewords;
-}
-CFX_ByteArray* CBC_QRDataBlock::GetCodewords() {
- return m_codewords;
-}
-CFX_ArrayTemplate<CBC_QRDataBlock*>* CBC_QRDataBlock::GetDataBlocks(
- CFX_ByteArray* rawCodewords,
- CBC_QRCoderVersion* version,
- CBC_QRCoderErrorCorrectionLevel* ecLevel,
- int32_t& e) {
- if (rawCodewords->GetSize() != version->GetTotalCodeWords()) {
- e = BCExceptionIllegalArgument;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel);
- int32_t totalBlocks = 0;
- CFX_ArrayTemplate<CBC_QRCoderECB*>* ecBlockArray = ecBlocks->GetECBlocks();
- int32_t i = 0;
- for (i = 0; i < ecBlockArray->GetSize(); i++) {
- totalBlocks += (*ecBlockArray)[i]->GetCount();
- }
- std::unique_ptr<CFX_ArrayTemplate<CBC_QRDataBlock*>> result(
- new CFX_ArrayTemplate<CBC_QRDataBlock*>());
- result->SetSize(totalBlocks);
- int32_t numResultBlocks = 0;
- for (int32_t j = 0; j < ecBlockArray->GetSize(); j++) {
- CBC_QRCoderECB* ecBlock = (*ecBlockArray)[j];
- for (int32_t k = 0; k < ecBlock->GetCount(); k++) {
- int32_t numDataCodewords = ecBlock->GetDataCodeWords();
- int32_t numBlockCodewords =
- ecBlocks->GetECCodeWordsPerBlock() + numDataCodewords;
- CFX_ByteArray* bytearray = new CFX_ByteArray();
- bytearray->SetSize(numBlockCodewords);
- (*result)[numResultBlocks++] =
- new CBC_QRDataBlock(numDataCodewords, bytearray);
- }
- }
- int32_t shorterBlocksTotalCodewords = (*result)[0]->m_codewords->GetSize();
- int32_t longerBlocksStartAt = result->GetSize() - 1;
- while (longerBlocksStartAt >= 0) {
- int32_t numCodewords =
- (*result)[longerBlocksStartAt]->m_codewords->GetSize();
- if (numCodewords == shorterBlocksTotalCodewords) {
- break;
- }
- longerBlocksStartAt--;
- }
- longerBlocksStartAt++;
- int32_t shorterBlocksNumDataCodewords =
- shorterBlocksTotalCodewords - ecBlocks->GetECCodeWordsPerBlock();
- int32_t rawCodewordsOffset = 0;
- int32_t x = 0;
- for (int32_t k = 0; k < shorterBlocksNumDataCodewords; k++) {
- for (x = 0; x < numResultBlocks; x++) {
- (*((*result)[x]->m_codewords))[k] = (*rawCodewords)[rawCodewordsOffset++];
- }
- }
- for (x = longerBlocksStartAt; x < numResultBlocks; x++) {
- (*((*result)[x]->m_codewords))[shorterBlocksNumDataCodewords] =
- (*rawCodewords)[rawCodewordsOffset++];
- }
- int32_t max = (*result)[0]->m_codewords->GetSize();
- for (i = shorterBlocksNumDataCodewords; i < max; i++) {
- for (int32_t y = 0; y < numResultBlocks; y++) {
- int32_t iOffset = y < longerBlocksStartAt ? i : i + 1;
- (*((*result)[y]->m_codewords))[iOffset] =
- (*rawCodewords)[rawCodewordsOffset++];
- }
- }
- return result.release();
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDataBlock.h b/xfa/fxbarcode/qrcode/BC_QRDataBlock.h
deleted file mode 100644
index 014018dec0..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDataBlock.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_QRCoderErrorCorrectionLevel;
-class CBC_QRCoderVersion;
-
-class CBC_QRDataBlock final {
- public:
- ~CBC_QRDataBlock();
- int32_t GetNumDataCodewords();
- CFX_ByteArray* GetCodewords();
- static CFX_ArrayTemplate<CBC_QRDataBlock*>* GetDataBlocks(
- CFX_ByteArray* rawCodewords,
- CBC_QRCoderVersion* version,
- CBC_QRCoderErrorCorrectionLevel* ecLevel,
- int32_t& e);
-
- private:
- CBC_QRDataBlock(int32_t numDataCodewords, CFX_ByteArray* codewords);
-
- int32_t m_numDataCodewords;
- CFX_ByteArray* m_codewords;
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp b/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp
deleted file mode 100644
index e21b5d2d37..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDataMask.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDataMask.h"
-#include "xfa/fxbarcode/utils.h"
-
-namespace {
-
-int32_t N_DATA_MASKS = 0;
-CFX_ArrayTemplate<CBC_QRDataMask*>* DATA_MASKS = nullptr;
-
-} // namespace
-
-void CBC_QRDataMask::Initialize() {
- DATA_MASKS = new CFX_ArrayTemplate<CBC_QRDataMask*>();
- N_DATA_MASKS = BuildDataMasks();
-}
-
-void CBC_QRDataMask::Finalize() {
- Destroy();
- delete DATA_MASKS;
- DATA_MASKS = nullptr;
-}
-
-void CBC_QRDataMask::Destroy() {
- for (int32_t i = 0; i < N_DATA_MASKS; ++i)
- delete (*DATA_MASKS)[i];
-}
-
-void CBC_QRDataMask::UnmaskBitMatrix(CBC_CommonBitMatrix* bits,
- int32_t dimension) {
- for (int32_t i = 0; i < dimension; i++) {
- for (int32_t j = 0; j < dimension; j++) {
- if (IsMasked(i, j))
- bits->Flip(j, i);
- }
- }
-}
-
-CBC_QRDataMask* CBC_QRDataMask::ForReference(int32_t reference, int32_t& e) {
- if (reference < 0 || reference > 7) {
- e = BCExceptionReferenceMustBeBetween0And7;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- return (*DATA_MASKS)[reference];
-}
-
-class DataMask000 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-class DataMask001 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-class DataMask010 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-class DataMask011 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-class DataMask100 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-class DataMask101 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-class DataMask110 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-class DataMask111 : public CBC_QRDataMask {
- public:
- // CBC_QRDataMask
- FX_BOOL IsMasked(int32_t x, int32_t y) override;
-};
-
-int32_t CBC_QRDataMask::BuildDataMasks() {
- DATA_MASKS->Add(new DataMask000);
- DATA_MASKS->Add(new DataMask001);
- DATA_MASKS->Add(new DataMask010);
- DATA_MASKS->Add(new DataMask011);
- DATA_MASKS->Add(new DataMask100);
- DATA_MASKS->Add(new DataMask101);
- DATA_MASKS->Add(new DataMask110);
- DATA_MASKS->Add(new DataMask111);
- return DATA_MASKS->GetSize();
-}
-
-CBC_QRDataMask::CBC_QRDataMask() {}
-
-CBC_QRDataMask::~CBC_QRDataMask() {}
-
-FX_BOOL DataMask000::IsMasked(int32_t x, int32_t y) {
- return ((x + y) % 2) == 0;
-}
-
-FX_BOOL DataMask001::IsMasked(int32_t x, int32_t y) {
- return (x % 2) == 0;
-}
-
-FX_BOOL DataMask010::IsMasked(int32_t x, int32_t y) {
- return y % 3 == 0;
-}
-
-FX_BOOL DataMask011::IsMasked(int32_t x, int32_t y) {
- return (x + y) % 3 == 0;
-}
-
-FX_BOOL DataMask100::IsMasked(int32_t x, int32_t y) {
- return (((x >> 1) + (y / 3)) % 2) == 0;
-}
-
-FX_BOOL DataMask101::IsMasked(int32_t x, int32_t y) {
- size_t temp = x * y;
- return (temp % 2) + (temp % 3) == 0;
-}
-
-FX_BOOL DataMask110::IsMasked(int32_t x, int32_t y) {
- size_t temp = x * y;
- return (((temp % 2) + (temp % 3)) % 2) == 0;
-}
-
-FX_BOOL DataMask111::IsMasked(int32_t x, int32_t y) {
- return ((((x + y) % 2) + ((x * y) % 3)) % 2) == 0;
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDataMask.h b/xfa/fxbarcode/qrcode/BC_QRDataMask.h
deleted file mode 100644
index dc8cf498b3..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDataMask.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRDATAMASK_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRDATAMASK_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_CommonBitMatrix;
-
-class CBC_QRDataMask {
- public:
- CBC_QRDataMask();
- virtual ~CBC_QRDataMask();
-
- static void Initialize();
- static void Finalize();
- static CBC_QRDataMask* ForReference(int32_t reference, int32_t& e);
- static int32_t BuildDataMasks();
- static void Destroy();
-
- virtual FX_BOOL IsMasked(int32_t i, int32_t j) = 0;
- void UnmaskBitMatrix(CBC_CommonBitMatrix* bits, int32_t dimension);
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRDATAMASK_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp b/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp
deleted file mode 100644
index 062b326bd7..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.cpp
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/BC_UtilCodingConvert.h"
-#include "xfa/fxbarcode/common/BC_CommonBitSource.h"
-#include "xfa/fxbarcode/common/BC_CommonCharacterSetECI.h"
-#include "xfa/fxbarcode/common/BC_CommonDecoderResult.h"
-#include "xfa/fxbarcode/common/BC_CommonECI.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h"
-
-const FX_CHAR* CBC_QRDecodedBitStreamParser::UTF_8 = "utf8";
-const FX_CHAR CBC_QRDecodedBitStreamParser::ALPHANUMERIC_CHARS[45] = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
- 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
- 'U', 'V', 'W', 'X', 'Y', 'Z', ' ', '$', '%', '*', '+', '-', '.', '/', ':'};
-
-CBC_QRDecodedBitStreamParser::CBC_QRDecodedBitStreamParser() {}
-CBC_QRDecodedBitStreamParser::~CBC_QRDecodedBitStreamParser() {}
-CBC_CommonDecoderResult* CBC_QRDecodedBitStreamParser::Decode(
- CFX_ByteArray* bytes,
- CBC_QRCoderVersion* version,
- CBC_QRCoderErrorCorrectionLevel* ecLevel,
- int32_t byteModeDecode,
- int32_t& e) {
- CBC_CommonBitSource bits(bytes);
- CFX_ByteString result;
- CBC_CommonCharacterSetECI* currentCharacterSetECI = nullptr;
- FX_BOOL fc1Infact = FALSE;
- CFX_Int32Array byteSegments;
- CBC_QRCoderMode* mode = nullptr;
- do {
- if (bits.Available() < 4) {
- mode = CBC_QRCoderMode::sTERMINATOR;
- } else {
- int32_t iTemp1 = bits.ReadBits(4, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- mode = CBC_QRCoderMode::ForBits(iTemp1, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- if (!mode) {
- e = BCExceptionUnSupportMode;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- }
- if (!(mode == CBC_QRCoderMode::sTERMINATOR)) {
- if (mode == CBC_QRCoderMode::sFNC1_FIRST_POSITION ||
- mode == CBC_QRCoderMode::sFNC1_SECOND_POSITION) {
- fc1Infact = TRUE;
- } else if (mode == CBC_QRCoderMode::sSTRUCTURED_APPEND) {
- bits.ReadBits(16, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- } else if (mode == CBC_QRCoderMode::sECI) {
- int32_t value = ParseECIValue(&bits, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- currentCharacterSetECI =
- CBC_CommonCharacterSetECI::GetCharacterSetECIByValue(value);
- } else {
- if (mode == CBC_QRCoderMode::sGBK) {
- bits.ReadBits(4, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- int32_t numBits = mode->GetCharacterCountBits(version, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- int32_t count = bits.ReadBits(numBits, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- if (mode == CBC_QRCoderMode::sNUMERIC) {
- DecodeNumericSegment(&bits, result, count, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- } else if (mode == CBC_QRCoderMode::sALPHANUMERIC) {
- DecodeAlphanumericSegment(&bits, result, count, fc1Infact, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- } else if (mode == CBC_QRCoderMode::sBYTE) {
- DecodeByteSegment(&bits, result, count, currentCharacterSetECI,
- &byteSegments, byteModeDecode, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- } else if (mode == CBC_QRCoderMode::sGBK) {
- DecodeGBKSegment(&bits, result, count, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- } else if (mode == CBC_QRCoderMode::sKANJI) {
- DecodeKanjiSegment(&bits, result, count, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- } else {
- e = BCExceptionUnSupportMode;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- }
- }
- } while (!(mode == CBC_QRCoderMode::sTERMINATOR));
- CBC_CommonDecoderResult* tempCd = new CBC_CommonDecoderResult();
- tempCd->Init(*bytes, result, byteSegments, ecLevel, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return tempCd;
-}
-void CBC_QRDecodedBitStreamParser::DecodeGBKSegment(CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- int32_t& e) {
- CFX_ByteString buffer;
- while (count > 0) {
- int32_t twoBytes = bits->ReadBits(13, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- int32_t assembledTwoBytes = ((twoBytes / 0x060) << 8) | (twoBytes % 0x060);
- if (assembledTwoBytes <= 0x0095d) {
- assembledTwoBytes += 0x0a1a1;
- } else {
- assembledTwoBytes += 0x0a6a1;
- }
- buffer += (uint8_t)(assembledTwoBytes >> 8);
- buffer += (uint8_t)assembledTwoBytes;
- count--;
- }
- CBC_UtilCodingConvert::LocaleToUtf8(buffer, result);
-}
-void CBC_QRDecodedBitStreamParser::DecodeKanjiSegment(CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- int32_t& e) {
- CFX_ByteString buffer;
- while (count > 0) {
- int32_t twoBytes = bits->ReadBits(13, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- int32_t assembledTwoBytes = ((twoBytes / 0x0c0) << 8) | (twoBytes % 0x0c0);
- if (assembledTwoBytes <= 0x01f00) {
- assembledTwoBytes += 0x08140;
- } else {
- assembledTwoBytes += 0x0c140;
- }
- buffer += (uint8_t)(assembledTwoBytes >> 8);
- buffer += (uint8_t)assembledTwoBytes;
- count--;
- }
- CBC_UtilCodingConvert::LocaleToUtf8(buffer, result);
-}
-void CBC_QRDecodedBitStreamParser::DecodeByteSegment(
- CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- CBC_CommonCharacterSetECI* currentCharacterSetECI,
- CFX_Int32Array* byteSegments,
- int32_t byteModeDecode,
- int32_t& e) {
- if (count < 0) {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- if ((count << 3) > bits->Available()) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- uint8_t* readBytes = FX_Alloc(uint8_t, count);
- FXSYS_memset(readBytes, 0x00, count);
- for (int32_t i = 0; i < count; i++) {
- readBytes[i] = (uint8_t)bits->ReadBits(8, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- CFX_ByteString bs(readBytes, count);
- result += bs;
- FX_Free(readBytes);
-}
-void CBC_QRDecodedBitStreamParser::DecodeAlphanumericSegment(
- CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- FX_BOOL fac1InEffect,
- int32_t& e) {
- int32_t start = result.GetLength();
- while (count > 1) {
- int32_t nextTwoCharsBits = bits->ReadBits(11, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- BC_FX_ByteString_Append(result, 1,
- ALPHANUMERIC_CHARS[nextTwoCharsBits / 45]);
- BC_FX_ByteString_Append(result, 1,
- ALPHANUMERIC_CHARS[nextTwoCharsBits % 45]);
- count -= 2;
- }
- if (count == 1) {
- int32_t itemp = bits->ReadBits(6, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[itemp]);
- }
- if (fac1InEffect) {
- for (int32_t i = start; i < result.GetLength(); i++) {
- if (result[i] == '%') {
- if ((i < result.GetLength() - 1) && result[i + 1] == '%') {
- result.Delete(i + 1, 1);
- } else {
- result.SetAt(i, (FX_CHAR)0x1d);
- }
- }
- }
- }
-}
-void CBC_QRDecodedBitStreamParser::DecodeNumericSegment(
- CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- int32_t& e) {
- while (count >= 3) {
- int32_t threeDigitsBits = bits->ReadBits(10, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- if (threeDigitsBits >= 1000) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- BC_FX_ByteString_Append(result, 1,
- ALPHANUMERIC_CHARS[threeDigitsBits / 100]);
- BC_FX_ByteString_Append(result, 1,
- ALPHANUMERIC_CHARS[(threeDigitsBits / 10) % 10]);
- BC_FX_ByteString_Append(result, 1,
- ALPHANUMERIC_CHARS[threeDigitsBits % 10]);
- count -= 3;
- }
- if (count == 2) {
- int32_t twoDigitBits = bits->ReadBits(7, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- if (twoDigitBits >= 100) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[twoDigitBits / 10]);
- BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[twoDigitBits % 10]);
- } else if (count == 1) {
- int32_t digitBits = bits->ReadBits(4, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- if (digitBits >= 10) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- BC_FX_ByteString_Append(result, 1, ALPHANUMERIC_CHARS[digitBits]);
- }
-}
-const CFX_ByteString CBC_QRDecodedBitStreamParser::GuessEncoding(
- CFX_ByteArray* bytes) {
- return *UTF_8;
-}
-int32_t CBC_QRDecodedBitStreamParser::ParseECIValue(CBC_CommonBitSource* bits,
- int32_t& e) {
- int32_t firstByte = bits->ReadBits(8, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- if ((firstByte & 0x80) == 0) {
- return firstByte & 0x7f;
- } else if ((firstByte & 0xc0) == 0x80) {
- int32_t secondByte = bits->ReadBits(8, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- return ((firstByte & 0x3f) << 8) | secondByte;
- } else if ((firstByte & 0xe0) == 0xc0) {
- int32_t secondThirdByte = bits->ReadBits(16, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- return ((firstByte & 0x1f) << 16) | secondThirdByte;
- }
- e = BCExceptionBadECI;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- return 0;
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h b/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h
deleted file mode 100644
index 0943bc0a4e..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDecodedBitStreamParser.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_
-
-class CBC_CommonDecoderResult;
-class CBC_QRCoderErrorCorrectionLevel;
-class CBC_CommonBitSource;
-class CBC_QRCoderVersion;
-class CBC_CommonCharacterSetECI;
-class CBC_QRDecodedBitStreamParser {
- private:
- static const FX_CHAR ALPHANUMERIC_CHARS[45];
- static const FX_CHAR* UTF_8;
- CBC_QRDecodedBitStreamParser();
-
- public:
- virtual ~CBC_QRDecodedBitStreamParser();
- static CBC_CommonDecoderResult* Decode(
- CFX_ByteArray* bytes,
- CBC_QRCoderVersion* version,
- CBC_QRCoderErrorCorrectionLevel* ecLevel,
- int32_t byteModeDecode,
- int32_t& e);
-
- static const CFX_ByteString GuessEncoding(CFX_ByteArray* bytes);
- static int32_t ParseECIValue(CBC_CommonBitSource* bits, int32_t& e);
- static void DecodeGBKSegment(CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- int32_t& e);
- static void DecodeKanjiSegment(CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- int32_t& e);
- static void DecodeNumericSegment(CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- int32_t& e);
- static void DecodeAlphanumericSegment(CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- FX_BOOL fac1InEffect,
- int32_t& e);
- static void DecodeByteSegment(
- CBC_CommonBitSource* bits,
- CFX_ByteString& result,
- int32_t count,
- CBC_CommonCharacterSetECI* currentCharacterSetECI,
- CFX_Int32Array* byteSegments,
- int32_t byteModeDecode,
- int32_t& e);
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRDECODEDBITSTREAMPARSER_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
deleted file mode 100644
index a5be32a232..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDetector.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRDetector.h"
-
-#include <algorithm>
-#include <memory>
-
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h"
-#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPattern.h"
-#include "xfa/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h"
-#include "xfa/fxbarcode/qrcode/BC_QRCoderVersion.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
-#include "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h"
-#include "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h"
-#include "xfa/fxbarcode/qrcode/BC_QRGridSampler.h"
-
-CBC_QRDetector::CBC_QRDetector(CBC_CommonBitMatrix* image) : m_image(image) {}
-CBC_QRDetector::~CBC_QRDetector() {}
-CBC_QRDetectorResult* CBC_QRDetector::Detect(int32_t hints, int32_t& e) {
- CBC_QRFinderPatternFinder finder(m_image);
- std::unique_ptr<CBC_QRFinderPatternInfo> info(finder.Find(hints, e));
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- CBC_QRDetectorResult* qdr = ProcessFinderPatternInfo(info.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return qdr;
-}
-CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo(
- CBC_QRFinderPatternInfo* info,
- int32_t& e) {
- std::unique_ptr<CBC_QRFinderPattern> topLeft(info->GetTopLeft());
- std::unique_ptr<CBC_QRFinderPattern> topRight(info->GetTopRight());
- std::unique_ptr<CBC_QRFinderPattern> bottomLeft(info->GetBottomLeft());
- FX_FLOAT moduleSize =
- CalculateModuleSize(topLeft.get(), topRight.get(), bottomLeft.get());
- if (moduleSize < 1.0f) {
- e = BCExceptionRead;
- return nullptr;
- }
- int32_t dimension = ComputeDimension(topLeft.get(), topRight.get(),
- bottomLeft.get(), moduleSize, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- CBC_QRCoderVersion* provisionalVersion =
- CBC_QRCoderVersion::GetProvisionalVersionForDimension(dimension, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- int32_t modulesBetweenFPCenters =
- provisionalVersion->GetDimensionForVersion() - 7;
- CBC_QRAlignmentPattern* alignmentPattern = nullptr;
- if (provisionalVersion->GetAlignmentPatternCenters()->GetSize() > 0) {
- FX_FLOAT bottomRightX =
- topRight->GetX() - topLeft->GetX() + bottomLeft->GetX();
- FX_FLOAT bottomRightY =
- topRight->GetY() - topLeft->GetY() + bottomLeft->GetY();
- FX_FLOAT correctionToTopLeft =
- 1.0f - 3.0f / (FX_FLOAT)modulesBetweenFPCenters;
- FX_FLOAT xtemp = (topLeft->GetX() +
- correctionToTopLeft * (bottomRightX - topLeft->GetX()));
- int32_t estAlignmentX = (int32_t)xtemp;
- FX_FLOAT ytemp = (topLeft->GetY() +
- correctionToTopLeft * (bottomRightY - topLeft->GetY()));
- int32_t estAlignmentY = (int32_t)ytemp;
- for (int32_t i = 4; i <= 16; i <<= 1) {
- CBC_QRAlignmentPattern* temp = FindAlignmentInRegion(
- moduleSize, estAlignmentX, estAlignmentY, (FX_FLOAT)i, e);
- if (temp) {
- alignmentPattern = temp;
- break;
- }
- }
- }
- CBC_CommonBitMatrix* bits =
- SampleGrid(m_image, topLeft.get(), topRight.get(), bottomLeft.get(),
- alignmentPattern, dimension, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
-
- CFX_ArrayTemplate<CBC_ResultPoint*>* points =
- new CFX_ArrayTemplate<CBC_ResultPoint*>();
- points->Add(bottomLeft.release());
- points->Add(topLeft.release());
- points->Add(topRight.release());
- if (alignmentPattern)
- points->Add(alignmentPattern);
- return new CBC_QRDetectorResult(bits, points);
-}
-CBC_CommonBitMatrix* CBC_QRDetector::SampleGrid(
- CBC_CommonBitMatrix* image,
- CBC_ResultPoint* topLeft,
- CBC_ResultPoint* topRight,
- CBC_ResultPoint* bottomLeft,
- CBC_ResultPoint* alignmentPattern,
- int32_t dimension,
- int32_t& e) {
- FX_FLOAT dimMinusThree = (FX_FLOAT)dimension - 3.5f;
- FX_FLOAT bottomRightX;
- FX_FLOAT bottomRightY;
- FX_FLOAT sourceBottomRightX;
- FX_FLOAT sourceBottomRightY;
- if (alignmentPattern) {
- bottomRightX = alignmentPattern->GetX();
- bottomRightY = alignmentPattern->GetY();
- sourceBottomRightX = sourceBottomRightY = dimMinusThree - 3.0f;
- } else {
- bottomRightX = (topRight->GetX() - topLeft->GetX()) + bottomLeft->GetX();
- bottomRightY = (topRight->GetY() - topLeft->GetY()) + bottomLeft->GetY();
- sourceBottomRightX = sourceBottomRightY = dimMinusThree;
- }
- CBC_QRGridSampler& sampler = CBC_QRGridSampler::GetInstance();
- CBC_CommonBitMatrix* cbm = sampler.SampleGrid(
- image, dimension, dimension, 3.5f, 3.5f, dimMinusThree, 3.5f,
- sourceBottomRightX, sourceBottomRightY, 3.5f, dimMinusThree,
- topLeft->GetX(), topLeft->GetY(), topRight->GetX(), topRight->GetY(),
- bottomRightX, bottomRightY, bottomLeft->GetX(), bottomLeft->GetY(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return cbm;
-}
-int32_t CBC_QRDetector::ComputeDimension(CBC_ResultPoint* topLeft,
- CBC_ResultPoint* topRight,
- CBC_ResultPoint* bottomLeft,
- FX_FLOAT moduleSize,
- int32_t& e) {
- int32_t tltrCentersDimension = Round(
- CBC_QRFinderPatternFinder::Distance(topLeft, topRight) / moduleSize);
- int32_t tlblCentersDimension = Round(
- CBC_QRFinderPatternFinder::Distance(topLeft, bottomLeft) / moduleSize);
- int32_t dimension = ((tltrCentersDimension + tlblCentersDimension) >> 1) + 7;
- switch (dimension & 0x03) {
- case 0:
- dimension++;
- break;
- case 2:
- dimension--;
- break;
- case 3: {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- }
- }
- return dimension;
-}
-FX_FLOAT CBC_QRDetector::CalculateModuleSize(CBC_ResultPoint* topLeft,
- CBC_ResultPoint* topRight,
- CBC_ResultPoint* bottomLeft) {
- return (CalculateModuleSizeOneWay(topLeft, topRight) +
- CalculateModuleSizeOneWay(topLeft, bottomLeft)) /
- 2.0f;
-}
-FX_FLOAT CBC_QRDetector::CalculateModuleSizeOneWay(
- CBC_ResultPoint* pattern,
- CBC_ResultPoint* otherPattern) {
- FX_FLOAT moduleSizeEst1 = SizeOfBlackWhiteBlackRunBothWays(
- (int32_t)pattern->GetX(), (int32_t)pattern->GetY(),
- (int32_t)otherPattern->GetX(), (int32_t)otherPattern->GetY());
- FX_FLOAT moduleSizeEst2 = SizeOfBlackWhiteBlackRunBothWays(
- (int32_t)otherPattern->GetX(), (int32_t)otherPattern->GetY(),
- (int32_t)pattern->GetX(), (int32_t)pattern->GetY());
- if (FXSYS_isnan(moduleSizeEst1)) {
- return moduleSizeEst2;
- }
- if (FXSYS_isnan(moduleSizeEst2)) {
- return moduleSizeEst1;
- }
- return (moduleSizeEst1 + moduleSizeEst2) / 14.0f;
-}
-int32_t CBC_QRDetector::Round(FX_FLOAT d) {
- return (int32_t)(d + 0.5f);
-}
-FX_FLOAT CBC_QRDetector::SizeOfBlackWhiteBlackRunBothWays(int32_t fromX,
- int32_t fromY,
- int32_t toX,
- int32_t toY) {
- FX_FLOAT result = SizeOfBlackWhiteBlackRun(fromX, fromY, toX, toY);
- int32_t otherToX = fromX - (toX - fromX);
- if (otherToX < 0) {
- otherToX = -1;
- } else if (otherToX >= m_image->GetWidth()) {
- otherToX = m_image->GetWidth();
- }
- int32_t otherToY = fromY - (toY - fromY);
- if (otherToY < 0) {
- otherToY = -1;
- } else if (otherToY >= m_image->GetHeight()) {
- otherToY = m_image->GetHeight();
- }
- result += SizeOfBlackWhiteBlackRun(fromX, fromY, otherToX, otherToY);
- return result - 1.0f;
-}
-FX_FLOAT CBC_QRDetector::SizeOfBlackWhiteBlackRun(int32_t fromX,
- int32_t fromY,
- int32_t toX,
- int32_t toY) {
- FX_BOOL steep = FXSYS_abs(toY - fromY) > FXSYS_abs(toX - fromX);
- if (steep) {
- int32_t temp = fromX;
- fromX = fromY;
- fromY = temp;
- temp = toX;
- toX = toY;
- toY = temp;
- }
- int32_t dx = FXSYS_abs(toX - fromX);
- int32_t dy = FXSYS_abs(toY - fromY);
- int32_t error = -dx >> 1;
- int32_t ystep = fromY < toY ? 1 : -1;
- int32_t xstep = fromX < toX ? 1 : -1;
- int32_t state = 0;
- for (int32_t x = fromX, y = fromY; x != toX; x += xstep) {
- int32_t realX = steep ? y : x;
- int32_t realY = steep ? x : y;
- if (state == 1) {
- if (m_image->Get(realX, realY)) {
- state++;
- }
- } else {
- if (!m_image->Get(realX, realY)) {
- state++;
- }
- }
- if (state == 3) {
- int32_t diffX = x - fromX;
- int32_t diffY = y - fromY;
- return (FX_FLOAT)sqrt((double)(diffX * diffX + diffY * diffY));
- }
- error += dy;
- if (error > 0) {
- y += ystep;
- error -= dx;
- }
- }
- int32_t diffX = toX - fromX;
- int32_t diffY = toY - fromY;
- return (FX_FLOAT)sqrt((double)(diffX * diffX + diffY * diffY));
-}
-CBC_QRAlignmentPattern* CBC_QRDetector::FindAlignmentInRegion(
- FX_FLOAT overallEstModuleSize,
- int32_t estAlignmentX,
- int32_t estAlignmentY,
- FX_FLOAT allowanceFactor,
- int32_t& e) {
- int32_t allowance = (int32_t)(allowanceFactor * overallEstModuleSize);
- int32_t alignmentAreaLeftX = std::max(0, estAlignmentX - allowance);
- int32_t alignmentAreaRightX =
- std::min(m_image->GetWidth() - 1, estAlignmentX + allowance);
- if (alignmentAreaRightX - alignmentAreaLeftX < overallEstModuleSize * 3) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- int32_t alignmentAreaTopY = std::max(0, estAlignmentY - allowance);
- int32_t alignmentAreaBottomY =
- std::min(m_image->GetHeight() - 1, estAlignmentY + allowance);
- CBC_QRAlignmentPatternFinder alignmentFinder(
- m_image, alignmentAreaLeftX, alignmentAreaTopY,
- alignmentAreaRightX - alignmentAreaLeftX,
- alignmentAreaBottomY - alignmentAreaTopY, overallEstModuleSize);
- CBC_QRAlignmentPattern* qap = alignmentFinder.Find(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- return qap;
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetector.h b/xfa/fxbarcode/qrcode/BC_QRDetector.h
deleted file mode 100644
index 91eed25415..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDetector.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRDETECTOR_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRDETECTOR_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_ResultPoint;
-class CBC_CommonBitMatrix;
-class CBC_QRDetectorResult;
-class CBC_QRFinderPatternInfo;
-class CBC_QRAlignmentPattern;
-
-class CBC_QRDetector {
- private:
- CBC_CommonBitMatrix* m_image;
-
- public:
- CBC_QRDetector(CBC_CommonBitMatrix* image);
- virtual ~CBC_QRDetector();
-
- CBC_CommonBitMatrix* GetImage();
- CBC_QRDetectorResult* Detect(int32_t hints, int32_t& e);
- CBC_QRDetectorResult* ProcessFinderPatternInfo(CBC_QRFinderPatternInfo* info,
- int32_t& e);
- FX_FLOAT CalculateModuleSize(CBC_ResultPoint* topLeft,
- CBC_ResultPoint* topRight,
- CBC_ResultPoint* bottomLeft);
- FX_FLOAT CalculateModuleSizeOneWay(CBC_ResultPoint* pattern,
- CBC_ResultPoint* otherPattern);
- FX_FLOAT SizeOfBlackWhiteBlackRunBothWays(int32_t fromX,
- int32_t fromY,
- int32_t toX,
- int32_t toY);
- FX_FLOAT SizeOfBlackWhiteBlackRun(int32_t fromX,
- int32_t fromY,
- int32_t toX,
- int32_t toY);
- CBC_QRAlignmentPattern* FindAlignmentInRegion(FX_FLOAT overallEstModuleSize,
- int32_t estAlignmentX,
- int32_t estAlignmentY,
- FX_FLOAT allowanceFactor,
- int32_t& e);
- static int32_t Round(FX_FLOAT d);
- static int32_t ComputeDimension(CBC_ResultPoint* topLeft,
- CBC_ResultPoint* topRight,
- CBC_ResultPoint* bottomLeft,
- FX_FLOAT moduleSize,
- int32_t& e);
- static CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image,
- CBC_ResultPoint* topLeft,
- CBC_ResultPoint* topRight,
- CBC_ResultPoint* bottomLeft,
- CBC_ResultPoint* alignmentPattern,
- int32_t dimension,
- int32_t& e);
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRDETECTOR_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
deleted file mode 100644
index 5ce2e75762..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/qrcode/BC_QRDetectorResult.h"
-
-CBC_QRDetectorResult::CBC_QRDetectorResult(
- CBC_CommonBitMatrix* bits,
- CFX_ArrayTemplate<CBC_ResultPoint*>* points)
- : m_bits(bits), m_points(points) {}
-
-CBC_QRDetectorResult::~CBC_QRDetectorResult() {
- for (int32_t i = 0; i < m_points->GetSize(); i++)
- delete (*m_points)[i];
-}
-
-CBC_CommonBitMatrix* CBC_QRDetectorResult::GetBits() const {
- return m_bits.get();
-}
-
-CFX_ArrayTemplate<CBC_ResultPoint*>* CBC_QRDetectorResult::GetPoints() const {
- return m_points.get();
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h b/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
deleted file mode 100644
index 5948c2a01c..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRDetectorResult.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
-
-#include <memory>
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_CommonBitMatrix;
-class CBC_ResultPoint;
-
-class CBC_QRDetectorResult final {
- public:
- // Takes ownership of |bits| and |points|.
- CBC_QRDetectorResult(CBC_CommonBitMatrix* bits,
- CFX_ArrayTemplate<CBC_ResultPoint*>* points);
- ~CBC_QRDetectorResult();
-
- CBC_CommonBitMatrix* GetBits() const;
- CFX_ArrayTemplate<CBC_ResultPoint*>* GetPoints() const;
-
- private:
- std::unique_ptr<CBC_CommonBitMatrix> m_bits;
- std::unique_ptr<CFX_ArrayTemplate<CBC_ResultPoint*>> m_points;
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRDETECTORRESULT_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp b/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp
deleted file mode 100644
index 1bc9648835..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRFinderPattern.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h"
-
-CBC_QRFinderPattern::CBC_QRFinderPattern(FX_FLOAT x,
- FX_FLOAT posY,
- FX_FLOAT estimatedModuleSize)
- : CBC_ResultPoint(x, posY),
- m_estimatedModuleSize(estimatedModuleSize),
- m_count(1) {}
-CBC_QRFinderPattern::~CBC_QRFinderPattern() {
- m_count = 0;
- m_x = 0.0f;
- m_y = 0.0f;
- m_estimatedModuleSize = 0.0f;
-}
-CBC_QRFinderPattern* CBC_QRFinderPattern::Clone() {
- CBC_QRFinderPattern* temp =
- new CBC_QRFinderPattern(m_x, m_y, m_estimatedModuleSize);
- temp->m_count = m_count;
- return temp;
-}
-FX_FLOAT CBC_QRFinderPattern::GetEstimatedModuleSize() {
- return m_estimatedModuleSize;
-}
-int32_t CBC_QRFinderPattern::GetCount() const {
- return m_count;
-}
-void CBC_QRFinderPattern::IncrementCount() {
- m_count++;
-}
-FX_BOOL CBC_QRFinderPattern::AboutEquals(FX_FLOAT moduleSize,
- FX_FLOAT i,
- FX_FLOAT j) {
- if ((fabs(i - GetY()) <= moduleSize) && (fabs(j - GetX()) <= moduleSize)) {
- FX_FLOAT moduleSizeDiff = fabs(moduleSize - m_estimatedModuleSize);
- return (moduleSizeDiff <= 1.0f) ||
- (moduleSizeDiff / m_estimatedModuleSize <= 1.0f);
- }
- return false;
-}
-FX_FLOAT CBC_QRFinderPattern::GetX() {
- return m_x;
-}
-FX_FLOAT CBC_QRFinderPattern::GetY() {
- return m_y;
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h b/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h
deleted file mode 100644
index f02a229121..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRFinderPattern.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_
-
-class CBC_ResultPoint;
-class CBC_QRFinderPattern;
-class CBC_QRFinderPattern : public CBC_ResultPoint {
- private:
- FX_FLOAT m_estimatedModuleSize;
- int32_t m_count;
-
- public:
- CBC_QRFinderPattern(FX_FLOAT x, FX_FLOAT posY, FX_FLOAT estimatedModuleSize);
- ~CBC_QRFinderPattern() override;
-
- // CBC_ResultPoint
- FX_FLOAT GetX() override;
- FX_FLOAT GetY() override;
-
- int32_t GetCount() const;
- FX_FLOAT GetEstimatedModuleSize();
- void IncrementCount();
- FX_BOOL AboutEquals(FX_FLOAT moduleSize, FX_FLOAT i, FX_FLOAT j);
- CBC_QRFinderPattern* Clone();
-};
-typedef CBC_QRFinderPattern FinderPattern;
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERN_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp b/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp
deleted file mode 100644
index 5ceeefac53..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp
+++ /dev/null
@@ -1,481 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h"
-
-#include <memory>
-
-#include "core/fxcrt/include/fx_basic.h"
-#include "xfa/fxbarcode/BC_ResultPoint.h"
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/qrcode/BC_FinderPatternInfo.h"
-#include "xfa/fxbarcode/qrcode/BC_QRFinderPattern.h"
-#include "xfa/fxbarcode/utils.h"
-
-const int32_t CBC_QRFinderPatternFinder::CENTER_QUORUM = 2;
-const int32_t CBC_QRFinderPatternFinder::MIN_SKIP = 3;
-const int32_t CBC_QRFinderPatternFinder::MAX_MODULES = 57;
-const int32_t CBC_QRFinderPatternFinder::INTEGER_MATH_SHIFT = 8;
-
-CBC_QRFinderPatternFinder::CBC_QRFinderPatternFinder(
- CBC_CommonBitMatrix* image) {
- m_image = image;
- m_crossCheckStateCount.SetSize(5);
- m_hasSkipped = FALSE;
-}
-
-CBC_QRFinderPatternFinder::~CBC_QRFinderPatternFinder() {
- for (int32_t i = 0; i < m_possibleCenters.GetSize(); i++)
- delete m_possibleCenters[i];
-}
-
-class ClosestToAverageComparator {
- private:
- FX_FLOAT m_averageModuleSize;
-
- public:
- ClosestToAverageComparator(FX_FLOAT averageModuleSize)
- : m_averageModuleSize(averageModuleSize) {}
- int32_t operator()(FinderPattern* a, FinderPattern* b) {
- FX_FLOAT dA =
- (FX_FLOAT)fabs(a->GetEstimatedModuleSize() - m_averageModuleSize);
- FX_FLOAT dB =
- (FX_FLOAT)fabs(b->GetEstimatedModuleSize() - m_averageModuleSize);
- return dA < dB ? -1 : dA > dB ? 1 : 0;
- }
-};
-class CenterComparator {
- public:
- int32_t operator()(FinderPattern* a, FinderPattern* b) {
- return b->GetCount() - a->GetCount();
- }
-};
-CBC_CommonBitMatrix* CBC_QRFinderPatternFinder::GetImage() {
- return m_image;
-}
-CFX_Int32Array& CBC_QRFinderPatternFinder::GetCrossCheckStateCount() {
- m_crossCheckStateCount[0] = 0;
- m_crossCheckStateCount[1] = 0;
- m_crossCheckStateCount[2] = 0;
- m_crossCheckStateCount[3] = 0;
- m_crossCheckStateCount[4] = 0;
- return m_crossCheckStateCount;
-}
-
-CFX_ArrayTemplate<CBC_QRFinderPattern*>*
-CBC_QRFinderPatternFinder::GetPossibleCenters() {
- return &m_possibleCenters;
-}
-
-CBC_QRFinderPatternInfo* CBC_QRFinderPatternFinder::Find(int32_t hint,
- int32_t& e) {
- int32_t maxI = m_image->GetHeight();
- int32_t maxJ = m_image->GetWidth();
- int32_t iSkip = (3 * maxI) / (4 * MAX_MODULES);
- if (iSkip < MIN_SKIP || 0) {
- iSkip = MIN_SKIP;
- }
- FX_BOOL done = FALSE;
- CFX_Int32Array stateCount;
- stateCount.SetSize(5);
- for (int32_t i = iSkip - 1; i < maxI && !done; i += iSkip) {
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
- stateCount[3] = 0;
- stateCount[4] = 0;
- int32_t currentState = 0;
- for (int32_t j = 0; j < maxJ; j++) {
- if (m_image->Get(j, i)) {
- if ((currentState & 1) == 1) {
- currentState++;
- }
- stateCount[currentState]++;
- } else {
- if ((currentState & 1) == 0) {
- if (currentState == 4) {
- if (FoundPatternCross(stateCount)) {
- FX_BOOL confirmed = HandlePossibleCenter(stateCount, i, j);
- if (confirmed) {
- iSkip = 2;
- if (m_hasSkipped) {
- done = HaveMultiplyConfirmedCenters();
- } else {
- int32_t rowSkip = FindRowSkip();
- if (rowSkip > stateCount[2]) {
- i += rowSkip - stateCount[2] - iSkip;
- j = maxJ - 1;
- }
- }
- } else {
- do {
- j++;
- } while (j < maxJ && !m_image->Get(j, i));
- j--;
- }
- currentState = 0;
- stateCount[0] = 0;
- stateCount[1] = 0;
- stateCount[2] = 0;
- stateCount[3] = 0;
- stateCount[4] = 0;
- } else {
- stateCount[0] = stateCount[2];
- stateCount[1] = stateCount[3];
- stateCount[2] = stateCount[4];
- stateCount[3] = 1;
- stateCount[4] = 0;
- currentState = 3;
- }
- } else {
- stateCount[++currentState]++;
- }
- } else {
- stateCount[currentState]++;
- }
- }
- }
- if (FoundPatternCross(stateCount)) {
- FX_BOOL confirmed = HandlePossibleCenter(stateCount, i, maxJ);
- if (confirmed) {
- iSkip = stateCount[0];
- if (m_hasSkipped) {
- done = HaveMultiplyConfirmedCenters();
- }
- }
- }
- }
- std::unique_ptr<CFX_ArrayTemplate<CBC_QRFinderPattern*>> patternInfo(
- SelectBestpatterns(e));
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- OrderBestPatterns(patternInfo.get());
- return new CBC_QRFinderPatternInfo(patternInfo.get());
-}
-void CBC_QRFinderPatternFinder::OrderBestPatterns(
- CFX_ArrayTemplate<CBC_QRFinderPattern*>* patterns) {
- FX_FLOAT abDistance = Distance((*patterns)[0], (*patterns)[1]);
- FX_FLOAT bcDistance = Distance((*patterns)[1], (*patterns)[2]);
- FX_FLOAT acDistance = Distance((*patterns)[0], (*patterns)[2]);
- CBC_QRFinderPattern* topLeft;
- CBC_QRFinderPattern* topRight;
- CBC_QRFinderPattern* bottomLeft;
- if (bcDistance >= abDistance && bcDistance >= acDistance) {
- topLeft = (*patterns)[0];
- topRight = (*patterns)[1];
- bottomLeft = (*patterns)[2];
- } else if (acDistance >= bcDistance && acDistance >= abDistance) {
- topLeft = (*patterns)[1];
- topRight = (*patterns)[0];
- bottomLeft = (*patterns)[2];
- } else {
- topLeft = (*patterns)[2];
- topRight = (*patterns)[0];
- bottomLeft = (*patterns)[1];
- }
- if ((bottomLeft->GetY() - topLeft->GetY()) *
- (topRight->GetX() - topLeft->GetX()) <
- (bottomLeft->GetX() - topLeft->GetX()) *
- (topRight->GetY() - topLeft->GetY())) {
- CBC_QRFinderPattern* temp = topRight;
- topRight = bottomLeft;
- bottomLeft = temp;
- }
- (*patterns)[0] = bottomLeft;
- (*patterns)[1] = topLeft;
- (*patterns)[2] = topRight;
-}
-FX_FLOAT CBC_QRFinderPatternFinder::Distance(CBC_ResultPoint* point1,
- CBC_ResultPoint* point2) {
- FX_FLOAT dx = point1->GetX() - point2->GetX();
- FX_FLOAT dy = point1->GetY() - point2->GetY();
- return (FX_FLOAT)FXSYS_sqrt(dx * dx + dy * dy);
-}
-FX_FLOAT CBC_QRFinderPatternFinder::CenterFromEnd(
- const CFX_Int32Array& stateCount,
- int32_t end) {
- return (FX_FLOAT)(end - stateCount[4] - stateCount[3]) - stateCount[2] / 2.0f;
-}
-FX_BOOL CBC_QRFinderPatternFinder::FoundPatternCross(
- const CFX_Int32Array& stateCount) {
- int32_t totalModuleSize = 0;
- for (int32_t i = 0; i < 5; i++) {
- int32_t count = stateCount[i];
- if (count == 0) {
- return FALSE;
- }
- totalModuleSize += count;
- }
- if (totalModuleSize < 7) {
- return FALSE;
- }
- int32_t moduleSize = (totalModuleSize << INTEGER_MATH_SHIFT) / 7;
- int32_t maxVariance = moduleSize / 2;
- return FXSYS_abs(moduleSize - (stateCount[0] << INTEGER_MATH_SHIFT)) <
- maxVariance &&
- FXSYS_abs(moduleSize - (stateCount[1] << INTEGER_MATH_SHIFT)) <
- maxVariance &&
- FXSYS_abs(3 * moduleSize - (stateCount[2] << INTEGER_MATH_SHIFT)) <
- 3 * maxVariance &&
- FXSYS_abs(moduleSize - (stateCount[3] << INTEGER_MATH_SHIFT)) <
- maxVariance &&
- FXSYS_abs(moduleSize - (stateCount[4] << INTEGER_MATH_SHIFT)) <
- maxVariance;
-}
-FX_FLOAT CBC_QRFinderPatternFinder::CrossCheckVertical(
- int32_t startI,
- int32_t centerJ,
- int32_t maxCount,
- int32_t originalStateCountTotal) {
- CBC_CommonBitMatrix* image = m_image;
- int32_t maxI = image->GetHeight();
- CFX_Int32Array& stateCount = GetCrossCheckStateCount();
- int32_t i = startI;
- while (i >= 0 && image->Get(centerJ, i)) {
- stateCount[2]++;
- i--;
- }
- if (i < 0) {
- return FXSYS_nan();
- }
- while (i >= 0 && !image->Get(centerJ, i) && stateCount[1] <= maxCount) {
- stateCount[1]++;
- i--;
- }
- if (i < 0 || stateCount[1] > maxCount) {
- return FXSYS_nan();
- }
- while (i >= 0 && image->Get(centerJ, i) && stateCount[0] <= maxCount) {
- stateCount[0]++;
- i--;
- }
- if (stateCount[0] > maxCount) {
- return FXSYS_nan();
- }
- i = startI + 1;
- while (i < maxI && image->Get(centerJ, i)) {
- stateCount[2]++;
- i++;
- }
- if (i == maxI) {
- return FXSYS_nan();
- }
- while (i < maxI && !image->Get(centerJ, i) && stateCount[3] < maxCount) {
- stateCount[3]++;
- i++;
- }
- if (i == maxI || stateCount[3] >= maxCount) {
- return FXSYS_nan();
- }
- while (i < maxI && image->Get(centerJ, i) && stateCount[4] < maxCount) {
- stateCount[4]++;
- i++;
- }
- if (stateCount[4] >= maxCount) {
- return FXSYS_nan();
- }
- int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] +
- stateCount[3] + stateCount[4];
- if (5 * FXSYS_abs(stateCountTotal - originalStateCountTotal) >=
- originalStateCountTotal) {
- return FXSYS_nan();
- }
- return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, i)
- : FXSYS_nan();
-}
-FX_FLOAT CBC_QRFinderPatternFinder::CrossCheckHorizontal(
- int32_t startJ,
- int32_t centerI,
- int32_t maxCount,
- int32_t originalStateCountTotal) {
- CBC_CommonBitMatrix* image = m_image;
- int32_t maxJ = image->GetWidth();
- CFX_Int32Array& stateCount = GetCrossCheckStateCount();
- int32_t j = startJ;
- while (j >= 0 && image->Get(j, centerI)) {
- stateCount[2]++;
- j--;
- }
- if (j < 0) {
- return FXSYS_nan();
- }
- while (j >= 0 && !image->Get(j, centerI) && stateCount[1] <= maxCount) {
- stateCount[1]++;
- j--;
- }
- if (j < 0 || stateCount[1] > maxCount) {
- return FXSYS_nan();
- }
- while (j >= 0 && image->Get(j, centerI) && stateCount[0] <= maxCount) {
- stateCount[0]++;
- j--;
- }
- if (stateCount[0] > maxCount) {
- return FXSYS_nan();
- }
- j = startJ + 1;
- while (j < maxJ && image->Get(j, centerI)) {
- stateCount[2]++;
- j++;
- }
- if (j == maxJ) {
- return FXSYS_nan();
- }
- while (j < maxJ && !image->Get(j, centerI) && stateCount[3] < maxCount) {
- stateCount[3]++;
- j++;
- }
- if (j == maxJ || stateCount[3] >= maxCount) {
- return FXSYS_nan();
- }
- while (j < maxJ && image->Get(j, centerI) && stateCount[4] < maxCount) {
- stateCount[4]++;
- j++;
- }
- if (stateCount[4] >= maxCount) {
- return FXSYS_nan();
- }
- int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] +
- stateCount[3] + stateCount[4];
- if (5 * FXSYS_abs(stateCountTotal - originalStateCountTotal) >=
- originalStateCountTotal) {
- return FXSYS_nan();
- }
- return FoundPatternCross(stateCount) ? CenterFromEnd(stateCount, j)
- : FXSYS_nan();
-}
-FX_BOOL CBC_QRFinderPatternFinder::HandlePossibleCenter(
- const CFX_Int32Array& stateCount,
- int32_t i,
- int32_t j) {
- int32_t stateCountTotal = stateCount[0] + stateCount[1] + stateCount[2] +
- stateCount[3] + stateCount[4];
- FX_FLOAT centerJ = CenterFromEnd(stateCount, j);
- FX_FLOAT centerI =
- CrossCheckVertical(i, (int32_t)centerJ, stateCount[2], stateCountTotal);
- if (!FXSYS_isnan(centerI)) {
- centerJ = CrossCheckHorizontal((int32_t)centerJ, (int32_t)centerI,
- stateCount[2], stateCountTotal);
- if (!FXSYS_isnan(centerJ)) {
- FX_FLOAT estimatedModuleSize = (FX_FLOAT)stateCountTotal / 7.0f;
- FX_BOOL found = FALSE;
- int32_t max = m_possibleCenters.GetSize();
- for (int32_t index = 0; index < max; index++) {
- CBC_QRFinderPattern* center = m_possibleCenters[index];
- if (center->AboutEquals(estimatedModuleSize, centerI, centerJ)) {
- center->IncrementCount();
- found = TRUE;
- break;
- }
- }
- if (!found) {
- m_possibleCenters.Add(
- new CBC_QRFinderPattern(centerJ, centerI, estimatedModuleSize));
- }
- return TRUE;
- }
- }
- return FALSE;
-}
-int32_t CBC_QRFinderPatternFinder::FindRowSkip() {
- int32_t max = m_possibleCenters.GetSize();
- if (max <= 1) {
- return 0;
- }
- FinderPattern* firstConfirmedCenter = nullptr;
- for (int32_t i = 0; i < max; i++) {
- CBC_QRFinderPattern* center = m_possibleCenters[i];
- if (center->GetCount() >= CENTER_QUORUM) {
- if (firstConfirmedCenter) {
- m_hasSkipped = TRUE;
- return (int32_t)((fabs(firstConfirmedCenter->GetX() - center->GetX()) -
- fabs(firstConfirmedCenter->GetY() - center->GetY())) /
- 2);
- }
- firstConfirmedCenter = center;
- }
- }
- return 0;
-}
-FX_BOOL CBC_QRFinderPatternFinder::HaveMultiplyConfirmedCenters() {
- int32_t confirmedCount = 0;
- FX_FLOAT totalModuleSize = 0.0f;
- int32_t max = m_possibleCenters.GetSize();
- int32_t i;
- for (i = 0; i < max; i++) {
- CBC_QRFinderPattern* pattern = m_possibleCenters[i];
- if (pattern->GetCount() >= CENTER_QUORUM) {
- confirmedCount++;
- totalModuleSize += pattern->GetEstimatedModuleSize();
- }
- }
- if (confirmedCount < 3) {
- return FALSE;
- }
- FX_FLOAT average = totalModuleSize / (FX_FLOAT)max;
- FX_FLOAT totalDeviation = 0.0f;
- for (i = 0; i < max; i++) {
- CBC_QRFinderPattern* pattern = m_possibleCenters[i];
- totalDeviation += fabs(pattern->GetEstimatedModuleSize() - average);
- }
- return totalDeviation <= 0.05f * totalModuleSize;
-}
-
-CFX_ArrayTemplate<CBC_QRFinderPattern*>*
-CBC_QRFinderPatternFinder::SelectBestpatterns(int32_t& e) {
- int32_t startSize = m_possibleCenters.GetSize();
- if (m_possibleCenters.GetSize() < 3) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- }
- FX_FLOAT average = 0.0f;
- if (startSize > 3) {
- FX_FLOAT totalModuleSize = 0.0f;
- for (int32_t i = 0; i < startSize; i++)
- totalModuleSize += m_possibleCenters[i]->GetEstimatedModuleSize();
-
- average = totalModuleSize / (FX_FLOAT)startSize;
- for (int32_t j = 0;
- j < m_possibleCenters.GetSize() && m_possibleCenters.GetSize() > 3;
- j++) {
- CBC_QRFinderPattern* pattern = m_possibleCenters[j];
- if (fabs(pattern->GetEstimatedModuleSize() - average) > 0.2f * average) {
- delete pattern;
- m_possibleCenters.RemoveAt(j);
- j--;
- }
- }
- }
- if (m_possibleCenters.GetSize() > 3) {
- std::sort(m_possibleCenters.GetData(),
- m_possibleCenters.GetData() + m_possibleCenters.GetSize(),
- [](const CBC_QRFinderPattern* a, CBC_QRFinderPattern* b) {
- return a->GetCount() > b->GetCount(); // e.g. Descending.
- });
- }
- CFX_ArrayTemplate<CBC_QRFinderPattern*>* vec =
- new CFX_ArrayTemplate<CBC_QRFinderPattern*>();
- vec->SetSize(3);
- (*vec)[0] = m_possibleCenters[0]->Clone();
- (*vec)[1] = m_possibleCenters[1]->Clone();
- (*vec)[2] = m_possibleCenters[2]->Clone();
- return vec;
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h b/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h
deleted file mode 100644
index 60ec184fe4..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRFinderPatternFinder.h
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_CommonBitMatrix;
-class CBC_QRFinderPattern;
-class CBC_ResultPoint;
-class CBC_QRFinderPatternInfo;
-
-class CBC_QRFinderPatternFinder {
- public:
- CBC_QRFinderPatternFinder(CBC_CommonBitMatrix* image);
- virtual ~CBC_QRFinderPatternFinder();
- int32_t FindRowSkip();
- CBC_CommonBitMatrix* GetImage();
- CBC_QRFinderPatternInfo* Find(int32_t hint, int32_t& e);
-
- CFX_Int32Array& GetCrossCheckStateCount();
- CFX_ArrayTemplate<CBC_QRFinderPattern*>* GetPossibleCenters();
- CFX_ArrayTemplate<CBC_QRFinderPattern*>* SelectBestpatterns(int32_t& e);
-
- FX_BOOL HandlePossibleCenter(const CFX_Int32Array& stateCount,
- int32_t i,
- int32_t j);
- FX_BOOL HaveMultiplyConfirmedCenters();
- FX_FLOAT CenterFromEnd(const CFX_Int32Array& stateCount, int32_t end);
- FX_FLOAT CrossCheckVertical(int32_t startI,
- int32_t centerJ,
- int32_t maxCount,
- int32_t originalStateCountTotal);
- FX_FLOAT CrossCheckHorizontal(int32_t startJ,
- int32_t CenterI,
- int32_t maxCOunt,
- int32_t originalStateCountTotal);
- static void OrderBestPatterns(
- CFX_ArrayTemplate<CBC_QRFinderPattern*>* patterns);
- static FX_BOOL FoundPatternCross(const CFX_Int32Array& stateCount);
- static FX_FLOAT Distance(CBC_ResultPoint* point1, CBC_ResultPoint* point2);
-
- private:
- static const int32_t CENTER_QUORUM;
- static const int32_t MIN_SKIP;
- static const int32_t MAX_MODULES;
- static const int32_t INTEGER_MATH_SHIFT;
-
- FX_BOOL m_hasSkipped;
- CBC_CommonBitMatrix* m_image;
- CFX_Int32Array m_crossCheckStateCount;
- CFX_ArrayTemplate<CBC_QRFinderPattern*> m_possibleCenters;
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp b/xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp
deleted file mode 100644
index be7407ceff..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRGridSampler.cpp
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/fxbarcode/qrcode/BC_QRGridSampler.h"
-
-#include <memory>
-
-#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/fxbarcode/common/BC_CommonPerspectiveTransform.h"
-#include "xfa/fxbarcode/utils.h"
-
-CBC_QRGridSampler CBC_QRGridSampler::m_gridSampler;
-
-CBC_QRGridSampler::CBC_QRGridSampler() {}
-CBC_QRGridSampler::~CBC_QRGridSampler() {}
-CBC_QRGridSampler& CBC_QRGridSampler::GetInstance() {
- return m_gridSampler;
-}
-void CBC_QRGridSampler::CheckAndNudgePoints(CBC_CommonBitMatrix* image,
- CFX_FloatArray* points,
- int32_t& e) {
- int32_t width = image->GetWidth();
- int32_t height = image->GetHeight();
- FX_BOOL nudged = TRUE;
- int32_t offset;
- for (offset = 0; offset < points->GetSize() && nudged; offset += 2) {
- int32_t x = (int32_t)(*points)[offset];
- int32_t y = (int32_t)(*points)[offset + 1];
- if (x < -1 || x > width || y < -1 || y > height) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- nudged = FALSE;
- if (x == -1) {
- (*points)[offset] = 0.0f;
- nudged = TRUE;
- } else if (x == width) {
- (*points)[offset] = (FX_FLOAT)(width - 1);
- nudged = TRUE;
- }
- if (y == -1) {
- (*points)[offset + 1] = 0.0f;
- nudged = TRUE;
- } else if (y == height) {
- (*points)[offset + 1] = (FX_FLOAT)(height - 1);
- nudged = TRUE;
- }
- }
- nudged = TRUE;
- for (offset = (*points).GetSize() - 2; offset >= 0 && nudged; offset -= 2) {
- int32_t x = (int32_t)(*points)[offset];
- int32_t y = (int32_t)(*points)[offset + 1];
- if (x < -1 || x > width || y < -1 || y > height) {
- e = BCExceptionRead;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- nudged = FALSE;
- if (x == -1) {
- (*points)[offset] = 0.0f;
- nudged = TRUE;
- } else if (x == width) {
- (*points)[offset] = (FX_FLOAT)(width - 1);
- nudged = TRUE;
- }
- if (y == -1) {
- (*points)[offset + 1] = 0.0f;
- nudged = TRUE;
- } else if (y == height) {
- (*points)[offset + 1] = (FX_FLOAT)(height - 1);
- nudged = TRUE;
- }
- }
-}
-CBC_CommonBitMatrix* CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix* image,
- int32_t dimensionX,
- int32_t dimensionY,
- FX_FLOAT p1ToX,
- FX_FLOAT p1ToY,
- FX_FLOAT p2ToX,
- FX_FLOAT p2ToY,
- FX_FLOAT p3ToX,
- FX_FLOAT p3ToY,
- FX_FLOAT p4ToX,
- FX_FLOAT p4ToY,
- FX_FLOAT p1FromX,
- FX_FLOAT p1FromY,
- FX_FLOAT p2FromX,
- FX_FLOAT p2FromY,
- FX_FLOAT p3FromX,
- FX_FLOAT p3FromY,
- FX_FLOAT p4FromX,
- FX_FLOAT p4FromY,
- int32_t& e) {
- std::unique_ptr<CBC_CommonPerspectiveTransform> transform(
- CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(
- p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX,
- p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY));
- std::unique_ptr<CBC_CommonBitMatrix> bits(new CBC_CommonBitMatrix());
- bits->Init(dimensionX, dimensionY);
- CFX_FloatArray points;
- points.SetSize(dimensionX << 1);
- for (int32_t y = 0; y < dimensionY; y++) {
- int32_t max = points.GetSize();
- FX_FLOAT iValue = (FX_FLOAT)(y + 0.5f);
- int32_t x;
- for (x = 0; x < max; x += 2) {
- points[x] = (FX_FLOAT)((x >> 1) + 0.5f);
- points[x + 1] = iValue;
- }
- transform->TransformPoints(&points);
- CheckAndNudgePoints(image, &points, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
- for (x = 0; x < max; x += 2) {
- if (image->Get((int32_t)points[x], (int32_t)points[x + 1])) {
- bits->Set(x >> 1, y);
- }
- }
- }
- return bits.release();
-}
diff --git a/xfa/fxbarcode/qrcode/BC_QRGridSampler.h b/xfa/fxbarcode/qrcode/BC_QRGridSampler.h
deleted file mode 100644
index 70bfb9e085..0000000000
--- a/xfa/fxbarcode/qrcode/BC_QRGridSampler.h
+++ /dev/null
@@ -1,48 +0,0 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef XFA_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_
-#define XFA_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_
-
-#include "core/fxcrt/include/fx_basic.h"
-
-class CBC_CommonBitMatrix;
-
-class CBC_QRGridSampler {
- private:
- static CBC_QRGridSampler m_gridSampler;
-
- public:
- CBC_QRGridSampler();
- virtual ~CBC_QRGridSampler();
- virtual CBC_CommonBitMatrix* SampleGrid(CBC_CommonBitMatrix* image,
- int32_t dimensionX,
- int32_t dimensionY,
- FX_FLOAT p1ToX,
- FX_FLOAT p1ToY,
- FX_FLOAT p2ToX,
- FX_FLOAT p2ToY,
- FX_FLOAT p3ToX,
- FX_FLOAT p3ToY,
- FX_FLOAT p4ToX,
- FX_FLOAT p4ToY,
- FX_FLOAT p1FromX,
- FX_FLOAT p1FromY,
- FX_FLOAT p2FromX,
- FX_FLOAT p2FromY,
- FX_FLOAT p3FromX,
- FX_FLOAT p3FromY,
- FX_FLOAT p4FromX,
- FX_FLOAT p4FromY,
- int32_t& e);
-
- static CBC_QRGridSampler& GetInstance();
- static void CheckAndNudgePoints(CBC_CommonBitMatrix* image,
- CFX_FloatArray* points,
- int32_t& e);
-};
-
-#endif // XFA_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_