summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-06-16 12:29:07 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-16 12:29:07 -0700
commita26153440b46b3b37b7e81435debb296f22769f4 (patch)
tree37b3073d15af7ae2850b5a02be87123feb54a054 /xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
parent8320ee28f24615d1d619a5db1b7c235ea6f91dde (diff)
downloadpdfium-a26153440b46b3b37b7e81435debb296f22769f4.tar.xz
Remove barcode reading code.
We never read barcodes, we only write them. Remove code related to barcode reading. Review-Url: https://codereview.chromium.org/2071633002
Diffstat (limited to 'xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp')
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp23
1 files changed, 20 insertions, 3 deletions
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;