| 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"); |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 int32_t numDataBytesInBlock; | 878 int32_t numDataBytesInBlock; |
| 879 int32_t numEcBytesInBlosk; | 879 int32_t numEcBytesInBlosk; |
| 880 GetNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, | 880 GetNumDataBytesAndNumECBytesForBlockID(numTotalBytes, numDataBytes, |
| 881 numRSBlocks, i, numDataBytesInBlock, | 881 numRSBlocks, i, numDataBytesInBlock, |
| 882 numEcBytesInBlosk); | 882 numEcBytesInBlosk); |
| 883 std::unique_ptr<CBC_CommonByteArray> dataBytes(new CBC_CommonByteArray); | 883 std::unique_ptr<CBC_CommonByteArray> dataBytes(new CBC_CommonByteArray); |
| 884 dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock); | 884 dataBytes->Set(bits->GetArray(), dataBytesOffset, numDataBytesInBlock); |
| 885 std::unique_ptr<CBC_CommonByteArray> ecBytes( | 885 std::unique_ptr<CBC_CommonByteArray> ecBytes( |
| 886 GenerateECBytes(dataBytes.get(), numEcBytesInBlosk, e)); | 886 GenerateECBytes(dataBytes.get(), numEcBytesInBlosk, e)); |
| 887 BC_EXCEPTION_CHECK_ReturnVoid(e); | 887 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 888 maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size()); |
| 889 maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size()); |
| 888 blocks.Add( | 890 blocks.Add( |
| 889 new CBC_QRCoderBlockPair(std::move(dataBytes), std::move(ecBytes))); | 891 new CBC_QRCoderBlockPair(std::move(dataBytes), std::move(ecBytes))); |
| 890 maxNumDataBytes = std::max(maxNumDataBytes, dataBytes->Size()); | |
| 891 maxNumEcBytes = std::max(maxNumEcBytes, ecBytes->Size()); | |
| 892 dataBytesOffset += numDataBytesInBlock; | 892 dataBytesOffset += numDataBytesInBlock; |
| 893 } | 893 } |
| 894 if (numDataBytes != dataBytesOffset) { | 894 if (numDataBytes != dataBytesOffset) { |
| 895 e = BCExceptionBytesNotMatchOffset; | 895 e = BCExceptionBytesNotMatchOffset; |
| 896 BC_EXCEPTION_CHECK_ReturnVoid(e); | 896 BC_EXCEPTION_CHECK_ReturnVoid(e); |
| 897 } | 897 } |
| 898 for (int32_t x = 0; x < maxNumDataBytes; x++) { | 898 for (int32_t x = 0; x < maxNumDataBytes; x++) { |
| 899 for (int32_t j = 0; j < blocks.GetSize(); j++) { | 899 for (int32_t j = 0; j < blocks.GetSize(); j++) { |
| 900 const CBC_CommonByteArray* dataBytes = blocks[j]->GetDataBytes(); | 900 const CBC_CommonByteArray* dataBytes = blocks[j]->GetDataBytes(); |
| 901 if (x < dataBytes->Size()) { | 901 if (x < dataBytes->Size()) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField); | 962 CBC_ReedSolomonEncoder encode(CBC_ReedSolomonGF256::QRCodeField); |
| 963 encode.Init(); | 963 encode.Init(); |
| 964 encode.Encode(&toEncode, numEcBytesInBlock, e); | 964 encode.Encode(&toEncode, numEcBytesInBlock, e); |
| 965 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); | 965 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 966 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); | 966 CBC_CommonByteArray* ecBytes = new CBC_CommonByteArray(numEcBytesInBlock); |
| 967 for (int32_t j = 0; j < numEcBytesInBlock; j++) { | 967 for (int32_t j = 0; j < numEcBytesInBlock; j++) { |
| 968 ecBytes->Set(j, toEncode[numDataBytes + j]); | 968 ecBytes->Set(j, toEncode[numDataBytes + j]); |
| 969 } | 969 } |
| 970 return ecBytes; | 970 return ecBytes; |
| 971 } | 971 } |
| OLD | NEW |