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 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"); |
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 "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" | 23 #include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" |
24 #include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" | 24 #include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" |
25 | 25 |
26 CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeFild = NULL; | 26 CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeFild = nullptr; |
27 CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = NULL; | 27 CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = nullptr; |
28 void CBC_ReedSolomonGF256::Initialize() { | 28 void CBC_ReedSolomonGF256::Initialize() { |
29 QRCodeFild = new CBC_ReedSolomonGF256(0x011D); | 29 QRCodeFild = new CBC_ReedSolomonGF256(0x011D); |
30 QRCodeFild->Init(); | 30 QRCodeFild->Init(); |
31 DataMatrixField = new CBC_ReedSolomonGF256(0x012D); | 31 DataMatrixField = new CBC_ReedSolomonGF256(0x012D); |
32 DataMatrixField->Init(); | 32 DataMatrixField->Init(); |
33 } | 33 } |
34 | 34 |
35 void CBC_ReedSolomonGF256::Finalize() { | 35 void CBC_ReedSolomonGF256::Finalize() { |
36 delete QRCodeFild; | 36 delete QRCodeFild; |
37 QRCodeFild = nullptr; | 37 QRCodeFild = nullptr; |
(...skipping 28 matching lines...) Loading... |
66 } | 66 } |
67 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() { | 67 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() { |
68 return m_one; | 68 return m_one; |
69 } | 69 } |
70 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial( | 70 CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial( |
71 int32_t degree, | 71 int32_t degree, |
72 int32_t coefficient, | 72 int32_t coefficient, |
73 int32_t& e) { | 73 int32_t& e) { |
74 if (degree < 0) { | 74 if (degree < 0) { |
75 e = BCExceptionDegreeIsNegative; | 75 e = BCExceptionDegreeIsNegative; |
76 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 76 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
77 } | 77 } |
78 if (coefficient == 0) { | 78 if (coefficient == 0) { |
79 CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); | 79 CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); |
80 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 80 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
81 return temp; | 81 return temp; |
82 } | 82 } |
83 CFX_Int32Array coefficients; | 83 CFX_Int32Array coefficients; |
84 coefficients.SetSize(degree + 1); | 84 coefficients.SetSize(degree + 1); |
85 coefficients[0] = coefficient; | 85 coefficients[0] = coefficient; |
86 CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); | 86 CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); |
87 temp->Init(this, &coefficients, e); | 87 temp->Init(this, &coefficients, e); |
88 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 88 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
89 return temp; | 89 return temp; |
90 } | 90 } |
91 int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) { | 91 int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) { |
92 return a ^ b; | 92 return a ^ b; |
93 } | 93 } |
94 int32_t CBC_ReedSolomonGF256::Exp(int32_t a) { | 94 int32_t CBC_ReedSolomonGF256::Exp(int32_t a) { |
95 return m_expTable[a]; | 95 return m_expTable[a]; |
96 } | 96 } |
97 int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { | 97 int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { |
98 if (a == 0) { | 98 if (a == 0) { |
(...skipping 14 matching lines...) Loading... |
113 return 0; | 113 return 0; |
114 } | 114 } |
115 if (a == 1) { | 115 if (a == 1) { |
116 return b; | 116 return b; |
117 } | 117 } |
118 if (b == 1) { | 118 if (b == 1) { |
119 return a; | 119 return a; |
120 } | 120 } |
121 return m_expTable[(m_logTable[a] + m_logTable[b]) % 255]; | 121 return m_expTable[(m_logTable[a] + m_logTable[b]) % 255]; |
122 } | 122 } |
OLD | NEW |