summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/common
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode/common')
-rw-r--r--xfa/fxbarcode/common/BC_CommonBitArray.cpp63
-rw-r--r--xfa/fxbarcode/common/BC_CommonBitArray.h22
-rw-r--r--xfa/fxbarcode/common/BC_CommonBitMatrix.cpp7
-rw-r--r--xfa/fxbarcode/common/BC_CommonByteArray.cpp2
-rw-r--r--xfa/fxbarcode/common/BC_CommonByteArray.h4
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp57
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h10
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp5
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp128
-rw-r--r--xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h10
10 files changed, 159 insertions, 149 deletions
diff --git a/xfa/fxbarcode/common/BC_CommonBitArray.cpp b/xfa/fxbarcode/common/BC_CommonBitArray.cpp
index 0371837fde..f53e677389 100644
--- a/xfa/fxbarcode/common/BC_CommonBitArray.cpp
+++ b/xfa/fxbarcode/common/BC_CommonBitArray.cpp
@@ -21,49 +21,63 @@
*/
#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.Copy(array->GetBits());
+ m_bits = array->GetBits();
}
+
CBC_CommonBitArray::CBC_CommonBitArray() {
- m_bits.SetSize(1);
+ m_bits.resize(1);
m_size = 0;
}
+
CBC_CommonBitArray::CBC_CommonBitArray(int32_t size) {
- m_bits.SetSize((size + 31) >> 5);
+ m_bits.resize((size + 31) >> 5);
m_size = size;
}
-CBC_CommonBitArray::~CBC_CommonBitArray() {
- m_size = 0;
-}
-int32_t CBC_CommonBitArray::GetSize() {
+
+CBC_CommonBitArray::~CBC_CommonBitArray() {}
+
+size_t CBC_CommonBitArray::GetSize() {
return m_size;
}
-CFX_ArrayTemplate<int32_t>& CBC_CommonBitArray::GetBits() {
+
+std::vector<int32_t>& CBC_CommonBitArray::GetBits() {
return m_bits;
}
-int32_t CBC_CommonBitArray::GetSizeInBytes() {
+
+size_t CBC_CommonBitArray::GetSizeInBytes() {
return (m_size + 7) >> 3;
}
-bool CBC_CommonBitArray::Get(int32_t i) {
+
+bool CBC_CommonBitArray::Get(size_t i) {
return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0;
}
-void CBC_CommonBitArray::Set(int32_t i) {
+
+void CBC_CommonBitArray::Set(size_t i) {
m_bits[i >> 5] |= 1 << (i & 0x1F);
}
-void CBC_CommonBitArray::Flip(int32_t i) {
+
+void CBC_CommonBitArray::Flip(size_t i) {
m_bits[i >> 5] ^= 1 << (i & 0x1F);
}
-void CBC_CommonBitArray::SetBulk(int32_t i, int32_t newBits) {
+
+void CBC_CommonBitArray::SetBulk(size_t i, int32_t newBits) {
m_bits[i >> 5] = newBits;
}
+
void CBC_CommonBitArray::Clear() {
- FXSYS_memset(&m_bits[0], 0x00, m_bits.GetSize() * sizeof(int32_t));
+ for (auto& value : m_bits)
+ value = 0;
}
-bool CBC_CommonBitArray::IsRange(int32_t start,
- int32_t end,
+
+bool CBC_CommonBitArray::IsRange(size_t start,
+ size_t end,
bool value,
int32_t& e) {
if (end < start) {
@@ -95,19 +109,16 @@ bool CBC_CommonBitArray::IsRange(int32_t start,
}
return true;
}
+
int32_t* CBC_CommonBitArray::GetBitArray() {
- return &m_bits[0];
+ return m_bits.data();
}
+
void CBC_CommonBitArray::Reverse() {
- int32_t* newBits = FX_Alloc(int32_t, m_bits.GetSize());
- FXSYS_memset(newBits, 0x00, m_bits.GetSize() * sizeof(int32_t));
- int32_t size = m_size;
- int32_t i;
- for (i = 0; i < size; i++) {
- if (Get(size - i - 1)) {
+ 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);
- }
}
- FXSYS_memcpy(&m_bits[0], newBits, m_bits.GetSize() * sizeof(int32_t));
- FX_Free(newBits);
+ m_bits = std::move(newBits);
}
diff --git a/xfa/fxbarcode/common/BC_CommonBitArray.h b/xfa/fxbarcode/common/BC_CommonBitArray.h
index 6ad8ab321d..841ca99149 100644
--- a/xfa/fxbarcode/common/BC_CommonBitArray.h
+++ b/xfa/fxbarcode/common/BC_CommonBitArray.h
@@ -7,6 +7,8 @@
#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 {
@@ -16,21 +18,21 @@ class CBC_CommonBitArray {
CBC_CommonBitArray();
virtual ~CBC_CommonBitArray();
- int32_t GetSize();
- CFX_ArrayTemplate<int32_t>& GetBits();
- int32_t GetSizeInBytes();
- bool Get(int32_t i);
- void Set(int32_t i);
- void Flip(int32_t i);
- void SetBulk(int32_t i, int32_t newBits);
- bool IsRange(int32_t start, int32_t end, bool value, int32_t& e);
+ 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:
- int32_t m_size;
- CFX_ArrayTemplate<int32_t> m_bits;
+ 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
index b9b218c60f..5e65bd74cf 100644
--- a/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/xfa/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -104,7 +104,7 @@ void CBC_CommonBitMatrix::SetRegion(int32_t left,
CBC_CommonBitArray* CBC_CommonBitMatrix::GetRow(int32_t y,
CBC_CommonBitArray* row) {
CBC_CommonBitArray* rowArray = nullptr;
- if (!row || row->GetSize() < m_width) {
+ if (!row || static_cast<int32_t>(row->GetSize()) < m_width) {
rowArray = new CBC_CommonBitArray(m_width);
} else {
rowArray = new CBC_CommonBitArray(row);
@@ -123,11 +123,12 @@ void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row) {
l++;
}
}
+
void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col) {
- for (int32_t i = 0; i < col->GetBits().GetSize(); i++) {
+ 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;
}
diff --git a/xfa/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/fxbarcode/common/BC_CommonByteArray.cpp
index 050ecb0bf8..e950f0f941 100644
--- a/xfa/fxbarcode/common/BC_CommonByteArray.cpp
+++ b/xfa/fxbarcode/common/BC_CommonByteArray.cpp
@@ -85,7 +85,7 @@ void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) {
FXSYS_memcpy(m_bytes, source + offset, count);
m_index = count;
}
-void CBC_CommonByteArray::Set(CFX_ArrayTemplate<uint8_t>* source,
+void CBC_CommonByteArray::Set(std::vector<uint8_t>* source,
int32_t offset,
int32_t count) {
FX_Free(m_bytes);
diff --git a/xfa/fxbarcode/common/BC_CommonByteArray.h b/xfa/fxbarcode/common/BC_CommonByteArray.h
index 009f625a86..e1fe4c7f2e 100644
--- a/xfa/fxbarcode/common/BC_CommonByteArray.h
+++ b/xfa/fxbarcode/common/BC_CommonByteArray.h
@@ -7,6 +7,8 @@
#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
@@ -25,7 +27,7 @@ class CBC_CommonByteArray {
void AppendByte(int32_t value);
void Reserve(int32_t capacity);
void Set(uint8_t* source, int32_t offset, int32_t count);
- void Set(CFX_ArrayTemplate<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;
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 7698890366..82a729b067 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -30,18 +30,17 @@
CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) {
m_field = field;
}
+
void CBC_ReedSolomonEncoder::Init() {
- m_cachedGenerators.Add(new CBC_ReedSolomonGF256Poly(m_field, 1));
+ m_cachedGenerators.push_back(new CBC_ReedSolomonGF256Poly(m_field, 1));
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
+
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(size_t degree,
int32_t& e) {
- if (degree >= m_cachedGenerators.GetSize()) {
- CBC_ReedSolomonGF256Poly* lastGenerator =
- m_cachedGenerators[m_cachedGenerators.GetSize() - 1];
- for (int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) {
- CFX_ArrayTemplate<int32_t> temp;
- temp.Add(1);
- temp.Add(m_field->Exp(d - 1));
+ 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)
@@ -50,31 +49,31 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
lastGenerator->Multiply(&temp_poly, e);
if (e != BCExceptionNO)
return nullptr;
- m_cachedGenerators.Add(nextGenerator);
+ m_cachedGenerators.push_back(nextGenerator);
lastGenerator = nextGenerator;
}
}
return m_cachedGenerators[degree];
}
-void CBC_ReedSolomonEncoder::Encode(CFX_ArrayTemplate<int32_t>* toEncode,
- int32_t ecBytes,
+
+void CBC_ReedSolomonEncoder::Encode(std::vector<int32_t>* toEncode,
+ size_t ecBytes,
int32_t& e) {
if (ecBytes == 0) {
e = BCExceptionNoCorrectionBytes;
return;
}
- int32_t dataBytes = toEncode->GetSize() - ecBytes;
- if (dataBytes <= 0) {
+ if (toEncode->size() <= ecBytes) {
e = BCExceptionNoDataBytesProvided;
return;
}
CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e);
if (e != BCExceptionNO)
return;
- CFX_ArrayTemplate<int32_t> infoCoefficients;
- infoCoefficients.SetSize(dataBytes);
- for (int32_t x = 0; x < dataBytes; x++) {
- infoCoefficients[x] = toEncode->operator[](x);
+ 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);
@@ -84,25 +83,23 @@ void CBC_ReedSolomonEncoder::Encode(CFX_ArrayTemplate<int32_t>* toEncode,
info.MultiplyByMonomial(ecBytes, 1, e));
if (e != BCExceptionNO)
return;
- std::unique_ptr<CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>> temp(
+ std::unique_ptr<std::vector<CBC_ReedSolomonGF256Poly*>> temp(
infoTemp->Divide(generator, e));
if (e != BCExceptionNO)
return;
CBC_ReedSolomonGF256Poly* remainder = (*temp)[1];
- CFX_ArrayTemplate<int32_t>* coefficients = remainder->GetCoefficients();
- int32_t numZeroCoefficients = ecBytes - coefficients->GetSize();
- for (int32_t i = 0; i < numZeroCoefficients; i++) {
+ 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 (int32_t y = 0; y < coefficients->GetSize(); y++) {
- (*toEncode)[dataBytes + numZeroCoefficients + y] =
- coefficients->operator[](y);
- }
- for (int32_t k = 0; k < temp->GetSize(); k++) {
+ 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 (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++)
+ 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
index 95828f1a0e..5e5c7c52d3 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
@@ -7,6 +7,8 @@
#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;
@@ -17,16 +19,14 @@ class CBC_ReedSolomonEncoder {
explicit CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field);
virtual ~CBC_ReedSolomonEncoder();
- void Encode(CFX_ArrayTemplate<int32_t>* toEncode,
- int32_t ecBytes,
- int32_t& e);
+ void Encode(std::vector<int32_t>* toEncode, size_t ecBytes, int32_t& e);
virtual void Init();
private:
- CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t& e);
+ CBC_ReedSolomonGF256Poly* BuildGenerator(size_t degree, int32_t& e);
CBC_ReedSolomonGF256* m_field;
- CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*> m_cachedGenerators;
+ 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
index ce84d8e08d..349ed0789a 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -22,6 +22,8 @@
#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"
@@ -86,8 +88,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(
return nullptr;
return temp;
}
- CFX_ArrayTemplate<int32_t> coefficients;
- coefficients.SetSize(degree + 1);
+ std::vector<int32_t> coefficients(degree + 1);
coefficients[0] = coefficient;
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
temp->Init(this, &coefficients, e);
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index a0bbc025c4..e4ee30b586 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -23,7 +23,9 @@
#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,
@@ -32,69 +34,75 @@ CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field,
return;
m_field = field;
- m_coefficients.Add(coefficients);
+ m_coefficients.push_back(coefficients);
}
+
CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() {
m_field = nullptr;
}
+
void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field,
- CFX_ArrayTemplate<int32_t>* coefficients,
+ std::vector<int32_t>* coefficients,
int32_t& e) {
- if (!coefficients || coefficients->GetSize() == 0) {
+ if (!coefficients || coefficients->empty()) {
e = BCExceptionCoefficientsSizeIsNull;
return;
}
m_field = field;
- int32_t coefficientsLength = coefficients->GetSize();
- if ((coefficientsLength > 1 && (*coefficients)[0] == 0)) {
- int32_t firstNonZero = 1;
- while ((firstNonZero < coefficientsLength) &&
- ((*coefficients)[firstNonZero] == 0)) {
+ 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.Copy(*(m_field->GetZero()->GetCoefficients()));
+ m_coefficients = *(m_field->GetZero()->GetCoefficients());
} else {
- m_coefficients.SetSize(coefficientsLength - firstNonZero);
- for (int32_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j++) {
- m_coefficients[j] = coefficients->operator[](i);
- }
+ m_coefficients.resize(coefficientsLength - firstNonZero);
+ for (size_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j++)
+ m_coefficients[j] = (*coefficients)[i];
}
} else {
- m_coefficients.Copy(*coefficients);
+ m_coefficients = *coefficients;
}
}
-CFX_ArrayTemplate<int32_t>* CBC_ReedSolomonGF256Poly::GetCoefficients() {
+
+std::vector<int32_t>* CBC_ReedSolomonGF256Poly::GetCoefficients() {
return &m_coefficients;
}
+
int32_t CBC_ReedSolomonGF256Poly::GetDegree() {
- return m_coefficients.GetSize() - 1;
+ return pdfium::CollectionSize<int32_t>(m_coefficients) - 1;
}
+
bool CBC_ReedSolomonGF256Poly::IsZero() {
- return m_coefficients[0] == 0;
+ return m_coefficients.front() == 0;
}
+
int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree) {
- return m_coefficients[m_coefficients.GetSize() - 1 - degree];
+ return m_coefficients[m_coefficients.size() - 1 - degree];
}
+
int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) {
if (a == 0) {
return GetCoefficients(0);
}
- int32_t size = m_coefficients.GetSize();
+ size_t size = m_coefficients.size();
if (a == 1) {
int32_t result = 0;
- for (int32_t i = 0; i < size; i++) {
+ 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 (int32_t j = 1; j < size; j++) {
+ 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);
@@ -110,26 +118,19 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(
if (other->IsZero())
return Clone(e);
- CFX_ArrayTemplate<int32_t> smallerCoefficients;
- smallerCoefficients.Copy(m_coefficients);
- CFX_ArrayTemplate<int32_t> largerCoefficients;
- largerCoefficients.Copy(*(other->GetCoefficients()));
- if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) {
- CFX_ArrayTemplate<int32_t> temp;
- temp.Copy(smallerCoefficients);
- smallerCoefficients.Copy(largerCoefficients);
- largerCoefficients.Copy(temp);
+ std::vector<int32_t> smallerCoefficients = m_coefficients;
+ std::vector<int32_t> largerCoefficients = *(other->GetCoefficients());
+ if (smallerCoefficients.size() > largerCoefficients.size()) {
+ std::swap(smallerCoefficients, largerCoefficients);
}
- CFX_ArrayTemplate<int32_t> sumDiff;
- sumDiff.SetSize(largerCoefficients.GetSize());
- int32_t lengthDiff =
- largerCoefficients.GetSize() - smallerCoefficients.GetSize();
- for (int32_t i = 0; i < lengthDiff; i++) {
+ 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 (int32_t j = lengthDiff; j < largerCoefficients.GetSize(); j++) {
- sumDiff[j] = (CBC_ReedSolomonGF256::AddOrSubtract(
- smallerCoefficients[j - lengthDiff], largerCoefficients[j]));
+ 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);
@@ -143,20 +144,17 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(
if (IsZero() || other->IsZero())
return m_field->GetZero()->Clone(e);
- CFX_ArrayTemplate<int32_t> aCoefficients;
- aCoefficients.Copy(m_coefficients);
- int32_t aLength = m_coefficients.GetSize();
- CFX_ArrayTemplate<int32_t> bCoefficients;
- bCoefficients.Copy(*(other->GetCoefficients()));
- int32_t bLength = other->GetCoefficients()->GetSize();
- CFX_ArrayTemplate<int32_t> product;
- product.SetSize(aLength + bLength - 1);
- for (int32_t i = 0; i < aLength; i++) {
+ 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 (int32_t j = 0; j < bLength; j++) {
+ for (size_t j = 0; j < bLength; j++) {
product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract(
product[i + j],
- m_field->Multiply(aCoeff, other->GetCoefficients()->operator[](j)));
+ m_field->Multiply(aCoeff, (*other->GetCoefficients())[j]));
}
}
CBC_ReedSolomonGF256Poly* temp = new CBC_ReedSolomonGF256Poly();
@@ -172,10 +170,9 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar,
if (scalar == 1)
return Clone(e);
- int32_t size = m_coefficients.GetSize();
- CFX_ArrayTemplate<int32_t> product;
- product.SetSize(size);
- for (int32_t i = 0; i < size; i++) {
+ 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();
@@ -195,11 +192,10 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
if (coefficient == 0)
return m_field->GetZero()->Clone(e);
- int32_t size = m_coefficients.GetSize();
- CFX_ArrayTemplate<int32_t> product;
- product.SetSize(size + degree);
- for (int32_t i = 0; i < size; i++) {
- product[i] = (m_field->Multiply(m_coefficients[i], coefficient));
+ 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);
@@ -208,7 +204,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
return temp;
}
-CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide(
+std::vector<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide(
CBC_ReedSolomonGF256Poly* other,
int32_t& e) {
if (other->IsZero()) {
@@ -247,13 +243,11 @@ CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* CBC_ReedSolomonGF256Poly::Divide(
if (e != BCExceptionNO)
return nullptr;
}
- CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* tempPtrA =
- new CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>();
- tempPtrA->Add(quotient.release());
- tempPtrA->Add(remainder.release());
+ 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() {
- m_coefficients.RemoveAll();
-}
+CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() {}
diff --git a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
index ff93264e00..6fc7509399 100644
--- a/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
+++ b/xfa/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
@@ -7,6 +7,8 @@
#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;
@@ -17,11 +19,11 @@ class CBC_ReedSolomonGF256Poly final {
CBC_ReedSolomonGF256Poly();
~CBC_ReedSolomonGF256Poly();
void Init(CBC_ReedSolomonGF256* field,
- CFX_ArrayTemplate<int32_t>* coefficients,
+ std::vector<int32_t>* coefficients,
int32_t& e);
int32_t GetCoefficients(int32_t degree);
- CFX_ArrayTemplate<int32_t>* GetCoefficients();
+ std::vector<int32_t>* GetCoefficients();
int32_t GetDegree();
bool IsZero();
int32_t EvaluateAt(int32_t a);
@@ -33,7 +35,7 @@ class CBC_ReedSolomonGF256Poly final {
CBC_ReedSolomonGF256Poly* MultiplyByMonomial(int32_t degree,
int32_t coefficient,
int32_t& e);
- CFX_ArrayTemplate<CBC_ReedSolomonGF256Poly*>* Divide(
+ std::vector<CBC_ReedSolomonGF256Poly*>* Divide(
CBC_ReedSolomonGF256Poly* other,
int32_t& e);
@@ -41,7 +43,7 @@ class CBC_ReedSolomonGF256Poly final {
private:
CBC_ReedSolomonGF256* m_field;
- CFX_ArrayTemplate<int32_t> m_coefficients;
+ std::vector<int32_t> m_coefficients;
};
#endif // XFA_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_