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

Side by Side Diff: xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 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 2012 ZXing authors 8 * Copyright 2012 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 "../barcode.h" 23 #include "../barcode.h"
24 #include "BC_PDF417Common.h" 24 #include "BC_PDF417Common.h"
25 #include "BC_PDF417ECModulusGF.h" 25 #include "BC_PDF417ECModulusGF.h"
26 #include "BC_PDF417ECModulusPoly.h" 26 #include "BC_PDF417ECModulusPoly.h"
27 CBC_PDF417ECModulusPoly::CBC_PDF417ECModulusPoly(CBC_PDF417ECModulusGF* field, C FX_Int32Array &coefficients, FX_INT32 &e) 27 CBC_PDF417ECModulusPoly::CBC_PDF417ECModulusPoly(CBC_PDF417ECModulusGF* field, C FX_Int32Array &coefficients, int32_t &e)
28 { 28 {
29 if (coefficients.GetSize() == 0) { 29 if (coefficients.GetSize() == 0) {
30 e = BCExceptionIllegalArgument; 30 e = BCExceptionIllegalArgument;
31 } 31 }
32 m_field = field; 32 m_field = field;
33 FX_INT32 coefficientsLength = coefficients.GetSize(); 33 int32_t coefficientsLength = coefficients.GetSize();
34 if (coefficientsLength > 1 && coefficients[0] == 0) { 34 if (coefficientsLength > 1 && coefficients[0] == 0) {
35 FX_INT32 firstNonZero = 1; 35 int32_t firstNonZero = 1;
36 while (firstNonZero < coefficientsLength && coefficients[firstNonZero] = = 0) { 36 while (firstNonZero < coefficientsLength && coefficients[firstNonZero] = = 0) {
37 firstNonZero++; 37 firstNonZero++;
38 } 38 }
39 if (firstNonZero == coefficientsLength) { 39 if (firstNonZero == coefficientsLength) {
40 m_coefficients = field->getZero()->m_coefficients; 40 m_coefficients = field->getZero()->m_coefficients;
41 } else { 41 } else {
42 m_coefficients.SetSize(coefficientsLength - firstNonZero); 42 m_coefficients.SetSize(coefficientsLength - firstNonZero);
43 FX_INT32 l = 0; 43 int32_t l = 0;
44 for (FX_INT32 i = firstNonZero; i < firstNonZero + m_coefficients.Ge tSize(); i++) { 44 for (int32_t i = firstNonZero; i < firstNonZero + m_coefficients.Get Size(); i++) {
45 m_coefficients.SetAt(l, coefficients.GetAt(i)); 45 m_coefficients.SetAt(l, coefficients.GetAt(i));
46 l++; 46 l++;
47 } 47 }
48 } 48 }
49 } else { 49 } else {
50 m_coefficients.Copy(coefficients); 50 m_coefficients.Copy(coefficients);
51 } 51 }
52 } 52 }
53 CBC_PDF417ECModulusPoly::~CBC_PDF417ECModulusPoly() 53 CBC_PDF417ECModulusPoly::~CBC_PDF417ECModulusPoly()
54 { 54 {
55 } 55 }
56 CFX_Int32Array& CBC_PDF417ECModulusPoly::getCoefficients() 56 CFX_Int32Array& CBC_PDF417ECModulusPoly::getCoefficients()
57 { 57 {
58 return m_coefficients; 58 return m_coefficients;
59 } 59 }
60 CBC_PDF417ECModulusGF* CBC_PDF417ECModulusPoly::getField() 60 CBC_PDF417ECModulusGF* CBC_PDF417ECModulusPoly::getField()
61 { 61 {
62 return m_field; 62 return m_field;
63 } 63 }
64 FX_INT32 CBC_PDF417ECModulusPoly::getDegree() 64 int32_t CBC_PDF417ECModulusPoly::getDegree()
65 { 65 {
66 return m_coefficients.GetSize() - 1; 66 return m_coefficients.GetSize() - 1;
67 } 67 }
68 FX_BOOL CBC_PDF417ECModulusPoly::isZero() 68 FX_BOOL CBC_PDF417ECModulusPoly::isZero()
69 { 69 {
70 return m_coefficients[0] == 0; 70 return m_coefficients[0] == 0;
71 } 71 }
72 FX_INT32 CBC_PDF417ECModulusPoly::getCoefficient(FX_INT32 degree) 72 int32_t CBC_PDF417ECModulusPoly::getCoefficient(int32_t degree)
73 { 73 {
74 return m_coefficients[m_coefficients.GetSize() - 1 - degree]; 74 return m_coefficients[m_coefficients.GetSize() - 1 - degree];
75 } 75 }
76 FX_INT32 CBC_PDF417ECModulusPoly::evaluateAt(FX_INT32 a) 76 int32_t CBC_PDF417ECModulusPoly::evaluateAt(int32_t a)
77 { 77 {
78 if (a == 0) { 78 if (a == 0) {
79 return getCoefficient(0); 79 return getCoefficient(0);
80 } 80 }
81 FX_INT32 size = m_coefficients.GetSize(); 81 int32_t size = m_coefficients.GetSize();
82 if (a == 1) { 82 if (a == 1) {
83 FX_INT32 result = 0; 83 int32_t result = 0;
84 for (FX_INT32 l = 0; l < m_coefficients.GetSize(); l++) { 84 for (int32_t l = 0; l < m_coefficients.GetSize(); l++) {
85 FX_INT32 coefficient = m_coefficients.GetAt(l); 85 int32_t coefficient = m_coefficients.GetAt(l);
86 result = m_field->add(result, coefficient); 86 result = m_field->add(result, coefficient);
87 } 87 }
88 return result; 88 return result;
89 } 89 }
90 FX_INT32 result = m_coefficients[0]; 90 int32_t result = m_coefficients[0];
91 for (FX_INT32 i = 1; i < size; i++) { 91 for (int32_t i = 1; i < size; i++) {
92 result = m_field->add(m_field->multiply(a, result), m_coefficients[i]); 92 result = m_field->add(m_field->multiply(a, result), m_coefficients[i]);
93 } 93 }
94 return result; 94 return result;
95 } 95 }
96 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::add(CBC_PDF417ECModulusPoly* o ther, FX_INT32 &e) 96 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::add(CBC_PDF417ECModulusPoly* o ther, int32_t &e)
97 { 97 {
98 CBC_PDF417ECModulusPoly* modulusPoly = NULL; 98 CBC_PDF417ECModulusPoly* modulusPoly = NULL;
99 if (isZero()) { 99 if (isZero()) {
100 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(other->getField(), other->g etCoefficients(), e); 100 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(other->getField(), other->g etCoefficients(), e);
101 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 101 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
102 return modulusPoly; 102 return modulusPoly;
103 } 103 }
104 if (other->isZero()) { 104 if (other->isZero()) {
105 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e) ; 105 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e) ;
106 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 106 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
107 return modulusPoly; 107 return modulusPoly;
108 } 108 }
109 CFX_Int32Array smallerCoefficients; 109 CFX_Int32Array smallerCoefficients;
110 smallerCoefficients.Copy(m_coefficients); 110 smallerCoefficients.Copy(m_coefficients);
111 CFX_Int32Array largerCoefficients; 111 CFX_Int32Array largerCoefficients;
112 largerCoefficients.Copy(other->m_coefficients); 112 largerCoefficients.Copy(other->m_coefficients);
113 if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) { 113 if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) {
114 CFX_Int32Array temp; 114 CFX_Int32Array temp;
115 temp.Copy(smallerCoefficients); 115 temp.Copy(smallerCoefficients);
116 smallerCoefficients.Copy(largerCoefficients); 116 smallerCoefficients.Copy(largerCoefficients);
117 largerCoefficients.Copy(temp); 117 largerCoefficients.Copy(temp);
118 } 118 }
119 CFX_Int32Array sumDiff; 119 CFX_Int32Array sumDiff;
120 sumDiff.SetSize(largerCoefficients.GetSize()); 120 sumDiff.SetSize(largerCoefficients.GetSize());
121 FX_INT32 lengthDiff = largerCoefficients.GetSize() - smallerCoefficients.Get Size(); 121 int32_t lengthDiff = largerCoefficients.GetSize() - smallerCoefficients.GetS ize();
122 for (FX_INT32 l = 0; l < lengthDiff; l++) { 122 for (int32_t l = 0; l < lengthDiff; l++) {
123 sumDiff.SetAt(l, largerCoefficients.GetAt(l)); 123 sumDiff.SetAt(l, largerCoefficients.GetAt(l));
124 } 124 }
125 for (FX_INT32 i = lengthDiff; i < largerCoefficients.GetSize(); i++) { 125 for (int32_t i = lengthDiff; i < largerCoefficients.GetSize(); i++) {
126 sumDiff[i] = m_field->add(smallerCoefficients[i - lengthDiff], largerCoe fficients[i]); 126 sumDiff[i] = m_field->add(smallerCoefficients[i - lengthDiff], largerCoe fficients[i]);
127 } 127 }
128 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, sumDiff, e); 128 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, sumDiff, e);
129 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 129 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
130 return modulusPoly; 130 return modulusPoly;
131 } 131 }
132 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::subtract(CBC_PDF417ECModulusPo ly* other, FX_INT32 &e) 132 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::subtract(CBC_PDF417ECModulusPo ly* other, int32_t &e)
133 { 133 {
134 CBC_PDF417ECModulusPoly* modulusPoly = NULL; 134 CBC_PDF417ECModulusPoly* modulusPoly = NULL;
135 if (other->isZero()) { 135 if (other->isZero()) {
136 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e) ; 136 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e) ;
137 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 137 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
138 return modulusPoly; 138 return modulusPoly;
139 } 139 }
140 CBC_PDF417ECModulusPoly* poly = other->negative(e); 140 CBC_PDF417ECModulusPoly* poly = other->negative(e);
141 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 141 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
142 modulusPoly = add(poly, e); 142 modulusPoly = add(poly, e);
143 delete poly; 143 delete poly;
144 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 144 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
145 return modulusPoly; 145 return modulusPoly;
146 } 146 }
147 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply(CBC_PDF417ECModulusPo ly* other, FX_INT32 &e) 147 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply(CBC_PDF417ECModulusPo ly* other, int32_t &e)
148 { 148 {
149 CBC_PDF417ECModulusPoly* modulusPoly = NULL; 149 CBC_PDF417ECModulusPoly* modulusPoly = NULL;
150 if (isZero() || other->isZero()) { 150 if (isZero() || other->isZero()) {
151 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field->getZero()->getFiel d(), m_field->getZero()->getCoefficients(), e); 151 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field->getZero()->getFiel d(), m_field->getZero()->getCoefficients(), e);
152 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 152 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
153 return modulusPoly; 153 return modulusPoly;
154 } 154 }
155 CFX_Int32Array aCoefficients; 155 CFX_Int32Array aCoefficients;
156 aCoefficients.Copy(m_coefficients); 156 aCoefficients.Copy(m_coefficients);
157 FX_INT32 aLength = aCoefficients.GetSize(); 157 int32_t aLength = aCoefficients.GetSize();
158 CFX_Int32Array bCoefficients; 158 CFX_Int32Array bCoefficients;
159 bCoefficients.Copy(other->m_coefficients); 159 bCoefficients.Copy(other->m_coefficients);
160 FX_INT32 bLength = bCoefficients.GetSize(); 160 int32_t bLength = bCoefficients.GetSize();
161 CFX_Int32Array product; 161 CFX_Int32Array product;
162 product.SetSize(aLength + bLength - 1); 162 product.SetSize(aLength + bLength - 1);
163 for (FX_INT32 i = 0; i < aLength; i++) { 163 for (int32_t i = 0; i < aLength; i++) {
164 FX_INT32 aCoeff = aCoefficients[i]; 164 int32_t aCoeff = aCoefficients[i];
165 for (FX_INT32 j = 0; j < bLength; j++) { 165 for (int32_t j = 0; j < bLength; j++) {
166 product[i + j] = m_field->add(product[i + j], m_field->multiply(aCoe ff, bCoefficients[j])); 166 product[i + j] = m_field->add(product[i + j], m_field->multiply(aCoe ff, bCoefficients[j]));
167 } 167 }
168 } 168 }
169 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, product, e); 169 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, product, e);
170 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 170 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
171 return modulusPoly; 171 return modulusPoly;
172 } 172 }
173 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::negative(FX_INT32 &e) 173 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::negative(int32_t &e)
174 { 174 {
175 FX_INT32 size = m_coefficients.GetSize(); 175 int32_t size = m_coefficients.GetSize();
176 CFX_Int32Array negativeCoefficients; 176 CFX_Int32Array negativeCoefficients;
177 negativeCoefficients.SetSize(size); 177 negativeCoefficients.SetSize(size);
178 for (FX_INT32 i = 0; i < size; i++) { 178 for (int32_t i = 0; i < size; i++) {
179 negativeCoefficients[i] = m_field->subtract(0, m_coefficients[i]); 179 negativeCoefficients[i] = m_field->subtract(0, m_coefficients[i]);
180 } 180 }
181 CBC_PDF417ECModulusPoly* modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_fiel d, negativeCoefficients, e); 181 CBC_PDF417ECModulusPoly* modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_fiel d, negativeCoefficients, e);
182 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 182 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
183 return modulusPoly; 183 return modulusPoly;
184 } 184 }
185 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply(FX_INT32 scalar, FX_I NT32 &e) 185 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiply(int32_t scalar, int32 _t &e)
186 { 186 {
187 CBC_PDF417ECModulusPoly* modulusPoly = NULL; 187 CBC_PDF417ECModulusPoly* modulusPoly = NULL;
188 if (scalar == 0) { 188 if (scalar == 0) {
189 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field->getZero()->getFiel d(), m_field->getZero()->getCoefficients(), e); 189 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field->getZero()->getFiel d(), m_field->getZero()->getCoefficients(), e);
190 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 190 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
191 return modulusPoly; 191 return modulusPoly;
192 } 192 }
193 if (scalar == 1) { 193 if (scalar == 1) {
194 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e) ; 194 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e) ;
195 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 195 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
196 return modulusPoly; 196 return modulusPoly;
197 } 197 }
198 FX_INT32 size = m_coefficients.GetSize(); 198 int32_t size = m_coefficients.GetSize();
199 CFX_Int32Array product; 199 CFX_Int32Array product;
200 product.SetSize(size); 200 product.SetSize(size);
201 for (FX_INT32 i = 0; i < size; i++) { 201 for (int32_t i = 0; i < size; i++) {
202 product[i] = m_field->multiply(m_coefficients[i], scalar); 202 product[i] = m_field->multiply(m_coefficients[i], scalar);
203 } 203 }
204 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, product, e); 204 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, product, e);
205 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 205 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
206 return modulusPoly; 206 return modulusPoly;
207 } 207 }
208 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiplyByMonomial(FX_INT32 de gree, FX_INT32 coefficient, FX_INT32 &e) 208 CBC_PDF417ECModulusPoly* CBC_PDF417ECModulusPoly::multiplyByMonomial(int32_t deg ree, int32_t coefficient, int32_t &e)
209 { 209 {
210 if (degree < 0) { 210 if (degree < 0) {
211 e = BCExceptionIllegalArgument; 211 e = BCExceptionIllegalArgument;
212 return NULL; 212 return NULL;
213 } 213 }
214 CBC_PDF417ECModulusPoly* modulusPoly = NULL; 214 CBC_PDF417ECModulusPoly* modulusPoly = NULL;
215 if (coefficient == 0) { 215 if (coefficient == 0) {
216 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field->getZero()->m_field , m_field->getZero()->m_coefficients, e); 216 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field->getZero()->m_field , m_field->getZero()->m_coefficients, e);
217 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 217 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
218 return modulusPoly; 218 return modulusPoly;
219 } 219 }
220 FX_INT32 size = m_coefficients.GetSize(); 220 int32_t size = m_coefficients.GetSize();
221 CFX_Int32Array product; 221 CFX_Int32Array product;
222 product.SetSize(size + degree); 222 product.SetSize(size + degree);
223 for (FX_INT32 i = 0; i < size; i++) { 223 for (int32_t i = 0; i < size; i++) {
224 product[i] = m_field->multiply(m_coefficients[i], coefficient); 224 product[i] = m_field->multiply(m_coefficients[i], coefficient);
225 } 225 }
226 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, product, e); 226 modulusPoly = FX_NEW CBC_PDF417ECModulusPoly(m_field, product, e);
227 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 227 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
228 return modulusPoly; 228 return modulusPoly;
229 } 229 }
230 CFX_PtrArray* CBC_PDF417ECModulusPoly::divide(CBC_PDF417ECModulusPoly* other, FX _INT32 &e) 230 CFX_PtrArray* CBC_PDF417ECModulusPoly::divide(CBC_PDF417ECModulusPoly* other, in t32_t &e)
231 { 231 {
232 if (other->isZero()) { 232 if (other->isZero()) {
233 e = BCExceptionDivideByZero; 233 e = BCExceptionDivideByZero;
234 return NULL; 234 return NULL;
235 } 235 }
236 CBC_PDF417ECModulusPoly* quotient = FX_NEW CBC_PDF417ECModulusPoly(m_field-> getZero()->m_field, m_field->getZero()->m_coefficients, e); 236 CBC_PDF417ECModulusPoly* quotient = FX_NEW CBC_PDF417ECModulusPoly(m_field-> getZero()->m_field, m_field->getZero()->m_coefficients, e);
237 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); 237 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
238 CBC_PDF417ECModulusPoly* remainder = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e); 238 CBC_PDF417ECModulusPoly* remainder = FX_NEW CBC_PDF417ECModulusPoly(m_field, m_coefficients, e);
239 if (e != BCExceptionNO) { 239 if (e != BCExceptionNO) {
240 delete quotient; 240 delete quotient;
241 return NULL; 241 return NULL;
242 } 242 }
243 FX_INT32 denominatorLeadingTerm = other->getCoefficient(other->getDegree()); 243 int32_t denominatorLeadingTerm = other->getCoefficient(other->getDegree());
244 FX_INT32 inverseDenominatorLeadingTerm = m_field->inverse(denominatorLeading Term, e); 244 int32_t inverseDenominatorLeadingTerm = m_field->inverse(denominatorLeadingT erm, e);
245 if (e != BCExceptionNO) { 245 if (e != BCExceptionNO) {
246 delete quotient; 246 delete quotient;
247 delete remainder; 247 delete remainder;
248 return NULL; 248 return NULL;
249 } 249 }
250 while (remainder->getDegree() >= other->getDegree() && !remainder->isZero()) { 250 while (remainder->getDegree() >= other->getDegree() && !remainder->isZero()) {
251 FX_INT32 degreeDifference = remainder->getDegree() - other->getDegree(); 251 int32_t degreeDifference = remainder->getDegree() - other->getDegree();
252 FX_INT32 scale = m_field->multiply(remainder->getCoefficient(remainder-> getDegree()), inverseDenominatorLeadingTerm); 252 int32_t scale = m_field->multiply(remainder->getCoefficient(remainder->g etDegree()), inverseDenominatorLeadingTerm);
253 CBC_PDF417ECModulusPoly* term = other->multiplyByMonomial(degreeDifferen ce, scale, e); 253 CBC_PDF417ECModulusPoly* term = other->multiplyByMonomial(degreeDifferen ce, scale, e);
254 if (e != BCExceptionNO) { 254 if (e != BCExceptionNO) {
255 delete quotient; 255 delete quotient;
256 delete remainder; 256 delete remainder;
257 return NULL; 257 return NULL;
258 } 258 }
259 CBC_PDF417ECModulusPoly* iterationQuotient = m_field->buildMonomial(degr eeDifference, scale, e); 259 CBC_PDF417ECModulusPoly* iterationQuotient = m_field->buildMonomial(degr eeDifference, scale, e);
260 if (e != BCExceptionNO) { 260 if (e != BCExceptionNO) {
261 delete quotient; 261 delete quotient;
262 delete remainder; 262 delete remainder;
(...skipping 18 matching lines...) Expand all
281 } 281 }
282 } 282 }
283 CFX_PtrArray* modulusPoly = FX_NEW CFX_PtrArray; 283 CFX_PtrArray* modulusPoly = FX_NEW CFX_PtrArray;
284 modulusPoly->Add(quotient); 284 modulusPoly->Add(quotient);
285 modulusPoly->Add(remainder); 285 modulusPoly->Add(remainder);
286 return modulusPoly; 286 return modulusPoly;
287 } 287 }
288 CFX_ByteString CBC_PDF417ECModulusPoly::toString() 288 CFX_ByteString CBC_PDF417ECModulusPoly::toString()
289 { 289 {
290 CFX_ByteString result; 290 CFX_ByteString result;
291 for (FX_INT32 degree = getDegree(); degree >= 0; degree--) { 291 for (int32_t degree = getDegree(); degree >= 0; degree--) {
292 FX_INT32 coefficient = getCoefficient(degree); 292 int32_t coefficient = getCoefficient(degree);
293 if (coefficient != 0) { 293 if (coefficient != 0) {
294 if (coefficient < 0) { 294 if (coefficient < 0) {
295 result += " - "; 295 result += " - ";
296 coefficient = -coefficient; 296 coefficient = -coefficient;
297 } else { 297 } else {
298 if (result.GetLength() > 0) { 298 if (result.GetLength() > 0) {
299 result += " + "; 299 result += " + ";
300 } 300 }
301 } 301 }
302 if (degree == 0 || coefficient != 1) { 302 if (degree == 0 || coefficient != 1) {
303 result += coefficient; 303 result += coefficient;
304 } 304 }
305 if (degree != 0) { 305 if (degree != 0) {
306 if (degree == 1) { 306 if (degree == 1) {
307 result += 'x'; 307 result += 'x';
308 } else { 308 } else {
309 result += "x^"; 309 result += "x^";
310 result += degree; 310 result += degree;
311 } 311 }
312 } 312 }
313 } 313 }
314 } 314 }
315 return result; 315 return result;
316 } 316 }
OLDNEW
« no previous file with comments | « xfa/src/fxbarcode/pdf417/BC_PDF417ECModulusPoly.h ('k') | xfa/src/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698