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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } | 58 } |
59 CBC_PDF417ECModulusPoly* syndrome = | 59 CBC_PDF417ECModulusPoly* syndrome = |
60 new CBC_PDF417ECModulusPoly(m_field, S, e); | 60 new CBC_PDF417ECModulusPoly(m_field, S, e); |
61 BC_EXCEPTION_CHECK_ReturnValue(e, -1); | 61 BC_EXCEPTION_CHECK_ReturnValue(e, -1); |
62 CBC_PDF417ECModulusPoly* buildmonomial = | 62 CBC_PDF417ECModulusPoly* buildmonomial = |
63 m_field->buildMonomial(numECCodewords, 1, e); | 63 m_field->buildMonomial(numECCodewords, 1, e); |
64 if (e != BCExceptionNO) { | 64 if (e != BCExceptionNO) { |
65 delete syndrome; | 65 delete syndrome; |
66 return -1; | 66 return -1; |
67 } | 67 } |
68 CFX_PtrArray* sigmaOmega = | 68 CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* sigmaOmega = |
69 runEuclideanAlgorithm(buildmonomial, syndrome, numECCodewords, e); | 69 runEuclideanAlgorithm(buildmonomial, syndrome, numECCodewords, e); |
70 delete buildmonomial; | 70 delete buildmonomial; |
71 delete syndrome; | 71 delete syndrome; |
72 BC_EXCEPTION_CHECK_ReturnValue(e, -1); | 72 BC_EXCEPTION_CHECK_ReturnValue(e, -1); |
73 CBC_PDF417ECModulusPoly* sigma = | 73 CBC_PDF417ECModulusPoly* sigma = |
74 (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(0); | 74 (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(0); |
75 CBC_PDF417ECModulusPoly* omega = | 75 CBC_PDF417ECModulusPoly* omega = |
76 (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(1); | 76 (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(1); |
77 CFX_Int32Array* errorLocations = findErrorLocations(sigma, e); | 77 CFX_Int32Array* errorLocations = findErrorLocations(sigma, e); |
78 if (e != BCExceptionNO) { | 78 if (e != BCExceptionNO) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 int32_t result = errorLocations->GetSize(); | 116 int32_t result = errorLocations->GetSize(); |
117 delete errorLocations; | 117 delete errorLocations; |
118 delete errorMagnitudes; | 118 delete errorMagnitudes; |
119 for (int32_t k = 0; k < sigmaOmega->GetSize(); k++) { | 119 for (int32_t k = 0; k < sigmaOmega->GetSize(); k++) { |
120 delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(k); | 120 delete (CBC_PDF417ECModulusPoly*)sigmaOmega->GetAt(k); |
121 } | 121 } |
122 sigmaOmega->RemoveAll(); | 122 sigmaOmega->RemoveAll(); |
123 delete sigmaOmega; | 123 delete sigmaOmega; |
124 return result; | 124 return result; |
125 } | 125 } |
126 CFX_PtrArray* CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm( | 126 CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* |
127 CBC_PDF417ECModulusPoly* a, | 127 CBC_PDF417ECErrorCorrection::runEuclideanAlgorithm(CBC_PDF417ECModulusPoly* a, |
128 CBC_PDF417ECModulusPoly* b, | 128 CBC_PDF417ECModulusPoly* b, |
129 int32_t R, | 129 int32_t R, |
130 int32_t& e) { | 130 int32_t& e) { |
131 if (a->getDegree() < b->getDegree()) { | 131 if (a->getDegree() < b->getDegree()) { |
132 CBC_PDF417ECModulusPoly* temp = a; | 132 CBC_PDF417ECModulusPoly* temp = a; |
133 a = b; | 133 a = b; |
134 b = temp; | 134 b = temp; |
135 } | 135 } |
136 CBC_PDF417ECModulusPoly* rLast = a; | 136 CBC_PDF417ECModulusPoly* rLast = a; |
137 CBC_PDF417ECModulusPoly* r = b; | 137 CBC_PDF417ECModulusPoly* r = b; |
138 CBC_PDF417ECModulusPoly* tLast = m_field->getZero(); | 138 CBC_PDF417ECModulusPoly* tLast = m_field->getZero(); |
139 CBC_PDF417ECModulusPoly* t = m_field->getOne(); | 139 CBC_PDF417ECModulusPoly* t = m_field->getOne(); |
140 CBC_PDF417ECModulusPoly* qtemp = NULL; | 140 CBC_PDF417ECModulusPoly* qtemp = NULL; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 } | 255 } |
256 CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e); | 256 CBC_PDF417ECModulusPoly* sigma = t->multiply(inverse, e); |
257 delete ttemp; | 257 delete ttemp; |
258 if (e != BCExceptionNO) { | 258 if (e != BCExceptionNO) { |
259 delete rtemp; | 259 delete rtemp; |
260 return nullptr; | 260 return nullptr; |
261 } | 261 } |
262 CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); | 262 CBC_PDF417ECModulusPoly* omega = r->multiply(inverse, e); |
263 delete rtemp; | 263 delete rtemp; |
264 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 264 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
265 CFX_PtrArray* modulusPoly = new CFX_PtrArray; | 265 CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>* modulusPoly = |
| 266 new CFX_ArrayTemplate<CBC_PDF417ECModulusPoly*>(); |
266 modulusPoly->Add(sigma); | 267 modulusPoly->Add(sigma); |
267 modulusPoly->Add(omega); | 268 modulusPoly->Add(omega); |
268 return modulusPoly; | 269 return modulusPoly; |
269 } | 270 } |
270 CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorLocations( | 271 CFX_Int32Array* CBC_PDF417ECErrorCorrection::findErrorLocations( |
271 CBC_PDF417ECModulusPoly* errorLocator, | 272 CBC_PDF417ECModulusPoly* errorLocator, |
272 int32_t& e) { | 273 int32_t& e) { |
273 int32_t numErrors = errorLocator->getDegree(); | 274 int32_t numErrors = errorLocator->getDegree(); |
274 CFX_Int32Array* result = new CFX_Int32Array; | 275 CFX_Int32Array* result = new CFX_Int32Array; |
275 result->SetSize(numErrors); | 276 result->SetSize(numErrors); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 int32_t denominator = | 321 int32_t denominator = |
321 m_field->inverse(formalDerivative.evaluateAt(xiInverse), e); | 322 m_field->inverse(formalDerivative.evaluateAt(xiInverse), e); |
322 if (e != BCExceptionNO) { | 323 if (e != BCExceptionNO) { |
323 delete result; | 324 delete result; |
324 return NULL; | 325 return NULL; |
325 } | 326 } |
326 result->SetAt(i, m_field->multiply(numerator, denominator)); | 327 result->SetAt(i, m_field->multiply(numerator, denominator)); |
327 } | 328 } |
328 return result; | 329 return result; |
329 } | 330 } |
OLD | NEW |