summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
commit9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch)
treec97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
parent780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff)
downloadpdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz
XFA: clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \ xargs ../../buildtools/mac/clang-format -i Then manually merged https://codereview.chromium.org/1269223002/ See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none
Diffstat (limited to 'xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp')
-rw-r--r--xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp145
1 files changed, 75 insertions, 70 deletions
diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
index 8dfdea81c1..d0fe37f167 100644
--- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
+++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp
@@ -29,82 +29,87 @@
#include "BC_DataMatrixVersion.h"
#include "BC_DataMatrixDataBlock.h"
#include "BC_DataMatrixDecodedBitStreamParser.h"
-CBC_DataMatrixDecoder::CBC_DataMatrixDecoder()
-{
- m_rsDecoder = NULL;
+CBC_DataMatrixDecoder::CBC_DataMatrixDecoder() {
+ m_rsDecoder = NULL;
}
-void CBC_DataMatrixDecoder::Init()
-{
- m_rsDecoder = FX_NEW CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256::DataMatrixField);
+void CBC_DataMatrixDecoder::Init() {
+ m_rsDecoder =
+ FX_NEW CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256::DataMatrixField);
}
-CBC_DataMatrixDecoder::~CBC_DataMatrixDecoder()
-{
- if(m_rsDecoder != NULL) {
- delete m_rsDecoder;
- }
- m_rsDecoder = NULL;
+CBC_DataMatrixDecoder::~CBC_DataMatrixDecoder() {
+ if (m_rsDecoder != NULL) {
+ delete m_rsDecoder;
+ }
+ m_rsDecoder = NULL;
}
-CBC_CommonDecoderResult *CBC_DataMatrixDecoder::Decode(CBC_CommonBitMatrix *bits, int32_t &e)
-{
- CBC_DataMatrixBitMatrixParser parser;
- parser.Init(bits, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_DataMatrixVersion *version = parser.GetVersion();
- CFX_ByteArray* byteTemp = parser.ReadCodewords(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CFX_ByteArray> codewords(byteTemp);
- CFX_PtrArray *dataBlocks = CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- int32_t dataBlocksCount = dataBlocks->GetSize();
- int32_t totalBytes = 0;
- int32_t i, j;
- for (i = 0; i < dataBlocksCount; i++) {
- totalBytes += ((CBC_DataMatrixDataBlock*)(*dataBlocks)[i])->GetNumDataCodewords();
- }
- CFX_ByteArray resultBytes;
- resultBytes.SetSize(totalBytes);
- for (j = 0; j < dataBlocksCount; j++) {
- CFX_ByteArray *codewordBytes = ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetCodewords();
- int32_t numDataCodewords = ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetNumDataCodewords();
- CorrectErrors(*codewordBytes, numDataCodewords, e);
- if (e != BCExceptionNO) {
- for(int32_t i = 0; i < dataBlocks->GetSize(); i++) {
- delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i];
- }
- delete dataBlocks;
- dataBlocks = NULL;
- return NULL;
- }
- int32_t i;
- for (i = 0; i < numDataCodewords; i++) {
- resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i];
- }
- }
- for(i = 0; i < (dataBlocks->GetSize()); i++) {
+CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode(
+ CBC_CommonBitMatrix* bits,
+ int32_t& e) {
+ CBC_DataMatrixBitMatrixParser parser;
+ parser.Init(bits, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_DataMatrixVersion* version = parser.GetVersion();
+ CFX_ByteArray* byteTemp = parser.ReadCodewords(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CFX_ByteArray> codewords(byteTemp);
+ CFX_PtrArray* dataBlocks =
+ CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ int32_t dataBlocksCount = dataBlocks->GetSize();
+ int32_t totalBytes = 0;
+ int32_t i, j;
+ for (i = 0; i < dataBlocksCount; i++) {
+ totalBytes +=
+ ((CBC_DataMatrixDataBlock*)(*dataBlocks)[i])->GetNumDataCodewords();
+ }
+ CFX_ByteArray resultBytes;
+ resultBytes.SetSize(totalBytes);
+ for (j = 0; j < dataBlocksCount; j++) {
+ CFX_ByteArray* codewordBytes =
+ ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetCodewords();
+ int32_t numDataCodewords =
+ ((CBC_DataMatrixDataBlock*)(*dataBlocks)[j])->GetNumDataCodewords();
+ CorrectErrors(*codewordBytes, numDataCodewords, e);
+ if (e != BCExceptionNO) {
+ for (int32_t i = 0; i < dataBlocks->GetSize(); i++) {
delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i];
+ }
+ delete dataBlocks;
+ dataBlocks = NULL;
+ return NULL;
}
- delete dataBlocks;
- dataBlocks = NULL;
- CBC_CommonDecoderResult *resultR = CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return resultR;
-}
-void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray &codewordBytes, int32_t numDataCodewords, int32_t &e)
-{
- int32_t numCodewords = codewordBytes.GetSize();
- CFX_Int32Array codewordsInts;
- codewordsInts.SetSize(numCodewords);
int32_t i;
- for (i = 0; i < numCodewords; i++) {
- codewordsInts[i] = codewordBytes[i] & 0xFF;
- }
- int32_t numECCodewords = codewordBytes.GetSize() - numDataCodewords;
- m_rsDecoder->Decode(&codewordsInts, numECCodewords, e);
- if (e != BCExceptionNO) {
- e = BCExceptionChecksumException;
- return ;
- }
for (i = 0; i < numDataCodewords; i++) {
- codewordBytes[i] = (uint8_t) codewordsInts[i];
+ resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i];
}
+ }
+ for (i = 0; i < (dataBlocks->GetSize()); i++) {
+ delete (CBC_DataMatrixDataBlock*)(*dataBlocks)[i];
+ }
+ delete dataBlocks;
+ dataBlocks = NULL;
+ CBC_CommonDecoderResult* resultR =
+ CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return resultR;
+}
+void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes,
+ int32_t numDataCodewords,
+ int32_t& e) {
+ int32_t numCodewords = codewordBytes.GetSize();
+ CFX_Int32Array codewordsInts;
+ codewordsInts.SetSize(numCodewords);
+ int32_t i;
+ for (i = 0; i < numCodewords; i++) {
+ codewordsInts[i] = codewordBytes[i] & 0xFF;
+ }
+ int32_t numECCodewords = codewordBytes.GetSize() - numDataCodewords;
+ m_rsDecoder->Decode(&codewordsInts, numECCodewords, e);
+ if (e != BCExceptionNO) {
+ e = BCExceptionChecksumException;
+ return;
+ }
+ for (i = 0; i < numDataCodewords; i++) {
+ codewordBytes[i] = (uint8_t)codewordsInts[i];
+ }
}