diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-06-09 13:24:12 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-06-09 13:24:12 -0700 |
commit | bfa9a824a20f37c2dd7111012b46c929cf2ed8a0 (patch) | |
tree | 4cfbe682869d89900f33751c37f6a84865beeb0a /xfa/src/fxbarcode/common/reedsolomon | |
parent | b116136da234afcad018bb44a3ccb64b9ad2a554 (diff) | |
download | pdfium-bfa9a824a20f37c2dd7111012b46c929cf2ed8a0.tar.xz |
Merge to XFA: Use stdint.h types throughout PDFium.
Near-automatic merge, plus re-running scripts to update
additional usage.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1172793002
Diffstat (limited to 'xfa/src/fxbarcode/common/reedsolomon')
8 files changed, 104 insertions, 104 deletions
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp index 1fc8b6685a..1ece2add2c 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp @@ -32,11 +32,11 @@ void CBC_ReedSolomonEncoder::Init() {
m_cachedGenerators.Add(FX_NEW CBC_ReedSolomonGF256Poly(m_field, 1));
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(FX_INT32 degree, FX_INT32 &e)
+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(FX_INT32 d = m_cachedGenerators.GetSize(); d <= degree; d++) {
+ for(int32_t d = m_cachedGenerators.GetSize(); d <= degree; d++) {
CFX_Int32Array temp;
temp.Add(1);
temp.Add(m_field->Exp(d - 1));
@@ -51,13 +51,13 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonEncoder::BuildGenerator(FX_INT32 degree }
return (CBC_ReedSolomonGF256Poly*)(m_cachedGenerators[degree]);
}
-void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array *toEncode, FX_INT32 ecBytes, FX_INT32 &e)
+void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array *toEncode, int32_t ecBytes, int32_t &e)
{
if(ecBytes == 0) {
e = BCExceptionNoCorrectionBytes;
BC_EXCEPTION_CHECK_ReturnVoid(e);
}
- FX_INT32 dataBytes = toEncode->GetSize() - ecBytes;
+ int32_t dataBytes = toEncode->GetSize() - ecBytes;
if(dataBytes <= 0) {
e = BCExceptionNoDataBytesProvided;
BC_EXCEPTION_CHECK_ReturnVoid(e);
@@ -66,7 +66,7 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array *toEncode, FX_INT32 ecBytes, BC_EXCEPTION_CHECK_ReturnVoid(e);
CFX_Int32Array infoCoefficients;
infoCoefficients.SetSize(dataBytes);
- for(FX_INT32 x = 0; x < dataBytes; x++) {
+ for(int32_t x = 0; x < dataBytes; x++) {
infoCoefficients[x] = toEncode->operator [](x);
}
CBC_ReedSolomonGF256Poly info;
@@ -80,21 +80,21 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array *toEncode, FX_INT32 ecBytes, CBC_AutoPtr<CFX_PtrArray > temp(pa);
CBC_ReedSolomonGF256Poly* remainder = (CBC_ReedSolomonGF256Poly*)(temp->operator [](1));
CFX_Int32Array* coefficients = remainder->GetCoefficients();
- FX_INT32 numZeroCoefficients = ecBytes - coefficients->GetSize();
- for(FX_INT32 i = 0; i < numZeroCoefficients; i++) {
+ int32_t numZeroCoefficients = ecBytes - coefficients->GetSize();
+ for(int32_t i = 0; i < numZeroCoefficients; i++) {
(*toEncode)[dataBytes + i] = 0;
}
- for(FX_INT32 y = 0; y < coefficients->GetSize(); y++) {
+ for(int32_t y = 0; y < coefficients->GetSize(); y++) {
(*toEncode)[dataBytes + numZeroCoefficients + y] =
coefficients->operator [](y);
}
- for (FX_INT32 k = 0; k < temp->GetSize(); k++) {
+ for (int32_t k = 0; k < temp->GetSize(); k++) {
delete (CBC_ReedSolomonGF256Poly*)(*temp)[k];
}
}
CBC_ReedSolomonEncoder::~CBC_ReedSolomonEncoder()
{
- for (FX_INT32 i = 0; i < m_cachedGenerators.GetSize(); i++) {
+ 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 713f343d98..bc35ebed1f 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h @@ -13,12 +13,12 @@ class CBC_ReedSolomonEncoder private:
CBC_ReedSolomonGF256* m_field;
CFX_PtrArray m_cachedGenerators;
- CBC_ReedSolomonGF256Poly* BuildGenerator(FX_INT32 degree, FX_INT32 &e);
+ CBC_ReedSolomonGF256Poly* BuildGenerator(int32_t degree, int32_t &e);
public:
CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256 * field);
virtual ~CBC_ReedSolomonEncoder();
- void Encode(CFX_Int32Array *toEncode, FX_INT32 ecBytes, FX_INT32 &e);
+ 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 3cb5e7762f..f0e87b8e40 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp @@ -31,7 +31,7 @@ CBC_ReedSolomonDecoder::CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256* field) CBC_ReedSolomonDecoder::~CBC_ReedSolomonDecoder()
{
}
-void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, FX_INT32 twoS, FX_INT32 &e)
+void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, int32_t twoS, int32_t &e)
{
CBC_ReedSolomonGF256Poly poly;
poly.Init(m_field, received, e);
@@ -40,8 +40,8 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, FX_INT32 twoS, FX_ syndromeCoefficients.SetSize(twoS);
FX_BOOL dataMatrix = FALSE;
FX_BOOL noError = TRUE;
- for (FX_INT32 i = 0; i < twoS; i++) {
- FX_INT32 eval = poly.EvaluateAt(m_field->Exp(dataMatrix ? i + 1 : i));
+ 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;
@@ -67,8 +67,8 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, FX_INT32 twoS, FX_ CFX_Int32Array* ia2 = FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e);
BC_EXCEPTION_CHECK_ReturnVoid(e);
CBC_AutoPtr<CFX_Int32Array > errorMagnitudes(ia2);
- for (FX_INT32 k = 0; k < errorLocations->GetSize(); k++) {
- FX_INT32 position = received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e);
+ 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;
@@ -77,7 +77,7 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, FX_INT32 twoS, FX_ (*received)[position] = CBC_ReedSolomonGF256::AddOrSubtract((*received)[position], (*errorMagnitudes)[k]);
}
}
-CFX_PtrArray *CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a, CBC_ReedSolomonGF256Poly* b, FX_INT32 R, FX_INT32 &e)
+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;
@@ -120,12 +120,12 @@ CFX_PtrArray *CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(CBC_ReedSolomonGF256 CBC_ReedSolomonGF256Poly* rsg8 = m_field->GetZero()->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
CBC_AutoPtr<CBC_ReedSolomonGF256Poly> q(rsg8);
- FX_INT32 denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree());
- FX_INT32 dltInverse = m_field->Inverse(denominatorLeadingTerm, e);
+ 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())) {
- FX_INT32 degreeDiff = r->GetDegree() - rLast->GetDegree();
- FX_INT32 scale = m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse);
+ 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);
@@ -156,12 +156,12 @@ CFX_PtrArray *CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(CBC_ReedSolomonGF256 CBC_AutoPtr<CBC_ReedSolomonGF256Poly> temp6(rsg12);
t = temp6;
}
- FX_INT32 sigmaTildeAtZero = t->GetCoefficients(0);
+ int32_t sigmaTildeAtZero = t->GetCoefficients(0);
if (sigmaTildeAtZero == 0) {
e = BCExceptionIsZero;
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- FX_INT32 inverse = m_field->Inverse(sigmaTildeAtZero, e);
+ 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);
@@ -174,9 +174,9 @@ CFX_PtrArray *CBC_ReedSolomonDecoder::RunEuclideanAlgorithm(CBC_ReedSolomonGF256 temp->Add(omega.release());
return temp;
}
-CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator, FX_INT32 &e)
+CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator, int32_t &e)
{
- FX_INT32 numErrors = errorLocator->GetDegree();
+ int32_t numErrors = errorLocator->GetDegree();
if (numErrors == 1) {
CBC_AutoPtr<CFX_Int32Array > temp(FX_NEW CFX_Int32Array);
temp->Add(errorLocator->GetCoefficients(1));
@@ -185,8 +185,8 @@ CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorLocations(CBC_ReedSolomonGF256P CFX_Int32Array *tempT = FX_NEW CFX_Int32Array;
tempT->SetSize(numErrors);
CBC_AutoPtr<CFX_Int32Array > result(tempT);
- FX_INT32 ie = 0;
- for (FX_INT32 i = 1; i < 256 && ie < numErrors; i++) {
+ 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);
@@ -199,23 +199,23 @@ CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorLocations(CBC_ReedSolomonGF256P }
return result.release();
}
-CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator, CFX_Int32Array* errorLocations, FX_BOOL dataMatrix, FX_INT32 &e)
+CFX_Int32Array *CBC_ReedSolomonDecoder::FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator, CFX_Int32Array* errorLocations, FX_BOOL dataMatrix, int32_t &e)
{
- FX_INT32 s = errorLocations->GetSize();
+ int32_t s = errorLocations->GetSize();
CFX_Int32Array * temp = FX_NEW CFX_Int32Array;
temp->SetSize(s);
CBC_AutoPtr<CFX_Int32Array > result(temp);
- for (FX_INT32 i = 0; i < s; i++) {
- FX_INT32 xiInverse = m_field->Inverse(errorLocations->operator [](i), e);
+ for (int32_t i = 0; i < s; i++) {
+ int32_t xiInverse = m_field->Inverse(errorLocations->operator [](i), e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- FX_INT32 denominator = 1;
- for(FX_INT32 j = 0; j < s; j++) {
+ 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)));
}
}
- FX_INT32 temp = m_field->Inverse(denominator, temp);
+ int32_t temp = m_field->Inverse(denominator, temp);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
(*result)[i] = m_field->Multiply(errorEvaluator->EvaluateAt(xiInverse),
temp);
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h index db026edd01..edefd4a29a 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h @@ -15,9 +15,9 @@ private: public:
CBC_ReedSolomonDecoder(CBC_ReedSolomonGF256 * field);
virtual ~CBC_ReedSolomonDecoder();
- void Decode(CFX_Int32Array* received, FX_INT32 twoS, FX_INT32 &e);
- CFX_PtrArray* RunEuclideanAlgorithm(CBC_ReedSolomonGF256Poly* a, CBC_ReedSolomonGF256Poly* b, FX_INT32 R, FX_INT32 &e);
- CFX_Int32Array* FindErrorLocations(CBC_ReedSolomonGF256Poly* errorLocator, FX_INT32 &e);
- CFX_Int32Array* FindErrorMagnitudes(CBC_ReedSolomonGF256Poly* errorEvaluator, CFX_Int32Array* errorLocations, FX_BOOL dataMatrix, FX_INT32 &e);
+ 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 bb045ac24c..426ac2fbd8 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp @@ -43,17 +43,17 @@ void CBC_ReedSolomonGF256::Finalize() }
DataMatrixField = NULL;
}
-CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(FX_INT32 primitive)
+CBC_ReedSolomonGF256::CBC_ReedSolomonGF256(int32_t primitive)
{
- FX_INT32 x = 1;
- for(FX_INT32 j = 0; j < 256; j++) {
+ int32_t x = 1;
+ for(int32_t j = 0; j < 256; j++) {
m_expTable[j] = x;
x <<= 1;
if(x >= 0x100) {
x ^= primitive;
}
}
- for(FX_INT32 i = 0; i < 255; i++) {
+ for(int32_t i = 0; i < 255; i++) {
m_logTable[m_expTable[i]] = i;
}
m_logTable[0] = 0;
@@ -82,7 +82,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetOne() {
return m_one;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(FX_INT32 degree, FX_INT32 coefficient, FX_INT32 &e)
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(int32_t degree, int32_t coefficient, int32_t &e)
{
if(degree < 0) {
e = BCExceptionDegreeIsNegative;
@@ -101,15 +101,15 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::BuildMonomial(FX_INT32 degree, F BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
-FX_INT32 CBC_ReedSolomonGF256::AddOrSubtract(FX_INT32 a, FX_INT32 b)
+int32_t CBC_ReedSolomonGF256::AddOrSubtract(int32_t a, int32_t b)
{
return a ^ b;
}
-FX_INT32 CBC_ReedSolomonGF256::Exp(FX_INT32 a)
+int32_t CBC_ReedSolomonGF256::Exp(int32_t a)
{
return m_expTable[a];
}
-FX_INT32 CBC_ReedSolomonGF256::Log(FX_INT32 a, FX_INT32 &e)
+int32_t CBC_ReedSolomonGF256::Log(int32_t a, int32_t &e)
{
if(a == 0) {
e = BCExceptionAIsZero;
@@ -117,7 +117,7 @@ FX_INT32 CBC_ReedSolomonGF256::Log(FX_INT32 a, FX_INT32 &e) }
return m_logTable[a];
}
-FX_INT32 CBC_ReedSolomonGF256::Inverse(FX_INT32 a, FX_INT32 &e)
+int32_t CBC_ReedSolomonGF256::Inverse(int32_t a, int32_t &e)
{
if(a == 0) {
e = BCExceptionAIsZero;
@@ -125,7 +125,7 @@ FX_INT32 CBC_ReedSolomonGF256::Inverse(FX_INT32 a, FX_INT32 &e) }
return m_expTable[255 - m_logTable[a]];
}
-FX_INT32 CBC_ReedSolomonGF256::Multiply(FX_INT32 a, FX_INT32 b)
+int32_t CBC_ReedSolomonGF256::Multiply(int32_t a, int32_t b)
{
if(a == 0 || b == 0) {
return 0;
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h index 40e7ffef28..141c3dab36 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h @@ -14,20 +14,20 @@ public: static void Finalize();
static CBC_ReedSolomonGF256 *QRCodeFild;
static CBC_ReedSolomonGF256 *DataMatrixField;
- CBC_ReedSolomonGF256(FX_INT32 primitive);
+ CBC_ReedSolomonGF256(int32_t primitive);
virtual ~CBC_ReedSolomonGF256();
CBC_ReedSolomonGF256Poly* GetZero();
CBC_ReedSolomonGF256Poly* GetOne();
- CBC_ReedSolomonGF256Poly* BuildMonomial(FX_INT32 degree, FX_INT32 coefficient, FX_INT32 &e);
- static FX_INT32 AddOrSubtract(FX_INT32 a, FX_INT32 b);
- FX_INT32 Exp(FX_INT32 a);
- FX_INT32 Log(FX_INT32 a, FX_INT32 &e);
- FX_INT32 Inverse(FX_INT32 a, FX_INT32 &e);
- FX_INT32 Multiply(FX_INT32 a, FX_INT32 b);
+ 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:
- FX_INT32 m_expTable[256];
- FX_INT32 m_logTable[256];
+ int32_t m_expTable[256];
+ int32_t m_logTable[256];
CBC_ReedSolomonGF256Poly *m_zero;
CBC_ReedSolomonGF256Poly *m_one;
};
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp index 6476e4cf80..d59f619e25 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp @@ -23,7 +23,7 @@ #include "../../barcode.h"
#include "BC_ReedSolomonGF256.h"
#include "BC_ReedSolomonGF256Poly.h"
-CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, FX_INT32 coefficients)
+CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients)
{
if(field == NULL) {
return;
@@ -35,16 +35,16 @@ CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly() {
m_field = NULL;
}
-void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, CFX_Int32Array* coefficients, FX_INT32 &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;
- FX_INT32 coefficientsLength = coefficients->GetSize();
+ int32_t coefficientsLength = coefficients->GetSize();
if((coefficientsLength > 1 && (*coefficients)[0] == 0)) {
- FX_INT32 firstNonZero = 1;
+ int32_t firstNonZero = 1;
while((firstNonZero < coefficientsLength) && ((*coefficients)[firstNonZero] == 0)) {
firstNonZero++;
}
@@ -52,7 +52,7 @@ void CBC_ReedSolomonGF256Poly::Init(CBC_ReedSolomonGF256* field, CFX_Int32Array* m_coefficients.Copy( *(m_field->GetZero()->GetCoefficients()));
} else {
m_coefficients.SetSize(coefficientsLength - firstNonZero);
- for(FX_INT32 i = firstNonZero, j = 0; i < coefficientsLength; i++, j++) {
+ for(int32_t i = firstNonZero, j = 0; i < coefficientsLength; i++, j++) {
m_coefficients[j] = coefficients->operator [](i);
}
}
@@ -64,7 +64,7 @@ CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() {
return &m_coefficients;
}
-FX_INT32 CBC_ReedSolomonGF256Poly::GetDegree()
+int32_t CBC_ReedSolomonGF256Poly::GetDegree()
{
return m_coefficients.GetSize() - 1;
}
@@ -72,39 +72,39 @@ FX_BOOL CBC_ReedSolomonGF256Poly::IsZero() {
return m_coefficients[0] == 0;
}
-FX_INT32 CBC_ReedSolomonGF256Poly::GetCoefficients(FX_INT32 degree)
+int32_t CBC_ReedSolomonGF256Poly::GetCoefficients(int32_t degree)
{
return m_coefficients[m_coefficients.GetSize() - 1 - degree];
}
-FX_INT32 CBC_ReedSolomonGF256Poly::EvaluateAt(FX_INT32 a)
+int32_t CBC_ReedSolomonGF256Poly::EvaluateAt(int32_t a)
{
if(a == 0) {
return GetCoefficients(0);
}
- FX_INT32 size = m_coefficients.GetSize();
+ int32_t size = m_coefficients.GetSize();
if(a == 1) {
- FX_INT32 result = 0;
- for(FX_INT32 i = 0; i < size; i++) {
+ int32_t result = 0;
+ for(int32_t i = 0; i < size; i++) {
result = CBC_ReedSolomonGF256::AddOrSubtract(result, m_coefficients[i]);
}
return result;
}
- FX_INT32 result = m_coefficients[0];
- for(FX_INT32 j = 1; j < size; j++) {
+ 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(FX_INT32 &e)
+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, FX_INT32 &e)
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(CBC_ReedSolomonGF256Poly* other, int32_t &e)
{
if(IsZero()) {
return other->Clone(e);
@@ -126,11 +126,11 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(CBC_ReedSolomo }
CFX_Int32Array sumDiff;
sumDiff.SetSize(largerCoefficients.GetSize() );
- FX_INT32 lengthDiff = largerCoefficients.GetSize() - smallerCoefficients.GetSize();
- for(FX_INT32 i = 0; i < lengthDiff; i++) {
+ int32_t lengthDiff = largerCoefficients.GetSize() - smallerCoefficients.GetSize();
+ for(int32_t i = 0; i < lengthDiff; i++) {
sumDiff[i] = largerCoefficients[i];
}
- for(FX_INT32 j = lengthDiff; j < largerCoefficients.GetSize(); j++) {
+ for(int32_t j = lengthDiff; j < largerCoefficients.GetSize(); j++) {
sumDiff[j] = (CBC_ReedSolomonGF256::AddOrSubtract(smallerCoefficients[j - lengthDiff],
largerCoefficients[j]));
}
@@ -139,7 +139,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::AddOrSubtract(CBC_ReedSolomo BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(CBC_ReedSolomonGF256Poly* other, FX_INT32 &e)
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(CBC_ReedSolomonGF256Poly* other, int32_t &e)
{
if(IsZero() || other->IsZero()) {
CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e);
@@ -148,15 +148,15 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(CBC_ReedSolomonGF25 }
CFX_Int32Array aCoefficients ;
aCoefficients.Copy(m_coefficients);
- FX_INT32 aLength = m_coefficients.GetSize();
+ int32_t aLength = m_coefficients.GetSize();
CFX_Int32Array bCoefficients;
bCoefficients.Copy(*(other->GetCoefficients()));
- FX_INT32 bLength = other->GetCoefficients()->GetSize();
+ int32_t bLength = other->GetCoefficients()->GetSize();
CFX_Int32Array product;
product.SetSize(aLength + bLength - 1);
- for(FX_INT32 i = 0; i < aLength; i++) {
- FX_INT32 aCoeff = m_coefficients[i];
- for(FX_INT32 j = 0; j < bLength; j++) {
+ 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)));
@@ -167,7 +167,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(CBC_ReedSolomonGF25 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(FX_INT32 scalar, FX_INT32 &e)
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(int32_t scalar, int32_t &e)
{
if(scalar == 0) {
CBC_ReedSolomonGF256Poly *temp = m_field->GetZero()->Clone(e);
@@ -178,10 +178,10 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(FX_INT32 scalar, FX return this->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
}
- FX_INT32 size = m_coefficients.GetSize();
+ int32_t size = m_coefficients.GetSize();
CFX_Int32Array product;
product.SetSize(size);
- for(FX_INT32 i = 0; i < size; i++) {
+ for(int32_t i = 0; i < size; i++) {
product[i] = m_field->Multiply(m_coefficients[i], scalar);
}
CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly();
@@ -189,7 +189,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::Multiply(FX_INT32 scalar, FX BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
-CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(FX_INT32 degree, FX_INT32 coefficient, FX_INT32 &e)
+CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(int32_t degree, int32_t coefficient, int32_t &e)
{
if(degree < 0) {
e = BCExceptionDegreeIsNegative;
@@ -200,10 +200,10 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(FX_INT32 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
- FX_INT32 size = m_coefficients.GetSize();
+ int32_t size = m_coefficients.GetSize();
CFX_Int32Array product;
product.SetSize(size + degree);
- for(FX_INT32 i = 0; i < size; i++) {
+ for(int32_t i = 0; i < size; i++) {
product[i] = (m_field->Multiply(m_coefficients[i], coefficient));
}
CBC_ReedSolomonGF256Poly *temp = FX_NEW CBC_ReedSolomonGF256Poly();
@@ -211,7 +211,7 @@ CBC_ReedSolomonGF256Poly* CBC_ReedSolomonGF256Poly::MultiplyByMonomial(FX_INT32 BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
return temp;
}
-CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly *other, FX_INT32 &e)
+CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly *other, int32_t &e)
{
if(other->IsZero()) {
e = BCExceptionDivideByZero;
@@ -223,13 +223,13 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly *other, CBC_ReedSolomonGF256Poly* rsg2 = this->Clone(e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
CBC_AutoPtr<CBC_ReedSolomonGF256Poly> remainder(rsg2);
- FX_INT32 denominatorLeadingTerm = other->GetCoefficients(other->GetDegree());
- FX_INT32 inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeadingTerm, e);
+ 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()) {
- FX_INT32 degreeDifference = remainder->GetDegree() - other->GetDegree();
- FX_INT32 scale = m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())),
+ 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);
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h index 5c9ae6cce6..d7f1508b40 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h @@ -10,21 +10,21 @@ class CBC_ReedSolomonGF256; class CBC_ReedSolomonGF256Poly
{
public:
- CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, FX_INT32 coefficients);
+ CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients);
CBC_ReedSolomonGF256Poly();
virtual ~CBC_ReedSolomonGF256Poly();
- FX_INT32 GetCoefficients(FX_INT32 degree);
+ int32_t GetCoefficients(int32_t degree);
CFX_Int32Array* GetCoefficients();
- FX_INT32 GetDegree();
+ int32_t GetDegree();
FX_BOOL IsZero();
- FX_INT32 EvaluateAt(FX_INT32 a);
- CBC_ReedSolomonGF256Poly* AddOrSubtract(CBC_ReedSolomonGF256Poly* other, FX_INT32 &e);
- CBC_ReedSolomonGF256Poly* Multiply(CBC_ReedSolomonGF256Poly* other, FX_INT32 &e);
- CBC_ReedSolomonGF256Poly* Multiply(FX_INT32 scalar, FX_INT32 &e);
- CBC_ReedSolomonGF256Poly* MultiplyByMonomial(FX_INT32 degree, FX_INT32 coefficient, FX_INT32 &e);
- CFX_PtrArray* Divide(CBC_ReedSolomonGF256Poly *other, FX_INT32 &e);
- CBC_ReedSolomonGF256Poly* Clone(FX_INT32 &e);
- virtual void Init(CBC_ReedSolomonGF256* field, CFX_Int32Array* coefficients, FX_INT32 &e);
+ 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;
|