Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 7 | #ifndef FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ |
| 8 | #define FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 9 | |
Lei Zhang | 1b22880 | 2017-04-05 18:42:22 -0700 | [diff] [blame] | 10 | #include <memory> |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 11 | #include <vector> |
| 12 | |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame^] | 13 | #include "core/fxcrt/unowned_ptr.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 14 | |
| 15 | class CBC_ReedSolomonGF256; |
| 16 | |
tsepez | d5d07dc | 2016-04-29 11:24:14 -0700 | [diff] [blame] | 17 | class CBC_ReedSolomonGF256Poly final { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 18 | public: |
| 19 | CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients); |
| 20 | CBC_ReedSolomonGF256Poly(); |
tsepez | d5d07dc | 2016-04-29 11:24:14 -0700 | [diff] [blame] | 21 | ~CBC_ReedSolomonGF256Poly(); |
Lei Zhang | 1b22880 | 2017-04-05 18:42:22 -0700 | [diff] [blame] | 22 | bool Init(CBC_ReedSolomonGF256* field, |
| 23 | const std::vector<int32_t>* coefficients); |
tsepez | d5d07dc | 2016-04-29 11:24:14 -0700 | [diff] [blame] | 24 | |
Lei Zhang | 1b22880 | 2017-04-05 18:42:22 -0700 | [diff] [blame] | 25 | int32_t GetCoefficients(int32_t degree) const; |
| 26 | const std::vector<int32_t>& GetCoefficients() const; |
| 27 | int32_t GetDegree() const; |
| 28 | bool IsZero() const; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 29 | int32_t EvaluateAt(int32_t a); |
Lei Zhang | 1b22880 | 2017-04-05 18:42:22 -0700 | [diff] [blame] | 30 | std::unique_ptr<CBC_ReedSolomonGF256Poly> AddOrSubtract( |
| 31 | const CBC_ReedSolomonGF256Poly* other); |
| 32 | std::unique_ptr<CBC_ReedSolomonGF256Poly> Multiply( |
| 33 | const CBC_ReedSolomonGF256Poly* other); |
| 34 | std::unique_ptr<CBC_ReedSolomonGF256Poly> Multiply(int32_t scalar); |
| 35 | std::unique_ptr<CBC_ReedSolomonGF256Poly> MultiplyByMonomial( |
| 36 | int32_t degree, |
| 37 | int32_t coefficient) const; |
| 38 | std::unique_ptr<CBC_ReedSolomonGF256Poly> Divide( |
| 39 | const CBC_ReedSolomonGF256Poly* other); |
| 40 | std::unique_ptr<CBC_ReedSolomonGF256Poly> Clone() const; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 41 | |
| 42 | private: |
Dan Sinclair | aee0db0 | 2017-09-21 16:53:58 -0400 | [diff] [blame^] | 43 | UnownedPtr<CBC_ReedSolomonGF256> m_field; |
Tom Sepez | 8b6186f | 2017-03-28 12:06:45 -0700 | [diff] [blame] | 44 | std::vector<int32_t> m_coefficients; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 45 | }; |
| 46 | |
Dan Sinclair | e778668 | 2017-03-29 15:18:41 -0400 | [diff] [blame] | 47 | #endif // FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ |