| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 CFX_Int32Array product; | 206 CFX_Int32Array product; |
| 207 product.SetSize(size + degree); | 207 product.SetSize(size + degree); |
| 208 for (int32_t i = 0; i < size; i++) { | 208 for (int32_t i = 0; i < size; i++) { |
| 209 product[i] = (m_field->Multiply(m_coefficients[i], coefficient)); | 209 product[i] = (m_field->Multiply(m_coefficients[i], coefficient)); |
| 210 } | 210 } |
| 211 CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); | 211 CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); |
| 212 temp->Init(m_field, &product, e); | 212 temp->Init(m_field, &product, e); |
| 213 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 213 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); |
| 214 return temp; | 214 return temp; |
| 215 } | 215 } |
| 216 CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, | 216 |
| 217 int32_t& e) { | 217 CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide( |
| 218 CBC_ReedSolomonGF256Poly* other, |
| 219 int32_t& e) { |
| 218 if (other->IsZero()) { | 220 if (other->IsZero()) { |
| 219 e = BCExceptionDivideByZero; | 221 e = BCExceptionDivideByZero; |
| 220 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 222 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 221 } | 223 } |
| 222 std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient( | 224 std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient( |
| 223 m_field->GetZero()->Clone(e)); | 225 m_field->GetZero()->Clone(e)); |
| 224 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 226 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 225 std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e)); | 227 std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e)); |
| 226 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 228 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 227 int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); | 229 int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); |
| 228 int32_t inverseDenominatorLeadingTeam = | 230 int32_t inverseDenominatorLeadingTeam = |
| 229 m_field->Inverse(denominatorLeadingTerm, e); | 231 m_field->Inverse(denominatorLeadingTerm, e); |
| 230 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 232 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 231 while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) { | 233 while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) { |
| 232 int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); | 234 int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); |
| 233 int32_t scale = | 235 int32_t scale = |
| 234 m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), | 236 m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), |
| 235 inverseDenominatorLeadingTeam); | 237 inverseDenominatorLeadingTeam); |
| 236 std::unique_ptr<CBC_ReedSolomonGF256Poly> term( | 238 std::unique_ptr<CBC_ReedSolomonGF256Poly> term( |
| 237 other->MultiplyByMonomial(degreeDifference, scale, e)); | 239 other->MultiplyByMonomial(degreeDifference, scale, e)); |
| 238 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 240 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 239 std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient( | 241 std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient( |
| 240 m_field->BuildMonomial(degreeDifference, scale, e)); | 242 m_field->BuildMonomial(degreeDifference, scale, e)); |
| 241 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 243 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 242 quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); | 244 quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); |
| 243 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 245 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 244 remainder.reset(remainder->AddOrSubtract(term.get(), e)); | 246 remainder.reset(remainder->AddOrSubtract(term.get(), e)); |
| 245 BC_EXCEPTION_CHECK_ReturnValue(e, NULL); | 247 BC_EXCEPTION_CHECK_ReturnValue(e, nullptr); |
| 246 } | 248 } |
| 247 CFX_PtrArray* tempPtrA = new CFX_PtrArray; | 249 CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* tempPtrA = |
| 250 new CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>(); |
| 248 tempPtrA->Add(quotient.release()); | 251 tempPtrA->Add(quotient.release()); |
| 249 tempPtrA->Add(remainder.release()); | 252 tempPtrA->Add(remainder.release()); |
| 250 return tempPtrA; | 253 return tempPtrA; |
| 251 } | 254 } |
| 255 |
| 252 CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() { | 256 CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() { |
| 253 m_coefficients.RemoveAll(); | 257 m_coefficients.RemoveAll(); |
| 254 } | 258 } |
| OLD | NEW |