summaryrefslogtreecommitdiff
path: root/xfa/src/fxbarcode/common
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-01-26 14:51:21 -0800
committerTom Sepez <tsepez@chromium.org>2016-01-26 14:51:21 -0800
commit99ffdb0b9b488d743331646dc410f26b71e1f037 (patch)
treed9f7a4b05c8d4c46b38f9940ff8e3be9803b73e1 /xfa/src/fxbarcode/common
parentc812495631df9f059bfd332ffe37e76dd011e96c (diff)
downloadpdfium-99ffdb0b9b488d743331646dc410f26b71e1f037.tar.xz
Fix DOS newlines
R=thestig@chromium.org Review URL: https://codereview.chromium.org/1636873004 .
Diffstat (limited to 'xfa/src/fxbarcode/common')
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitArray.cpp224
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitArray.h62
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp298
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitMatrix.h82
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitSource.cpp142
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonBitSource.h44
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteArray.cpp212
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteArray.h58
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp132
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonByteMatrix.h56
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp88
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h52
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp154
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonDecoderResult.h80
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonECI.cpp82
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonECI.h40
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp296
-rw-r--r--xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h122
-rw-r--r--xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp338
-rw-r--r--xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h60
-rw-r--r--xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp520
-rw-r--r--xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h96
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp204
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h48
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp478
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h60
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp260
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h72
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp518
-rw-r--r--xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h76
30 files changed, 2477 insertions, 2477 deletions
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp b/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp
index 61b4ce3b4f..e9bb3b747a 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitArray.cpp
@@ -1,112 +1,112 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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() {
- 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() {
- m_size = 0;
-}
-int32_t CBC_CommonBitArray::GetSize() {
- return m_size;
-}
-CFX_Int32Array& CBC_CommonBitArray::GetBits() {
- return m_bits;
-}
-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;
-}
-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::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));
-}
-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;
- }
- }
- if ((m_bits[i] & mask) != (value ? mask : 0)) {
- return FALSE;
- }
- }
- return TRUE;
-}
-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);
- }
- }
- FXSYS_memcpy(&m_bits[0], newBits, m_bits.GetSize() * sizeof(int32_t));
- FX_Free(newBits);
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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() {
+ 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() {
+ m_size = 0;
+}
+int32_t CBC_CommonBitArray::GetSize() {
+ return m_size;
+}
+CFX_Int32Array& CBC_CommonBitArray::GetBits() {
+ return m_bits;
+}
+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;
+}
+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::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));
+}
+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;
+ }
+ }
+ if ((m_bits[i] & mask) != (value ? mask : 0)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+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);
+ }
+ }
+ 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 f4758f7d68..fb93a9e912 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitArray.h
+++ b/xfa/src/fxbarcode/common/BC_CommonBitArray.h
@@ -1,31 +1,31 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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;
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
index c45e28c0c8..42e07c3dee 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.cpp
@@ -1,149 +1,149 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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_Alloc2D(int32_t, m_rowSize, m_height);
- FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
-}
-void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
- m_width = width;
- m_height = height;
- int32_t rowSize = (width + 31) >> 5;
- m_rowSize = rowSize;
- m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height);
- FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
-}
-CBC_CommonBitMatrix::~CBC_CommonBitMatrix() {
- 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 = new CBC_CommonBitArray(m_width);
- } else {
- rowArray = new CBC_CommonBitArray(row);
- }
- int32_t offset = y * m_rowSize;
- int32_t x;
- for (x = 0; x < m_rowSize; x++) {
- rowArray->SetBulk(x << 5, m_bits[offset + x]);
- }
- return rowArray;
-}
-void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row) {
- int32_t l = y * m_rowSize;
- for (int32_t i = 0; i < m_rowSize; i++) {
- m_bits[l] = row->GetBitArray()[i];
- l++;
- }
-}
-void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col) {
- for (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;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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_Alloc2D(int32_t, m_rowSize, m_height);
+ FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+}
+void CBC_CommonBitMatrix::Init(int32_t width, int32_t height) {
+ m_width = width;
+ m_height = height;
+ int32_t rowSize = (width + 31) >> 5;
+ m_rowSize = rowSize;
+ m_bits = FX_Alloc2D(int32_t, m_rowSize, m_height);
+ FXSYS_memset(m_bits, 0, m_rowSize * m_height * sizeof(int32_t));
+}
+CBC_CommonBitMatrix::~CBC_CommonBitMatrix() {
+ 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 = new CBC_CommonBitArray(m_width);
+ } else {
+ rowArray = new CBC_CommonBitArray(row);
+ }
+ int32_t offset = y * m_rowSize;
+ int32_t x;
+ for (x = 0; x < m_rowSize; x++) {
+ rowArray->SetBulk(x << 5, m_bits[offset + x]);
+ }
+ return rowArray;
+}
+void CBC_CommonBitMatrix::SetRow(int32_t y, CBC_CommonBitArray* row) {
+ int32_t l = y * m_rowSize;
+ for (int32_t i = 0; i < m_rowSize; i++) {
+ m_bits[l] = row->GetBitArray()[i];
+ l++;
+ }
+}
+void CBC_CommonBitMatrix::SetCol(int32_t y, CBC_CommonBitArray* col) {
+ for (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 42cbedf00c..d60e437ea1 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h
+++ b/xfa/src/fxbarcode/common/BC_CommonBitMatrix.h
@@ -1,41 +1,41 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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;
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp b/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp
index c308638fad..7bf4bf61fd 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonBitSource.cpp
@@ -1,71 +1,71 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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() {}
-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++;
- }
- }
- 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;
- }
- }
- return result;
-}
-int32_t CBC_CommonBitSource::Available() {
- return 8 * (m_bytes.GetSize() - m_byteOffset) - m_bitOffset;
-}
-int32_t CBC_CommonBitSource::getByteOffset() {
- return m_byteOffset;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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() {}
+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++;
+ }
+ }
+ 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;
+ }
+ }
+ return result;
+}
+int32_t CBC_CommonBitSource::Available() {
+ return 8 * (m_bytes.GetSize() - m_byteOffset) - m_bitOffset;
+}
+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 ccb66bf49b..098a6060d3 100644
--- a/xfa/src/fxbarcode/common/BC_CommonBitSource.h
+++ b/xfa/src/fxbarcode/common/BC_CommonBitSource.h
@@ -1,22 +1,22 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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;
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
index c36ff34a6d..b3e2a636e5 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonByteArray.cpp
@@ -1,106 +1,106 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <algorithm>
-
-#include "xfa/src/fxbarcode/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(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() {
- if (m_bytes != NULL) {
- FX_Free(m_bytes);
- m_bytes = NULL;
- }
- m_index = 0;
- m_size = 0;
-}
-int32_t CBC_CommonByteArray::At(int32_t index) {
- return m_bytes[index] & 0xff;
-}
-void CBC_CommonByteArray::Set(int32_t index, int32_t value) {
- m_bytes[index] = (uint8_t)value;
-}
-int32_t CBC_CommonByteArray::Size() {
- return m_size;
-}
-FX_BOOL CBC_CommonByteArray::IsEmpty() {
- return m_size == 0;
-}
-void CBC_CommonByteArray::AppendByte(int32_t value) {
- if (m_size == 0 || m_index >= m_size) {
- int32_t newSize = std::max(32, m_size << 1);
- Reserve(newSize);
- }
- m_bytes[m_index] = (uint8_t)value;
- m_index++;
-}
-void CBC_CommonByteArray::Reserve(int32_t capacity) {
- if (m_bytes == 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::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;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2008 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <algorithm>
+
+#include "xfa/src/fxbarcode/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(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() {
+ if (m_bytes != NULL) {
+ FX_Free(m_bytes);
+ m_bytes = NULL;
+ }
+ m_index = 0;
+ m_size = 0;
+}
+int32_t CBC_CommonByteArray::At(int32_t index) {
+ return m_bytes[index] & 0xff;
+}
+void CBC_CommonByteArray::Set(int32_t index, int32_t value) {
+ m_bytes[index] = (uint8_t)value;
+}
+int32_t CBC_CommonByteArray::Size() {
+ return m_size;
+}
+FX_BOOL CBC_CommonByteArray::IsEmpty() {
+ return m_size == 0;
+}
+void CBC_CommonByteArray::AppendByte(int32_t value) {
+ if (m_size == 0 || m_index >= m_size) {
+ int32_t newSize = std::max(32, m_size << 1);
+ Reserve(newSize);
+ }
+ m_bytes[m_index] = (uint8_t)value;
+ m_index++;
+}
+void CBC_CommonByteArray::Reserve(int32_t capacity) {
+ if (m_bytes == 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::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 12e214c0c2..6e89aa4518 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteArray.h
+++ b/xfa/src/fxbarcode/common/BC_CommonByteArray.h
@@ -1,29 +1,29 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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);
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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);
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
index 875b8026c9..e075a5fab8 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.cpp
@@ -1,66 +1,66 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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;
-}
-void CBC_CommonByteMatrix::Init() {
- m_bytes = FX_Alloc2D(uint8_t, m_height, m_width);
- FXSYS_memset(m_bytes, 0xff, m_height * m_width);
-}
-CBC_CommonByteMatrix::~CBC_CommonByteMatrix() {
- if (m_bytes != NULL) {
- FX_Free(m_bytes);
- m_bytes = NULL;
- }
-}
-int32_t CBC_CommonByteMatrix::GetHeight() {
- return m_height;
-}
-int32_t CBC_CommonByteMatrix::GetWidth() {
- return m_width;
-}
-uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) {
- return m_bytes[y * m_width + x];
-}
-void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value) {
- m_bytes[y * m_width + x] = (uint8_t)value;
-}
-void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value) {
- m_bytes[y * m_width + x] = value;
-}
-void CBC_CommonByteMatrix::clear(uint8_t value) {
- int32_t y;
- for (y = 0; y < m_height; y++) {
- int32_t x;
- for (x = 0; x < m_width; x++) {
- m_bytes[y * m_width + x] = value;
- }
- }
-}
-uint8_t* CBC_CommonByteMatrix::GetArray() {
- return m_bytes;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2008 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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;
+}
+void CBC_CommonByteMatrix::Init() {
+ m_bytes = FX_Alloc2D(uint8_t, m_height, m_width);
+ FXSYS_memset(m_bytes, 0xff, m_height * m_width);
+}
+CBC_CommonByteMatrix::~CBC_CommonByteMatrix() {
+ if (m_bytes != NULL) {
+ FX_Free(m_bytes);
+ m_bytes = NULL;
+ }
+}
+int32_t CBC_CommonByteMatrix::GetHeight() {
+ return m_height;
+}
+int32_t CBC_CommonByteMatrix::GetWidth() {
+ return m_width;
+}
+uint8_t CBC_CommonByteMatrix::Get(int32_t x, int32_t y) {
+ return m_bytes[y * m_width + x];
+}
+void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, int32_t value) {
+ m_bytes[y * m_width + x] = (uint8_t)value;
+}
+void CBC_CommonByteMatrix::Set(int32_t x, int32_t y, uint8_t value) {
+ m_bytes[y * m_width + x] = value;
+}
+void CBC_CommonByteMatrix::clear(uint8_t value) {
+ int32_t y;
+ for (y = 0; y < m_height; y++) {
+ int32_t x;
+ for (x = 0; x < m_width; x++) {
+ m_bytes[y * m_width + x] = value;
+ }
+ }
+}
+uint8_t* CBC_CommonByteMatrix::GetArray() {
+ return m_bytes;
+}
diff --git a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h
index b94daf81a8..db01704a23 100644
--- a/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h
+++ b/xfa/src/fxbarcode/common/BC_CommonByteMatrix.h
@@ -1,28 +1,28 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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();
-
- 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
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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();
+
+ 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 2beb850963..6bd7d70c49 100644
--- a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.cpp
@@ -1,44 +1,44 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/barcode.h"
-#include "BC_CommonECI.h"
-#include "BC_CommonCharacterSetECI.h"
-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;
-}
-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;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2008 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/barcode.h"
+#include "BC_CommonECI.h"
+#include "BC_CommonCharacterSetECI.h"
+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;
+}
+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;
+}
diff --git a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h
index 5cdc4d6a51..6626f7be7e 100644
--- a/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h
+++ b/xfa/src/fxbarcode/common/BC_CommonCharacterSetECI.h
@@ -1,26 +1,26 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _BC_COMMONCHARACTERSETECI_H_
-#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();
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _BC_COMMONCHARACTERSETECI_H_
+#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();
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
index 1bf9f57981..76219794df 100644
--- a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.cpp
@@ -1,77 +1,77 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/barcode.h"
-#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
-#include "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h"
-#include "BC_CommonDecoderResult.h"
-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_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;
-}
-CBC_CommonDecoderResult::~CBC_CommonDecoderResult() {
- if (m_other != NULL) {
- delete m_other;
- }
-}
-const CFX_ByteArray& CBC_CommonDecoderResult::GetRawBytes() {
- return m_rawBytes;
-}
-const CFX_Int32Array& CBC_CommonDecoderResult::GetByteSegments() {
- return m_byteSegments;
-}
-const CFX_ByteString& CBC_CommonDecoderResult::GetText() {
- return m_text;
-}
-CBC_QRCoderErrorCorrectionLevel* CBC_CommonDecoderResult::GetECLevel() {
- return m_ecLevel;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/barcode.h"
+#include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h"
+#include "xfa/src/fxbarcode/pdf417/BC_PDF417ResultMetadata.h"
+#include "BC_CommonDecoderResult.h"
+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_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;
+}
+CBC_CommonDecoderResult::~CBC_CommonDecoderResult() {
+ if (m_other != NULL) {
+ delete m_other;
+ }
+}
+const CFX_ByteArray& CBC_CommonDecoderResult::GetRawBytes() {
+ return m_rawBytes;
+}
+const CFX_Int32Array& CBC_CommonDecoderResult::GetByteSegments() {
+ return m_byteSegments;
+}
+const CFX_ByteString& CBC_CommonDecoderResult::GetText() {
+ return m_text;
+}
+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 40c3a09078..93bab384ab 100644
--- a/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h
+++ b/xfa/src/fxbarcode/common/BC_CommonDecoderResult.h
@@ -1,40 +1,40 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _BC_COMMONDECODERRESULT_H_
-#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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _BC_COMMONDECODERRESULT_H_
+#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;
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonECI.cpp b/xfa/src/fxbarcode/common/BC_CommonECI.cpp
index d9f918b025..c83980bb20 100644
--- a/xfa/src/fxbarcode/common/BC_CommonECI.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonECI.cpp
@@ -1,41 +1,41 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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 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) {
- }
- return NULL;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2008 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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 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) {
+ }
+ return NULL;
+}
diff --git a/xfa/src/fxbarcode/common/BC_CommonECI.h b/xfa/src/fxbarcode/common/BC_CommonECI.h
index 1f90383497..07b7e41870 100644
--- a/xfa/src/fxbarcode/common/BC_CommonECI.h
+++ b/xfa/src/fxbarcode/common/BC_CommonECI.h
@@ -1,20 +1,20 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _BC_COMMONECI_H_
-#define _BC_COMMONECI_H_
-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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _BC_COMMONECI_H_
+#define _BC_COMMONECI_H_
+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;
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
index 3fd2e4a893..e67041a50c 100644
--- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
+++ b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp
@@ -1,148 +1,148 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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_a12(a12),
- m_a13(a13),
- m_a21(a21),
- m_a22(a22),
- m_a23(a23),
- m_a31(a31),
- m_a32(a32),
- 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()));
-}
-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::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 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 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::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 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 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);
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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_a12(a12),
+ m_a13(a13),
+ m_a21(a21),
+ m_a22(a22),
+ m_a23(a23),
+ m_a31(a31),
+ m_a32(a32),
+ 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()));
+}
+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::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 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 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::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 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 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 22e90cdc46..f53bb00632 100644
--- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h
+++ b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h
@@ -1,61 +1,61 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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;
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
index 24c17712cc..42438978df 100644
--- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
+++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp
@@ -1,169 +1,169 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2009 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/barcode.h"
-#include "xfa/src/fxbarcode/BC_Binarizer.h"
-#include "xfa/src/fxbarcode/BC_LuminanceSource.h"
-#include "BC_CommonBitMatrix.h"
-#include "BC_CommonBitArray.h"
-#include "BC_GlobalHistogramBinarizer.h"
-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(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;
- }
- 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 = 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);
- 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);
- }
- 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 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 (buckets[x] > maxBucketCount) {
- maxBucketCount = buckets[x];
- }
- }
- 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;
- }
- }
- 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;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2009 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/barcode.h"
+#include "xfa/src/fxbarcode/BC_Binarizer.h"
+#include "xfa/src/fxbarcode/BC_LuminanceSource.h"
+#include "BC_CommonBitMatrix.h"
+#include "BC_CommonBitArray.h"
+#include "BC_GlobalHistogramBinarizer.h"
+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(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;
+ }
+ 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 = 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);
+ 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);
+ }
+ 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 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 (buckets[x] > maxBucketCount) {
+ maxBucketCount = buckets[x];
+ }
+ }
+ 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;
+ }
+ }
+ 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;
+}
diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
index 63ff3e7533..52b653542c 100644
--- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
+++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h
@@ -1,30 +1,30 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _BC_GLOBALHISTOGRAMBINARIZER_H_
-#define _BC_GLOBALHISTOGRAMBINARIZER_H_
-class CBC_CommonBinarizer;
-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();
-
- 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
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _BC_GLOBALHISTOGRAMBINARIZER_H_
+#define _BC_GLOBALHISTOGRAMBINARIZER_H_
+class CBC_CommonBinarizer;
+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();
+
+ 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 a01eaee3ac..a2d6c55067 100644
--- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
+++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp
@@ -1,260 +1,260 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2010 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/barcode.h"
-#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h"
-#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h"
-#include "xfa/src/fxbarcode/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;
-}
-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() {}
-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);
-}
-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 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));
-}
-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 = new CFX_PtrArray;
- result->SetSize(4);
- (*result)[0] = new CBC_ResultPoint(ti - CORR, tj + CORR);
- (*result)[1] = new CBC_ResultPoint(zi + CORR, zj + CORR);
- (*result)[2] = new CBC_ResultPoint(xi - CORR, xj - CORR);
- (*result)[3] = new CBC_ResultPoint(yi + CORR, yj - CORR);
- return result;
- } else {
- CFX_PtrArray* result = new CFX_PtrArray;
- result->SetSize(4);
- (*result)[0] = new CBC_ResultPoint(ti + CORR, tj + CORR);
- (*result)[1] = new CBC_ResultPoint(zi + CORR, zj - CORR);
- (*result)[2] = new CBC_ResultPoint(xi - CORR, xj + CORR);
- (*result)[3] = 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;
- }
- }
- } else {
- for (int32_t y = a; y <= b; y++) {
- if (m_image->Get(fixed, y)) {
- return TRUE;
- }
- }
- }
- return FALSE;
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2010 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/barcode.h"
+#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h"
+#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h"
+#include "xfa/src/fxbarcode/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;
+}
+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() {}
+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);
+}
+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 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));
+}
+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 = new CFX_PtrArray;
+ result->SetSize(4);
+ (*result)[0] = new CBC_ResultPoint(ti - CORR, tj + CORR);
+ (*result)[1] = new CBC_ResultPoint(zi + CORR, zj + CORR);
+ (*result)[2] = new CBC_ResultPoint(xi - CORR, xj - CORR);
+ (*result)[3] = new CBC_ResultPoint(yi + CORR, yj - CORR);
+ return result;
+ } else {
+ CFX_PtrArray* result = new CFX_PtrArray;
+ result->SetSize(4);
+ (*result)[0] = new CBC_ResultPoint(ti + CORR, tj + CORR);
+ (*result)[1] = new CBC_ResultPoint(zi + CORR, zj - CORR);
+ (*result)[2] = new CBC_ResultPoint(xi - CORR, xj + CORR);
+ (*result)[3] = 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;
+ }
+ }
+ } 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 74112d20d6..f0de614d99 100644
--- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h
+++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h
@@ -1,48 +1,48 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _BC_WHITERECTANLEDETECTOR_H_
-#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;
-
- 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
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _BC_WHITERECTANLEDETECTOR_H_
+#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;
+
+ 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 a14a2d9cb5..af526a7ead 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp
@@ -1,102 +1,102 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/barcode.h"
-#include "BC_ReedSolomonGF256.h"
-#include "BC_ReedSolomonGF256Poly.h"
-#include "BC_ReedSolomon.h"
-CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) {
- m_field = field;
-}
-void CBC_ReedSolomonEncoder::Init() {
- m_cachedGenerators.Add(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;
- }
- }
- 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);
- 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];
- }
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/barcode.h"
+#include "BC_ReedSolomonGF256.h"
+#include "BC_ReedSolomonGF256Poly.h"
+#include "BC_ReedSolomon.h"
+CBC_ReedSolomonEncoder::CBC_ReedSolomonEncoder(CBC_ReedSolomonGF256* field) {
+ m_field = field;
+}
+void CBC_ReedSolomonEncoder::Init() {
+ m_cachedGenerators.Add(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;
+ }
+ }
+ 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);
+ 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];
+ }
+}
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
index 6725636408..138163b10d 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h
@@ -1,24 +1,24 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _BC_READSOLOMON_H_
-#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();
-
- void Encode(CFX_Int32Array* toEncode, int32_t ecBytes, int32_t& e);
- virtual void Init();
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _BC_READSOLOMON_H_
+#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();
+
+ 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 4ee87a4fa7..b053f2a784 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp
@@ -1,239 +1,239 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/barcode.h"
-#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() {}
-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);
- 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]);
- }
-}
-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* 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);
- 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 = 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(new CFX_Int32Array);
- temp->Add(errorLocator->GetCoefficients(1));
- return temp.release();
- }
- CFX_Int32Array* tempT = 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();
-}
-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 = 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);
- }
- return result.release();
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/barcode.h"
+#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() {}
+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);
+ 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]);
+ }
+}
+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* 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);
+ 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 = 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(new CFX_Int32Array);
+ temp->Add(errorLocator->GetCoefficients(1));
+ return temp.release();
+ }
+ CFX_Int32Array* tempT = 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();
+}
+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 = 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);
+ }
+ return result.release();
+}
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
index 747755c011..e230a3af74 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h
@@ -1,30 +1,30 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _BC_REEDSOLOMONDECODER_H_
-#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);
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _BC_REEDSOLOMONDECODER_H_
+#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);
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
index 0957ca51b7..97aa70d786 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.cpp
@@ -1,130 +1,130 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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 = new CBC_ReedSolomonGF256(0x011D);
- QRCodeFild->Init();
- DataMatrixField = new CBC_ReedSolomonGF256(0x012D);
- DataMatrixField->Init();
-}
-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;
- }
- }
- for (int32_t i = 0; i < 255; i++) {
- m_logTable[m_expTable[i]] = i;
- }
- m_logTable[0] = 0;
-}
-void CBC_ReedSolomonGF256::Init() {
- m_zero = new CBC_ReedSolomonGF256Poly(this, 0);
- m_one = 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_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() {
- return m_zero;
-}
-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 = 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::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::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];
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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 = new CBC_ReedSolomonGF256(0x011D);
+ QRCodeFild->Init();
+ DataMatrixField = new CBC_ReedSolomonGF256(0x012D);
+ DataMatrixField->Init();
+}
+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;
+ }
+ }
+ for (int32_t i = 0; i < 255; i++) {
+ m_logTable[m_expTable[i]] = i;
+ }
+ m_logTable[0] = 0;
+}
+void CBC_ReedSolomonGF256::Init() {
+ m_zero = new CBC_ReedSolomonGF256Poly(this, 0);
+ m_one = 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_ReedSolomonGF256Poly* CBC_ReedSolomonGF256::GetZero() {
+ return m_zero;
+}
+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 = 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::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::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];
+}
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h
index 58e2f9ec3e..d414f13d3c 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h
@@ -1,36 +1,36 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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;
+};
+#endif
diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
index f87cd5ba86..b1eed008cf 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp
@@ -1,259 +1,259 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-// Original code is licensed as follows:
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include "xfa/src/fxbarcode/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() {
- 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);
- }
- 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);
- }
- }
- } else {
- m_coefficients.Copy(*coefficients);
- }
-}
-CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() {
- return &m_coefficients;
-}
-int32_t CBC_ReedSolomonGF256Poly::GetDegree() {
- return m_coefficients.GetSize() - 1;
-}
-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::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 = 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 = 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 = 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 = 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 = 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);
- 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);
- 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 = new CFX_PtrArray;
- tempPtrA->Add(quotient.release());
- tempPtrA->Add(remainder.release());
- return tempPtrA;
-}
-CBC_ReedSolomonGF256Poly::~CBC_ReedSolomonGF256Poly() {
- m_coefficients.RemoveAll();
-}
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+// Original code is licensed as follows:
+/*
+ * Copyright 2007 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "xfa/src/fxbarcode/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() {
+ 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);
+ }
+ 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);
+ }
+ }
+ } else {
+ m_coefficients.Copy(*coefficients);
+ }
+}
+CFX_Int32Array* CBC_ReedSolomonGF256Poly::GetCoefficients() {
+ return &m_coefficients;
+}
+int32_t CBC_ReedSolomonGF256Poly::GetDegree() {
+ return m_coefficients.GetSize() - 1;
+}
+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::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 = 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 = 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 = 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 = 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 = 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);
+ 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);
+ 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 = new CFX_PtrArray;
+ tempPtrA->Add(quotient.release());
+ tempPtrA->Add(remainder.release());
+ return tempPtrA;
+}
+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 9f1a5dfac7..2ff7602eba 100644
--- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
+++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h
@@ -1,38 +1,38 @@
-// Copyright 2014 PDFium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
-
-#ifndef _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;
-};
-#endif
+// Copyright 2014 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef _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;
+};
+#endif