Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: xfa/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp

Issue 2027273002: Fix all the code which has duplicate variable declarations (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: rebase Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 // Original code is licensed as follows: 6 // Original code is licensed as follows:
7 /* 7 /*
8 * Copyright 2007 ZXing authors 8 * Copyright 2007 ZXing authors
9 * 9 *
10 * Licensed under the Apache License, Version 2.0 (the "License"); 10 * Licensed under the Apache License, Version 2.0 (the "License");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 parser.Init(bits, e); 50 parser.Init(bits, e);
51 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 51 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
52 CBC_DataMatrixVersion* version = parser.GetVersion(); 52 CBC_DataMatrixVersion* version = parser.GetVersion();
53 std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e)); 53 std::unique_ptr<CFX_ByteArray> codewords(parser.ReadCodewords(e));
54 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 54 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
55 CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* dataBlocks = 55 CFX_ArrayTemplate<CBC_DataMatrixDataBlock*>* dataBlocks =
56 CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); 56 CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e);
57 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 57 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
58 int32_t dataBlocksCount = dataBlocks->GetSize(); 58 int32_t dataBlocksCount = dataBlocks->GetSize();
59 int32_t totalBytes = 0; 59 int32_t totalBytes = 0;
60 int32_t i, j; 60 for (int32_t i = 0; i < dataBlocksCount; i++) {
61 for (i = 0; i < dataBlocksCount; i++) {
62 totalBytes += (*dataBlocks)[i]->GetNumDataCodewords(); 61 totalBytes += (*dataBlocks)[i]->GetNumDataCodewords();
63 } 62 }
64 CFX_ByteArray resultBytes; 63 CFX_ByteArray resultBytes;
65 resultBytes.SetSize(totalBytes); 64 resultBytes.SetSize(totalBytes);
66 for (j = 0; j < dataBlocksCount; j++) { 65 for (int32_t j = 0; j < dataBlocksCount; j++) {
67 CFX_ByteArray* codewordBytes = (*dataBlocks)[j]->GetCodewords(); 66 CFX_ByteArray* codewordBytes = (*dataBlocks)[j]->GetCodewords();
68 int32_t numDataCodewords = (*dataBlocks)[j]->GetNumDataCodewords(); 67 int32_t numDataCodewords = (*dataBlocks)[j]->GetNumDataCodewords();
69 CorrectErrors(*codewordBytes, numDataCodewords, e); 68 CorrectErrors(*codewordBytes, numDataCodewords, e);
70 if (e != BCExceptionNO) { 69 if (e != BCExceptionNO) {
71 for (int32_t i = 0; i < dataBlocks->GetSize(); i++) { 70 for (int32_t i = 0; i < dataBlocks->GetSize(); i++) {
72 delete (*dataBlocks)[i]; 71 delete (*dataBlocks)[i];
73 } 72 }
74 delete dataBlocks; 73 delete dataBlocks;
75 return nullptr; 74 return nullptr;
76 } 75 }
77 int32_t i; 76 for (int32_t i = 0; i < numDataCodewords; i++) {
78 for (i = 0; i < numDataCodewords; i++) {
79 resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i]; 77 resultBytes[i * dataBlocksCount + j] = (*codewordBytes)[i];
80 } 78 }
81 } 79 }
82 for (i = 0; i < (dataBlocks->GetSize()); i++) { 80 for (int32_t i = 0; i < (dataBlocks->GetSize()); i++) {
83 delete (*dataBlocks)[i]; 81 delete (*dataBlocks)[i];
84 } 82 }
85 delete dataBlocks; 83 delete dataBlocks;
86 CBC_CommonDecoderResult* resultR = 84 CBC_CommonDecoderResult* resultR =
87 CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e); 85 CBC_DataMatrixDecodedBitStreamParser::Decode(resultBytes, e);
88 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); 86 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
89 return resultR; 87 return resultR;
90 } 88 }
91 89
92 void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes, 90 void CBC_DataMatrixDecoder::CorrectErrors(CFX_ByteArray& codewordBytes,
93 int32_t numDataCodewords, 91 int32_t numDataCodewords,
94 int32_t& e) { 92 int32_t& e) {
95 int32_t numCodewords = codewordBytes.GetSize(); 93 int32_t numCodewords = codewordBytes.GetSize();
96 CFX_Int32Array codewordsInts; 94 CFX_Int32Array codewordsInts;
97 codewordsInts.SetSize(numCodewords); 95 codewordsInts.SetSize(numCodewords);
98 int32_t i; 96 int32_t i;
99 for (i = 0; i < numCodewords; i++) { 97 for (i = 0; i < numCodewords; i++) {
100 codewordsInts[i] = codewordBytes[i] & 0xFF; 98 codewordsInts[i] = codewordBytes[i] & 0xFF;
101 } 99 }
102 int32_t numECCodewords = codewordBytes.GetSize() - numDataCodewords; 100 int32_t numECCodewords = codewordBytes.GetSize() - numDataCodewords;
103 m_rsDecoder->Decode(&codewordsInts, numECCodewords, e); 101 m_rsDecoder->Decode(&codewordsInts, numECCodewords, e);
104 if (e != BCExceptionNO) { 102 if (e != BCExceptionNO) {
105 e = BCExceptionChecksumException; 103 e = BCExceptionChecksumException;
106 return; 104 return;
107 } 105 }
108 for (i = 0; i < numDataCodewords; i++) { 106 for (i = 0; i < numDataCodewords; i++) {
109 codewordBytes[i] = (uint8_t)codewordsInts[i]; 107 codewordBytes[i] = (uint8_t)codewordsInts[i];
110 } 108 }
111 } 109 }
OLDNEW
« no previous file with comments | « xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp ('k') | xfa/fxbarcode/oned/BC_OneDimWriter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698