diff options
author | Lei Zhang <thestig@chromium.org> | 2017-04-04 16:15:13 -0700 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-04-04 23:35:59 +0000 |
commit | b2a40475ade2fe34a406472e53787bdac5a6950a (patch) | |
tree | 70676e292db220552549a427a662a9c88241ff1a /fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp | |
parent | 20a909e655147e21f966b95af6b683d85736c8c2 (diff) | |
download | pdfium-b2a40475ade2fe34a406472e53787bdac5a6950a.tar.xz |
Clean up QRCoderBitVector.
Use std::vector and return booleans results when possible.
Change-Id: If3ce4559f137fb449fd1ab818750558a1b5f8df0
Reviewed-on: https://pdfium-review.googlesource.com/3561
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp')
-rw-r--r-- | fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp | 42 |
1 files changed, 15 insertions, 27 deletions
diff --git a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp index b6ffaa00fc..b0be2b6f2a 100644 --- a/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp +++ b/fxbarcode/qrcode/BC_QRCoderMatrixUtil.cpp @@ -130,6 +130,7 @@ void CBC_QRCoderMatrixUtil::EmbedBasicPatterns(int32_t version, if (e != BCExceptionNO) return; } + void CBC_QRCoderMatrixUtil::EmbedTypeInfo( CBC_QRCoderErrorCorrectionLevel* ecLevel, int32_t maskPattern, @@ -140,11 +141,11 @@ void CBC_QRCoderMatrixUtil::EmbedTypeInfo( return; } CBC_QRCoderBitVector typeInfoBits; - typeInfoBits.Init(); MakeTypeInfoBits(ecLevel, maskPattern, &typeInfoBits, e); if (e != BCExceptionNO) return; - for (int32_t i = 0; i < typeInfoBits.Size(); i++) { + + for (size_t i = 0; i < typeInfoBits.Size(); i++) { int32_t bit = typeInfoBits.At(typeInfoBits.Size() - 1 - i, e); if (e != BCExceptionNO) return; @@ -162,6 +163,7 @@ void CBC_QRCoderMatrixUtil::EmbedTypeInfo( } } } + void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version, CBC_CommonByteMatrix* matrix, int32_t& e) { @@ -173,7 +175,6 @@ void CBC_QRCoderMatrixUtil::MaybeEmbedVersionInfo(int32_t version, return; } CBC_QRCoderBitVector versionInfoBits; - versionInfoBits.Init(); MakeVersionInfoBits(version, &versionInfoBits, e); if (e != BCExceptionNO) return; @@ -197,7 +198,7 @@ void CBC_QRCoderMatrixUtil::EmbedDataBits(CBC_QRCoderBitVector* dataBits, e = BCExceptionNullPointer; return; } - int32_t bitIndex = 0; + size_t bitIndex = 0; int32_t direction = -1; int32_t x = matrix->GetWidth() - 1; int32_t y = matrix->GetHeight() - 1; @@ -266,23 +267,16 @@ void CBC_QRCoderMatrixUtil::MakeTypeInfoBits( return; } int32_t typeInfo = (ecLevel->GetBits() << 3) | maskPattern; - if (e != BCExceptionNO) - return; - bits->AppendBits(typeInfo, 5, e); + bits->AppendBits(typeInfo, 5); int32_t bchCode = CalculateBCHCode(typeInfo, TYPE_INFO_POLY); - if (e != BCExceptionNO) - return; - bits->AppendBits(bchCode, 10, e); + bits->AppendBits(bchCode, 10); CBC_QRCoderBitVector maskBits; - maskBits.Init(); - maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15, e); - if (e != BCExceptionNO) + maskBits.AppendBits(TYPE_INFO_MASK_PATTERN, 15); + if (!bits->XOR(&maskBits)) { + e = BCExceptionGeneric; return; - bits->XOR(&maskBits, e); - if (e != BCExceptionNO) - return; - if (bits->Size() != 15) - e = BCExceptionBitSizeNot15; + } + ASSERT(bits->Size() == 15); } void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version, @@ -292,17 +286,11 @@ void CBC_QRCoderMatrixUtil::MakeVersionInfoBits(int32_t version, e = BCExceptionNullPointer; return; } - bits->AppendBits(version, 6, e); - if (e != BCExceptionNO) - return; + bits->AppendBits(version, 6); int32_t bchCode = CalculateBCHCode(version, VERSION_INFO_POLY); - bits->AppendBits(bchCode, 12, e); - if (e != BCExceptionNO) - return; - - if (bits->Size() != 18) - e = BCExceptionBitSizeNot18; + bits->AppendBits(bchCode, 12); + ASSERT(bits->Size() == 18); } bool CBC_QRCoderMatrixUtil::IsEmpty(int32_t value) { |