diff options
Diffstat (limited to 'xfa/fxbarcode/common')
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonBitArray.cpp | 124 | ||||
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonBitArray.h | 38 | ||||
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonBitMatrix.cpp | 147 | ||||
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonBitMatrix.h | 48 | ||||
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonByteArray.cpp | 99 | ||||
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonByteArray.h | 38 | ||||
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonByteMatrix.cpp | 64 | ||||
-rw-r--r-- | xfa/fxbarcode/common/BC_CommonByteMatrix.h | 35 | ||||
-rw-r--r-- | xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp | 105 | ||||
-rw-r--r-- | xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h | 32 | ||||
-rw-r--r-- | xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp | 135 | ||||
-rw-r--r-- | xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h | 47 | ||||
-rw-r--r-- | xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp | 253 | ||||
-rw-r--r-- | xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h | 49 |
14 files changed, 0 insertions, 1214 deletions
diff --git a/xfa/fxbarcode/common/BC_CommonBitArray.cpp b/xfa/fxbarcode/common/BC_CommonBitArray.cpp deleted file mode 100644 index f53e677389..0000000000 --- a/xfa/fxbarcode/common/BC_CommonBitArray.cpp +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/fxbarcode/common/BC_CommonBitArray.h" - -#include <utility> - -#include "xfa/fxbarcode/utils.h" - -CBC_CommonBitArray::CBC_CommonBitArray(CBC_CommonBitArray* array) { - m_size = array->GetSize(); - m_bits = array->GetBits(); -} - -CBC_CommonBitArray::CBC_CommonBitArray() { - m_bits.resize(1); - m_size = 0; -} - -CBC_CommonBitArray::CBC_CommonBitArray(int32_t size) { - m_bits.resize((size + 31) >> 5); - m_size = size; -} - -CBC_CommonBitArray::~CBC_CommonBitArray() {} - -size_t CBC_CommonBitArray::GetSize() { - return m_size; -} - -std::vector<int32_t>& CBC_CommonBitArray::GetBits() { - return m_bits; -} - -size_t CBC_CommonBitArray::GetSizeInBytes() { - return (m_size + 7) >> 3; -} - -bool CBC_CommonBitArray::Get(size_t i) { - return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0; -} - -void CBC_CommonBitArray::Set(size_t i) { - m_bits[i >> 5] |= 1 << (i & 0x1F); -} - -void CBC_CommonBitArray::Flip(size_t i) { - m_bits[i >> 5] ^= 1 << (i & 0x1F); -} - -void CBC_CommonBitArray::SetBulk(size_t i, int32_t newBits) { - m_bits[i >> 5] = newBits; -} - -void CBC_CommonBitArray::Clear() { - for (auto& value : m_bits) - value = 0; -} - -bool CBC_CommonBitArray::IsRange(size_t start, - size_t end, - bool value, - int32_t& e) { - if (end < start) { - e = BCExceptionEndLessThanStart; - return false; - } - if (end == start) { - return true; - } - end--; - int32_t firstInt = start >> 5; - int32_t lastInt = end >> 5; - int32_t i; - for (i = firstInt; i <= lastInt; i++) { - int32_t firstBit = i > firstInt ? 0 : start & 0x1F; - int32_t lastBit = i < lastInt ? 31 : end & 0x1F; - int32_t mask; - if (firstBit == 0 && lastBit == 31) { - mask = -1; - } else { - mask = 0; - for (int32_t j = firstBit; j <= lastBit; j++) { - mask |= 1 << j; - } - } - if ((m_bits[i] & mask) != (value ? mask : 0)) { - return false; - } - } - return true; -} - -int32_t* CBC_CommonBitArray::GetBitArray() { - return m_bits.data(); -} - -void CBC_CommonBitArray::Reverse() { - std::vector<int32_t> newBits(m_bits.size()); - for (size_t i = 0; i < m_size; i++) { - if (Get(m_size - i - 1)) - newBits[i >> 5] |= 1 << (i & 0x1F); - } - m_bits = std::move(newBits); -} diff --git a/xfa/fxbarcode/common/BC_CommonBitArray.h b/xfa/fxbarcode/common/BC_CommonBitArray.h deleted file mode 100644 index 841ca99149..0000000000 --- a/xfa/fxbarcode/common/BC_CommonBitArray.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ -#define XFA_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ - -#include <vector> - -#include "core/fxcrt/fx_basic.h" - -class CBC_CommonBitArray { - public: - explicit CBC_CommonBitArray(CBC_CommonBitArray* array); - explicit CBC_CommonBitArray(int32_t size); - CBC_CommonBitArray(); - virtual ~CBC_CommonBitArray(); - - size_t GetSize(); - size_t GetSizeInBytes(); - std::vector<int32_t>& GetBits(); - int32_t* GetBitArray(); - bool Get(size_t i); - void Set(size_t i); - void Flip(size_t i); - void SetBulk(size_t i, int32_t newBits); - bool IsRange(size_t start, size_t end, bool value, int32_t& e); - void Reverse(); - void Clear(); - - private: - size_t m_size; - std::vector<int32_t> m_bits; -}; - -#endif // XFA_FXBARCODE_COMMON_BC_COMMONBITARRAY_H_ diff --git a/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp deleted file mode 100644 index 5e65bd74cf..0000000000 --- a/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp +++ /dev/null @@ -1,147 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/fxbarcode/common/BC_CommonBitArray.h" -#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/fxbarcode/utils.h" - -CBC_CommonBitMatrix::CBC_CommonBitMatrix() { - m_width = 0; - m_height = 0; - m_rowSize = 0; - m_bits = nullptr; -} -void CBC_CommonBitMatrix::Init(int32_t dimension) { - m_width = dimension; - m_height = dimension; - int32_t rowSize = (m_height + 31) >> 5; - m_rowSize = rowSize; - m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); - FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); -} -void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) { - m_width = width; - m_height = height; - int32_t rowSize = (width + 31) >> 5; - m_rowSize = rowSize; - m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height); - FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); -} -CBC_CommonBitMatrix::~CBC_CommonBitMatrix() { - FX_Free(m_bits); -} -bool CBC_CommonBitMatrix::Get(int32_t x, int32_t y) { - int32_t offset = y * m_rowSize + (x >> 5); - if (offset >= m_rowSize * m_height || offset < 0) { - return false; - } - return ((((uint32_t)m_bits[offset]) >> (x & 0x1f)) & 1) != 0; -} -int32_t* CBC_CommonBitMatrix::GetBits() { - return m_bits; -} -void CBC_CommonBitMatrix::Set(int32_t x, int32_t y) { - int32_t offset = y * m_rowSize + (x >> 5); - if (offset >= m_rowSize * m_height || offset < 0) { - return; - } - m_bits[offset] |= 1 << (x & 0x1f); -} -void CBC_CommonBitMatrix::Flip(int32_t x, int32_t y) { - int32_t offset = y * m_rowSize + (x >> 5); - m_bits[offset] ^= 1 << (x & 0x1f); -} -void CBC_CommonBitMatrix::Clear() { - FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t)); -} -void CBC_CommonBitMatrix::SetRegion(int32_t left, - int32_t top, - int32_t width, - int32_t height, - int32_t& e) { - if (top < 0 || left < 0) { - e = BCExceptionLeftAndTopMustBeNonnegative; - return; - } - if (height < 1 || width < 1) { - e = BCExceptionHeightAndWidthMustBeAtLeast1; - return; - } - int32_t right = left + width; - int32_t bottom = top + height; - if (m_height < bottom || m_width < right) { - e = BCExceptionRegionMustFitInsideMatrix; - return; - } - int32_t y; - for (y = top; y < bottom; y++) { - int32_t offset = y * m_rowSize; - int32_t x; - for (x = left; x < right; x++) { - m_bits[offset + (x >> 5)] |= 1 << (x & 0x1f); - } - } -} -CBC_CommonBitArray* CBC_CommonBitMatrix::GetRow(int32_t y, - CBC_CommonBitArray* row) { - CBC_CommonBitArray* rowArray = nullptr; - if (!row || static_cast<int32_t>(row->GetSize()) < m_width) { - rowArray = new CBC_CommonBitArray(m_width); - } else { - rowArray = new CBC_CommonBitArray(row); - } - int32_t offset = y * m_rowSize; - int32_t x; - for (x = 0; x < m_rowSize; x++) { - rowArray->SetBulk(x << 5, m_bits[offset + x]); - } - return rowArray; -} -void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row) { - int32_t l = y * m_rowSize; - for (int32_t i = 0; i < m_rowSize; i++) { - m_bits[l] = row->GetBitArray()[i]; - l++; - } -} - -void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col) { - for (size_t i = 0; i < col->GetBits().size(); ++i) - m_bits[i * m_rowSize + y] = col->GetBitArray()[i]; -} - -int32_t CBC_CommonBitMatrix::GetWidth() { - return m_width; -} -int32_t CBC_CommonBitMatrix::GetHeight() { - return m_height; -} -int32_t CBC_CommonBitMatrix::GetRowSize() { - return m_rowSize; -} -int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) { - if (m_width != m_height) { - e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix; - return 0; - } - return m_width; -} diff --git a/xfa/fxbarcode/common/BC_CommonBitMatrix.h b/xfa/fxbarcode/common/BC_CommonBitMatrix.h deleted file mode 100644 index ed1f684a37..0000000000 --- a/xfa/fxbarcode/common/BC_CommonBitMatrix.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ -#define XFA_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ - -#include "core/fxcrt/fx_system.h" - -class CBC_CommonBitArray; - -class CBC_CommonBitMatrix { - public: - CBC_CommonBitMatrix(); - virtual ~CBC_CommonBitMatrix(); - - virtual void Init(int32_t dimension); - virtual void Init(int32_t width, int32_t height); - - bool Get(int32_t x, int32_t y); - void Set(int32_t x, int32_t y); - void Flip(int32_t x, int32_t y); - void Clear(); - void SetRegion(int32_t left, - int32_t top, - int32_t width, - int32_t height, - int32_t& e); - CBC_CommonBitArray* GetRow(int32_t y, CBC_CommonBitArray* row); - void SetRow(int32_t y, CBC_CommonBitArray* row); - CBC_CommonBitArray* GetCol(int32_t y, CBC_CommonBitArray* row); - void SetCol(int32_t y, CBC_CommonBitArray* col); - int32_t GetWidth(); - int32_t GetHeight(); - int32_t GetRowSize(); - int32_t GetDimension(int32_t& e); - int32_t* GetBits(); - - private: - int32_t m_width; - int32_t m_height; - int32_t m_rowSize; - int32_t* m_bits; -}; - -#endif // XFA_FXBARCODE_COMMON_BC_COMMONBITMATRIX_H_ diff --git a/xfa/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/fxbarcode/common/BC_CommonByteArray.cpp deleted file mode 100644 index e950f0f941..0000000000 --- a/xfa/fxbarcode/common/BC_CommonByteArray.cpp +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <algorithm> - -#include "xfa/fxbarcode/common/BC_CommonByteArray.h" - -CBC_CommonByteArray::CBC_CommonByteArray() { - m_bytes = nullptr; - m_size = 0; - m_index = 0; -} -CBC_CommonByteArray::CBC_CommonByteArray(int32_t size) { - m_size = size; - m_bytes = FX_Alloc(uint8_t, size); - FXSYS_memset(m_bytes, 0, size); - m_index = 0; -} -CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) { - m_size = size; - m_bytes = FX_Alloc(uint8_t, size); - FXSYS_memcpy(m_bytes, byteArray, size); - m_index = size; -} -CBC_CommonByteArray::~CBC_CommonByteArray() { - FX_Free(m_bytes); -} -int32_t CBC_CommonByteArray::At(int32_t index) const { - return m_bytes[index] & 0xff; -} -void CBC_CommonByteArray::Set(int32_t index, int32_t value) { - m_bytes[index] = (uint8_t)value; -} -int32_t CBC_CommonByteArray::Size() const { - return m_size; -} -bool CBC_CommonByteArray::IsEmpty() const { - return m_size == 0; -} -void CBC_CommonByteArray::AppendByte(int32_t value) { - if (m_size == 0 || m_index >= m_size) { - int32_t newSize = std::max(32, m_size << 1); - Reserve(newSize); - } - m_bytes[m_index] = (uint8_t)value; - m_index++; -} -void CBC_CommonByteArray::Reserve(int32_t capacity) { - if (!m_bytes || m_size < capacity) { - uint8_t* newArray = FX_Alloc(uint8_t, capacity); - if (m_bytes) { - FXSYS_memcpy(newArray, m_bytes, m_size); - FXSYS_memset(newArray + m_size, 0, capacity - m_size); - } else { - FXSYS_memset(newArray, 0, capacity); - } - FX_Free(m_bytes); - m_bytes = newArray; - m_size = capacity; - } -} -void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) { - FX_Free(m_bytes); - m_bytes = FX_Alloc(uint8_t, count); - m_size = count; - FXSYS_memcpy(m_bytes, source + offset, count); - m_index = count; -} -void CBC_CommonByteArray::Set(std::vector<uint8_t>* source, - int32_t offset, - int32_t count) { - FX_Free(m_bytes); - m_bytes = FX_Alloc(uint8_t, count); - m_size = count; - int32_t i; - for (i = 0; i < count; i++) { - m_bytes[i] = source->operator[](i + offset); - } - m_index = m_size; -} diff --git a/xfa/fxbarcode/common/BC_CommonByteArray.h b/xfa/fxbarcode/common/BC_CommonByteArray.h deleted file mode 100644 index e1fe4c7f2e..0000000000 --- a/xfa/fxbarcode/common/BC_CommonByteArray.h +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ -#define XFA_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ - -#include <vector> - -#include "core/fxcrt/fx_basic.h" - -// TODO(weili): The usage of this class should be replaced by -// std::vector<uint8_t>. -class CBC_CommonByteArray { - public: - CBC_CommonByteArray(); - explicit CBC_CommonByteArray(int32_t size); - CBC_CommonByteArray(uint8_t* byteArray, int32_t size); - virtual ~CBC_CommonByteArray(); - - int32_t At(int32_t index) const; - int32_t Size() const; - bool IsEmpty() const; - void Set(int32_t index, int32_t value); - void AppendByte(int32_t value); - void Reserve(int32_t capacity); - void Set(uint8_t* source, int32_t offset, int32_t count); - void Set(std::vector<uint8_t>* source, int32_t offset, int32_t count); - - private: - int32_t m_size; - int32_t m_index; - uint8_t* m_bytes; -}; - -#endif // XFA_FXBARCODE_COMMON_BC_COMMONBYTEARRAY_H_ diff --git a/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp deleted file mode 100644 index 0e7ce80e29..0000000000 --- a/xfa/fxbarcode/common/BC_CommonByteMatrix.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2008 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "core/fxcrt/fx_memory.h" -#include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" - -CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height) { - m_height = height; - m_width = width; - m_bytes = nullptr; -} -void CBC_CommonByteMatrix::Init() { - m_bytes = FX_Alloc2D(uint8_t, m_height, m_width); - FXSYS_memset(m_bytes, 0xff, m_height * m_width); -} -CBC_CommonByteMatrix::~CBC_CommonByteMatrix() { - FX_Free(m_bytes); -} -int32_t CBC_CommonByteMatrix::GetHeight() { - return m_height; -} -int32_t CBC_CommonByteMatrix::GetWidth() { - return m_width; -} -uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) { - return m_bytes[y * m_width + x]; -} -void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value) { - m_bytes[y * m_width + x] = (uint8_t)value; -} -void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value) { - m_bytes[y * m_width + x] = value; -} -void CBC_CommonByteMatrix::clear(uint8_t value) { - int32_t y; - for (y = 0; y < m_height; y++) { - int32_t x; - for (x = 0; x < m_width; x++) { - m_bytes[y * m_width + x] = value; - } - } -} -uint8_t* CBC_CommonByteMatrix::GetArray() { - return m_bytes; -} diff --git a/xfa/fxbarcode/common/BC_CommonByteMatrix.h b/xfa/fxbarcode/common/BC_CommonByteMatrix.h deleted file mode 100644 index 13cf5c330e..0000000000 --- a/xfa/fxbarcode/common/BC_CommonByteMatrix.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ -#define XFA_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ - -#include <stdint.h> - -#include "core/fxcrt/fx_system.h" - -class CBC_CommonByteMatrix { - public: - CBC_CommonByteMatrix(int32_t width, int32_t height); - virtual ~CBC_CommonByteMatrix(); - - int32_t GetHeight(); - int32_t GetWidth(); - uint8_t Get(int32_t x, int32_t y); - uint8_t* GetArray(); - - void Set(int32_t x, int32_t y, int32_t value); - void Set(int32_t x, int32_t y, uint8_t value); - void clear(uint8_t value); - virtual void Init(); - - private: - uint8_t* m_bytes; - int32_t m_width; - int32_t m_height; -}; - -#endif // XFA_FXBARCODE_COMMON_BC_COMMONBYTEMATRIX_H_ diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp deleted file mode 100644 index 82a729b067..0000000000 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" - -#include <memory> - -#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" - -CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) { - m_field = field; -} - -void CBC_ReedSolomonEncoder::Init() { - m_cachedGenerators.push_back(new CBC_ReedSolomonGF256Poly(m_field, 1)); -} - -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(size_t degree, - int32_t& e) { - if (degree >= m_cachedGenerators.size()) { - CBC_ReedSolomonGF256Poly* lastGenerator = m_cachedGenerators.back(); - for (size_t d = m_cachedGenerators.size(); d <= degree; ++d) { - std::vector<int32_t> temp = {1, m_field->Exp(d - 1)}; - CBC_ReedSolomonGF256Poly temp_poly; - temp_poly.Init(m_field, &temp, e); - if (e != BCExceptionNO) - return nullptr; - CBC_ReedSolomonGF256Poly* nextGenerator = - lastGenerator->Multiply(&temp_poly, e); - if (e != BCExceptionNO) - return nullptr; - m_cachedGenerators.push_back(nextGenerator); - lastGenerator = nextGenerator; - } - } - return m_cachedGenerators[degree]; -} - -void CBC_ReedSolomonEncoder::Encode(std::vector<int32_t>* toEncode, - size_t ecBytes, - int32_t& e) { - if (ecBytes == 0) { - e = BCExceptionNoCorrectionBytes; - return; - } - if (toEncode->size() <= ecBytes) { - e = BCExceptionNoDataBytesProvided; - return; - } - CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e); - if (e != BCExceptionNO) - return; - size_t dataBytes = toEncode->size() - ecBytes; - std::vector<int32_t> infoCoefficients(dataBytes); - for (size_t x = 0; x < dataBytes; x++) { - infoCoefficients[x] = (*toEncode)[x]; - } - CBC_ReedSolomonGF256Poly info; - info.Init(m_field, &infoCoefficients, e); - if (e != BCExceptionNO) - return; - std::unique_ptr<CBC_ReedSolomonGF256Poly> infoTemp( - info.MultiplyByMonomial(ecBytes, 1, e)); - if (e != BCExceptionNO) - return; - std::unique_ptr<std::vector<CBC_ReedSolomonGF256Poly*>> temp( - infoTemp->Divide(generator, e)); - if (e != BCExceptionNO) - return; - CBC_ReedSolomonGF256Poly* remainder = (*temp)[1]; - std::vector<int32_t>* coefficients = remainder->GetCoefficients(); - size_t numZeroCoefficients = - ecBytes > coefficients->size() ? ecBytes - coefficients->size() : 0; - for (size_t i = 0; i < numZeroCoefficients; i++) - (*toEncode)[dataBytes + i] = 0; - for (size_t y = 0; y < coefficients->size(); y++) - (*toEncode)[dataBytes + numZeroCoefficients + y] = (*coefficients)[y]; - for (size_t k = 0; k < temp->size(); k++) - delete (*temp)[k]; -} - -CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() { - for (size_t i = 0; i < m_cachedGenerators.size(); i++) - delete m_cachedGenerators[i]; -} diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h deleted file mode 100644 index 5e5c7c52d3..0000000000 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ -#define XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ - -#include <vector> - -#include "core/fxcrt/fx_basic.h" - -class CBC_ReedSolomonGF256; -class CBC_ReedSolomonGF256Poly; - -class CBC_ReedSolomonEncoder { - public: - explicit CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field); - virtual ~CBC_ReedSolomonEncoder(); - - void Encode(std::vector<int32_t>* toEncode, size_t ecBytes, int32_t& e); - virtual void Init(); - - private: - CBC_ReedSolomonGF256Poly* BuildGenerator(size_t degree, int32_t& e); - - CBC_ReedSolomonGF256* m_field; - std::vector<CBC_ReedSolomonGF256Poly*> m_cachedGenerators; -}; - -#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMON_H_ diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp deleted file mode 100644 index 349ed0789a..0000000000 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" - -#include <vector> - -#include "third_party/base/ptr_util.h" -#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" - -CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeField = nullptr; -CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = nullptr; - -void CBC_ReedSolomonGF256::Initialize() { - QRCodeField = new CBC_ReedSolomonGF256(0x011D); - QRCodeField->Init(); - DataMatrixField = new CBC_ReedSolomonGF256(0x012D); - DataMatrixField->Init(); -} - -void CBC_ReedSolomonGF256::Finalize() { - delete QRCodeField; - QRCodeField = nullptr; - delete DataMatrixField; - DataMatrixField = nullptr; -} - -CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive) { - int32_t x = 1; - for (int32_t j = 0; j < 256; j++) { - m_expTable[j] = x; - x <<= 1; - if (x >= 0x100) { - x ^= primitive; - } - } - for (int32_t i = 0; i < 255; i++) { - m_logTable[m_expTable[i]] = i; - } - m_logTable[0] = 0; -} - -void CBC_ReedSolomonGF256::Init() { - m_zero = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>(this, 0); - m_one = pdfium::MakeUnique<CBC_ReedSolomonGF256Poly>(this, 1); -} - -CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() {} - -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() const { - return m_zero.get(); -} - -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() const { - return m_one.get(); -} - -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial( - int32_t degree, - int32_t coefficient, - int32_t& e) { - if (degree < 0) { - e = BCExceptionDegreeIsNegative; - return nullptr; - } - if (coefficient == 0) { - CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e); - if (e != BCExceptionNO) - return nullptr; - return temp; - } - std::vector<int32_t> coefficients(degree + 1); - coefficients[0] = coefficient; - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(this, &coefficients, e); - if (e != BCExceptionNO) - return nullptr; - return temp; -} - -int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b) { - return a ^ b; -} - -int32_t CBC_ReedSolomonGF256::Exp(int32_t a) { - return m_expTable[a]; -} - -int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionAIsZero; - return 0; - } - return m_logTable[a]; -} - -int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t& e) { - if (a == 0) { - e = BCExceptionAIsZero; - return 0; - } - return m_expTable[255 - m_logTable[a]]; -} - -int32_t CBC_ReedSolomonGF256::Multiply(int32_t a, int32_t b) { - if (a == 0 || b == 0) { - return 0; - } - if (a == 1) { - return b; - } - if (b == 1) { - return a; - } - return m_expTable[(m_logTable[a] + m_logTable[b]) % 255]; -} diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h deleted file mode 100644 index 16f1ad17f7..0000000000 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ -#define XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ - -#include <memory> - -#include "core/fxcrt/fx_basic.h" -#include "xfa/fxbarcode/utils.h" - -class CBC_ReedSolomonGF256Poly; - -class CBC_ReedSolomonGF256 { - public: - explicit CBC_ReedSolomonGF256(int32_t primitive); - virtual ~CBC_ReedSolomonGF256(); - - static void Initialize(); - static void Finalize(); - - CBC_ReedSolomonGF256Poly* GetZero() const; - CBC_ReedSolomonGF256Poly* GetOne() const; - CBC_ReedSolomonGF256Poly* BuildMonomial(int32_t degree, - int32_t coefficient, - int32_t& e); - static int32_t AddOrSubtract(int32_t a, int32_t b); - int32_t Exp(int32_t a); - int32_t Log(int32_t a, int32_t& e); - int32_t Inverse(int32_t a, int32_t& e); - int32_t Multiply(int32_t a, int32_t b); - virtual void Init(); - - static CBC_ReedSolomonGF256* QRCodeField; - static CBC_ReedSolomonGF256* DataMatrixField; - - private: - int32_t m_expTable[256]; - int32_t m_logTable[256]; - std::unique_ptr<CBC_ReedSolomonGF256Poly> m_zero; - std::unique_ptr<CBC_ReedSolomonGF256Poly> m_one; -}; - -#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256_H_ diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp deleted file mode 100644 index e4ee30b586..0000000000 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp +++ /dev/null @@ -1,253 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -// Original code is licensed as follows: -/* - * Copyright 2007 ZXing authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" - -#include <memory> -#include <utility> - -#include "third_party/base/stl_util.h" -#include "xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" - -CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, - int32_t coefficients) { - if (!field) - return; - - m_field = field; - m_coefficients.push_back(coefficients); -} - -CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() { - m_field = nullptr; -} - -void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, - std::vector<int32_t>* coefficients, - int32_t& e) { - if (!coefficients || coefficients->empty()) { - e = BCExceptionCoefficientsSizeIsNull; - return; - } - m_field = field; - size_t coefficientsLength = coefficients->size(); - if (coefficientsLength > 1 && coefficients->front() == 0) { - size_t firstNonZero = 1; - while (firstNonZero < coefficientsLength && - (*coefficients)[firstNonZero] == 0) { - firstNonZero++; - } - if (firstNonZero == coefficientsLength) { - m_coefficients = *(m_field->GetZero()->GetCoefficients()); - } else { - m_coefficients.resize(coefficientsLength - firstNonZero); - for (size_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j++) - m_coefficients[j] = (*coefficients)[i]; - } - } else { - m_coefficients = *coefficients; - } -} - -std::vector<int32_t>* CBC_ReedSolomonGF256Poly::GetCoefficients() { - return &m_coefficients; -} - -int32_t CBC_ReedSolomonGF256Poly::GetDegree() { - return pdfium::CollectionSize<int32_t>(m_coefficients) - 1; -} - -bool CBC_ReedSolomonGF256Poly::IsZero() { - return m_coefficients.front() == 0; -} - -int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree) { - return m_coefficients[m_coefficients.size() - 1 - degree]; -} - -int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) { - if (a == 0) { - return GetCoefficients(0); - } - size_t size = m_coefficients.size(); - if (a == 1) { - int32_t result = 0; - for (size_t i = 0; i < size; i++) - result = CBC_ReedSolomonGF256::AddOrSubtract(result, m_coefficients[i]); - return result; - } - int32_t result = m_coefficients[0]; - for (size_t j = 1; j < size; j++) { - result = CBC_ReedSolomonGF256::AddOrSubtract(m_field->Multiply(a, result), - m_coefficients[j]); - } - return result; -} - -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Clone(int32_t& e) { - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &m_coefficients, e); - if (e != BCExceptionNO) - return nullptr; - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract( - CBC_ReedSolomonGF256Poly* other, - int32_t& e) { - if (IsZero()) - return other->Clone(e); - if (other->IsZero()) - return Clone(e); - - std::vector<int32_t> smallerCoefficients = m_coefficients; - std::vector<int32_t> largerCoefficients = *(other->GetCoefficients()); - if (smallerCoefficients.size() > largerCoefficients.size()) { - std::swap(smallerCoefficients, largerCoefficients); - } - std::vector<int32_t> sumDiff(largerCoefficients.size()); - size_t lengthDiff = largerCoefficients.size() - smallerCoefficients.size(); - for (size_t i = 0; i < lengthDiff; i++) { - sumDiff[i] = largerCoefficients[i]; - } - for (size_t j = lengthDiff; j < largerCoefficients.size(); j++) { - sumDiff[j] = CBC_ReedSolomonGF256::AddOrSubtract( - smallerCoefficients[j - lengthDiff], largerCoefficients[j]); - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &sumDiff, e); - if (e != BCExceptionNO) - return nullptr; - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply( - CBC_ReedSolomonGF256Poly* other, - int32_t& e) { - if (IsZero() || other->IsZero()) - return m_field->GetZero()->Clone(e); - - std::vector<int32_t> aCoefficients = m_coefficients; - std::vector<int32_t> bCoefficients = *(other->GetCoefficients()); - size_t aLength = aCoefficients.size(); - size_t bLength = bCoefficients.size(); - std::vector<int32_t> product(aLength + bLength - 1); - for (size_t i = 0; i < aLength; i++) { - int32_t aCoeff = m_coefficients[i]; - for (size_t j = 0; j < bLength; j++) { - product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract( - product[i + j], - m_field->Multiply(aCoeff, (*other->GetCoefficients())[j])); - } - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &product, e); - if (e != BCExceptionNO) - return nullptr; - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, - int32_t& e) { - if (scalar == 0) - return m_field->GetZero()->Clone(e); - if (scalar == 1) - return Clone(e); - - size_t size = m_coefficients.size(); - std::vector<int32_t> product(size); - for (size_t i = 0; i < size; i++) { - product[i] = m_field->Multiply(m_coefficients[i], scalar); - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &product, e); - if (e != BCExceptionNO) - return nullptr; - return temp; -} -CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial( - int32_t degree, - int32_t coefficient, - int32_t& e) { - if (degree < 0) { - e = BCExceptionDegreeIsNegative; - return nullptr; - } - if (coefficient == 0) - return m_field->GetZero()->Clone(e); - - size_t size = m_coefficients.size(); - std::vector<int32_t> product(size + degree); - for (size_t i = 0; i < size; i++) { - product[i] = m_field->Multiply(m_coefficients[i], coefficient); - } - CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly(); - temp->Init(m_field, &product, e); - if (e != BCExceptionNO) - return nullptr; - return temp; -} - -std::vector<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide( - CBC_ReedSolomonGF256Poly* other, - int32_t& e) { - if (other->IsZero()) { - e = BCExceptionDivideByZero; - return nullptr; - } - std::unique_ptr<CBC_ReedSolomonGF256Poly> quotient( - m_field->GetZero()->Clone(e)); - if (e != BCExceptionNO) - return nullptr; - std::unique_ptr<CBC_ReedSolomonGF256Poly> remainder(Clone(e)); - if (e != BCExceptionNO) - return nullptr; - int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); - int32_t inverseDenominatorLeadingTeam = - m_field->Inverse(denominatorLeadingTerm, e); - if (e != BCExceptionNO) - return nullptr; - while (remainder->GetDegree() >= other->GetDegree() && !remainder->IsZero()) { - int32_t degreeDifference = remainder->GetDegree() - other->GetDegree(); - int32_t scale = - m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), - inverseDenominatorLeadingTeam); - std::unique_ptr<CBC_ReedSolomonGF256Poly> term( - other->MultiplyByMonomial(degreeDifference, scale, e)); - if (e != BCExceptionNO) - return nullptr; - std::unique_ptr<CBC_ReedSolomonGF256Poly> iteratorQuotient( - m_field->BuildMonomial(degreeDifference, scale, e)); - if (e != BCExceptionNO) - return nullptr; - quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); - if (e != BCExceptionNO) - return nullptr; - remainder.reset(remainder->AddOrSubtract(term.get(), e)); - if (e != BCExceptionNO) - return nullptr; - } - std::vector<CBC_ReedSolomonGF256Poly*>* tempPtrA = - new std::vector<CBC_ReedSolomonGF256Poly*>(); - tempPtrA->push_back(quotient.release()); - tempPtrA->push_back(remainder.release()); - return tempPtrA; -} - -CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() {} diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h deleted file mode 100644 index 6fc7509399..0000000000 --- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#ifndef XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ -#define XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ - -#include <vector> - -#include "core/fxcrt/fx_basic.h" - -class CBC_ReedSolomonGF256; - -class CBC_ReedSolomonGF256Poly final { - public: - CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients); - CBC_ReedSolomonGF256Poly(); - ~CBC_ReedSolomonGF256Poly(); - void Init(CBC_ReedSolomonGF256* field, - std::vector<int32_t>* coefficients, - int32_t& e); - - int32_t GetCoefficients(int32_t degree); - std::vector<int32_t>* GetCoefficients(); - int32_t GetDegree(); - bool IsZero(); - int32_t EvaluateAt(int32_t a); - CBC_ReedSolomonGF256Poly* AddOrSubtract(CBC_ReedSolomonGF256Poly* other, - int32_t& e); - CBC_ReedSolomonGF256Poly* Multiply(CBC_ReedSolomonGF256Poly* other, - int32_t& e); - CBC_ReedSolomonGF256Poly* Multiply(int32_t scalar, int32_t& e); - CBC_ReedSolomonGF256Poly* MultiplyByMonomial(int32_t degree, - int32_t coefficient, - int32_t& e); - std::vector<CBC_ReedSolomonGF256Poly*>* Divide( - CBC_ReedSolomonGF256Poly* other, - int32_t& e); - - CBC_ReedSolomonGF256Poly* Clone(int32_t& e); - - private: - CBC_ReedSolomonGF256* m_field; - std::vector<int32_t> m_coefficients; -}; - -#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ |