| 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 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"); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 int32_t n = 0; | 146 int32_t n = 0; |
| 147 while (r->getDegree() >= R / 2) { | 147 while (r->getDegree() >= R / 2) { |
| 148 CBC_PDF417ECModulusPoly* rLastLast = rLast; | 148 CBC_PDF417ECModulusPoly* rLastLast = rLast; |
| 149 CBC_PDF417ECModulusPoly* tLastLast = tLast; | 149 CBC_PDF417ECModulusPoly* tLastLast = tLast; |
| 150 rLast = r; | 150 rLast = r; |
| 151 tLast = t; | 151 tLast = t; |
| 152 m = i; | 152 m = i; |
| 153 n = j; | 153 n = j; |
| 154 if (rLast->isZero()) { | 154 if (rLast->isZero()) { |
| 155 e = BCExceptionChecksumException; | 155 e = BCExceptionChecksumException; |
| 156 if (qtemp) { | 156 delete qtemp; |
| 157 delete qtemp; | 157 delete rtemp; |
| 158 } | 158 delete ttemp; |
| 159 if (rtemp) { | 159 return nullptr; |
| 160 delete rtemp; | |
| 161 } | |
| 162 if (ttemp) { | |
| 163 delete ttemp; | |
| 164 } | |
| 165 return NULL; | |
| 166 } | 160 } |
| 167 r = rLastLast; | 161 r = rLastLast; |
| 168 CBC_PDF417ECModulusPoly* q = m_field->getZero(); | 162 CBC_PDF417ECModulusPoly* q = m_field->getZero(); |
| 169 int32_t denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree()); | 163 int32_t denominatorLeadingTerm = rLast->getCoefficient(rLast->getDegree()); |
| 170 int32_t dltInverse = m_field->inverse(denominatorLeadingTerm, e); | 164 int32_t dltInverse = m_field->inverse(denominatorLeadingTerm, e); |
| 171 if (e != BCExceptionNO) { | 165 if (e != BCExceptionNO) { |
| 172 if (qtemp) { | 166 delete qtemp; |
| 173 delete qtemp; | 167 delete rtemp; |
| 174 } | 168 delete ttemp; |
| 175 if (rtemp) { | 169 return nullptr; |
| 176 delete rtemp; | |
| 177 } | |
| 178 if (ttemp) { | |
| 179 delete ttemp; | |
| 180 } | |
| 181 return NULL; | |
| 182 } | 170 } |
| 183 while (r->getDegree() >= rLast->getDegree() && !r->isZero()) { | 171 while (r->getDegree() >= rLast->getDegree() && !r->isZero()) { |
| 184 int32_t degreeDiff = r->getDegree() - rLast->getDegree(); | 172 int32_t degreeDiff = r->getDegree() - rLast->getDegree(); |
| 185 int32_t scale = | 173 int32_t scale = |
| 186 m_field->multiply(r->getCoefficient(r->getDegree()), dltInverse); | 174 m_field->multiply(r->getCoefficient(r->getDegree()), dltInverse); |
| 187 CBC_PDF417ECModulusPoly* buildmonomial = | 175 CBC_PDF417ECModulusPoly* buildmonomial = |
| 188 m_field->buildMonomial(degreeDiff, scale, e); | 176 m_field->buildMonomial(degreeDiff, scale, e); |
| 189 if (e != BCExceptionNO) { | 177 if (e != BCExceptionNO) { |
| 190 if (qtemp) { | 178 delete qtemp; |
| 191 delete qtemp; | 179 delete rtemp; |
| 192 } | 180 delete ttemp; |
| 193 if (rtemp) { | 181 return nullptr; |
| 194 delete rtemp; | |
| 195 } | |
| 196 if (ttemp) { | |
| 197 delete ttemp; | |
| 198 } | |
| 199 return NULL; | |
| 200 } | 182 } |
| 201 q = q->add(buildmonomial, e); | 183 q = q->add(buildmonomial, e); |
| 202 delete buildmonomial; | 184 delete buildmonomial; |
| 203 if (qtemp) { | 185 delete qtemp; |
| 204 delete qtemp; | |
| 205 } | |
| 206 if (e != BCExceptionNO) { | 186 if (e != BCExceptionNO) { |
| 207 if (rtemp) { | 187 delete rtemp; |
| 208 delete rtemp; | 188 delete ttemp; |
| 209 } | 189 return nullptr; |
| 210 if (ttemp) { | |
| 211 delete ttemp; | |
| 212 } | |
| 213 return NULL; | |
| 214 } | 190 } |
| 215 qtemp = q; | 191 qtemp = q; |
| 216 CBC_PDF417ECModulusPoly* multiply = | 192 CBC_PDF417ECModulusPoly* multiply = |
| 217 rLast->multiplyByMonomial(degreeDiff, scale, e); | 193 rLast->multiplyByMonomial(degreeDiff, scale, e); |
| 218 if (e != BCExceptionNO) { | 194 if (e != BCExceptionNO) { |
| 219 if (qtemp) { | 195 delete qtemp; |
| 220 delete qtemp; | 196 delete rtemp; |
| 221 } | 197 delete ttemp; |
| 222 if (rtemp) { | 198 return nullptr; |
| 223 delete rtemp; | |
| 224 } | |
| 225 if (ttemp) { | |
| 226 delete ttemp; | |
| 227 } | |
| 228 return NULL; | |
| 229 } | 199 } |
| 230 CBC_PDF417ECModulusPoly* temp = r; | 200 CBC_PDF417ECModulusPoly* temp = r; |
| 231 r = temp->subtract(multiply, e); | 201 r = temp->subtract(multiply, e); |
| 232 delete multiply; | 202 delete multiply; |
| 233 if (m > 1 && i > m) { | 203 if (m > 1 && i > m) { |
| 234 delete temp; | 204 delete temp; |
| 235 temp = NULL; | 205 temp = nullptr; |
| 236 } | 206 } |
| 237 if (e != BCExceptionNO) { | 207 if (e != BCExceptionNO) { |
| 238 if (qtemp) { | 208 delete qtemp; |
| 239 delete qtemp; | 209 delete rtemp; |
| 240 } | 210 delete ttemp; |
| 241 if (rtemp) { | 211 return nullptr; |
| 242 delete rtemp; | |
| 243 } | |
| 244 if (ttemp) { | |
| 245 delete ttemp; | |
| 246 } | |
| 247 return NULL; | |
| 248 } | 212 } |
| 249 rtemp = r; | 213 rtemp = r; |
| 250 i = m + 1; | 214 i = m + 1; |
| 251 } | 215 } |
| 252 ttemp = q->multiply(tLast, e); | 216 ttemp = q->multiply(tLast, e); |
| 253 if (qtemp) { | 217 delete qtemp; |
| 254 delete qtemp; | 218 qtemp = nullptr; |
| 255 qtemp = NULL; | |
| 256 } | |
| 257 if (e != BCExceptionNO) { | 219 if (e != BCExceptionNO) { |
| 258 if (rtemp) { | 220 delete rtemp; |
| 259 delete rtemp; | 221 delete ttemp; |
| 260 } | 222 return nullptr; |
| 261 if (ttemp) { | |
| 262 delete ttemp; | |
| 263 } | |
| 264 return NULL; | |
| 265 } | 223 } |
| 266 t = ttemp->subtract(tLastLast, e); | 224 t = ttemp->subtract(tLastLast, e); |
| 267 if (n > 1 && j > n) { | 225 if (n > 1 && j > n) { |
| 268 delete tLastLast; | 226 delete tLastLast; |
| 269 } | 227 } |
| 270 delete ttemp; | 228 delete ttemp; |
| 271 if (e != BCExceptionNO) { | 229 if (e != BCExceptionNO) { |
| 272 if (rtemp) { | 230 delete rtemp; |
| 273 delete rtemp; | 231 return nullptr; |
| 274 } | |
| 275 return NULL; | |
| 276 } | 232 } |
| 277 ttemp = t; | 233 ttemp = t; |
| 278 t = ttemp->negative(e); | 234 t = ttemp->negative(e); |
| 279 delete ttemp; | 235 delete ttemp; |
| 280 if (e != BCExceptionNO) { | 236 if (e != BCExceptionNO) { |
| 281 if (rtemp) { | 237 delete rtemp; |
| 282 delete rtemp; | 238 return nullptr; |
| 283 } | |
| 284 return NULL; | |
| 285 } | 239 } |
| 286 ttemp = t; | 240 ttemp = t; |
| 287 j++; | 241 j++; |
| 288 } | 242 } |
| 289 int32_t sigmaTildeAtZero = t->getCoefficient(0); | 243 int32_t sigmaTildeAtZero = t->getCoefficient(0); |
| 290 if (sigmaTildeAtZero == 0) { | 244 if (sigmaTildeAtZero == 0) { |
| 291 e = BCExceptionChecksumException; | 245 e = BCExceptionChecksumException; |
| 292 if (rtemp) { | 246 delete rtemp; |
| 293 delete rtemp; | 247 delete ttemp; |
| 294 } | 248 return nullptr; |
| 295 if (ttemp) { | |
| 296 delete ttemp; | |
| 297 } | |
| 298 return NULL; | |
| 299 } | 249 } |
| 300 int32_t inverse = m_field->inverse(sigmaTildeAtZero, e); | 250 int32_t inverse = m_field->inverse(sigmaTildeAtZero, e); |
| 301 if (e != BCExceptionNO) { | 251 if (e != BCExceptionNO) { |
| 302 if (rtemp) { | 252 delete rtemp; |
| 303 delete rtemp; | 253 delete ttemp; |
| 304 } | 254 return nullptr; |
| 305 if (ttemp) { | |
| 306 delete ttemp; | |
| 307 } | |
| 308 return NULL; | |
| 309 } | 255 } |
| 310 CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e); | 256 CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e); |
| 311 if (ttemp) { | 257 delete ttemp; |
| 312 delete ttemp; | |
| 313 } | |
| 314 if (e != BCExceptionNO) { | 258 if (e != BCExceptionNO) { |
| 315 if (rtemp) { | 259 delete rtemp; |
| 316 delete rtemp; | 260 return nullptr; |
| 317 } | |
| 318 return NULL; | |
| 319 } | 261 } |
| 320 CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); | 262 CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); |
| 321 if (rtemp) { | 263 delete rtemp; |
| 322 delete rtemp; | |
| 323 } | |
| 324 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 264 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 325 CFX_PtrArray* modulusPoly = new CFX_PtrArray; | 265 CFX_PtrArray* modulusPoly = new CFX_PtrArray; |
| 326 modulusPoly->Add(sigma); | 266 modulusPoly->Add(sigma); |
| 327 modulusPoly->Add(omega); | 267 modulusPoly->Add(omega); |
| 328 return modulusPoly; | 268 return modulusPoly; |
| 329 } | 269 } |
| 330 CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorLocations( | 270 CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorLocations( |
| 331 CBC_PDF417ECModulusPoly* errorLocator, | 271 CBC_PDF417ECModulusPoly* errorLocator, |
| 332 int32_t& e) { | 272 int32_t& e) { |
| 333 int32_t numErrors = errorLocator->getDegree(); | 273 int32_t numErrors = errorLocator->getDegree(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 int32_t denominator = | 320 int32_t denominator = |
| 381 m_field->inverse(formalDerivative.evaluateAt(xiInverse), e); | 321 m_field->inverse(formalDerivative.evaluateAt(xiInverse), e); |
| 382 if (e != BCExceptionNO) { | 322 if (e != BCExceptionNO) { |
| 383 delete result; | 323 delete result; |
| 384 return NULL; | 324 return NULL; |
| 385 } | 325 } |
| 386 result->SetAt(i, m_field->multiply(numerator, denominator)); | 326 result->SetAt(i, m_field->multiply(numerator, denominator)); |
| 387 } | 327 } |
| 388 return result; | 328 return result; |
| 389 } | 329 } |
| OLD | NEW |