| 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"); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 temp->Add(errorLocator->GetCoefficients(1)); | 174 temp->Add(errorLocator->GetCoefficients(1)); |
| 175 return temp.release(); | 175 return temp.release(); |
| 176 } | 176 } |
| 177 CFX_Int32Array* tempT = new CFX_Int32Array; | 177 CFX_Int32Array* tempT = new CFX_Int32Array; |
| 178 tempT->SetSize(numErrors); | 178 tempT->SetSize(numErrors); |
| 179 std::unique_ptr<CFX_Int32Array> result(tempT); | 179 std::unique_ptr<CFX_Int32Array> result(tempT); |
| 180 int32_t ie = 0; | 180 int32_t ie = 0; |
| 181 for (int32_t i = 1; i < 256 && ie < numErrors; i++) { | 181 for (int32_t i = 1; i < 256 && ie < numErrors; i++) { |
| 182 if (errorLocator->EvaluateAt(i) == 0) { | 182 if (errorLocator->EvaluateAt(i) == 0) { |
| 183 (*result)[ie] = m_field->Inverse(i, ie); | 183 (*result)[ie] = m_field->Inverse(i, ie); |
| 184 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 184 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 185 ie++; | 185 ie++; |
| 186 } | 186 } |
| 187 } | 187 } |
| 188 if (ie != numErrors) { | 188 if (ie != numErrors) { |
| 189 e = BCExceptionDegreeNotMatchRoots; | 189 e = BCExceptionDegreeNotMatchRoots; |
| 190 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 190 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 191 } | 191 } |
| 192 return result.release(); | 192 return result.release(); |
| 193 } | 193 } |
| 194 CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes( | 194 CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes( |
| 195 CBC_ReedSolomonGF256Poly* errorEvaluator, | 195 CBC_ReedSolomonGF256Poly* errorEvaluator, |
| 196 CFX_Int32Array* errorLocations, | 196 CFX_Int32Array* errorLocations, |
| 197 FX_BOOL dataMatrix, | 197 FX_BOOL dataMatrix, |
| 198 int32_t& e) { | 198 int32_t& e) { |
| 199 int32_t s = errorLocations->GetSize(); | 199 int32_t s = errorLocations->GetSize(); |
| 200 CFX_Int32Array* tempArray = new CFX_Int32Array; | 200 CFX_Int32Array* tempArray = new CFX_Int32Array; |
| 201 tempArray->SetSize(s); | 201 tempArray->SetSize(s); |
| 202 std::unique_ptr<CFX_Int32Array> result(tempArray); | 202 std::unique_ptr<CFX_Int32Array> result(tempArray); |
| 203 for (int32_t i = 0; i < s; i++) { | 203 for (int32_t i = 0; i < s; i++) { |
| 204 int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e); | 204 int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e); |
| 205 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 205 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 206 int32_t denominator = 1; | 206 int32_t denominator = 1; |
| 207 for (int32_t j = 0; j < s; j++) { | 207 for (int32_t j = 0; j < s; j++) { |
| 208 if (i != j) { | 208 if (i != j) { |
| 209 denominator = m_field->Multiply( | 209 denominator = m_field->Multiply( |
| 210 denominator, CBC_ReedSolomonGF256::AddOrSubtract( | 210 denominator, CBC_ReedSolomonGF256::AddOrSubtract( |
| 211 1, m_field->Multiply(errorLocations->operator[](j), | 211 1, m_field->Multiply(errorLocations->operator[](j), |
| 212 xiInverse))); | 212 xiInverse))); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 int32_t temp = m_field->Inverse(denominator, e); | 215 int32_t temp = m_field->Inverse(denominator, e); |
| 216 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 216 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 217 (*result)[i] = | 217 (*result)[i] = |
| 218 m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp); | 218 m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp); |
| 219 } | 219 } |
| 220 return result.release(); | 220 return result.release(); |
| 221 } | 221 } |
| OLD | NEW |