OLD | NEW |
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 2008 ZXing authors | 8 * Copyright 2008 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"); |
11 * you may not use this file except in compliance with the License. | 11 * you may not use this file except in compliance with the License. |
12 * You may obtain a copy of the License at | 12 * You may obtain a copy of the License at |
13 * | 13 * |
14 * http://www.apache.org/licenses/LICENSE-2.0 | 14 * http://www.apache.org/licenses/LICENSE-2.0 |
15 * | 15 * |
16 * Unless required by applicable law or agreed to in writing, software | 16 * Unless required by applicable law or agreed to in writing, software |
17 * distributed under the License is distributed on an "AS IS" BASIS, | 17 * distributed under the License is distributed on an "AS IS" BASIS, |
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
19 * See the License for the specific language governing permissions and | 19 * See the License for the specific language governing permissions and |
20 * limitations under the License. | 20 * limitations under the License. |
21 */ | 21 */ |
22 | 22 |
| 23 #include <algorithm> |
| 24 |
23 #include "xfa/src/fxbarcode/barcode.h" | 25 #include "xfa/src/fxbarcode/barcode.h" |
24 #include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" | 26 #include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" |
25 #include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" | 27 #include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" |
26 #include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" | 28 #include "xfa/src/fxbarcode/common/BC_CommonByteMatrix.h" |
27 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" | 29 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" |
28 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" | 30 #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" |
29 #include "BC_QRCoder.h" | 31 #include "BC_QRCoder.h" |
30 #include "BC_QRCoderEncoder.h" | 32 #include "BC_QRCoderEncoder.h" |
31 #include "BC_QRCoderMode.h" | 33 #include "BC_QRCoderMode.h" |
32 #include "BC_QRCoderEncoder.h" | 34 #include "BC_QRCoderEncoder.h" |
(...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 int32_t numEcBytesInBlosk; | 871 int32_t numEcBytesInBlosk; |
870 GetNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, | 872 GetNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, |
871 numRSBlocks, i, numDataBytesInBlock, | 873 numRSBlocks, i, numDataBytesInBlock, |
872 numEcBytesInBlosk); | 874 numEcBytesInBlosk); |
873 CBC_CommonByteArray* dataBytes = new CBC_CommonByteArray; | 875 CBC_CommonByteArray* dataBytes = new CBC_CommonByteArray; |
874 dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock); | 876 dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock); |
875 CBC_CommonByteArray* ecBytes = | 877 CBC_CommonByteArray* ecBytes = |
876 GenerateECBytes(dataBytes, numEcBytesInBlosk, e); | 878 GenerateECBytes(dataBytes, numEcBytesInBlosk, e); |
877 BC_EXCEPTION_CHECK_ReturnVoid(e); | 879 BC_EXCEPTION_CHECK_ReturnVoid(e); |
878 blocks.Add(new CBC_QRCoderBlockPair(dataBytes, ecBytes)); | 880 blocks.Add(new CBC_QRCoderBlockPair(dataBytes, ecBytes)); |
879 maxNumDataBytes = FX_MAX(maxNumDataBytes, dataBytes->Size()); | 881 maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size()); |
880 maxNumEcBytes = FX_MAX(maxNumEcBytes, ecBytes->Size()); | 882 maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size()); |
881 dataBytesOffset += numDataBytesInBlock; | 883 dataBytesOffset += numDataBytesInBlock; |
882 } | 884 } |
883 if (numDataBytes != dataBytesOffset) { | 885 if (numDataBytes != dataBytesOffset) { |
884 e = BCExceptionBytesNotMatchOffset; | 886 e = BCExceptionBytesNotMatchOffset; |
885 BC_EXCEPTION_CHECK_ReturnVoid(e); | 887 BC_EXCEPTION_CHECK_ReturnVoid(e); |
886 } | 888 } |
887 for (int32_t x = 0; x < maxNumDataBytes; x++) { | 889 for (int32_t x = 0; x < maxNumDataBytes; x++) { |
888 for (int32_t j = 0; j < blocks.GetSize(); j++) { | 890 for (int32_t j = 0; j < blocks.GetSize(); j++) { |
889 CBC_CommonByteArray* dataBytes = | 891 CBC_CommonByteArray* dataBytes = |
890 ((CBC_QRCoderBlockPair*)blocks[j])->GetDataBytes(); | 892 ((CBC_QRCoderBlockPair*)blocks[j])->GetDataBytes(); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
951 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); | 953 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeFild); |
952 encode.Init(); | 954 encode.Init(); |
953 encode.Encode(&toEncode, numEcBytesInBlock, e); | 955 encode.Encode(&toEncode, numEcBytesInBlock, e); |
954 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 956 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
955 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); | 957 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); |
956 for (int32_t j = 0; j < numEcBytesInBlock; j++) { | 958 for (int32_t j = 0; j < numEcBytesInBlock; j++) { |
957 ecBytes->Set(j, toEncode[numDataBytes + j]); | 959 ecBytes->Set(j, toEncode[numDataBytes + j]); |
958 } | 960 } |
959 return ecBytes; | 961 return ecBytes; |
960 } | 962 } |
OLD | NEW |