summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/common
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/src/fxbarcode/common')
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitArray.cpp152
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitArray.h42
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp252
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitMatrix.h56
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitSource.cpp83
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitSource.h24
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteArray.cpp144
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteArray.h38
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp72
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteMatrix.h34
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp38
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h27
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp88
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonDecoderResult.h48
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonECI.cpp29
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonECI.h18
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp212
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h79
-rw-r--r--xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp250
-rw-r--r--xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h26
-rw-r--r--xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp428
-rw-r--r--xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h59
-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
30 files changed, 1749 insertions, 1699 deletions
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp b/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp
index 71c5217cf9..d0d0d8ea54 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp
@@ -22,103 +22,91 @@
#include "../barcode.h"
#include "BC_CommonBitArray.h"
-CBC_CommonBitArray::CBC_CommonBitArray(CBC_CommonBitArray* array)
-{
- m_size = array->GetSize();
- m_bits.Copy(array->GetBits());
+CBC_CommonBitArray::CBC_CommonBitArray(CBC_CommonBitArray* array) {
+ m_size = array->GetSize();
+ m_bits.Copy(array->GetBits());
}
-CBC_CommonBitArray::CBC_CommonBitArray()
-{
- m_bits.SetSize(1);
- m_size = 0;
+CBC_CommonBitArray::CBC_CommonBitArray() {
+ m_bits.SetSize(1);
+ m_size = 0;
}
-CBC_CommonBitArray::CBC_CommonBitArray(int32_t size)
-{
- m_bits.SetSize((size + 31) >> 5);
- m_size = size;
+CBC_CommonBitArray::CBC_CommonBitArray(int32_t size) {
+ m_bits.SetSize((size + 31) >> 5);
+ m_size = size;
}
-CBC_CommonBitArray::~CBC_CommonBitArray()
-{
- m_size = 0;
+CBC_CommonBitArray::~CBC_CommonBitArray() {
+ m_size = 0;
}
-int32_t CBC_CommonBitArray::GetSize()
-{
- return m_size;
+int32_t CBC_CommonBitArray::GetSize() {
+ return m_size;
}
-CFX_Int32Array& CBC_CommonBitArray::GetBits()
-{
- return m_bits;
+CFX_Int32Array& CBC_CommonBitArray::GetBits() {
+ return m_bits;
}
-int32_t CBC_CommonBitArray::GetSizeInBytes()
-{
- return (m_size + 7) >> 3;
+int32_t CBC_CommonBitArray::GetSizeInBytes() {
+ return (m_size + 7) >> 3;
}
-FX_BOOL CBC_CommonBitArray::Get(int32_t i)
-{
- return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0;
+FX_BOOL CBC_CommonBitArray::Get(int32_t i) {
+ return (m_bits[i >> 5] & (1 << (i & 0x1f))) != 0;
}
-void CBC_CommonBitArray::Set(int32_t i)
-{
- m_bits[i >> 5] |= 1 << (i & 0x1F);
+void CBC_CommonBitArray::Set(int32_t i) {
+ m_bits[i >> 5] |= 1 << (i & 0x1F);
}
-void CBC_CommonBitArray::Flip(int32_t i)
-{
- m_bits[i >> 5] ^= 1 << (i & 0x1F);
+void CBC_CommonBitArray::Flip(int32_t i) {
+ m_bits[i >> 5] ^= 1 << (i & 0x1F);
}
-void CBC_CommonBitArray::SetBulk(int32_t i, int32_t newBits)
-{
- m_bits[i >> 5] = newBits;
+void CBC_CommonBitArray::SetBulk(int32_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));
+void CBC_CommonBitArray::Clear() {
+ FXSYS_memset(&m_bits[0], 0x00, m_bits.GetSize() * sizeof(int32_t));
}
-FX_BOOL CBC_CommonBitArray::IsRange(int32_t start, int32_t end, FX_BOOL value, int32_t &e)
-{
- if (end < start) {
- e = BCExceptionEndLessThanStart;
- return FALSE;
- }
- if (end == start) {
- return TRUE;
+FX_BOOL CBC_CommonBitArray::IsRange(int32_t start,
+ int32_t end,
+ FX_BOOL value,
+ int32_t& e) {
+ if (end < start) {
+ e = BCExceptionEndLessThanStart;
+ return FALSE;
+ }
+ if (end == start) {
+ return TRUE;
+ }
+ end--;
+ int32_t firstInt = start >> 5;
+ int32_t lastInt = end >> 5;
+ int32_t i;
+ for (i = firstInt; i <= lastInt; i++) {
+ int32_t firstBit = i > firstInt ? 0 : start & 0x1F;
+ int32_t lastBit = i < lastInt ? 31 : end & 0x1F;
+ int32_t mask;
+ if (firstBit == 0 && lastBit == 31) {
+ mask = -1;
+ } else {
+ mask = 0;
+ for (int32_t j = firstBit; j <= lastBit; j++) {
+ mask |= 1 << j;
+ }
}
- end--;
- int32_t firstInt = start >> 5;
- int32_t lastInt = end >> 5;
- int32_t i;
- for (i = firstInt; i <= lastInt; i++) {
- int32_t firstBit = i > firstInt ? 0 : start & 0x1F;
- int32_t lastBit = i < lastInt ? 31 : end & 0x1F;
- int32_t mask;
- if (firstBit == 0 && lastBit == 31) {
- mask = -1;
- } else {
- mask = 0;
- for (int32_t j = firstBit; j <= lastBit; j++) {
- mask |= 1 << j;
- }
- }
- if ((m_bits[i] & mask) != (value ? mask : 0)) {
- return FALSE;
- }
+ if ((m_bits[i] & mask) != (value ? mask : 0)) {
+ return FALSE;
}
- return TRUE;
+ }
+ return TRUE;
}
-int32_t* CBC_CommonBitArray::GetBitArray()
-{
- return &m_bits[0];
+int32_t* CBC_CommonBitArray::GetBitArray() {
+ return &m_bits[0];
}
-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)) {
- newBits[i >> 5] |= 1 << (i & 0x1F);
- }
+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)) {
+ newBits[i >> 5] |= 1 << (i & 0x1F);
}
- FXSYS_memcpy(&m_bits[0], newBits, m_bits.GetSize() * sizeof(int32_t));
- FX_Free(newBits);
+ }
+ FXSYS_memcpy(&m_bits[0], newBits, m_bits.GetSize() * sizeof(int32_t));
+ FX_Free(newBits);
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitArray.h b/xfa/src/fxbarcode/common/BC_CommonBitArray.h
index 32b94f4912..f4758f7d68 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitArray.h
+++ b/xfa/src/fxbarcode/common/BC_CommonBitArray.h
@@ -6,26 +6,26 @@
#ifndef _BC_COMMONBITARRAY_H_
#define _BC_COMMONBITARRAY_H_
-class CBC_CommonBitArray
-{
-public:
- CBC_CommonBitArray(CBC_CommonBitArray* array);
- CBC_CommonBitArray(int32_t size);
- CBC_CommonBitArray();
- virtual ~CBC_CommonBitArray();
- int32_t GetSize();
- CFX_Int32Array& GetBits();
- int32_t GetSizeInBytes();
- FX_BOOL Get(int32_t i);
- void Set(int32_t i);
- void Flip(int32_t i);
- void SetBulk(int32_t i, int32_t newBits);
- FX_BOOL IsRange(int32_t start, int32_t end, FX_BOOL value, int32_t &e);
- int32_t *GetBitArray();
- void Reverse();
- void Clear();
-private:
- int32_t m_size;
- CFX_Int32Array m_bits;
+class CBC_CommonBitArray {
+ public:
+ CBC_CommonBitArray(CBC_CommonBitArray* array);
+ CBC_CommonBitArray(int32_t size);
+ CBC_CommonBitArray();
+ virtual ~CBC_CommonBitArray();
+ int32_t GetSize();
+ CFX_Int32Array& GetBits();
+ int32_t GetSizeInBytes();
+ FX_BOOL Get(int32_t i);
+ void Set(int32_t i);
+ void Flip(int32_t i);
+ void SetBulk(int32_t i, int32_t newBits);
+ FX_BOOL IsRange(int32_t start, int32_t end, FX_BOOL value, int32_t& e);
+ int32_t* GetBitArray();
+ void Reverse();
+ void Clear();
+
+ private:
+ int32_t m_size;
+ CFX_Int32Array m_bits;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
index 96dbed8d66..d5796d1263 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -23,139 +23,127 @@
#include "../barcode.h"
#include "BC_CommonBitArray.h"
#include "BC_CommonBitMatrix.h"
-CBC_CommonBitMatrix::CBC_CommonBitMatrix()
-{
- m_width = 0;
- m_height = 0;
- m_rowSize = 0;
- m_bits = NULL;
-}
-void CBC_CommonBitMatrix::Init(int32_t dimension)
-{
- m_width = dimension;
- m_height = dimension;
- int32_t rowSize = (m_height + 31) >> 5;
- m_rowSize = rowSize;
- m_bits = FX_Alloc(int32_t, m_rowSize * m_height);
- FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
-}
-void CBC_CommonBitMatrix::Init(int32_t width, int32_t height)
-{
- m_width = width;
- m_height = height;
- int32_t rowSize = (width + 31) >> 5;
- m_rowSize = rowSize;
- m_bits = FX_Alloc(int32_t, m_rowSize * m_height);
- FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
-}
-CBC_CommonBitMatrix::~CBC_CommonBitMatrix()
-{
- if (m_bits != NULL) {
- FX_Free(m_bits);
- }
- m_bits = NULL;
- m_height = m_width = m_rowSize = 0;
-}
-FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y)
-{
- int32_t offset = y * m_rowSize + (x >> 5);
- if (offset >= m_rowSize * m_height || offset < 0) {
- return false;
- }
- return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0;
-}
-int32_t* CBC_CommonBitMatrix::GetBits()
-{
- return m_bits;
-}
-void CBC_CommonBitMatrix::Set(int32_t x, int32_t y)
-{
- int32_t offset = y * m_rowSize + (x >> 5);
- if (offset >= m_rowSize * m_height || offset < 0) {
- return;
- }
- m_bits[offset] |= 1 << (x & 0x1f);
-}
-void CBC_CommonBitMatrix::Flip(int32_t x, int32_t y)
-{
- int32_t offset = y * m_rowSize + (x >> 5);
- m_bits[offset] ^= 1 << (x & 0x1f);
-}
-void CBC_CommonBitMatrix::Clear()
-{
- FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
-}
-void CBC_CommonBitMatrix::SetRegion(int32_t left, int32_t top, int32_t width, int32_t height, int32_t &e)
-{
- if (top < 0 || left < 0) {
- e = BCExceptionLeftAndTopMustBeNonnegative;
- return;
- }
- if (height < 1 || width < 1) {
- e = BCExceptionHeightAndWidthMustBeAtLeast1;
- return;
- }
- int32_t right = left + width;
- int32_t bottom = top + height;
- if (m_height < bottom || m_width < right) {
- e = BCExceptionRegionMustFitInsideMatrix;
- return;
- }
- int32_t y;
- for (y = top; y < bottom; y++) {
- int32_t offset = y * m_rowSize;
- int32_t x;
- for (x = left; x < right; x++) {
- m_bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
- }
- }
-}
-CBC_CommonBitArray* CBC_CommonBitMatrix::GetRow(int32_t y, CBC_CommonBitArray* row)
-{
- CBC_CommonBitArray* rowArray = NULL;
- if (row == NULL || row->GetSize() < m_width) {
- rowArray = FX_NEW CBC_CommonBitArray(m_width);
- } else {
- rowArray = FX_NEW CBC_CommonBitArray(row);
- }
+CBC_CommonBitMatrix::CBC_CommonBitMatrix() {
+ m_width = 0;
+ m_height = 0;
+ m_rowSize = 0;
+ m_bits = NULL;
+}
+void CBC_CommonBitMatrix::Init(int32_t dimension) {
+ m_width = dimension;
+ m_height = dimension;
+ int32_t rowSize = (m_height + 31) >> 5;
+ m_rowSize = rowSize;
+ m_bits = FX_Alloc(int32_t, m_rowSize * m_height);
+ FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+}
+void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
+ m_width = width;
+ m_height = height;
+ int32_t rowSize = (width + 31) >> 5;
+ m_rowSize = rowSize;
+ m_bits = FX_Alloc(int32_t, m_rowSize * m_height);
+ FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+}
+CBC_CommonBitMatrix::~CBC_CommonBitMatrix() {
+ if (m_bits != NULL) {
+ FX_Free(m_bits);
+ }
+ m_bits = NULL;
+ m_height = m_width = m_rowSize = 0;
+}
+FX_BOOL CBC_CommonBitMatrix::Get(int32_t x, int32_t y) {
+ int32_t offset = y * m_rowSize + (x >> 5);
+ if (offset >= m_rowSize * m_height || offset < 0) {
+ return false;
+ }
+ return ((((FX_DWORD)m_bits[offset]) >> (x & 0x1f)) & 1) != 0;
+}
+int32_t* CBC_CommonBitMatrix::GetBits() {
+ return m_bits;
+}
+void CBC_CommonBitMatrix::Set(int32_t x, int32_t y) {
+ int32_t offset = y * m_rowSize + (x >> 5);
+ if (offset >= m_rowSize * m_height || offset < 0) {
+ return;
+ }
+ m_bits[offset] |= 1 << (x & 0x1f);
+}
+void CBC_CommonBitMatrix::Flip(int32_t x, int32_t y) {
+ int32_t offset = y * m_rowSize + (x >> 5);
+ m_bits[offset] ^= 1 << (x & 0x1f);
+}
+void CBC_CommonBitMatrix::Clear() {
+ FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+}
+void CBC_CommonBitMatrix::SetRegion(int32_t left,
+ int32_t top,
+ int32_t width,
+ int32_t height,
+ int32_t& e) {
+ if (top < 0 || left < 0) {
+ e = BCExceptionLeftAndTopMustBeNonnegative;
+ return;
+ }
+ if (height < 1 || width < 1) {
+ e = BCExceptionHeightAndWidthMustBeAtLeast1;
+ return;
+ }
+ int32_t right = left + width;
+ int32_t bottom = top + height;
+ if (m_height < bottom || m_width < right) {
+ e = BCExceptionRegionMustFitInsideMatrix;
+ return;
+ }
+ int32_t y;
+ for (y = top; y < bottom; y++) {
int32_t offset = y * m_rowSize;
int32_t x;
- for (x = 0; x < m_rowSize; x++) {
- rowArray->SetBulk(x << 5, m_bits[offset + x]);
- }
- return rowArray;
-}
-void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row)
-{
- int32_t l = y * m_rowSize;
- for (int32_t i = 0; i < m_rowSize; i++) {
- m_bits[l] = row->GetBitArray()[i];
- l++;
- }
-}
-void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col)
-{
- for (int32_t i = 0; i < col->GetBits().GetSize(); i++) {
- m_bits[i * m_rowSize + y] = col->GetBitArray()[i];
- }
-}
-int32_t CBC_CommonBitMatrix::GetWidth()
-{
- return m_width;
-}
-int32_t CBC_CommonBitMatrix::GetHeight()
-{
- return m_height;
-}
-int32_t CBC_CommonBitMatrix::GetRowSize()
-{
- return m_rowSize;
-}
-int32_t CBC_CommonBitMatrix::GetDimension(int32_t &e)
-{
- if (m_width != m_height) {
- e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix;
- return 0;
+ for (x = left; x < right; x++) {
+ m_bits[offset + (x >> 5)] |= 1 << (x & 0x1f);
}
- return m_width;
+ }
+}
+CBC_CommonBitArray* CBC_CommonBitMatrix::GetRow(int32_t y,
+ CBC_CommonBitArray* row) {
+ CBC_CommonBitArray* rowArray = NULL;
+ if (row == NULL || row->GetSize() < m_width) {
+ rowArray = FX_NEW CBC_CommonBitArray(m_width);
+ } else {
+ rowArray = FX_NEW CBC_CommonBitArray(row);
+ }
+ int32_t offset = y * m_rowSize;
+ int32_t x;
+ for (x = 0; x < m_rowSize; x++) {
+ rowArray->SetBulk(x << 5, m_bits[offset + x]);
+ }
+ return rowArray;
+}
+void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row) {
+ int32_t l = y * m_rowSize;
+ for (int32_t i = 0; i < m_rowSize; i++) {
+ m_bits[l] = row->GetBitArray()[i];
+ l++;
+ }
+}
+void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col) {
+ for (int32_t i = 0; i < col->GetBits().GetSize(); i++) {
+ m_bits[i * m_rowSize + y] = col->GetBitArray()[i];
+ }
+}
+int32_t CBC_CommonBitMatrix::GetWidth() {
+ return m_width;
+}
+int32_t CBC_CommonBitMatrix::GetHeight() {
+ return m_height;
+}
+int32_t CBC_CommonBitMatrix::GetRowSize() {
+ return m_rowSize;
+}
+int32_t CBC_CommonBitMatrix::GetDimension(int32_t& e) {
+ if (m_width != m_height) {
+ e = BCExceptionCanNotCallGetDimensionOnNonSquareMatrix;
+ return 0;
+ }
+ return m_width;
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h
index 4c129fdb82..42cbedf00c 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h
+++ b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h
@@ -7,31 +7,35 @@
#ifndef _BC_COMMONBITMATRIX_H_
#define _BC_COMMONBITMATRIX_H_
class CBC_CommonBitArray;
-class CBC_CommonBitMatrix
-{
-public:
- CBC_CommonBitMatrix();
- virtual ~CBC_CommonBitMatrix();
- FX_BOOL Get(int32_t x, int32_t y);
- void Set(int32_t x, int32_t y);
- void Flip(int32_t x, int32_t y);
- void Clear();
- void SetRegion(int32_t left, int32_t top, int32_t width, int32_t height, int32_t &e);
- CBC_CommonBitArray* GetRow(int32_t y, CBC_CommonBitArray* row);
- void SetRow(int32_t y, CBC_CommonBitArray* row);
- CBC_CommonBitArray* GetCol(int32_t y, CBC_CommonBitArray* row);
- void SetCol(int32_t y, CBC_CommonBitArray* col);
- int32_t GetWidth();
- int32_t GetHeight();
- int32_t GetRowSize();
- int32_t GetDimension(int32_t &e);
- virtual void Init(int32_t dimension);
- virtual void Init(int32_t width, int32_t height);
- int32_t* GetBits();
-private:
- int32_t m_width;
- int32_t m_height;
- int32_t m_rowSize;
- int32_t* m_bits;
+class CBC_CommonBitMatrix {
+ public:
+ CBC_CommonBitMatrix();
+ virtual ~CBC_CommonBitMatrix();
+ FX_BOOL Get(int32_t x, int32_t y);
+ void Set(int32_t x, int32_t y);
+ void Flip(int32_t x, int32_t y);
+ void Clear();
+ void SetRegion(int32_t left,
+ int32_t top,
+ int32_t width,
+ int32_t height,
+ int32_t& e);
+ CBC_CommonBitArray* GetRow(int32_t y, CBC_CommonBitArray* row);
+ void SetRow(int32_t y, CBC_CommonBitArray* row);
+ CBC_CommonBitArray* GetCol(int32_t y, CBC_CommonBitArray* row);
+ void SetCol(int32_t y, CBC_CommonBitArray* col);
+ int32_t GetWidth();
+ int32_t GetHeight();
+ int32_t GetRowSize();
+ int32_t GetDimension(int32_t& e);
+ virtual void Init(int32_t dimension);
+ virtual void Init(int32_t width, int32_t height);
+ int32_t* GetBits();
+
+ private:
+ int32_t m_width;
+ int32_t m_height;
+ int32_t m_rowSize;
+ int32_t* m_bits;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp b/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp
index f32d634a5a..20b0d2accc 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp
@@ -22,55 +22,50 @@
#include "../barcode.h"
#include "BC_CommonBitSource.h"
-CBC_CommonBitSource::CBC_CommonBitSource(CFX_ByteArray* bytes)
-{
- m_bytes.Copy((*bytes));
- m_bitOffset = 0;
- m_byteOffset = 0;
+CBC_CommonBitSource::CBC_CommonBitSource(CFX_ByteArray* bytes) {
+ m_bytes.Copy((*bytes));
+ m_bitOffset = 0;
+ m_byteOffset = 0;
}
-CBC_CommonBitSource::~CBC_CommonBitSource()
-{
-}
-int32_t CBC_CommonBitSource::ReadBits(int32_t numBits, int32_t &e)
-{
- if (numBits < 1 || numBits > 32) {
- e = BCExceptionIllegalArgument;
- return 0;
+CBC_CommonBitSource::~CBC_CommonBitSource() {}
+int32_t CBC_CommonBitSource::ReadBits(int32_t numBits, int32_t& e) {
+ if (numBits < 1 || numBits > 32) {
+ e = BCExceptionIllegalArgument;
+ return 0;
+ }
+ int32_t result = 0;
+ if (m_bitOffset > 0) {
+ int32_t bitsLeft = 8 - m_bitOffset;
+ int32_t toRead = numBits < bitsLeft ? numBits : bitsLeft;
+ int32_t bitsToNotRead = bitsLeft - toRead;
+ int32_t mask = (0xff >> (8 - toRead)) << bitsToNotRead;
+ result = (m_bytes[m_byteOffset] & mask) >> bitsToNotRead;
+ numBits -= toRead;
+ m_bitOffset += toRead;
+ if (m_bitOffset == 8) {
+ m_bitOffset = 0;
+ m_byteOffset++;
}
- int32_t result = 0;
- if (m_bitOffset > 0) {
- int32_t bitsLeft = 8 - m_bitOffset;
- int32_t toRead = numBits < bitsLeft ? numBits : bitsLeft;
- int32_t bitsToNotRead = bitsLeft - toRead;
- int32_t mask = (0xff >> (8 - toRead)) << bitsToNotRead;
- result = (m_bytes[m_byteOffset] & mask) >> bitsToNotRead;
- numBits -= toRead;
- m_bitOffset += toRead;
- if (m_bitOffset == 8) {
- m_bitOffset = 0;
- m_byteOffset++;
- }
+ }
+ if (numBits > 0) {
+ while (numBits >= 8) {
+ result = (result << 8) | (m_bytes[m_byteOffset] & 0xff);
+ m_byteOffset++;
+ numBits -= 8;
}
if (numBits > 0) {
- while(numBits >= 8) {
- result = (result << 8) | (m_bytes[m_byteOffset] & 0xff);
- m_byteOffset++;
- numBits -= 8;
- }
- if (numBits > 0) {
- int32_t bitsToNotRead = 8 - numBits;
- int32_t mask = (0xff >> bitsToNotRead) << bitsToNotRead;
- result = (result << numBits) | ((m_bytes[m_byteOffset] & mask) >> bitsToNotRead);
- m_bitOffset += numBits;
- }
+ int32_t bitsToNotRead = 8 - numBits;
+ int32_t mask = (0xff >> bitsToNotRead) << bitsToNotRead;
+ result = (result << numBits) |
+ ((m_bytes[m_byteOffset] & mask) >> bitsToNotRead);
+ m_bitOffset += numBits;
}
- return result;
+ }
+ return result;
}
-int32_t CBC_CommonBitSource::Available()
-{
- return 8 * (m_bytes.GetSize() - m_byteOffset) - m_bitOffset;
+int32_t CBC_CommonBitSource::Available() {
+ return 8 * (m_bytes.GetSize() - m_byteOffset) - m_bitOffset;
}
-int32_t CBC_CommonBitSource::getByteOffset()
-{
- return m_byteOffset;
+int32_t CBC_CommonBitSource::getByteOffset() {
+ return m_byteOffset;
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitSource.h b/xfa/src/fxbarcode/common/BC_CommonBitSource.h
index 278b4b6a1c..ccb66bf49b 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitSource.h
+++ b/xfa/src/fxbarcode/common/BC_CommonBitSource.h
@@ -6,17 +6,17 @@
#ifndef _BC_COMMONBITSOURCE_H_
#define _BC_COMMONBITSOURCE_H_
-class CBC_CommonBitSource
-{
-public:
- CBC_CommonBitSource(CFX_ByteArray *bytes);
- virtual ~CBC_CommonBitSource();
- int32_t ReadBits(int32_t numBits, int32_t &e);
- int32_t Available();
- int32_t getByteOffset();
-private:
- CFX_ByteArray m_bytes;
- int32_t m_byteOffset;
- int32_t m_bitOffset;
+class CBC_CommonBitSource {
+ public:
+ CBC_CommonBitSource(CFX_ByteArray* bytes);
+ virtual ~CBC_CommonBitSource();
+ int32_t ReadBits(int32_t numBits, int32_t& e);
+ int32_t Available();
+ int32_t getByteOffset();
+
+ private:
+ CFX_ByteArray m_bytes;
+ int32_t m_byteOffset;
+ int32_t m_bitOffset;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
index bec79d2ba0..0ad07fd981 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
@@ -22,93 +22,83 @@
#include "../barcode.h"
#include "BC_CommonByteArray.h"
-CBC_CommonByteArray::CBC_CommonByteArray()
-{
- m_bytes = NULL;
- m_size = 0;
- m_index = 0;
-}
-CBC_CommonByteArray::CBC_CommonByteArray(int32_t size)
-{
- m_size = size;
- m_bytes = FX_Alloc(uint8_t, size);
- FXSYS_memset(m_bytes, 0, size);
- m_index = 0;
+CBC_CommonByteArray::CBC_CommonByteArray() {
+ m_bytes = NULL;
+ m_size = 0;
+ m_index = 0;
}
-CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size)
-{
- m_size = size;
- m_bytes = FX_Alloc(uint8_t, size);
- FXSYS_memcpy(m_bytes, byteArray, size);
- m_index = size;
+CBC_CommonByteArray::CBC_CommonByteArray(int32_t size) {
+ m_size = size;
+ m_bytes = FX_Alloc(uint8_t, size);
+ FXSYS_memset(m_bytes, 0, size);
+ m_index = 0;
}
-CBC_CommonByteArray::~CBC_CommonByteArray()
-{
- if ( m_bytes != NULL) {
- FX_Free( m_bytes );
- m_bytes = NULL;
- }
- m_index = 0;
- m_size = 0;
+CBC_CommonByteArray::CBC_CommonByteArray(uint8_t* byteArray, int32_t size) {
+ m_size = size;
+ m_bytes = FX_Alloc(uint8_t, size);
+ FXSYS_memcpy(m_bytes, byteArray, size);
+ m_index = size;
}
-int32_t CBC_CommonByteArray::At(int32_t index)
-{
- return m_bytes[index] & 0xff;
+CBC_CommonByteArray::~CBC_CommonByteArray() {
+ if (m_bytes != NULL) {
+ FX_Free(m_bytes);
+ m_bytes = NULL;
+ }
+ m_index = 0;
+ m_size = 0;
}
-void CBC_CommonByteArray::Set(int32_t index, int32_t value)
-{
- m_bytes[index] = (uint8_t) value;
+int32_t CBC_CommonByteArray::At(int32_t index) {
+ return m_bytes[index] & 0xff;
}
-int32_t CBC_CommonByteArray::Size()
-{
- return m_size;
+void CBC_CommonByteArray::Set(int32_t index, int32_t value) {
+ m_bytes[index] = (uint8_t)value;
}
-FX_BOOL CBC_CommonByteArray::IsEmpty()
-{
- return m_size == 0;
+int32_t CBC_CommonByteArray::Size() {
+ return m_size;
}
-void CBC_CommonByteArray::AppendByte(int32_t value)
-{
- if (m_size == 0 || m_index >= m_size) {
- int32_t newSize = FX_MAX(32, m_size << 1);
- Reserve(newSize);
- }
- m_bytes[m_index] = (uint8_t)value;
- m_index++;
+FX_BOOL CBC_CommonByteArray::IsEmpty() {
+ return m_size == 0;
}
-void CBC_CommonByteArray::Reserve(int32_t capacity)
-{
- if (m_bytes == NULL || m_size < capacity) {
- uint8_t *newArray = FX_Alloc(uint8_t, capacity);
- FXSYS_memset(newArray, 0, capacity);
- if (m_bytes != NULL) {
- FXSYS_memcpy(newArray, m_bytes, m_size);
- FX_Free( m_bytes );
- }
- m_bytes = newArray;
- m_size = capacity;
- }
+void CBC_CommonByteArray::AppendByte(int32_t value) {
+ if (m_size == 0 || m_index >= m_size) {
+ int32_t newSize = FX_MAX(32, m_size << 1);
+ Reserve(newSize);
+ }
+ m_bytes[m_index] = (uint8_t)value;
+ m_index++;
}
-void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count)
-{
+void CBC_CommonByteArray::Reserve(int32_t capacity) {
+ if (m_bytes == NULL || m_size < capacity) {
+ uint8_t* newArray = FX_Alloc(uint8_t, capacity);
+ FXSYS_memset(newArray, 0, capacity);
if (m_bytes != NULL) {
- FX_Free( m_bytes );
+ FXSYS_memcpy(newArray, m_bytes, m_size);
+ FX_Free(m_bytes);
}
- m_bytes = FX_Alloc(uint8_t, count);
- m_size = count;
- FXSYS_memcpy(m_bytes, source + offset, count);
- m_index = count;
+ m_bytes = newArray;
+ m_size = capacity;
+ }
}
-void CBC_CommonByteArray::Set(CFX_ByteArray* source, int32_t offset, int32_t count)
-{
- if (m_bytes != NULL) {
- FX_Free( m_bytes );
- }
- m_bytes = FX_Alloc(uint8_t, count);
- m_size = count;
- int32_t i;
- for(i = 0; i < count; i++) {
- m_bytes[i] = source->operator [](i + offset);
- }
- m_index = m_size;
+void CBC_CommonByteArray::Set(uint8_t* source, int32_t offset, int32_t count) {
+ if (m_bytes != NULL) {
+ FX_Free(m_bytes);
+ }
+ m_bytes = FX_Alloc(uint8_t, count);
+ m_size = count;
+ FXSYS_memcpy(m_bytes, source + offset, count);
+ m_index = count;
+}
+void CBC_CommonByteArray::Set(CFX_ByteArray* source,
+ int32_t offset,
+ int32_t count) {
+ if (m_bytes != NULL) {
+ FX_Free(m_bytes);
+ }
+ m_bytes = FX_Alloc(uint8_t, count);
+ m_size = count;
+ int32_t i;
+ for (i = 0; i < count; i++) {
+ m_bytes[i] = source->operator[](i + offset);
+ }
+ m_index = m_size;
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.h b/xfa/src/fxbarcode/common/BC_CommonByteArray.h
index 234b25db69..12e214c0c2 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteArray.h
+++ b/xfa/src/fxbarcode/common/BC_CommonByteArray.h
@@ -6,24 +6,24 @@
#ifndef _BC_COMMONBYTEARRAY_H_
#define _BC_COMMONBYTEARRAY_H_
-class CBC_CommonByteArray
-{
-private:
- int32_t m_size;
- int32_t m_index;
- uint8_t* m_bytes;
-public:
- CBC_CommonByteArray();
- CBC_CommonByteArray(int32_t size);
- CBC_CommonByteArray(uint8_t* byteArray, int32_t size);
- virtual ~CBC_CommonByteArray();
- int32_t At(int32_t index);
- void Set(int32_t index, int32_t value);
- int32_t Size();
- FX_BOOL IsEmpty();
- void AppendByte(int32_t value);
- void Reserve(int32_t capacity);
- void Set(uint8_t* source, int32_t offset, int32_t count);
- void Set(CFX_ByteArray* source, int32_t offset, int32_t count);
+class CBC_CommonByteArray {
+ private:
+ int32_t m_size;
+ int32_t m_index;
+ uint8_t* m_bytes;
+
+ public:
+ CBC_CommonByteArray();
+ CBC_CommonByteArray(int32_t size);
+ CBC_CommonByteArray(uint8_t* byteArray, int32_t size);
+ virtual ~CBC_CommonByteArray();
+ int32_t At(int32_t index);
+ void Set(int32_t index, int32_t value);
+ int32_t Size();
+ FX_BOOL IsEmpty();
+ void AppendByte(int32_t value);
+ void Reserve(int32_t capacity);
+ void Set(uint8_t* source, int32_t offset, int32_t count);
+ void Set(CFX_ByteArray* source, int32_t offset, int32_t count);
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
index d963eb9f5e..ee4eee26a9 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
@@ -22,55 +22,45 @@
#include "../barcode.h"
#include "BC_CommonByteMatrix.h"
-CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height)
-{
- m_height = height;
- m_width = width;
- m_bytes = NULL;
+CBC_CommonByteMatrix::CBC_CommonByteMatrix(int32_t width, int32_t height) {
+ m_height = height;
+ m_width = width;
+ m_bytes = NULL;
}
-void CBC_CommonByteMatrix::Init()
-{
- m_bytes = FX_Alloc(uint8_t, m_height * m_width);
- FXSYS_memset(m_bytes, 0xff, m_height * m_width);
+void CBC_CommonByteMatrix::Init() {
+ m_bytes = FX_Alloc(uint8_t, m_height * m_width);
+ FXSYS_memset(m_bytes, 0xff, m_height * m_width);
}
-CBC_CommonByteMatrix::~CBC_CommonByteMatrix()
-{
- if(m_bytes != NULL) {
- FX_Free(m_bytes);
- m_bytes = NULL;
- }
+CBC_CommonByteMatrix::~CBC_CommonByteMatrix() {
+ if (m_bytes != NULL) {
+ FX_Free(m_bytes);
+ m_bytes = NULL;
+ }
}
-int32_t CBC_CommonByteMatrix::GetHeight()
-{
- return m_height;
+int32_t CBC_CommonByteMatrix::GetHeight() {
+ return m_height;
}
-int32_t CBC_CommonByteMatrix::GetWidth()
-{
- return m_width;
+int32_t CBC_CommonByteMatrix::GetWidth() {
+ return m_width;
}
-uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y)
-{
- return m_bytes[y * m_width + x];
+uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) {
+ return m_bytes[y * m_width + x];
}
-void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value)
-{
- m_bytes[y * m_width + x] = (uint8_t)value;
+void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value) {
+ m_bytes[y * m_width + x] = (uint8_t)value;
}
-void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value)
-{
- m_bytes[y * m_width + x] = value;
+void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value) {
+ m_bytes[y * m_width + x] = value;
}
-void CBC_CommonByteMatrix::clear(uint8_t value)
-{
- int32_t y;
- for(y = 0; y < m_height; y++) {
- int32_t x;
- for(x = 0; x < m_width; x++) {
- m_bytes[y * m_width + x] = value;
- }
+void CBC_CommonByteMatrix::clear(uint8_t value) {
+ int32_t y;
+ for (y = 0; y < m_height; y++) {
+ int32_t x;
+ for (x = 0; x < m_width; x++) {
+ m_bytes[y * m_width + x] = value;
}
+ }
}
-uint8_t* CBC_CommonByteMatrix::GetArray()
-{
- return m_bytes;
+uint8_t* CBC_CommonByteMatrix::GetArray() {
+ return m_bytes;
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h
index f19e0038b6..b94daf81a8 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h
+++ b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h
@@ -6,23 +6,23 @@
#ifndef _BC_COMMONBYTEMATRIX_H_
#define _BC_COMMONBYTEMATRIX_H_
-class CBC_CommonByteMatrix
-{
-public:
- CBC_CommonByteMatrix(int32_t width, int32_t height);
- virtual ~CBC_CommonByteMatrix();
- int32_t GetHeight();
- int32_t GetWidth();
- uint8_t Get(int32_t x, int32_t y);
- uint8_t* GetArray();
+class CBC_CommonByteMatrix {
+ public:
+ CBC_CommonByteMatrix(int32_t width, int32_t height);
+ virtual ~CBC_CommonByteMatrix();
+ int32_t GetHeight();
+ int32_t GetWidth();
+ uint8_t Get(int32_t x, int32_t y);
+ uint8_t* GetArray();
- void Set(int32_t x, int32_t y, int32_t value);
- void Set(int32_t x, int32_t y, uint8_t value);
- void clear(uint8_t value);
- virtual void Init();
-private:
- uint8_t *m_bytes;
- int32_t m_width;
- int32_t m_height;
+ void Set(int32_t x, int32_t y, int32_t value);
+ void Set(int32_t x, int32_t y, uint8_t value);
+ void clear(uint8_t value);
+ virtual void Init();
+
+ private:
+ uint8_t* m_bytes;
+ int32_t m_width;
+ int32_t m_height;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp
index 36f8e10af1..fbc6607ae7 100644
--- a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp
@@ -23,28 +23,22 @@
#include "../barcode.h"
#include "BC_CommonECI.h"
#include "BC_CommonCharacterSetECI.h"
-void CBC_CommonCharacterSetECI::initialize()
-{
+void CBC_CommonCharacterSetECI::initialize() {}
+CBC_CommonCharacterSetECI::CBC_CommonCharacterSetECI(
+ int32_t value,
+ CFX_ByteString encodingName)
+ : CBC_CommonECI(value), m_encodingName(encodingName) {}
+CBC_CommonCharacterSetECI::~CBC_CommonCharacterSetECI() {}
+CFX_ByteString CBC_CommonCharacterSetECI::GetEncodingName() {
+ return m_encodingName;
}
-CBC_CommonCharacterSetECI::CBC_CommonCharacterSetECI(int32_t value, CFX_ByteString encodingName):
- CBC_CommonECI(value), m_encodingName(encodingName)
-{
+void CBC_CommonCharacterSetECI::AddCharacterSet(int32_t value,
+ CFX_ByteString encodingName) {}
+CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByValue(
+ int32_t value) {
+ return NULL;
}
-CBC_CommonCharacterSetECI::~CBC_CommonCharacterSetECI()
-{
-}
-CFX_ByteString CBC_CommonCharacterSetECI::GetEncodingName()
-{
- return m_encodingName;
-}
-void CBC_CommonCharacterSetECI::AddCharacterSet(int32_t value, CFX_ByteString encodingName)
-{
-}
-CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByValue(int32_t value)
-{
- return NULL;
-}
-CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByName(const CFX_ByteString& name)
-{
- return NULL;
+CBC_CommonCharacterSetECI* CBC_CommonCharacterSetECI::GetCharacterSetECIByName(
+ const CFX_ByteString& name) {
+ return NULL;
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h
index 1c324796c8..5cdc4d6a51 100644
--- a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h
+++ b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h
@@ -8,18 +8,19 @@
#define _BC_COMMONCHARACTERSETECI_H_
class CBC_CommonECI;
class CBC_CommonCharacterSetECI;
-class CBC_CommonCharacterSetECI : public CBC_CommonECI
-{
-public:
- CBC_CommonCharacterSetECI(int32_t value, CFX_ByteString encodingName);
- virtual ~CBC_CommonCharacterSetECI();
- CFX_ByteString GetEncodingName();
- static void AddCharacterSet(int32_t value, CFX_ByteString encodingName);
- int32_t GetValue();
- static CBC_CommonCharacterSetECI* GetCharacterSetECIByValue(int32_t value);
- static CBC_CommonCharacterSetECI* GetCharacterSetECIByName(const CFX_ByteString& name);
-private:
- CFX_ByteString m_encodingName;
- static void initialize();
+class CBC_CommonCharacterSetECI : public CBC_CommonECI {
+ public:
+ CBC_CommonCharacterSetECI(int32_t value, CFX_ByteString encodingName);
+ virtual ~CBC_CommonCharacterSetECI();
+ CFX_ByteString GetEncodingName();
+ static void AddCharacterSet(int32_t value, CFX_ByteString encodingName);
+ int32_t GetValue();
+ static CBC_CommonCharacterSetECI* GetCharacterSetECIByValue(int32_t value);
+ static CBC_CommonCharacterSetECI* GetCharacterSetECIByName(
+ const CFX_ByteString& name);
+
+ private:
+ CFX_ByteString m_encodingName;
+ static void initialize();
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
index e17a58db43..d5f97029f4 100644
--- a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
@@ -24,56 +24,54 @@
#include "../qrcode/BC_QRCoderErrorCorrectionLevel.h"
#include "../pdf417/BC_PDF417ResultMetadata.h"
#include "BC_CommonDecoderResult.h"
-CBC_CommonDecoderResult::CBC_CommonDecoderResult()
-{
+CBC_CommonDecoderResult::CBC_CommonDecoderResult() {}
+void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
+ const CFX_ByteString& text,
+ const CFX_Int32Array& byteSegments,
+ CBC_QRCoderErrorCorrectionLevel* ecLevel,
+ int32_t& e) {
+ if (text.IsEmpty()) {
+ e = BCExceptionIllegalArgument;
+ return;
+ }
+ m_rawBytes.Copy(rawBytes);
+ m_text = text;
+ m_byteSegments.Copy(byteSegments);
+ m_ecLevel = ecLevel;
+ m_other = NULL;
}
-void CBC_CommonDecoderResult::Init(const CFX_ByteArray &rawBytes, const CFX_ByteString &text, const CFX_Int32Array &byteSegments, CBC_QRCoderErrorCorrectionLevel* ecLevel, int32_t &e)
-{
- if(text.IsEmpty()) {
- e = BCExceptionIllegalArgument;
- return;
- }
- m_rawBytes.Copy(rawBytes);
- m_text = text;
- m_byteSegments.Copy(byteSegments);
- m_ecLevel = ecLevel;
- m_other = NULL;
+void CBC_CommonDecoderResult::Init(const CFX_ByteArray& rawBytes,
+ const CFX_ByteString& text,
+ const CFX_PtrArray& byteSegments,
+ const CFX_ByteString& ecLevel,
+ int32_t& e) {
+ if (text.IsEmpty()) {
+ e = BCExceptionIllegalArgument;
+ return;
+ }
+ m_rawBytes.Copy(rawBytes);
+ m_text = text;
+ m_pdf417byteSegments.Copy(byteSegments);
+ m_pdf417ecLevel = ecLevel;
+ m_other = NULL;
}
-void CBC_CommonDecoderResult::Init(const CFX_ByteArray &rawBytes, const CFX_ByteString &text, const CFX_PtrArray &byteSegments, const CFX_ByteString &ecLevel, int32_t &e)
-{
- if(text.IsEmpty()) {
- e = BCExceptionIllegalArgument;
- return;
- }
- m_rawBytes.Copy(rawBytes);
- m_text = text;
- m_pdf417byteSegments.Copy(byteSegments);
- m_pdf417ecLevel = ecLevel;
- m_other = NULL;
+void CBC_CommonDecoderResult::setOther(CBC_PDF417ResultMetadata* other) {
+ m_other = other;
}
-void CBC_CommonDecoderResult::setOther(CBC_PDF417ResultMetadata* other)
-{
- m_other = other;
+CBC_CommonDecoderResult::~CBC_CommonDecoderResult() {
+ if (m_other != NULL) {
+ delete m_other;
+ }
}
-CBC_CommonDecoderResult::~CBC_CommonDecoderResult()
-{
- if (m_other != NULL) {
- delete m_other;
- }
+const CFX_ByteArray& CBC_CommonDecoderResult::GetRawBytes() {
+ return m_rawBytes;
}
-const CFX_ByteArray& CBC_CommonDecoderResult::GetRawBytes()
-{
- return m_rawBytes;
+const CFX_Int32Array& CBC_CommonDecoderResult::GetByteSegments() {
+ return m_byteSegments;
}
-const CFX_Int32Array& CBC_CommonDecoderResult::GetByteSegments()
-{
- return m_byteSegments;
+const CFX_ByteString& CBC_CommonDecoderResult::GetText() {
+ return m_text;
}
-const CFX_ByteString& CBC_CommonDecoderResult::GetText()
-{
- return m_text;
-}
-CBC_QRCoderErrorCorrectionLevel* CBC_CommonDecoderResult::GetECLevel()
-{
- return m_ecLevel;
+CBC_QRCoderErrorCorrectionLevel* CBC_CommonDecoderResult::GetECLevel() {
+ return m_ecLevel;
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h
index e85317934a..40c3a09078 100644
--- a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h
+++ b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h
@@ -8,25 +8,33 @@
#define _BC_COMMONDECODERRESULT_H_
class CBC_QRCoderErrorCorrectionLevel;
class CBC_PDF417ResultMetadata;
-class CBC_CommonDecoderResult
-{
-public:
- CBC_CommonDecoderResult();
- virtual ~CBC_CommonDecoderResult();
- const CFX_ByteArray& GetRawBytes();
- const CFX_ByteString& GetText();
- const CFX_Int32Array& GetByteSegments();
- CBC_QRCoderErrorCorrectionLevel* GetECLevel();
- virtual void Init(const CFX_ByteArray &rawBytes, const CFX_ByteString &text, const CFX_Int32Array &byteSegments, CBC_QRCoderErrorCorrectionLevel* ecLevel, int32_t &e);
- virtual void Init(const CFX_ByteArray &rawBytes, const CFX_ByteString &text, const CFX_PtrArray &byteSegments, const CFX_ByteString &ecLevel, int32_t &e);
- void setOther(CBC_PDF417ResultMetadata* other);
-private:
- CFX_ByteArray m_rawBytes;
- CFX_ByteString m_text;
- CFX_Int32Array m_byteSegments;
- CFX_PtrArray m_pdf417byteSegments;
- CBC_QRCoderErrorCorrectionLevel* m_ecLevel;
- CFX_ByteString m_pdf417ecLevel;
- CBC_PDF417ResultMetadata* m_other;
+class CBC_CommonDecoderResult {
+ public:
+ CBC_CommonDecoderResult();
+ virtual ~CBC_CommonDecoderResult();
+ const CFX_ByteArray& GetRawBytes();
+ const CFX_ByteString& GetText();
+ const CFX_Int32Array& GetByteSegments();
+ CBC_QRCoderErrorCorrectionLevel* GetECLevel();
+ virtual void Init(const CFX_ByteArray& rawBytes,
+ const CFX_ByteString& text,
+ const CFX_Int32Array& byteSegments,
+ CBC_QRCoderErrorCorrectionLevel* ecLevel,
+ int32_t& e);
+ virtual void Init(const CFX_ByteArray& rawBytes,
+ const CFX_ByteString& text,
+ const CFX_PtrArray& byteSegments,
+ const CFX_ByteString& ecLevel,
+ int32_t& e);
+ void setOther(CBC_PDF417ResultMetadata* other);
+
+ private:
+ CFX_ByteArray m_rawBytes;
+ CFX_ByteString m_text;
+ CFX_Int32Array m_byteSegments;
+ CFX_PtrArray m_pdf417byteSegments;
+ CBC_QRCoderErrorCorrectionLevel* m_ecLevel;
+ CFX_ByteString m_pdf417ecLevel;
+ CBC_PDF417ResultMetadata* m_other;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonECI.cpp b/xfa/src/fxbarcode/common/BC_CommonECI.cpp
index 98e88b5dab..08cddc90a6 100644
--- a/xfa/src/fxbarcode/common/BC_CommonECI.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonECI.cpp
@@ -23,24 +23,19 @@
#include "../barcode.h"
#include "BC_CommonECI.h"
#include "BC_CommonCharacterSetECI.h"
-CBC_CommonECI::CBC_CommonECI(int32_t value)
-{
- m_value = value;
+CBC_CommonECI::CBC_CommonECI(int32_t value) {
+ m_value = value;
}
-CBC_CommonECI::~CBC_CommonECI()
-{
+CBC_CommonECI::~CBC_CommonECI() {}
+int32_t CBC_CommonECI::GetValue() {
+ return m_value;
}
-int32_t CBC_CommonECI::GetValue()
-{
- return m_value;
-}
-CBC_CommonECI* CBC_CommonECI::GetEICByValue(int32_t value, int32_t &e)
-{
- if(value < 0 || value > 999999) {
- e = BCExceptionBadECI;
- return NULL;
- }
- if(value < 900) {
- }
+CBC_CommonECI* CBC_CommonECI::GetEICByValue(int32_t value, int32_t& e) {
+ if (value < 0 || value > 999999) {
+ e = BCExceptionBadECI;
return NULL;
+ }
+ if (value < 900) {
+ }
+ return NULL;
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonECI.h b/xfa/src/fxbarcode/common/BC_CommonECI.h
index 503f15fef7..1f90383497 100644
--- a/xfa/src/fxbarcode/common/BC_CommonECI.h
+++ b/xfa/src/fxbarcode/common/BC_CommonECI.h
@@ -6,15 +6,15 @@
#ifndef _BC_COMMONECI_H_
#define _BC_COMMONECI_H_
-class CBC_CommonECI
-{
-public:
- CBC_CommonECI(int32_t value);
- virtual ~CBC_CommonECI();
+class CBC_CommonECI {
+ public:
+ CBC_CommonECI(int32_t value);
+ virtual ~CBC_CommonECI();
- int32_t GetValue();
- static CBC_CommonECI* GetEICByValue(int32_t value, int32_t &e);
-private:
- int32_t m_value;
+ int32_t GetValue();
+ static CBC_CommonECI* GetEICByValue(int32_t value, int32_t& e);
+
+ private:
+ int32_t m_value;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
index 7fbcac5bb2..498cca2dbb 100644
--- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
@@ -22,104 +22,126 @@
#include "../barcode.h"
#include "BC_CommonPerspectiveTransform.h"
-CBC_CommonPerspectiveTransform::CBC_CommonPerspectiveTransform(FX_FLOAT a11, FX_FLOAT a21, FX_FLOAT a31,
- FX_FLOAT a12, FX_FLOAT a22, FX_FLOAT a32,
- FX_FLOAT a13, FX_FLOAT a23, FX_FLOAT a33) :
- m_a11(a11), m_a21(a21), m_a31(a31),
- m_a12(a12), m_a22(a22), m_a32(a32),
- m_a13(a13), m_a23(a23), m_a33(a33)
-{
+CBC_CommonPerspectiveTransform::CBC_CommonPerspectiveTransform(FX_FLOAT a11,
+ FX_FLOAT a21,
+ FX_FLOAT a31,
+ FX_FLOAT a12,
+ FX_FLOAT a22,
+ FX_FLOAT a32,
+ FX_FLOAT a13,
+ FX_FLOAT a23,
+ FX_FLOAT a33)
+ : m_a11(a11),
+ m_a21(a21),
+ m_a31(a31),
+ m_a12(a12),
+ m_a22(a22),
+ m_a32(a32),
+ m_a13(a13),
+ m_a23(a23),
+ m_a33(a33) {}
+CBC_CommonPerspectiveTransform::~CBC_CommonPerspectiveTransform() {}
+CBC_CommonPerspectiveTransform*
+CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(FX_FLOAT x0,
+ FX_FLOAT y0,
+ FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ FX_FLOAT x3,
+ FX_FLOAT y3,
+ FX_FLOAT x0p,
+ FX_FLOAT y0p,
+ FX_FLOAT x1p,
+ FX_FLOAT y1p,
+ FX_FLOAT x2p,
+ FX_FLOAT y2p,
+ FX_FLOAT x3p,
+ FX_FLOAT y3p) {
+ CBC_AutoPtr<CBC_CommonPerspectiveTransform> qToS(
+ QuadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3));
+ CBC_AutoPtr<CBC_CommonPerspectiveTransform> sToQ(
+ SquareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p));
+ return sToQ->Times(*(qToS.get()));
}
-CBC_CommonPerspectiveTransform::~CBC_CommonPerspectiveTransform()
-{
+void CBC_CommonPerspectiveTransform::TransformPoints(CFX_FloatArray* points) {
+ int32_t max = points->GetSize();
+ FX_FLOAT a11 = m_a11;
+ FX_FLOAT a12 = m_a12;
+ FX_FLOAT a13 = m_a13;
+ FX_FLOAT a21 = m_a21;
+ FX_FLOAT a22 = m_a22;
+ FX_FLOAT a23 = m_a23;
+ FX_FLOAT a31 = m_a31;
+ FX_FLOAT a32 = m_a32;
+ FX_FLOAT a33 = m_a33;
+ int32_t i;
+ for (i = 0; i < max; i += 2) {
+ FX_FLOAT x = (*points)[i];
+ FX_FLOAT y = (*points)[i + 1];
+ FX_FLOAT denominator = a13 * x + a23 * y + a33;
+ (*points)[i] = (a11 * x + a21 * y + a31) / denominator;
+ (*points)[i + 1] = (a12 * x + a22 * y + a32) / denominator;
+ }
}
-CBC_CommonPerspectiveTransform *CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(FX_FLOAT x0, FX_FLOAT y0,
- FX_FLOAT x1, FX_FLOAT y1,
- FX_FLOAT x2, FX_FLOAT y2,
- FX_FLOAT x3, FX_FLOAT y3,
- FX_FLOAT x0p, FX_FLOAT y0p,
- FX_FLOAT x1p, FX_FLOAT y1p,
- FX_FLOAT x2p, FX_FLOAT y2p,
- FX_FLOAT x3p, FX_FLOAT y3p)
-{
- CBC_AutoPtr<CBC_CommonPerspectiveTransform> qToS(QuadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3));
- CBC_AutoPtr<CBC_CommonPerspectiveTransform> sToQ(SquareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p));
- return sToQ->Times(*(qToS.get()));
+CBC_CommonPerspectiveTransform*
+CBC_CommonPerspectiveTransform::SquareToQuadrilateral(FX_FLOAT x0,
+ FX_FLOAT y0,
+ FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ FX_FLOAT x3,
+ FX_FLOAT y3) {
+ FX_FLOAT dy2 = y3 - y2;
+ FX_FLOAT dy3 = y0 - y1 + y2 - y3;
+ if ((dy2 == 0.0f) && (dy3 == 0.0f)) {
+ return FX_NEW CBC_CommonPerspectiveTransform(x1 - x0, x2 - x1, x0, y1 - y0,
+ y2 - y1, y0, 0.0f, 0.0f, 1.0f);
+ } else {
+ FX_FLOAT dx1 = x1 - x2;
+ FX_FLOAT dx2 = x3 - x2;
+ FX_FLOAT dx3 = x0 - x1 + x2 - x3;
+ FX_FLOAT dy1 = y1 - y2;
+ FX_FLOAT denominator = dx1 * dy2 - dx2 * dy1;
+ FX_FLOAT a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
+ FX_FLOAT a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
+ return FX_NEW CBC_CommonPerspectiveTransform(
+ x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0, y1 - y0 + a13 * y1,
+ y3 - y0 + a23 * y3, y0, a13, a23, 1.0f);
+ }
}
-void CBC_CommonPerspectiveTransform::TransformPoints(CFX_FloatArray *points)
-{
- int32_t max = points->GetSize();
- FX_FLOAT a11 = m_a11;
- FX_FLOAT a12 = m_a12;
- FX_FLOAT a13 = m_a13;
- FX_FLOAT a21 = m_a21;
- FX_FLOAT a22 = m_a22;
- FX_FLOAT a23 = m_a23;
- FX_FLOAT a31 = m_a31;
- FX_FLOAT a32 = m_a32;
- FX_FLOAT a33 = m_a33;
- int32_t i;
- for (i = 0; i < max; i += 2) {
- FX_FLOAT x = (*points)[i];
- FX_FLOAT y = (*points)[i + 1];
- FX_FLOAT denominator = a13 * x + a23 * y + a33;
- (*points)[i] = (a11 * x + a21 * y + a31) / denominator;
- (*points)[i + 1] = (a12 * x + a22 * y + a32) / denominator;
- }
+CBC_CommonPerspectiveTransform*
+CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0,
+ FX_FLOAT y0,
+ FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ FX_FLOAT x3,
+ FX_FLOAT y3) {
+ CBC_AutoPtr<CBC_CommonPerspectiveTransform> temp1(
+ SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3));
+ return temp1->BuildAdjoint();
}
-CBC_CommonPerspectiveTransform *CBC_CommonPerspectiveTransform::SquareToQuadrilateral(FX_FLOAT x0, FX_FLOAT y0,
- FX_FLOAT x1, FX_FLOAT y1,
- FX_FLOAT x2, FX_FLOAT y2,
- FX_FLOAT x3, FX_FLOAT y3)
-{
- FX_FLOAT dy2 = y3 - y2;
- FX_FLOAT dy3 = y0 - y1 + y2 - y3;
- if ((dy2 == 0.0f) && (dy3 == 0.0f)) {
- return FX_NEW CBC_CommonPerspectiveTransform(x1 - x0, x2 - x1, x0,
- y1 - y0, y2 - y1, y0,
- 0.0f, 0.0f, 1.0f);
- } else {
- FX_FLOAT dx1 = x1 - x2;
- FX_FLOAT dx2 = x3 - x2;
- FX_FLOAT dx3 = x0 - x1 + x2 - x3;
- FX_FLOAT dy1 = y1 - y2;
- FX_FLOAT denominator = dx1 * dy2 - dx2 * dy1;
- FX_FLOAT a13 = (dx3 * dy2 - dx2 * dy3) / denominator;
- FX_FLOAT a23 = (dx1 * dy3 - dx3 * dy1) / denominator;
- return FX_NEW CBC_CommonPerspectiveTransform(x1 - x0 + a13 * x1, x3 - x0 + a23 * x3, x0,
- y1 - y0 + a13 * y1, y3 - y0 + a23 * y3, y0,
- a13, a23, 1.0f);
- }
+CBC_CommonPerspectiveTransform* CBC_CommonPerspectiveTransform::BuildAdjoint() {
+ return FX_NEW CBC_CommonPerspectiveTransform(
+ m_a22 * m_a33 - m_a23 * m_a32, m_a23 * m_a31 - m_a21 * m_a33,
+ m_a21 * m_a32 - m_a22 * m_a31, m_a13 * m_a32 - m_a12 * m_a33,
+ m_a11 * m_a33 - m_a13 * m_a31, m_a12 * m_a31 - m_a11 * m_a32,
+ m_a12 * m_a23 - m_a13 * m_a22, m_a13 * m_a21 - m_a11 * m_a23,
+ m_a11 * m_a22 - m_a12 * m_a21);
}
-CBC_CommonPerspectiveTransform *CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0, FX_FLOAT y0,
- FX_FLOAT x1, FX_FLOAT y1,
- FX_FLOAT x2, FX_FLOAT y2,
- FX_FLOAT x3, FX_FLOAT y3)
-{
- CBC_AutoPtr<CBC_CommonPerspectiveTransform> temp1(SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3));
- return temp1->BuildAdjoint();
-}
-CBC_CommonPerspectiveTransform *CBC_CommonPerspectiveTransform::BuildAdjoint()
-{
- return FX_NEW CBC_CommonPerspectiveTransform(m_a22 * m_a33 - m_a23 * m_a32,
- m_a23 * m_a31 - m_a21 * m_a33,
- m_a21 * m_a32 - m_a22 * m_a31,
- m_a13 * m_a32 - m_a12 * m_a33,
- m_a11 * m_a33 - m_a13 * m_a31,
- m_a12 * m_a31 - m_a11 * m_a32,
- m_a12 * m_a23 - m_a13 * m_a22,
- m_a13 * m_a21 - m_a11 * m_a23,
- m_a11 * m_a22 - m_a12 * m_a21);
-}
-CBC_CommonPerspectiveTransform *CBC_CommonPerspectiveTransform::Times(CBC_CommonPerspectiveTransform &other)
-{
- return FX_NEW CBC_CommonPerspectiveTransform(m_a11 * other.m_a11 + m_a21 * other.m_a12 + m_a31 * other.m_a13,
- m_a11 * other.m_a21 + m_a21 * other.m_a22 + m_a31 * other.m_a23,
- m_a11 * other.m_a31 + m_a21 * other.m_a32 + m_a31 * other.m_a33,
- m_a12 * other.m_a11 + m_a22 * other.m_a12 + m_a32 * other.m_a13,
- m_a12 * other.m_a21 + m_a22 * other.m_a22 + m_a32 * other.m_a23,
- m_a12 * other.m_a31 + m_a22 * other.m_a32 + m_a32 * other.m_a33,
- m_a13 * other.m_a11 + m_a23 * other.m_a12 + m_a33 * other.m_a13,
- m_a13 * other.m_a21 + m_a23 * other.m_a22 + m_a33 * other.m_a23,
- m_a13 * other.m_a31 + m_a23 * other.m_a32 + m_a33 * other.m_a33);
+CBC_CommonPerspectiveTransform* CBC_CommonPerspectiveTransform::Times(
+ CBC_CommonPerspectiveTransform& other) {
+ return FX_NEW CBC_CommonPerspectiveTransform(
+ m_a11 * other.m_a11 + m_a21 * other.m_a12 + m_a31 * other.m_a13,
+ m_a11 * other.m_a21 + m_a21 * other.m_a22 + m_a31 * other.m_a23,
+ m_a11 * other.m_a31 + m_a21 * other.m_a32 + m_a31 * other.m_a33,
+ m_a12 * other.m_a11 + m_a22 * other.m_a12 + m_a32 * other.m_a13,
+ m_a12 * other.m_a21 + m_a22 * other.m_a22 + m_a32 * other.m_a23,
+ m_a12 * other.m_a31 + m_a22 * other.m_a32 + m_a32 * other.m_a33,
+ m_a13 * other.m_a11 + m_a23 * other.m_a12 + m_a33 * other.m_a13,
+ m_a13 * other.m_a21 + m_a23 * other.m_a22 + m_a33 * other.m_a23,
+ m_a13 * other.m_a31 + m_a23 * other.m_a32 + m_a33 * other.m_a33);
}
diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h
index cf7f804a2c..22e90cdc46 100644
--- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h
+++ b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h
@@ -6,33 +6,56 @@
#ifndef _BC_COMMONPERSPECTIVETRANSFORM_H_
#define _BC_COMMONPERSPECTIVETRANSFORM_H_
-class CBC_CommonPerspectiveTransform
-{
-public:
- CBC_CommonPerspectiveTransform(FX_FLOAT a11, FX_FLOAT a21, FX_FLOAT a31,
- FX_FLOAT a12, FX_FLOAT a22, FX_FLOAT a32,
- FX_FLOAT a13, FX_FLOAT a23, FX_FLOAT a33);
- virtual ~CBC_CommonPerspectiveTransform();
- static CBC_CommonPerspectiveTransform *QuadrilateralToQuadrilateral(FX_FLOAT x0, FX_FLOAT y0,
- FX_FLOAT x1, FX_FLOAT y1,
- FX_FLOAT x2, FX_FLOAT y2,
- FX_FLOAT x3, FX_FLOAT y3,
- FX_FLOAT x0p, FX_FLOAT y0p,
- FX_FLOAT x1p, FX_FLOAT y1p,
- FX_FLOAT x2p, FX_FLOAT y2p,
- FX_FLOAT x3p, FX_FLOAT y3p);
- static CBC_CommonPerspectiveTransform *SquareToQuadrilateral(FX_FLOAT x0, FX_FLOAT y0,
- FX_FLOAT x1, FX_FLOAT y1,
- FX_FLOAT x2, FX_FLOAT y2,
- FX_FLOAT x3, FX_FLOAT y3);
- static CBC_CommonPerspectiveTransform *QuadrilateralToSquare(FX_FLOAT x0, FX_FLOAT y0,
- FX_FLOAT x1, FX_FLOAT y1,
- FX_FLOAT x2, FX_FLOAT y2,
- FX_FLOAT x3, FX_FLOAT y3);
- CBC_CommonPerspectiveTransform *BuildAdjoint();
- CBC_CommonPerspectiveTransform *Times(CBC_CommonPerspectiveTransform &other);
- void TransformPoints(CFX_FloatArray *points);
-private:
- FX_FLOAT m_a11, m_a12, m_a13, m_a21, m_a22, m_a23, m_a31, m_a32, m_a33;
+class CBC_CommonPerspectiveTransform {
+ public:
+ CBC_CommonPerspectiveTransform(FX_FLOAT a11,
+ FX_FLOAT a21,
+ FX_FLOAT a31,
+ FX_FLOAT a12,
+ FX_FLOAT a22,
+ FX_FLOAT a32,
+ FX_FLOAT a13,
+ FX_FLOAT a23,
+ FX_FLOAT a33);
+ virtual ~CBC_CommonPerspectiveTransform();
+ static CBC_CommonPerspectiveTransform* QuadrilateralToQuadrilateral(
+ FX_FLOAT x0,
+ FX_FLOAT y0,
+ FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ FX_FLOAT x3,
+ FX_FLOAT y3,
+ FX_FLOAT x0p,
+ FX_FLOAT y0p,
+ FX_FLOAT x1p,
+ FX_FLOAT y1p,
+ FX_FLOAT x2p,
+ FX_FLOAT y2p,
+ FX_FLOAT x3p,
+ FX_FLOAT y3p);
+ static CBC_CommonPerspectiveTransform* SquareToQuadrilateral(FX_FLOAT x0,
+ FX_FLOAT y0,
+ FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ FX_FLOAT x3,
+ FX_FLOAT y3);
+ static CBC_CommonPerspectiveTransform* QuadrilateralToSquare(FX_FLOAT x0,
+ FX_FLOAT y0,
+ FX_FLOAT x1,
+ FX_FLOAT y1,
+ FX_FLOAT x2,
+ FX_FLOAT y2,
+ FX_FLOAT x3,
+ FX_FLOAT y3);
+ CBC_CommonPerspectiveTransform* BuildAdjoint();
+ CBC_CommonPerspectiveTransform* Times(CBC_CommonPerspectiveTransform& other);
+ void TransformPoints(CFX_FloatArray* points);
+
+ private:
+ FX_FLOAT m_a11, m_a12, m_a13, m_a21, m_a22, m_a23, m_a31, m_a32, m_a33;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
index 5976d450d9..88b0c43828 100644
--- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
+++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
@@ -29,141 +29,141 @@
const int32_t LUMINANCE_BITS = 5;
const int32_t LUMINANCE_SHIFT = 8 - LUMINANCE_BITS;
const int32_t LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS;
-CBC_GlobalHistogramBinarizer::CBC_GlobalHistogramBinarizer(CBC_LuminanceSource *source): CBC_Binarizer(source)
-{
-}
-CBC_GlobalHistogramBinarizer::~CBC_GlobalHistogramBinarizer()
-{
-}
-CBC_CommonBitArray *CBC_GlobalHistogramBinarizer::GetBlackRow(int32_t y, CBC_CommonBitArray *row, int32_t &e)
-{
- CBC_LuminanceSource *source = GetLuminanceSource();
- int32_t width = source->GetWidth();
- CBC_AutoPtr<CBC_CommonBitArray> result(FX_NEW CBC_CommonBitArray(width));
- InitArrays(width);
- CFX_ByteArray *localLuminances = source->GetRow(y, m_luminance, e);
- if (e != BCExceptionNO) {
- return result.release();
- }
- CFX_Int32Array localBuckets;
- localBuckets.Copy(m_buckets);
- int32_t x;
- for (x = 0; x < width; x++) {
- int32_t pixel = (*localLuminances)[x] & 0xff;
- localBuckets[pixel >> LUMINANCE_SHIFT]++;
- }
- int32_t blackPoint = EstimateBlackPoint(localBuckets, e);
- if (e != BCExceptionNO) {
- return result.release();
- }
- int32_t left = (*localLuminances)[0] & 0xff;
- int32_t center = (*localLuminances)[1] & 0xff;
- for (x = 1; x < width - 1; x++) {
- int32_t right = (*localLuminances)[x + 1] & 0xff;
- int32_t luminance = ((center << 2) - left - right) >> 1;
- if (luminance < blackPoint) {
- result->Set(x);
- }
- left = center;
- center = right;
+CBC_GlobalHistogramBinarizer::CBC_GlobalHistogramBinarizer(
+ CBC_LuminanceSource* source)
+ : CBC_Binarizer(source) {}
+CBC_GlobalHistogramBinarizer::~CBC_GlobalHistogramBinarizer() {}
+CBC_CommonBitArray* CBC_GlobalHistogramBinarizer::GetBlackRow(
+ int32_t y,
+ CBC_CommonBitArray* row,
+ int32_t& e) {
+ CBC_LuminanceSource* source = GetLuminanceSource();
+ int32_t width = source->GetWidth();
+ CBC_AutoPtr<CBC_CommonBitArray> result(FX_NEW CBC_CommonBitArray(width));
+ InitArrays(width);
+ CFX_ByteArray* localLuminances = source->GetRow(y, m_luminance, e);
+ if (e != BCExceptionNO) {
+ return result.release();
+ }
+ CFX_Int32Array localBuckets;
+ localBuckets.Copy(m_buckets);
+ int32_t x;
+ for (x = 0; x < width; x++) {
+ int32_t pixel = (*localLuminances)[x] & 0xff;
+ localBuckets[pixel >> LUMINANCE_SHIFT]++;
+ }
+ int32_t blackPoint = EstimateBlackPoint(localBuckets, e);
+ if (e != BCExceptionNO) {
+ return result.release();
+ }
+ int32_t left = (*localLuminances)[0] & 0xff;
+ int32_t center = (*localLuminances)[1] & 0xff;
+ for (x = 1; x < width - 1; x++) {
+ int32_t right = (*localLuminances)[x + 1] & 0xff;
+ int32_t luminance = ((center << 2) - left - right) >> 1;
+ if (luminance < blackPoint) {
+ result->Set(x);
}
- return result.release();
+ left = center;
+ center = right;
+ }
+ return result.release();
}
-CBC_CommonBitMatrix *CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t &e)
-{
- CBC_LuminanceSource *source = GetLuminanceSource();
- int32_t width = source->GetWidth();
- int32_t height = source->GetHeight();
- CBC_CommonBitMatrix *BitMatrixTemp = FX_NEW CBC_CommonBitMatrix();
- BitMatrixTemp->Init(width, height);
- CBC_AutoPtr<CBC_CommonBitMatrix> matrix(BitMatrixTemp);
- InitArrays(width);
- CFX_Int32Array localBuckets;
- localBuckets.Copy(m_buckets);
- int32_t y;
- for (y = 1; y < 5; y++) {
- int32_t row = height * y / 5;
- CFX_ByteArray *localLuminances = source->GetRow(row, m_luminance, e);
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- int32_t right = (width << 2) / 5;
- int32_t x;
- for (x = width / 5; x < right; x++) {
- int32_t pixel = (*localLuminances)[x] & 0xff;
- localBuckets[pixel >> LUMINANCE_SHIFT]++;
- }
- }
- int32_t blackPoint = EstimateBlackPoint(localBuckets, e);
+CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) {
+ CBC_LuminanceSource* source = GetLuminanceSource();
+ int32_t width = source->GetWidth();
+ int32_t height = source->GetHeight();
+ CBC_CommonBitMatrix* BitMatrixTemp = FX_NEW CBC_CommonBitMatrix();
+ BitMatrixTemp->Init(width, height);
+ CBC_AutoPtr<CBC_CommonBitMatrix> matrix(BitMatrixTemp);
+ InitArrays(width);
+ CFX_Int32Array localBuckets;
+ localBuckets.Copy(m_buckets);
+ int32_t y;
+ for (y = 1; y < 5; y++) {
+ int32_t row = height * y / 5;
+ CFX_ByteArray* localLuminances = source->GetRow(row, m_luminance, e);
BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- CBC_AutoPtr<CFX_ByteArray> localLuminances(source->GetMatrix());
- for (y = 0; y < height; y++) {
- int32_t offset = y * width;
- for (int32_t x = 0; x < width; x++) {
- int32_t pixel = (*localLuminances)[offset + x] & 0xff;
- if (pixel < blackPoint) {
- matrix->Set(x, y);
- }
- }
- }
- return matrix.release();
-}
-void CBC_GlobalHistogramBinarizer::InitArrays(int32_t luminanceSize)
-{
- if(m_luminance.GetSize() < luminanceSize) {
- m_luminance.SetSize(luminanceSize);
+ int32_t right = (width << 2) / 5;
+ int32_t x;
+ for (x = width / 5; x < right; x++) {
+ int32_t pixel = (*localLuminances)[x] & 0xff;
+ localBuckets[pixel >> LUMINANCE_SHIFT]++;
}
- if(m_buckets.GetSize() <= 0) {
- m_buckets.SetSize(LUMINANCE_BUCKETS);
- } else {
- int32_t x;
- for(x = 0; x < LUMINANCE_BUCKETS; x++) {
- m_buckets[x] = 0;
- }
+ }
+ int32_t blackPoint = EstimateBlackPoint(localBuckets, e);
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ CBC_AutoPtr<CFX_ByteArray> localLuminances(source->GetMatrix());
+ for (y = 0; y < height; y++) {
+ int32_t offset = y * width;
+ for (int32_t x = 0; x < width; x++) {
+ int32_t pixel = (*localLuminances)[offset + x] & 0xff;
+ if (pixel < blackPoint) {
+ matrix->Set(x, y);
+ }
}
+ }
+ return matrix.release();
}
-int32_t CBC_GlobalHistogramBinarizer::EstimateBlackPoint(CFX_Int32Array &buckets, int32_t &e)
-{
- int32_t numBuckets = buckets.GetSize();
- int32_t maxBucketCount = 0;
- int32_t firstPeak = 0;
- int32_t firstPeakSize = 0;
+void CBC_GlobalHistogramBinarizer::InitArrays(int32_t luminanceSize) {
+ if (m_luminance.GetSize() < luminanceSize) {
+ m_luminance.SetSize(luminanceSize);
+ }
+ if (m_buckets.GetSize() <= 0) {
+ m_buckets.SetSize(LUMINANCE_BUCKETS);
+ } else {
int32_t x;
- for (x = 0; x < numBuckets; x++) {
- if (buckets[x] > firstPeakSize) {
- firstPeak = x;
- firstPeakSize = buckets[x];
- }
- if (buckets[x] > maxBucketCount) {
- maxBucketCount = buckets[x];
- }
+ for (x = 0; x < LUMINANCE_BUCKETS; x++) {
+ m_buckets[x] = 0;
}
- int32_t secondPeak = 0;
- int32_t secondPeakScore = 0;
- for (x = 0; x < numBuckets; x++) {
- int32_t distanceToBiggest = x - firstPeak;
- int32_t score = buckets[x] * distanceToBiggest * distanceToBiggest;
- if (score > secondPeakScore) {
- secondPeak = x;
- secondPeakScore = score;
- }
+ }
+}
+int32_t CBC_GlobalHistogramBinarizer::EstimateBlackPoint(
+ CFX_Int32Array& buckets,
+ int32_t& e) {
+ int32_t numBuckets = buckets.GetSize();
+ int32_t maxBucketCount = 0;
+ int32_t firstPeak = 0;
+ int32_t firstPeakSize = 0;
+ int32_t x;
+ for (x = 0; x < numBuckets; x++) {
+ if (buckets[x] > firstPeakSize) {
+ firstPeak = x;
+ firstPeakSize = buckets[x];
}
- if (firstPeak > secondPeak) {
- int32_t temp = firstPeak;
- firstPeak = secondPeak;
- secondPeak = temp;
+ if (buckets[x] > maxBucketCount) {
+ maxBucketCount = buckets[x];
}
- if (secondPeak - firstPeak <= numBuckets >> 4) {
- e = BCExceptionRead;
- return 0;
+ }
+ int32_t secondPeak = 0;
+ int32_t secondPeakScore = 0;
+ for (x = 0; x < numBuckets; x++) {
+ int32_t distanceToBiggest = x - firstPeak;
+ int32_t score = buckets[x] * distanceToBiggest * distanceToBiggest;
+ if (score > secondPeakScore) {
+ secondPeak = x;
+ secondPeakScore = score;
}
- int32_t bestValley = secondPeak - 1;
- int32_t bestValleyScore = -1;
- for (x = secondPeak - 1; x > firstPeak; x--) {
- int32_t fromFirst = x - firstPeak;
- int32_t score = fromFirst * fromFirst * (secondPeak - x) * (maxBucketCount - buckets[x]);
- if (score > bestValleyScore) {
- bestValley = x;
- bestValleyScore = score;
- }
+ }
+ if (firstPeak > secondPeak) {
+ int32_t temp = firstPeak;
+ firstPeak = secondPeak;
+ secondPeak = temp;
+ }
+ if (secondPeak - firstPeak <= numBuckets >> 4) {
+ e = BCExceptionRead;
+ return 0;
+ }
+ int32_t bestValley = secondPeak - 1;
+ int32_t bestValleyScore = -1;
+ for (x = secondPeak - 1; x > firstPeak; x--) {
+ int32_t fromFirst = x - firstPeak;
+ int32_t score = fromFirst * fromFirst * (secondPeak - x) *
+ (maxBucketCount - buckets[x]);
+ if (score > bestValleyScore) {
+ bestValley = x;
+ bestValleyScore = score;
}
- return bestValley << LUMINANCE_SHIFT;
+ }
+ return bestValley << LUMINANCE_SHIFT;
}
diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
index 6c6d8ba188..63ff3e7533 100644
--- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
+++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
@@ -11,18 +11,20 @@ class CBC_CommonBitArray;
class CBC_CommonBitMatrix;
class CBC_LuminanceSource;
class CBC_GlobalHistogramBinarizer;
-class CBC_GlobalHistogramBinarizer : public CBC_Binarizer
-{
-public:
- CBC_GlobalHistogramBinarizer(CBC_LuminanceSource *source);
- virtual ~CBC_GlobalHistogramBinarizer();
+class CBC_GlobalHistogramBinarizer : public CBC_Binarizer {
+ public:
+ CBC_GlobalHistogramBinarizer(CBC_LuminanceSource* source);
+ virtual ~CBC_GlobalHistogramBinarizer();
- void InitArrays(int32_t luminanceSize);
- CBC_CommonBitMatrix *GetBlackMatrix(int32_t &e);
- CBC_CommonBitArray *GetBlackRow(int32_t y, CBC_CommonBitArray *row, int32_t &e);
- static int32_t EstimateBlackPoint(CFX_Int32Array &buckets, int32_t &e);
-private:
- CFX_ByteArray m_luminance;
- CFX_Int32Array m_buckets;
+ void InitArrays(int32_t luminanceSize);
+ CBC_CommonBitMatrix* GetBlackMatrix(int32_t& e);
+ CBC_CommonBitArray* GetBlackRow(int32_t y,
+ CBC_CommonBitArray* row,
+ int32_t& e);
+ static int32_t EstimateBlackPoint(CFX_Int32Array& buckets, int32_t& e);
+
+ private:
+ CFX_ByteArray m_luminance;
+ CFX_Int32Array m_buckets;
};
#endif
diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
index 3d350996dd..251eb5919c 100644
--- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
+++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
@@ -26,219 +26,235 @@
#include "../BC_ResultPoint.h"
const int32_t CBC_WhiteRectangleDetector::INIT_SIZE = 30;
const int32_t CBC_WhiteRectangleDetector::CORR = 1;
-CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector(CBC_CommonBitMatrix *image)
-{
- m_image = image;
- m_height = image->GetHeight();
- m_width = image->GetWidth();
- m_leftInit = (m_width - INIT_SIZE) >> 1;
- m_rightInit = (m_width + INIT_SIZE) >> 1;
- m_upInit = (m_height - INIT_SIZE) >> 1;
- m_downInit = (m_height + INIT_SIZE) >> 1;
+CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector(
+ CBC_CommonBitMatrix* image) {
+ m_image = image;
+ m_height = image->GetHeight();
+ m_width = image->GetWidth();
+ m_leftInit = (m_width - INIT_SIZE) >> 1;
+ m_rightInit = (m_width + INIT_SIZE) >> 1;
+ m_upInit = (m_height - INIT_SIZE) >> 1;
+ m_downInit = (m_height + INIT_SIZE) >> 1;
}
-void CBC_WhiteRectangleDetector::Init(int32_t &e)
-{
- if (m_upInit < 0 || m_leftInit < 0 || m_downInit >= m_height || m_rightInit >= m_width) {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnVoid(e);
- }
+void CBC_WhiteRectangleDetector::Init(int32_t& e) {
+ if (m_upInit < 0 || m_leftInit < 0 || m_downInit >= m_height ||
+ m_rightInit >= m_width) {
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnVoid(e);
+ }
}
-CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector(CBC_CommonBitMatrix *image, int32_t initSize, int32_t x, int32_t y)
-{
- m_image = image;
- m_height = image->GetHeight();
- m_width = image->GetWidth();
- int32_t halfsize = initSize >> 1;
- m_leftInit = x - halfsize;
- m_rightInit = x + halfsize;
- m_upInit = y - halfsize;
- m_downInit = y + halfsize;
+CBC_WhiteRectangleDetector::CBC_WhiteRectangleDetector(
+ CBC_CommonBitMatrix* image,
+ int32_t initSize,
+ int32_t x,
+ int32_t y) {
+ m_image = image;
+ m_height = image->GetHeight();
+ m_width = image->GetWidth();
+ int32_t halfsize = initSize >> 1;
+ m_leftInit = x - halfsize;
+ m_rightInit = x + halfsize;
+ m_upInit = y - halfsize;
+ m_downInit = y + halfsize;
}
-CBC_WhiteRectangleDetector::~CBC_WhiteRectangleDetector()
-{
+CBC_WhiteRectangleDetector::~CBC_WhiteRectangleDetector() {}
+CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) {
+ int32_t left = m_leftInit;
+ int32_t right = m_rightInit;
+ int32_t up = m_upInit;
+ int32_t down = m_downInit;
+ FX_BOOL sizeExceeded = FALSE;
+ FX_BOOL aBlackPointFoundOnBorder = TRUE;
+ FX_BOOL atLeastOneBlackPointFoundOnBorder = FALSE;
+ while (aBlackPointFoundOnBorder) {
+ aBlackPointFoundOnBorder = FALSE;
+ FX_BOOL rightBorderNotWhite = TRUE;
+ while (rightBorderNotWhite && right < m_width) {
+ rightBorderNotWhite = ContainsBlackPoint(up, down, right, FALSE);
+ if (rightBorderNotWhite) {
+ right++;
+ aBlackPointFoundOnBorder = TRUE;
+ }
+ }
+ if (right >= m_width) {
+ sizeExceeded = TRUE;
+ break;
+ }
+ FX_BOOL bottomBorderNotWhite = TRUE;
+ while (bottomBorderNotWhite && down < m_height) {
+ bottomBorderNotWhite = ContainsBlackPoint(left, right, down, TRUE);
+ if (bottomBorderNotWhite) {
+ down++;
+ aBlackPointFoundOnBorder = TRUE;
+ }
+ }
+ if (down >= m_height) {
+ sizeExceeded = TRUE;
+ break;
+ }
+ FX_BOOL leftBorderNotWhite = TRUE;
+ while (leftBorderNotWhite && left >= 0) {
+ leftBorderNotWhite = ContainsBlackPoint(up, down, left, FALSE);
+ if (leftBorderNotWhite) {
+ left--;
+ aBlackPointFoundOnBorder = TRUE;
+ }
+ }
+ if (left < 0) {
+ sizeExceeded = TRUE;
+ break;
+ }
+ FX_BOOL topBorderNotWhite = TRUE;
+ while (topBorderNotWhite && up >= 0) {
+ topBorderNotWhite = ContainsBlackPoint(left, right, up, TRUE);
+ if (topBorderNotWhite) {
+ up--;
+ aBlackPointFoundOnBorder = TRUE;
+ }
+ }
+ if (up < 0) {
+ sizeExceeded = TRUE;
+ break;
+ }
+ if (aBlackPointFoundOnBorder) {
+ atLeastOneBlackPointFoundOnBorder = TRUE;
+ }
+ }
+ if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
+ int32_t maxSize = right - left;
+ CBC_AutoPtr<CBC_ResultPoint> z(NULL);
+ for (int32_t i = 1; i < maxSize; i++) {
+ z = CBC_AutoPtr<CBC_ResultPoint>(
+ GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i),
+ (FX_FLOAT)(left + i), (FX_FLOAT)(down)));
+ if (z.get() != NULL) {
+ break;
+ }
+ }
+ if (z.get() == NULL) {
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ CBC_AutoPtr<CBC_ResultPoint> t(NULL);
+ for (int32_t j = 1; j < maxSize; j++) {
+ t = CBC_AutoPtr<CBC_ResultPoint>(
+ GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j),
+ (FX_FLOAT)(left + j), (FX_FLOAT)up));
+ if (t.get() != NULL) {
+ break;
+ }
+ }
+ if (t.get() == NULL) {
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ CBC_AutoPtr<CBC_ResultPoint> x(NULL);
+ for (int32_t k = 1; k < maxSize; k++) {
+ x = CBC_AutoPtr<CBC_ResultPoint>(
+ GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k),
+ (FX_FLOAT)(right - k), (FX_FLOAT)up));
+ if (x.get() != NULL) {
+ break;
+ }
+ }
+ if (x.get() == NULL) {
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ CBC_AutoPtr<CBC_ResultPoint> y(NULL);
+ for (int32_t m = 1; m < maxSize; m++) {
+ y = CBC_AutoPtr<CBC_ResultPoint>(
+ GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m),
+ (FX_FLOAT)(right - m), (FX_FLOAT)down));
+ if (y.get() != NULL) {
+ break;
+ }
+ }
+ if (y.get() == NULL) {
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ return CenterEdges(y.get(), z.get(), x.get(), t.get());
+ } else {
+ e = BCExceptionNotFound;
+ BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ }
+ return NULL;
}
-CFX_PtrArray *CBC_WhiteRectangleDetector::Detect(int32_t &e)
-{
- int32_t left = m_leftInit;
- int32_t right = m_rightInit;
- int32_t up = m_upInit;
- int32_t down = m_downInit;
- FX_BOOL sizeExceeded = FALSE;
- FX_BOOL aBlackPointFoundOnBorder = TRUE;
- FX_BOOL atLeastOneBlackPointFoundOnBorder = FALSE;
- while (aBlackPointFoundOnBorder) {
- aBlackPointFoundOnBorder = FALSE;
- FX_BOOL rightBorderNotWhite = TRUE;
- while (rightBorderNotWhite && right < m_width) {
- rightBorderNotWhite = ContainsBlackPoint(up, down, right, FALSE);
- if (rightBorderNotWhite) {
- right++;
- aBlackPointFoundOnBorder = TRUE;
- }
- }
- if (right >= m_width) {
- sizeExceeded = TRUE;
- break;
- }
- FX_BOOL bottomBorderNotWhite = TRUE;
- while (bottomBorderNotWhite && down < m_height) {
- bottomBorderNotWhite = ContainsBlackPoint(left, right, down, TRUE);
- if (bottomBorderNotWhite) {
- down++;
- aBlackPointFoundOnBorder = TRUE;
- }
- }
- if (down >= m_height) {
- sizeExceeded = TRUE;
- break;
- }
- FX_BOOL leftBorderNotWhite = TRUE;
- while (leftBorderNotWhite && left >= 0) {
- leftBorderNotWhite = ContainsBlackPoint(up, down, left, FALSE);
- if (leftBorderNotWhite) {
- left--;
- aBlackPointFoundOnBorder = TRUE;
- }
- }
- if (left < 0) {
- sizeExceeded = TRUE;
- break;
- }
- FX_BOOL topBorderNotWhite = TRUE;
- while (topBorderNotWhite && up >= 0) {
- topBorderNotWhite = ContainsBlackPoint(left, right, up, TRUE);
- if (topBorderNotWhite) {
- up--;
- aBlackPointFoundOnBorder = TRUE;
- }
- }
- if (up < 0) {
- sizeExceeded = TRUE;
- break;
- }
- if (aBlackPointFoundOnBorder) {
- atLeastOneBlackPointFoundOnBorder = TRUE;
- }
- }
- if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) {
- int32_t maxSize = right - left;
- CBC_AutoPtr<CBC_ResultPoint> z(NULL);
- for (int32_t i = 1; i < maxSize; i++) {
- z = CBC_AutoPtr<CBC_ResultPoint>(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i), (FX_FLOAT)(left + i), (FX_FLOAT)(down)) );
- if (z.get() != NULL) {
- break;
- }
- }
- if (z.get() == NULL) {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- CBC_AutoPtr<CBC_ResultPoint> t(NULL);
- for (int32_t j = 1; j < maxSize; j++) {
- t = CBC_AutoPtr<CBC_ResultPoint>(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j), (FX_FLOAT)(left + j), (FX_FLOAT)up));
- if (t.get() != NULL) {
- break;
- }
- }
- if (t.get() == NULL) {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- CBC_AutoPtr<CBC_ResultPoint> x(NULL);
- for (int32_t k = 1; k < maxSize; k++) {
- x = CBC_AutoPtr<CBC_ResultPoint>(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k), (FX_FLOAT)(right - k), (FX_FLOAT)up));
- if (x.get() != NULL) {
- break;
- }
- }
- if (x.get() == NULL) {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- CBC_AutoPtr<CBC_ResultPoint> y(NULL);
- for (int32_t m = 1; m < maxSize; m++) {
- y = CBC_AutoPtr<CBC_ResultPoint>(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m), (FX_FLOAT)(right - m), (FX_FLOAT) down));
- if (y.get() != NULL) {
- break;
- }
- }
- if (y.get() == NULL) {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- return CenterEdges(y.get(), z.get(), x.get(), t.get());
- } else {
- e = BCExceptionNotFound;
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
- }
- return NULL;
+int32_t CBC_WhiteRectangleDetector::Round(FX_FLOAT d) {
+ return (int32_t)(d + 0.5f);
}
-int32_t CBC_WhiteRectangleDetector::Round(FX_FLOAT d)
-{
- return (int32_t) (d + 0.5f);
+CBC_ResultPoint* CBC_WhiteRectangleDetector::GetBlackPointOnSegment(
+ FX_FLOAT aX,
+ FX_FLOAT aY,
+ FX_FLOAT bX,
+ FX_FLOAT bY) {
+ int32_t dist = DistanceL2(aX, aY, bX, bY);
+ float xStep = (bX - aX) / dist;
+ float yStep = (bY - aY) / dist;
+ for (int32_t i = 0; i < dist; i++) {
+ int32_t x = Round(aX + i * xStep);
+ int32_t y = Round(aY + i * yStep);
+ if (m_image->Get(x, y)) {
+ return FX_NEW CBC_ResultPoint((FX_FLOAT)x, (FX_FLOAT)y);
+ }
+ }
+ return NULL;
}
-CBC_ResultPoint *CBC_WhiteRectangleDetector::GetBlackPointOnSegment(FX_FLOAT aX, FX_FLOAT aY, FX_FLOAT bX, FX_FLOAT bY)
-{
- int32_t dist = DistanceL2(aX, aY, bX, bY);
- float xStep = (bX - aX) / dist;
- float yStep = (bY - aY) / dist;
- for (int32_t i = 0; i < dist; i++) {
- int32_t x = Round(aX + i * xStep);
- int32_t y = Round(aY + i * yStep);
- if (m_image->Get(x, y)) {
- return FX_NEW CBC_ResultPoint((FX_FLOAT)x, (FX_FLOAT) y);
- }
- }
- return NULL;
+int32_t CBC_WhiteRectangleDetector::DistanceL2(FX_FLOAT aX,
+ FX_FLOAT aY,
+ FX_FLOAT bX,
+ FX_FLOAT bY) {
+ float xDiff = aX - bX;
+ float yDiff = aY - bY;
+ return Round((float)sqrt(xDiff * xDiff + yDiff * yDiff));
}
-int32_t CBC_WhiteRectangleDetector::DistanceL2(FX_FLOAT aX, FX_FLOAT aY, FX_FLOAT bX, FX_FLOAT bY)
-{
- float xDiff = aX - bX;
- float yDiff = aY - bY;
- return Round((float)sqrt(xDiff * xDiff + yDiff * yDiff));
+CFX_PtrArray* CBC_WhiteRectangleDetector::CenterEdges(CBC_ResultPoint* y,
+ CBC_ResultPoint* z,
+ CBC_ResultPoint* x,
+ CBC_ResultPoint* t) {
+ float yi = y->GetX();
+ float yj = y->GetY();
+ float zi = z->GetX();
+ float zj = z->GetY();
+ float xi = x->GetX();
+ float xj = x->GetY();
+ float ti = t->GetX();
+ float tj = t->GetY();
+ if (yi < m_width / 2) {
+ CFX_PtrArray* result = FX_NEW CFX_PtrArray;
+ result->SetSize(4);
+ (*result)[0] = FX_NEW CBC_ResultPoint(ti - CORR, tj + CORR);
+ (*result)[1] = FX_NEW CBC_ResultPoint(zi + CORR, zj + CORR);
+ (*result)[2] = FX_NEW CBC_ResultPoint(xi - CORR, xj - CORR);
+ (*result)[3] = FX_NEW CBC_ResultPoint(yi + CORR, yj - CORR);
+ return result;
+ } else {
+ CFX_PtrArray* result = FX_NEW CFX_PtrArray;
+ result->SetSize(4);
+ (*result)[0] = FX_NEW CBC_ResultPoint(ti + CORR, tj + CORR);
+ (*result)[1] = FX_NEW CBC_ResultPoint(zi + CORR, zj - CORR);
+ (*result)[2] = FX_NEW CBC_ResultPoint(xi - CORR, xj + CORR);
+ (*result)[3] = FX_NEW CBC_ResultPoint(yi - CORR, yj - CORR);
+ return result;
+ }
}
-CFX_PtrArray *CBC_WhiteRectangleDetector::CenterEdges(CBC_ResultPoint *y, CBC_ResultPoint *z, CBC_ResultPoint *x, CBC_ResultPoint *t)
-{
- float yi = y->GetX();
- float yj = y->GetY();
- float zi = z->GetX();
- float zj = z->GetY();
- float xi = x->GetX();
- float xj = x->GetY();
- float ti = t->GetX();
- float tj = t->GetY();
- if (yi < m_width / 2) {
- CFX_PtrArray *result = FX_NEW CFX_PtrArray;
- result->SetSize(4);
- (*result)[0] = FX_NEW CBC_ResultPoint(ti - CORR, tj + CORR);
- (*result)[1] = FX_NEW CBC_ResultPoint(zi + CORR, zj + CORR);
- (*result)[2] = FX_NEW CBC_ResultPoint(xi - CORR, xj - CORR);
- (*result)[3] = FX_NEW CBC_ResultPoint(yi + CORR, yj - CORR);
- return result;
- } else {
- CFX_PtrArray *result = FX_NEW CFX_PtrArray;
- result->SetSize(4);
- (*result)[0] = FX_NEW CBC_ResultPoint(ti + CORR, tj + CORR);
- (*result)[1] = FX_NEW CBC_ResultPoint(zi + CORR, zj - CORR);
- (*result)[2] = FX_NEW CBC_ResultPoint(xi - CORR, xj + CORR);
- (*result)[3] = FX_NEW CBC_ResultPoint(yi - CORR, yj - CORR);
- return result;
+FX_BOOL CBC_WhiteRectangleDetector::ContainsBlackPoint(int32_t a,
+ int32_t b,
+ int32_t fixed,
+ FX_BOOL horizontal) {
+ if (horizontal) {
+ for (int32_t x = a; x <= b; x++) {
+ if (m_image->Get(x, fixed)) {
+ return TRUE;
+ }
}
-}
-FX_BOOL CBC_WhiteRectangleDetector::ContainsBlackPoint(int32_t a, int32_t b, int32_t fixed, FX_BOOL horizontal)
-{
- if (horizontal) {
- for (int32_t x = a; x <= b; x++) {
- if (m_image->Get(x, fixed)) {
- return TRUE;
- }
- }
- } else {
- for (int32_t y = a; y <= b; y++) {
- if (m_image->Get(fixed, y)) {
- return TRUE;
- }
- }
- }
- return FALSE;
+ } else {
+ for (int32_t y = a; y <= b; y++) {
+ if (m_image->Get(fixed, y)) {
+ return TRUE;
+ }
+ }
+ }
+ return FALSE;
}
diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h
index c7607f9e56..74112d20d6 100644
--- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h
+++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h
@@ -8,30 +8,41 @@
#define _BC_WHITERECTANLEDETECTOR_H_
class CBC_CommonBitMatrix;
class CBC_ResultPoint;
-class CBC_WhiteRectangleDetector
-{
-public:
- CBC_WhiteRectangleDetector(CBC_CommonBitMatrix *image);
- CBC_WhiteRectangleDetector(CBC_CommonBitMatrix *image, int32_t initSize, int32_t x, int32_t y);
- virtual ~CBC_WhiteRectangleDetector();
- CFX_PtrArray *Detect(int32_t &e);
- virtual void Init(int32_t &e);
-private:
- int32_t Round(float d);
- CBC_ResultPoint *GetBlackPointOnSegment(FX_FLOAT aX, FX_FLOAT aY, FX_FLOAT bX, FX_FLOAT bY);
- int32_t DistanceL2(FX_FLOAT aX, FX_FLOAT aY, FX_FLOAT bX, FX_FLOAT bY);
- CFX_PtrArray *CenterEdges(CBC_ResultPoint *y, CBC_ResultPoint *z,
- CBC_ResultPoint *x, CBC_ResultPoint *t);
- FX_BOOL ContainsBlackPoint(int32_t a, int32_t b, int32_t fixed, FX_BOOL horizontal);
- const static int32_t INIT_SIZE;
- const static int32_t CORR;
+class CBC_WhiteRectangleDetector {
+ public:
+ CBC_WhiteRectangleDetector(CBC_CommonBitMatrix* image);
+ CBC_WhiteRectangleDetector(CBC_CommonBitMatrix* image,
+ int32_t initSize,
+ int32_t x,
+ int32_t y);
+ virtual ~CBC_WhiteRectangleDetector();
+ CFX_PtrArray* Detect(int32_t& e);
+ virtual void Init(int32_t& e);
- CBC_CommonBitMatrix *m_image;
- int32_t m_height;
- int32_t m_width;
- int32_t m_leftInit;
- int32_t m_rightInit;
- int32_t m_downInit;
- int32_t m_upInit;
+ private:
+ int32_t Round(float d);
+ CBC_ResultPoint* GetBlackPointOnSegment(FX_FLOAT aX,
+ FX_FLOAT aY,
+ FX_FLOAT bX,
+ FX_FLOAT bY);
+ int32_t DistanceL2(FX_FLOAT aX, FX_FLOAT aY, FX_FLOAT bX, FX_FLOAT bY);
+ CFX_PtrArray* CenterEdges(CBC_ResultPoint* y,
+ CBC_ResultPoint* z,
+ CBC_ResultPoint* x,
+ CBC_ResultPoint* t);
+ FX_BOOL ContainsBlackPoint(int32_t a,
+ int32_t b,
+ int32_t fixed,
+ FX_BOOL horizontal);
+ const static int32_t INIT_SIZE;
+ const static int32_t CORR;
+
+ CBC_CommonBitMatrix* m_image;
+ int32_t m_height;
+ int32_t m_width;
+ int32_t m_leftInit;
+ int32_t m_rightInit;
+ int32_t m_downInit;
+ int32_t m_upInit;
};
#endif
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