summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/common/reedsolomon
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
committerNico Weber <thakis@chromium.org>2015-08-04 13:00:21 -0700
commit9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch)
treec97037f398d714665aefccb6eb54d0969ad7030c /xfa/src/fxbarcode/common/reedsolomon
parent780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff)
downloadpdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz
XFA: clang-format all pdfium code.
No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \ xargs ../../buildtools/mac/clang-format -i Then manually merged https://codereview.chromium.org/1269223002/ See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none
Diffstat (limited to 'xfa/src/fxbarcode/common/reedsolomon')
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp134
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h22
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp373
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h29
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp188
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h48
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp407
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h48
8 files changed, 637 insertions, 612 deletions
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
index 1ece2add2c..286906d152 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -24,77 +24,79 @@
#include "BC_ReedSolomonGF256.h"
#include "BC_ReedSolomonGF256Poly.h"
#include "BC_ReedSolomon.h"
-CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field)
-{
- m_field = field;
+CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) {
+ m_field = field;
}
-void CBC_ReedSolomonEncoder::Init()
-{
- m_cachedGenerators.Add(FX_NEW CBC_ReedSolomonGF256Poly(m_field, 1));
+void CBC_ReedSolomonEncoder::Init() {
+ m_cachedGenerators.Add(FX_NEW CBC_ReedSolomonGF256Poly(m_field, 1));
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree, int32_t &e)
-{
- if(degree >= m_cachedGenerators.GetSize()) {
- CBC_ReedSolomonGF256Poly* lastGenerator = (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[m_cachedGenerators.GetSize() - 1]);
- for(int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) {
- CFX_Int32Array temp;
- temp.Add(1);
- temp.Add(m_field->Exp(d - 1));
- CBC_ReedSolomonGF256Poly temp_poly;
- temp_poly.Init(m_field, &temp, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_ReedSolomonGF256Poly* nextGenerator = lastGenerator->Multiply(&temp_poly, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- m_cachedGenerators.Add(nextGenerator);
- lastGenerator = nextGenerator;
- }
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(int32_t degree,
+ int32_t& e) {
+ if (degree >= m_cachedGenerators.GetSize()) {
+ CBC_ReedSolomonGF256Poly* lastGenerator =
+ (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators
+ [m_cachedGenerators.GetSize() - 1]);
+ for (int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) {
+ CFX_Int32Array temp;
+ temp.Add(1);
+ temp.Add(m_field->Exp(d - 1));
+ CBC_ReedSolomonGF256Poly temp_poly;
+ temp_poly.Init(m_field, &temp, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_ReedSolomonGF256Poly* nextGenerator =
+ lastGenerator->Multiply(&temp_poly, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ m_cachedGenerators.Add(nextGenerator);
+ lastGenerator = nextGenerator;
}
- return (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[degree]);
+ }
+ return (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[degree]);
}
-void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array *toEncode, int32_t ecBytes, int32_t &e)
-{
- if(ecBytes == 0) {
- e = BCExceptionNoCorrectionBytes;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- int32_t dataBytes = toEncode->GetSize() - ecBytes;
- if(dataBytes <= 0) {
- e = BCExceptionNoDataBytesProvided;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- CFX_Int32Array infoCoefficients;
- infoCoefficients.SetSize(dataBytes);
- for(int32_t x = 0; x < dataBytes; x++) {
- infoCoefficients[x] = toEncode->operator [](x);
- }
- CBC_ReedSolomonGF256Poly info;
- info.Init(m_field, &infoCoefficients, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_ReedSolomonGF256Poly* rsg = info.MultiplyByMonomial(ecBytes, 1, e);
+void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode,
+ int32_t ecBytes,
+ int32_t& e) {
+ if (ecBytes == 0) {
+ e = BCExceptionNoCorrectionBytes;
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> infoTemp(rsg);
- CFX_PtrArray *pa = infoTemp->Divide(generator, e);
+ }
+ int32_t dataBytes = toEncode->GetSize() - ecBytes;
+ if (dataBytes <= 0) {
+ e = BCExceptionNoDataBytesProvided;
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_PtrArray > temp(pa);
- CBC_ReedSolomonGF256Poly* remainder = (CBC_ReedSolomonGF256Poly*)(temp->operator [](1));
- CFX_Int32Array* coefficients = remainder->GetCoefficients();
- int32_t numZeroCoefficients = ecBytes - coefficients->GetSize();
- for(int32_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++) {
- delete (CBC_ReedSolomonGF256Poly*)(*temp)[k];
- }
+ }
+ CBC_ReedSolomonGF256Poly* generator = BuildGenerator(ecBytes, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CFX_Int32Array infoCoefficients;
+ infoCoefficients.SetSize(dataBytes);
+ for (int32_t x = 0; x < dataBytes; x++) {
+ infoCoefficients[x] = toEncode->operator[](x);
+ }
+ CBC_ReedSolomonGF256Poly info;
+ info.Init(m_field, &infoCoefficients, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_ReedSolomonGF256Poly* rsg = info.MultiplyByMonomial(ecBytes, 1, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> infoTemp(rsg);
+ CFX_PtrArray* pa = infoTemp->Divide(generator, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_AutoPtr<CFX_PtrArray> temp(pa);
+ CBC_ReedSolomonGF256Poly* remainder =
+ (CBC_ReedSolomonGF256Poly*)(temp->operator[](1));
+ CFX_Int32Array* coefficients = remainder->GetCoefficients();
+ int32_t numZeroCoefficients = ecBytes - coefficients->GetSize();
+ for (int32_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++) {
+ delete (CBC_ReedSolomonGF256Poly*)(*temp)[k];
+ }
}
-CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder()
-{
- for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++) {
- delete (CBC_ReedSolomonGF256Poly*)m_cachedGenerators[i];
- }
+CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder() {
+ for (int32_t i = 0; i < m_cachedGenerators.GetSize(); i++) {
+ delete (CBC_ReedSolomonGF256Poly*)m_cachedGenerators[i];
+ }
}
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
index bc35ebed1f..6725636408 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
@@ -8,17 +8,17 @@
#define _BC_READSOLOMON_H_
class CBC_ReedSolomonGF256;
class CBC_ReedSolomonGF256Poly;
-class CBC_ReedSolomonEncoder
-{
-private:
- CBC_ReedSolomonGF256* m_field;
- CFX_PtrArray m_cachedGenerators;
- CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t &e);
-public:
- CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256 * field);
- virtual ~CBC_ReedSolomonEncoder();
+class CBC_ReedSolomonEncoder {
+ private:
+ CBC_ReedSolomonGF256* m_field;
+ CFX_PtrArray m_cachedGenerators;
+ CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t& e);
- void Encode(CFX_Int32Array *toEncode, int32_t ecBytes, int32_t &e);
- virtual void Init();
+ public:
+ CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field);
+ virtual ~CBC_ReedSolomonEncoder();
+
+ void Encode(CFX_Int32Array* toEncode, int32_t ecBytes, int32_t& e);
+ virtual void Init();
};
#endif
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
index f0e87b8e40..d57efe1408 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
@@ -24,201 +24,216 @@
#include "BC_ReedSolomonGF256.h"
#include "BC_ReedSolomonGF256Poly.h"
#include "BC_ReedSolomonDecoder.h"
-CBC_ReedSolomonDecoder::CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field)
-{
- m_field = field;
+CBC_ReedSolomonDecoder::CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field) {
+ m_field = field;
}
-CBC_ReedSolomonDecoder::~CBC_ReedSolomonDecoder()
-{
-}
-void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, int32_t twoS, int32_t &e)
-{
- CBC_ReedSolomonGF256Poly poly;
- poly.Init(m_field, received, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- CFX_Int32Array syndromeCoefficients;
- syndromeCoefficients.SetSize(twoS);
- FX_BOOL dataMatrix = FALSE;
- FX_BOOL noError = TRUE;
- for (int32_t i = 0; i < twoS; i++) {
- int32_t eval = poly.EvaluateAt(m_field->Exp(dataMatrix ? i + 1 : i));
- syndromeCoefficients[twoS - 1 - i] = eval;
- if (eval != 0) {
- noError = FALSE;
- }
+CBC_ReedSolomonDecoder::~CBC_ReedSolomonDecoder() {}
+void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received,
+ int32_t twoS,
+ int32_t& e) {
+ CBC_ReedSolomonGF256Poly poly;
+ poly.Init(m_field, received, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CFX_Int32Array syndromeCoefficients;
+ syndromeCoefficients.SetSize(twoS);
+ FX_BOOL dataMatrix = FALSE;
+ FX_BOOL noError = TRUE;
+ for (int32_t i = 0; i < twoS; i++) {
+ int32_t eval = poly.EvaluateAt(m_field->Exp(dataMatrix ? i + 1 : i));
+ syndromeCoefficients[twoS - 1 - i] = eval;
+ if (eval != 0) {
+ noError = FALSE;
}
- if(noError) {
- return;
- }
- CBC_ReedSolomonGF256Poly syndrome;
- syndrome.Init(m_field, &syndromeCoefficients, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_ReedSolomonGF256Poly* rsg = m_field->BuildMonomial(twoS, 1, e);
+ }
+ if (noError) {
+ return;
+ }
+ CBC_ReedSolomonGF256Poly syndrome;
+ syndrome.Init(m_field, &syndromeCoefficients, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_ReedSolomonGF256Poly* rsg = m_field->BuildMonomial(twoS, 1, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg);
+ CFX_PtrArray* pa = RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_AutoPtr<CFX_PtrArray> sigmaOmega(pa);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(
+ (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(
+ (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]);
+ CFX_Int32Array* ia1 = FindErrorLocations(sigma.get(), e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_AutoPtr<CFX_Int32Array> errorLocations(ia1);
+ CFX_Int32Array* ia2 =
+ FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e);
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ CBC_AutoPtr<CFX_Int32Array> errorMagnitudes(ia2);
+ for (int32_t k = 0; k < errorLocations->GetSize(); k++) {
+ int32_t position =
+ received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg);
- CFX_PtrArray* pa = RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_PtrArray > sigmaOmega(pa);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma((CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega((CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]);
- CFX_Int32Array* ia1 = FindErrorLocations(sigma.get(), e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_Int32Array > errorLocations(ia1);
- CFX_Int32Array* ia2 = FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- CBC_AutoPtr<CFX_Int32Array > errorMagnitudes(ia2);
- for (int32_t k = 0; k < errorLocations->GetSize(); k++) {
- int32_t position = received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e);
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- if(position < 0) {
- e = BCExceptionBadErrorLocation;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
- (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract((*received)[position], (*errorMagnitudes)[k]);
+ if (position < 0) {
+ e = BCExceptionBadErrorLocation;
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
}
+ (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract(
+ (*received)[position], (*errorMagnitudes)[k]);
+ }
}
-CFX_PtrArray *CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a, CBC_ReedSolomonGF256Poly* b, int32_t R, int32_t &e)
-{
- if (a->GetDegree() < b->GetDegree()) {
- CBC_ReedSolomonGF256Poly* temp = a;
- a = b;
- b = temp;
+CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(
+ CBC_ReedSolomonGF256Poly* a,
+ CBC_ReedSolomonGF256Poly* b,
+ int32_t R,
+ int32_t& e) {
+ if (a->GetDegree() < b->GetDegree()) {
+ CBC_ReedSolomonGF256Poly* temp = a;
+ a = b;
+ b = temp;
+ }
+ CBC_ReedSolomonGF256Poly* rsg1 = a->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLast(rsg1);
+ CBC_ReedSolomonGF256Poly* rsg2 = b->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> r(rsg2);
+ CBC_ReedSolomonGF256Poly* rsg3 = m_field->GetOne()->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLast(rsg3);
+ CBC_ReedSolomonGF256Poly* rsg4 = m_field->GetZero()->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> s(rsg4);
+ CBC_ReedSolomonGF256Poly* rsg5 = m_field->GetZero()->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLast(rsg5);
+ CBC_ReedSolomonGF256Poly* rsg6 = m_field->GetOne()->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> t(rsg6);
+ while (r->GetDegree() >= R / 2) {
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLastLast = rLast;
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLastLast = sLast;
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLastlast = tLast;
+ rLast = r;
+ sLast = s;
+ tLast = t;
+ if (rLast->IsZero()) {
+ e = BCExceptionR_I_1IsZero;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- CBC_ReedSolomonGF256Poly* rsg1 = a->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLast(rsg1);
- CBC_ReedSolomonGF256Poly* rsg2 = b->Clone(e);
+ CBC_ReedSolomonGF256Poly* rsg7 = rLastLast->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> r(rsg2);
- CBC_ReedSolomonGF256Poly* rsg3 = m_field->GetOne()->Clone(e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rTemp(rsg7);
+ r = rTemp;
+ CBC_ReedSolomonGF256Poly* rsg8 = m_field->GetZero()->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLast(rsg3);
- CBC_ReedSolomonGF256Poly* rsg4 = m_field->GetZero()->Clone(e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> q(rsg8);
+ int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree());
+ int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> s(rsg4);
- CBC_ReedSolomonGF256Poly* rsg5 = m_field->GetZero()->Clone(e);
+ while (r->GetDegree() >= rLast->GetDegree() && !(r->IsZero())) {
+ int32_t degreeDiff = r->GetDegree() - rLast->GetDegree();
+ int32_t scale =
+ m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse);
+ CBC_ReedSolomonGF256Poly* rsgp1 =
+ m_field->BuildMonomial(degreeDiff, scale, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> build(rsgp1);
+ CBC_ReedSolomonGF256Poly* rsgp2 = q->AddOrSubtract(build.get(), e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsgp2);
+ q = temp;
+ CBC_ReedSolomonGF256Poly* rsgp3 =
+ rLast->MultiplyByMonomial(degreeDiff, scale, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> multiply(rsgp3);
+ CBC_ReedSolomonGF256Poly* rsgp4 = r->AddOrSubtract(multiply.get(), e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp3(rsgp4);
+ r = temp3;
+ }
+ CBC_ReedSolomonGF256Poly* rsg9 = q->Multiply(sLast.get(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLast(rsg5);
- CBC_ReedSolomonGF256Poly* rsg6 = m_field->GetOne()->Clone(e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg9);
+ CBC_ReedSolomonGF256Poly* rsg10 = temp1->AddOrSubtract(sLastLast.get(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> t(rsg6);
- while (r->GetDegree() >= R / 2) {
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rLastLast = rLast;
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sLastLast = sLast;
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> tLastlast = tLast;
- rLast = r;
- sLast = s;
- tLast = t;
- if (rLast->IsZero()) {
- e = BCExceptionR_I_1IsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- CBC_ReedSolomonGF256Poly* rsg7 = rLastLast->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> rTemp(rsg7);
- r = rTemp;
- CBC_ReedSolomonGF256Poly* rsg8 = m_field->GetZero()->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> q(rsg8);
- int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree());
- int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- while (r->GetDegree() >= rLast->GetDegree() && !(r->IsZero())) {
- int32_t degreeDiff = r->GetDegree() - rLast->GetDegree();
- int32_t scale = m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse);
- CBC_ReedSolomonGF256Poly* rsgp1 = m_field->BuildMonomial(degreeDiff, scale, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> build(rsgp1);
- CBC_ReedSolomonGF256Poly* rsgp2 = q->AddOrSubtract(build.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsgp2);
- q = temp;
- CBC_ReedSolomonGF256Poly* rsgp3 = rLast->MultiplyByMonomial(degreeDiff, scale, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> multiply(rsgp3);
- CBC_ReedSolomonGF256Poly* rsgp4 = r->AddOrSubtract(multiply.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp3(rsgp4);
- r = temp3;
- }
- CBC_ReedSolomonGF256Poly* rsg9 = q->Multiply(sLast.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg9);
- CBC_ReedSolomonGF256Poly* rsg10 = temp1->AddOrSubtract(sLastLast.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp2(rsg10);
- s = temp2;
- CBC_ReedSolomonGF256Poly* rsg11 = q->Multiply(tLast.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp5(rsg11);
- CBC_ReedSolomonGF256Poly* rsg12 = temp5->AddOrSubtract(tLastlast.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp6(rsg12);
- t = temp6;
- }
- int32_t sigmaTildeAtZero = t->GetCoefficients(0);
- if (sigmaTildeAtZero == 0) {
- e = BCExceptionIsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp2(rsg10);
+ s = temp2;
+ CBC_ReedSolomonGF256Poly* rsg11 = q->Multiply(tLast.get(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_ReedSolomonGF256Poly* rsg13 = t->Multiply(inverse, e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp5(rsg11);
+ CBC_ReedSolomonGF256Poly* rsg12 = temp5->AddOrSubtract(tLastlast.get(), e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(rsg13);
- CBC_ReedSolomonGF256Poly* rsg14 = r->Multiply(inverse, e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp6(rsg12);
+ t = temp6;
+ }
+ int32_t sigmaTildeAtZero = t->GetCoefficients(0);
+ if (sigmaTildeAtZero == 0) {
+ e = BCExceptionIsZero;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(rsg14);
- CFX_PtrArray *temp = FX_NEW CFX_PtrArray;
- temp->Add(sigma.release());
- temp->Add(omega.release());
- return temp;
+ }
+ int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_ReedSolomonGF256Poly* rsg13 = t->Multiply(inverse, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> sigma(rsg13);
+ CBC_ReedSolomonGF256Poly* rsg14 = r->Multiply(inverse, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> omega(rsg14);
+ CFX_PtrArray* temp = FX_NEW CFX_PtrArray;
+ temp->Add(sigma.release());
+ temp->Add(omega.release());
+ return temp;
}
-CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator, int32_t &e)
-{
- int32_t numErrors = errorLocator->GetDegree();
- if (numErrors == 1) {
- CBC_AutoPtr<CFX_Int32Array > temp(FX_NEW CFX_Int32Array);
- temp->Add(errorLocator->GetCoefficients(1));
- return temp.release();
- }
- CFX_Int32Array *tempT = FX_NEW CFX_Int32Array;
- tempT->SetSize(numErrors);
- CBC_AutoPtr<CFX_Int32Array > result(tempT);
- int32_t ie = 0;
- for (int32_t i = 1; i < 256 && ie < numErrors; i++) {
- if(errorLocator->EvaluateAt(i) == 0) {
- (*result)[ie] = m_field->Inverse(i, ie);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- ie++;
- }
+CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations(
+ CBC_ReedSolomonGF256Poly* errorLocator,
+ int32_t& e) {
+ int32_t numErrors = errorLocator->GetDegree();
+ if (numErrors == 1) {
+ CBC_AutoPtr<CFX_Int32Array> temp(FX_NEW CFX_Int32Array);
+ temp->Add(errorLocator->GetCoefficients(1));
+ return temp.release();
+ }
+ CFX_Int32Array* tempT = FX_NEW CFX_Int32Array;
+ tempT->SetSize(numErrors);
+ CBC_AutoPtr<CFX_Int32Array> result(tempT);
+ int32_t ie = 0;
+ for (int32_t i = 1; i < 256 && ie < numErrors; i++) {
+ if (errorLocator->EvaluateAt(i) == 0) {
+ (*result)[ie] = m_field->Inverse(i, ie);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ ie++;
}
- if (ie != numErrors) {
- e = BCExceptionDegreeNotMatchRoots;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- return result.release();
+ }
+ if (ie != numErrors) {
+ e = BCExceptionDegreeNotMatchRoots;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ return result.release();
}
-CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator, CFX_Int32Array* errorLocations, FX_BOOL dataMatrix, int32_t &e)
-{
- int32_t s = errorLocations->GetSize();
- CFX_Int32Array * temp = FX_NEW CFX_Int32Array;
- temp->SetSize(s);
- CBC_AutoPtr<CFX_Int32Array > result(temp);
- for (int32_t i = 0; i < s; i++) {
- int32_t xiInverse = m_field->Inverse(errorLocations->operator [](i), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- int32_t denominator = 1;
- for(int32_t j = 0; j < s; j++) {
- if(i != j) {
- denominator = m_field->Multiply(denominator,
- CBC_ReedSolomonGF256::AddOrSubtract(1, m_field->Multiply(errorLocations->operator [](j), xiInverse)));
- }
- }
- int32_t temp = m_field->Inverse(denominator, temp);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- (*result)[i] = m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse),
- temp);
+CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes(
+ CBC_ReedSolomonGF256Poly* errorEvaluator,
+ CFX_Int32Array* errorLocations,
+ FX_BOOL dataMatrix,
+ int32_t& e) {
+ int32_t s = errorLocations->GetSize();
+ CFX_Int32Array* temp = FX_NEW CFX_Int32Array;
+ temp->SetSize(s);
+ CBC_AutoPtr<CFX_Int32Array> result(temp);
+ for (int32_t i = 0; i < s; i++) {
+ int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ int32_t denominator = 1;
+ for (int32_t j = 0; j < s; j++) {
+ if (i != j) {
+ denominator = m_field->Multiply(
+ denominator, CBC_ReedSolomonGF256::AddOrSubtract(
+ 1, m_field->Multiply(errorLocations->operator[](j),
+ xiInverse)));
+ }
}
- return result.release();
+ int32_t temp = m_field->Inverse(denominator, temp);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ (*result)[i] =
+ m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse), temp);
+ }
+ return result.release();
}
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
index edefd4a29a..747755c011 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
@@ -8,16 +8,23 @@
#define _BC_REEDSOLOMONDECODER_H_
class CBC_ReedSolomonGF256;
class CBC_ReedSolomonGF256Poly;
-class CBC_ReedSolomonDecoder
-{
-private:
- CBC_ReedSolomonGF256 * m_field;
-public:
- CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256 * field);
- virtual ~CBC_ReedSolomonDecoder();
- void Decode(CFX_Int32Array* received, int32_t twoS, int32_t &e);
- CFX_PtrArray* RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a, CBC_ReedSolomonGF256Poly* b, int32_t R, int32_t &e);
- CFX_Int32Array* FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator, int32_t &e);
- CFX_Int32Array* FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator, CFX_Int32Array* errorLocations, FX_BOOL dataMatrix, int32_t &e);
+class CBC_ReedSolomonDecoder {
+ private:
+ CBC_ReedSolomonGF256* m_field;
+
+ public:
+ CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field);
+ virtual ~CBC_ReedSolomonDecoder();
+ void Decode(CFX_Int32Array* received, int32_t twoS, int32_t& e);
+ CFX_PtrArray* RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a,
+ CBC_ReedSolomonGF256Poly* b,
+ int32_t R,
+ int32_t& e);
+ CFX_Int32Array* FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator,
+ int32_t& e);
+ CFX_Int32Array* FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator,
+ CFX_Int32Array* errorLocations,
+ FX_BOOL dataMatrix,
+ int32_t& e);
};
#endif
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index 426ac2fbd8..43c8c82a4d 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -23,118 +23,108 @@
#include "../../barcode.h"
#include "BC_ReedSolomonGF256Poly.h"
#include "BC_ReedSolomonGF256.h"
-CBC_ReedSolomonGF256 *CBC_ReedSolomonGF256::QRCodeFild = NULL;
-CBC_ReedSolomonGF256 *CBC_ReedSolomonGF256::DataMatrixField = NULL;
-void CBC_ReedSolomonGF256::Initialize()
-{
- QRCodeFild = FX_NEW CBC_ReedSolomonGF256(0x011D);
- QRCodeFild->Init();
- DataMatrixField = FX_NEW CBC_ReedSolomonGF256(0x012D);
- DataMatrixField->Init();
+CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::QRCodeFild = NULL;
+CBC_ReedSolomonGF256* CBC_ReedSolomonGF256::DataMatrixField = NULL;
+void CBC_ReedSolomonGF256::Initialize() {
+ QRCodeFild = FX_NEW CBC_ReedSolomonGF256(0x011D);
+ QRCodeFild->Init();
+ DataMatrixField = FX_NEW CBC_ReedSolomonGF256(0x012D);
+ DataMatrixField->Init();
}
-void CBC_ReedSolomonGF256::Finalize()
-{
- if (QRCodeFild) {
- delete QRCodeFild;
- }
- QRCodeFild = NULL;
- if (DataMatrixField) {
- delete DataMatrixField;
- }
- DataMatrixField = NULL;
+void CBC_ReedSolomonGF256::Finalize() {
+ if (QRCodeFild) {
+ delete QRCodeFild;
+ }
+ QRCodeFild = NULL;
+ if (DataMatrixField) {
+ delete DataMatrixField;
+ }
+ DataMatrixField = NULL;
}
-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;
- }
+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;
+ }
+ for (int32_t i = 0; i < 255; i++) {
+ m_logTable[m_expTable[i]] = i;
+ }
+ m_logTable[0] = 0;
}
-void CBC_ReedSolomonGF256::Init()
-{
- m_zero = FX_NEW CBC_ReedSolomonGF256Poly(this, 0);
- m_one = FX_NEW CBC_ReedSolomonGF256Poly(this, 1);
+void CBC_ReedSolomonGF256::Init() {
+ m_zero = FX_NEW CBC_ReedSolomonGF256Poly(this, 0);
+ m_one = FX_NEW CBC_ReedSolomonGF256Poly(this, 1);
}
-CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256()
-{
- if(m_zero != NULL) {
- delete m_zero;
- m_zero = NULL;
- }
- if(m_one != NULL) {
- delete m_one;
- m_one = NULL;
- }
+CBC_ReedSolomonGF256::~CBC_ReedSolomonGF256() {
+ if (m_zero != NULL) {
+ delete m_zero;
+ m_zero = NULL;
+ }
+ if (m_one != NULL) {
+ delete m_one;
+ m_one = NULL;
+ }
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero()
-{
- return m_zero;
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() {
+ return m_zero;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne()
-{
- return m_one;
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() {
+ return m_one;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(int32_t degree, int32_t coefficient, int32_t &e)
-{
- if(degree < 0) {
- e = BCExceptionDegreeIsNegative;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- if(coefficient == 0) {
- CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
- }
- CFX_Int32Array coefficients;
- coefficients.SetSize(degree + 1);
- coefficients[0] = coefficient;
- CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly();
- temp->Init(this, &coefficients, e);
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(
+ int32_t degree,
+ int32_t coefficient,
+ int32_t& e) {
+ if (degree < 0) {
+ e = BCExceptionDegreeIsNegative;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ if (coefficient == 0) {
+ CBC_ReedSolomonGF256Poly* temp = m_zero->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
+ }
+ CFX_Int32Array coefficients;
+ coefficients.SetSize(degree + 1);
+ coefficients[0] = coefficient;
+ CBC_ReedSolomonGF256Poly* temp = FX_NEW CBC_ReedSolomonGF256Poly();
+ temp->Init(this, &coefficients, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return temp;
}
-int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b)
-{
- return a ^ b;
+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::Exp(int32_t a) {
+ return m_expTable[a];
}
-int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t &e)
-{
- if(a == 0) {
- e = BCExceptionAIsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- }
- return m_logTable[a];
+int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t& e) {
+ if (a == 0) {
+ e = BCExceptionAIsZero;
+ BC_EXCEPTION_CHECK_ReturnValue(e, 0);
+ }
+ return m_logTable[a];
}
-int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t &e)
-{
- if(a == 0) {
- e = BCExceptionAIsZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, 0);
- }
- return m_expTable[255 - m_logTable[a]];
+int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t& e) {
+ if (a == 0) {
+ e = BCExceptionAIsZero;
+ BC_EXCEPTION_CHECK_ReturnValue(e, 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];
+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/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h
index 141c3dab36..58e2f9ec3e 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h
@@ -7,28 +7,30 @@
#ifndef _BC_REEDSOLOMONGF256_H_
#define _BC_REEDSOLOMONGF256_H_
class CBC_ReedSolomonGF256Poly;
-class CBC_ReedSolomonGF256
-{
-public:
- static void Initialize();
- static void Finalize();
- static CBC_ReedSolomonGF256 *QRCodeFild;
- static CBC_ReedSolomonGF256 *DataMatrixField;
- CBC_ReedSolomonGF256(int32_t primitive);
- virtual ~CBC_ReedSolomonGF256();
- CBC_ReedSolomonGF256Poly* GetZero();
- CBC_ReedSolomonGF256Poly* GetOne();
- 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();
-private:
- int32_t m_expTable[256];
- int32_t m_logTable[256];
- CBC_ReedSolomonGF256Poly *m_zero;
- CBC_ReedSolomonGF256Poly *m_one;
+class CBC_ReedSolomonGF256 {
+ public:
+ static void Initialize();
+ static void Finalize();
+ static CBC_ReedSolomonGF256* QRCodeFild;
+ static CBC_ReedSolomonGF256* DataMatrixField;
+ CBC_ReedSolomonGF256(int32_t primitive);
+ virtual ~CBC_ReedSolomonGF256();
+ CBC_ReedSolomonGF256Poly* GetZero();
+ CBC_ReedSolomonGF256Poly* GetOne();
+ 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();
+
+ private:
+ int32_t m_expTable[256];
+ int32_t m_logTable[256];
+ CBC_ReedSolomonGF256Poly* m_zero;
+ CBC_ReedSolomonGF256Poly* m_one;
};
#endif
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index d59f619e25..1ab42eb831 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -23,235 +23,238 @@
#include "../../barcode.h"
#include "BC_ReedSolomonGF256.h"
#include "BC_ReedSolomonGF256Poly.h"
-CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients)
-{
- if(field == NULL) {
- return;
- }
- m_field = field;
- m_coefficients.Add(coefficients);
+CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field,
+ int32_t coefficients) {
+ if (field == NULL) {
+ return;
+ }
+ m_field = field;
+ m_coefficients.Add(coefficients);
}
-CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly()
-{
- m_field = NULL;
+CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() {
+ m_field = NULL;
}
-void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, CFX_Int32Array* coefficients, int32_t &e)
-{
- if(coefficients == NULL || coefficients->GetSize() == 0) {
- e = BCExceptionCoefficientsSizeIsNull;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
+void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field,
+ CFX_Int32Array* coefficients,
+ int32_t& e) {
+ if (coefficients == NULL || coefficients->GetSize() == 0) {
+ e = BCExceptionCoefficientsSizeIsNull;
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ }
+ m_field = field;
+ int32_t coefficientsLength = coefficients->GetSize();
+ if ((coefficientsLength > 1 && (*coefficients)[0] == 0)) {
+ int32_t firstNonZero = 1;
+ while ((firstNonZero < coefficientsLength) &&
+ ((*coefficients)[firstNonZero] == 0)) {
+ firstNonZero++;
}
- m_field = field;
- int32_t coefficientsLength = coefficients->GetSize();
- if((coefficientsLength > 1 && (*coefficients)[0] == 0)) {
- int32_t firstNonZero = 1;
- while((firstNonZero < coefficientsLength) && ((*coefficients)[firstNonZero] == 0)) {
- firstNonZero++;
- }
- if(firstNonZero == coefficientsLength) {
- m_coefficients.Copy( *(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);
- }
- }
+ if (firstNonZero == coefficientsLength) {
+ m_coefficients.Copy(*(m_field->GetZero()->GetCoefficients()));
} else {
- m_coefficients.Copy(*coefficients);
+ m_coefficients.SetSize(coefficientsLength - firstNonZero);
+ for (int32_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j++) {
+ m_coefficients[j] = coefficients->operator[](i);
+ }
}
+ } else {
+ m_coefficients.Copy(*coefficients);
+ }
}
-CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients()
-{
- return &m_coefficients;
+CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() {
+ return &m_coefficients;
}
-int32_t CBC_ReedSolomonGF256Poly::GetDegree()
-{
- return m_coefficients.GetSize() - 1;
+int32_t CBC_ReedSolomonGF256Poly::GetDegree() {
+ return m_coefficients.GetSize() - 1;
}
-FX_BOOL CBC_ReedSolomonGF256Poly::IsZero()
-{
- return m_coefficients[0] == 0;
+FX_BOOL CBC_ReedSolomonGF256Poly::IsZero() {
+ return m_coefficients[0] == 0;
}
-int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree)
-{
- return m_coefficients[m_coefficients.GetSize() - 1 - degree];
+int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree) {
+ return m_coefficients[m_coefficients.GetSize() - 1 - degree];
}
-int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a)
-{
- if(a == 0) {
- return GetCoefficients(0);
- }
- int32_t size = m_coefficients.GetSize();
- if(a == 1) {
- int32_t result = 0;
- for(int32_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++) {
- result = CBC_ReedSolomonGF256::AddOrSubtract(
- m_field->Multiply(a, result),
- m_coefficients[j]);
+int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a) {
+ if (a == 0) {
+ return GetCoefficients(0);
+ }
+ int32_t size = m_coefficients.GetSize();
+ if (a == 1) {
+ int32_t result = 0;
+ for (int32_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++) {
+ 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 = FX_NEW CBC_ReedSolomonGF256Poly();
- temp->Init(m_field, &m_coefficients, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Clone(int32_t& e) {
+ CBC_ReedSolomonGF256Poly* temp = FX_NEW CBC_ReedSolomonGF256Poly();
+ temp->Init(m_field, &m_coefficients, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return temp;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(CBC_ReedSolomonGF256Poly* other, int32_t &e)
-{
- if(IsZero()) {
- return other->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- if(other->IsZero()) {
- return this->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- CFX_Int32Array smallerCoefficients;
- smallerCoefficients.Copy(m_coefficients);
- CFX_Int32Array largerCoefficients;
- largerCoefficients.Copy( *(other->GetCoefficients()));
- if(smallerCoefficients.GetSize() > largerCoefficients.GetSize()) {
- CFX_Int32Array temp;
- temp.Copy(smallerCoefficients);
- smallerCoefficients.Copy(largerCoefficients);
- largerCoefficients.Copy(temp);
- }
- CFX_Int32Array sumDiff;
- sumDiff.SetSize(largerCoefficients.GetSize() );
- int32_t lengthDiff = largerCoefficients.GetSize() - smallerCoefficients.GetSize();
- for(int32_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]));
- }
- CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly();
- temp->Init(m_field, &sumDiff, e);
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(
+ CBC_ReedSolomonGF256Poly* other,
+ int32_t& e) {
+ if (IsZero()) {
+ return other->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
+ }
+ if (other->IsZero()) {
+ return this->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ CFX_Int32Array smallerCoefficients;
+ smallerCoefficients.Copy(m_coefficients);
+ CFX_Int32Array largerCoefficients;
+ largerCoefficients.Copy(*(other->GetCoefficients()));
+ if (smallerCoefficients.GetSize() > largerCoefficients.GetSize()) {
+ CFX_Int32Array temp;
+ temp.Copy(smallerCoefficients);
+ smallerCoefficients.Copy(largerCoefficients);
+ largerCoefficients.Copy(temp);
+ }
+ CFX_Int32Array sumDiff;
+ sumDiff.SetSize(largerCoefficients.GetSize());
+ int32_t lengthDiff =
+ largerCoefficients.GetSize() - smallerCoefficients.GetSize();
+ for (int32_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]));
+ }
+ CBC_ReedSolomonGF256Poly* temp = FX_NEW CBC_ReedSolomonGF256Poly();
+ temp->Init(m_field, &sumDiff, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return temp;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(CBC_ReedSolomonGF256Poly* other, int32_t &e)
-{
- if(IsZero() || other->IsZero()) {
- CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
- }
- CFX_Int32Array aCoefficients ;
- aCoefficients.Copy(m_coefficients);
- int32_t aLength = m_coefficients.GetSize();
- CFX_Int32Array bCoefficients;
- bCoefficients.Copy(*(other->GetCoefficients()));
- int32_t bLength = other->GetCoefficients()->GetSize();
- CFX_Int32Array product;
- product.SetSize(aLength + bLength - 1);
- for(int32_t i = 0; i < aLength; i++) {
- int32_t aCoeff = m_coefficients[i];
- for(int32_t j = 0; j < bLength; j++) {
- product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract(
- product[i + j],
- m_field->Multiply(aCoeff, other->GetCoefficients()->operator [](j)));
- }
- }
- CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly();
- temp->Init(m_field, &product, e);
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(
+ CBC_ReedSolomonGF256Poly* other,
+ int32_t& e) {
+ if (IsZero() || other->IsZero()) {
+ CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
-}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, int32_t &e)
-{
- if(scalar == 0) {
- CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
- }
- if(scalar == 1) {
- return this->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ CFX_Int32Array aCoefficients;
+ aCoefficients.Copy(m_coefficients);
+ int32_t aLength = m_coefficients.GetSize();
+ CFX_Int32Array bCoefficients;
+ bCoefficients.Copy(*(other->GetCoefficients()));
+ int32_t bLength = other->GetCoefficients()->GetSize();
+ CFX_Int32Array product;
+ product.SetSize(aLength + bLength - 1);
+ for (int32_t i = 0; i < aLength; i++) {
+ int32_t aCoeff = m_coefficients[i];
+ for (int32_t j = 0; j < bLength; j++) {
+ product[i + j] = CBC_ReedSolomonGF256::AddOrSubtract(
+ product[i + j],
+ m_field->Multiply(aCoeff, other->GetCoefficients()->operator[](j)));
}
- int32_t size = m_coefficients.GetSize();
- CFX_Int32Array product;
- product.SetSize(size);
- for(int32_t i = 0; i < size; i++) {
- product[i] = m_field->Multiply(m_coefficients[i], scalar);
- }
- CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly();
- temp->Init(m_field, &product, e);
+ }
+ CBC_ReedSolomonGF256Poly* temp = FX_NEW CBC_ReedSolomonGF256Poly();
+ temp->Init(m_field, &product, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return temp;
+}
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar,
+ int32_t& e) {
+ if (scalar == 0) {
+ CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
+ }
+ if (scalar == 1) {
+ return this->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ int32_t size = m_coefficients.GetSize();
+ CFX_Int32Array product;
+ product.SetSize(size);
+ for (int32_t i = 0; i < size; i++) {
+ product[i] = m_field->Multiply(m_coefficients[i], scalar);
+ }
+ CBC_ReedSolomonGF256Poly* temp = FX_NEW CBC_ReedSolomonGF256Poly();
+ temp->Init(m_field, &product, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return temp;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(int32_t degree, int32_t coefficient, int32_t &e)
-{
- if(degree < 0) {
- e = BCExceptionDegreeIsNegative;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- if(coefficient == 0) {
- CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- return temp;
- }
- int32_t size = m_coefficients.GetSize();
- CFX_Int32Array product;
- product.SetSize(size + degree);
- for(int32_t i = 0; i < size; i++) {
- product[i] = (m_field->Multiply(m_coefficients[i], coefficient));
- }
- CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly();
- temp->Init(m_field, &product, e);
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(
+ int32_t degree,
+ int32_t coefficient,
+ int32_t& e) {
+ if (degree < 0) {
+ e = BCExceptionDegreeIsNegative;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ if (coefficient == 0) {
+ CBC_ReedSolomonGF256Poly* temp = m_field->GetZero()->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
+ }
+ int32_t size = m_coefficients.GetSize();
+ CFX_Int32Array product;
+ product.SetSize(size + degree);
+ for (int32_t i = 0; i < size; i++) {
+ product[i] = (m_field->Multiply(m_coefficients[i], coefficient));
+ }
+ CBC_ReedSolomonGF256Poly* temp = FX_NEW CBC_ReedSolomonGF256Poly();
+ temp->Init(m_field, &product, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ return temp;
}
-CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly *other, int32_t &e)
-{
- if(other->IsZero()) {
- e = BCExceptionDivideByZero;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e);
+CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other,
+ int32_t& e) {
+ if (other->IsZero()) {
+ e = BCExceptionDivideByZero;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> quotient(rsg1);
- CBC_ReedSolomonGF256Poly* rsg2 = this->Clone(e);
+ }
+ CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> quotient(rsg1);
+ CBC_ReedSolomonGF256Poly* rsg2 = this->Clone(e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2);
+ int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree());
+ int32_t inverseDenominatorLeadingTeam =
+ m_field->Inverse(denominatorLeadingTerm, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ FX_BOOL bFirst = TRUE;
+ 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);
+ CBC_ReedSolomonGF256Poly* rsg3 =
+ other->MultiplyByMonomial(degreeDifference, scale, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2);
- int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree());
- int32_t inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeadingTerm, e);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> term(rsg3);
+ CBC_ReedSolomonGF256Poly* rsg4 =
+ m_field->BuildMonomial(degreeDifference, scale, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- FX_BOOL bFirst = TRUE;
- 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);
- CBC_ReedSolomonGF256Poly* rsg3 = other->MultiplyByMonomial(degreeDifference, scale, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> term(rsg3);
- CBC_ReedSolomonGF256Poly* rsg4 = m_field->BuildMonomial(degreeDifference, scale, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> iteratorQuotient(rsg4);
- CBC_ReedSolomonGF256Poly* rsg5 = quotient->AddOrSubtract(iteratorQuotient.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg5);
- quotient = temp;
- CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg6);
- remainder = temp1;
- }
- CFX_PtrArray* tempPtrA = FX_NEW CFX_PtrArray;
- tempPtrA->Add(quotient.release());
- tempPtrA->Add(remainder.release());
- return tempPtrA;
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> iteratorQuotient(rsg4);
+ CBC_ReedSolomonGF256Poly* rsg5 =
+ quotient->AddOrSubtract(iteratorQuotient.get(), e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp(rsg5);
+ quotient = temp;
+ CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp1(rsg6);
+ remainder = temp1;
+ }
+ CFX_PtrArray* tempPtrA = FX_NEW CFX_PtrArray;
+ tempPtrA->Add(quotient.release());
+ tempPtrA->Add(remainder.release());
+ return tempPtrA;
}
-CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly()
-{
- m_coefficients.RemoveAll();
+CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() {
+ m_coefficients.RemoveAll();
}
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
index d7f1508b40..9f1a5dfac7 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
@@ -7,26 +7,32 @@
#ifndef _BC_READSOLOMONGF256POLY_H_
#define _BC_READSOLOMONGF256POLY_H_
class CBC_ReedSolomonGF256;
-class CBC_ReedSolomonGF256Poly
-{
-public:
- CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients);
- CBC_ReedSolomonGF256Poly();
- virtual ~CBC_ReedSolomonGF256Poly();
- int32_t GetCoefficients(int32_t degree);
- CFX_Int32Array* GetCoefficients();
- int32_t GetDegree();
- FX_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);
- CFX_PtrArray* Divide(CBC_ReedSolomonGF256Poly *other, int32_t &e);
- CBC_ReedSolomonGF256Poly* Clone(int32_t &e);
- virtual void Init(CBC_ReedSolomonGF256* field, CFX_Int32Array* coefficients, int32_t &e);
-private:
- CBC_ReedSolomonGF256* m_field;
- CFX_Int32Array m_coefficients;
+class CBC_ReedSolomonGF256Poly {
+ public:
+ CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients);
+ CBC_ReedSolomonGF256Poly();
+ virtual ~CBC_ReedSolomonGF256Poly();
+ int32_t GetCoefficients(int32_t degree);
+ CFX_Int32Array* GetCoefficients();
+ int32_t GetDegree();
+ FX_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);
+ CFX_PtrArray* Divide(CBC_ReedSolomonGF256Poly* other, int32_t& e);
+ CBC_ReedSolomonGF256Poly* Clone(int32_t& e);
+ virtual void Init(CBC_ReedSolomonGF256* field,
+ CFX_Int32Array* coefficients,
+ int32_t& e);
+
+ private:
+ CBC_ReedSolomonGF256* m_field;
+ CFX_Int32Array m_coefficients;
};
#endif