summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-03-18 09:32:06 -0700
committerTom Sepez <tsepez@chromium.org>2016-03-18 09:32:06 -0700
commit314743a4a752716b8e977482ad6c757c70d019db (patch)
tree3bb2332e5232c1b37e9da0ccb02aec2e87de1a00
parent3420909bbb47d6e47d6c561cbcce06d056fdf0a3 (diff)
downloadpdfium-314743a4a752716b8e977482ad6c757c70d019db.tar.xz
Reduce size of several PDFium constant tables.
Either by using the smallest possible data type, or By accurately calcuating the bounds, or Moving to array of pointers for varying length rows. Notes: The 929 is reassuring since PDF417 barcode uses GF(929). FX_WCHAR is 4 bytes on unix (2 on windows). Binary looks to be about 240k smaller on linux/64 R=ochang@chromium.org Review URL: https://codereview.chromium.org/1807373002 .
-rw-r--r--core/fpdftext/unicodenormalization.cpp4
-rw-r--r--core/fpdftext/unicodenormalizationdata.cpp10
-rw-r--r--core/fpdftext/unicodenormalizationdata.h12
-rw-r--r--xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp113
-rw-r--r--xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h2
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417.cpp4
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417.h6
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp6
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h1
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417Common.cpp16
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417Common.h20
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp173
-rw-r--r--xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h3
13 files changed, 210 insertions, 160 deletions
diff --git a/core/fpdftext/unicodenormalization.cpp b/core/fpdftext/unicodenormalization.cpp
index b8e8eb98d3..dd563e5ee3 100644
--- a/core/fpdftext/unicodenormalization.cpp
+++ b/core/fpdftext/unicodenormalization.cpp
@@ -11,7 +11,7 @@
namespace {
-const FX_WCHAR* const g_UnicodeData_Normalization_Maps[5] = {
+const uint16_t* const g_UnicodeData_Normalization_Maps[5] = {
nullptr, g_UnicodeData_Normalization_Map1, g_UnicodeData_Normalization_Map2,
g_UnicodeData_Normalization_Map3, g_UnicodeData_Normalization_Map4};
@@ -33,7 +33,7 @@ FX_STRSIZE FX_Unicode_GetNormalization(FX_WCHAR wch, FX_WCHAR* pDst) {
wch = wFind & 0x0FFF;
wFind >>= 12;
}
- const FX_WCHAR* pMap = g_UnicodeData_Normalization_Maps[wFind];
+ const uint16_t* pMap = g_UnicodeData_Normalization_Maps[wFind];
if (pMap == g_UnicodeData_Normalization_Map4) {
pMap = g_UnicodeData_Normalization_Map4 + wch;
wFind = (FX_WCHAR)(*pMap++);
diff --git a/core/fpdftext/unicodenormalizationdata.cpp b/core/fpdftext/unicodenormalizationdata.cpp
index e9f3fbf2e9..b22625cf9e 100644
--- a/core/fpdftext/unicodenormalizationdata.cpp
+++ b/core/fpdftext/unicodenormalizationdata.cpp
@@ -7,7 +7,7 @@
#include "core/fpdftext/unicodenormalizationdata.h"
#include "core/include/fxcrt/fx_system.h"
-const FX_WCHAR g_UnicodeData_Normalization[65536] = {
+const uint16_t g_UnicodeData_Normalization[65536] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
@@ -7291,7 +7291,7 @@ const FX_WCHAR g_UnicodeData_Normalization[65536] = {
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000};
-const FX_WCHAR g_UnicodeData_Normalization_Map1[5376] = {
+const uint16_t g_UnicodeData_Normalization_Map1[5376] = {
0x0066, 0x0053, 0x0053, 0x0059, 0x0020, 0x0308, 0x0061, 0x0052, 0x0304,
0x0032, 0x0033, 0x0301, 0x03BC, 0x0327, 0x0031, 0x006F, 0x0041, 0x0041,
0x0041, 0x0041, 0x0041, 0x0041, 0x0043, 0x0045, 0x0045, 0x0045, 0x0045,
@@ -7891,7 +7891,7 @@ const FX_WCHAR g_UnicodeData_Normalization_Map1[5376] = {
0x00AC, 0x00AF, 0x00A6, 0x00A5, 0x20A9, 0x2502, 0x2190, 0x2191, 0x2192,
0x2193, 0x25A0, 0x25CB};
-const FX_WCHAR g_UnicodeData_Normalization_Map2[1724] = {
+const uint16_t g_UnicodeData_Normalization_Map2[1724] = {
0x004F, 0x0045, 0x0054, 0x004D, 0x006F, 0x0065, 0x0049, 0x004A, 0x0069,
0x006A, 0x004F, 0x0045, 0x006F, 0x0065, 0x0044, 0x017D, 0x0044, 0x017E,
0x0064, 0x017E, 0x004C, 0x004A, 0x004C, 0x006A, 0x006C, 0x006A, 0x004E,
@@ -8085,7 +8085,7 @@ const FX_WCHAR g_UnicodeData_Normalization_Map2[1724] = {
0x0644, 0x0622, 0x0644, 0x0623, 0x0644, 0x0623, 0x0644, 0x0625, 0x0644,
0x0625, 0x0644, 0x0627, 0x0644, 0x0627};
-const FX_WCHAR g_UnicodeData_Normalization_Map3[1164] = {
+const uint16_t g_UnicodeData_Normalization_Map3[1164] = {
0x0031, 0x002F, 0x0034, 0x0031, 0x002F, 0x0032, 0x0033, 0x002F, 0x0034,
0x002E, 0x002E, 0x002E, 0x2032, 0x2032, 0x2032, 0x2035, 0x2035, 0x2035,
0x0061, 0x002F, 0x0063, 0x0061, 0x002F, 0x0073, 0x0063, 0x002F, 0x006F,
@@ -8217,7 +8217,7 @@ const FX_WCHAR g_UnicodeData_Normalization_Map3[1164] = {
0x0646, 0x062C, 0x064A, 0x0635, 0x0644, 0x06D2, 0x0642, 0x0644, 0x06D2,
0x0635, 0x0644, 0x0649};
-const FX_WCHAR g_UnicodeData_Normalization_Map4[488] = {
+const uint16_t g_UnicodeData_Normalization_Map4[488] = {
0x0004, 0x2032, 0x2032, 0x2032, 0x2032, 0x0004, 0x0031, 0x002F, 0x0031,
0x0030, 0x0004, 0x0056, 0x0049, 0x0049, 0x0049, 0x0004, 0x0076, 0x0069,
0x0069, 0x0069, 0x0004, 0x0028, 0x0031, 0x0030, 0x0029, 0x0004, 0x0028,
diff --git a/core/fpdftext/unicodenormalizationdata.h b/core/fpdftext/unicodenormalizationdata.h
index d586aa3781..39ee552ec4 100644
--- a/core/fpdftext/unicodenormalizationdata.h
+++ b/core/fpdftext/unicodenormalizationdata.h
@@ -7,12 +7,12 @@
#ifndef CORE_FPDFTEXT_UNICODENORMALIZATIONDATA_H_
#define CORE_FPDFTEXT_UNICODENORMALIZATIONDATA_H_
-#include "core/include/fxcrt/fx_system.h"
+#include <stdint.h>
-extern const FX_WCHAR g_UnicodeData_Normalization[];
-extern const FX_WCHAR g_UnicodeData_Normalization_Map1[];
-extern const FX_WCHAR g_UnicodeData_Normalization_Map2[];
-extern const FX_WCHAR g_UnicodeData_Normalization_Map3[];
-extern const FX_WCHAR g_UnicodeData_Normalization_Map4[];
+extern const uint16_t g_UnicodeData_Normalization[];
+extern const uint16_t g_UnicodeData_Normalization_Map1[];
+extern const uint16_t g_UnicodeData_Normalization_Map2[];
+extern const uint16_t g_UnicodeData_Normalization_Map3[];
+extern const uint16_t g_UnicodeData_Normalization_Map4[];
#endif // CORE_FPDFTEXT_UNICODENORMALIZATIONDATA_H_
diff --git a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
index 98c0599e50..f091de08b5 100644
--- a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.cpp
@@ -25,45 +25,80 @@
#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h"
-int32_t CBC_ErrorCorrection::FACTOR_SETS[] = {5, 7, 10, 11, 12, 14, 18, 20,
- 24, 28, 36, 42, 48, 56, 62, 68};
-int32_t CBC_ErrorCorrection::FACTORS[][100] = {
- {228, 48, 15, 111, 62},
- {23, 68, 144, 134, 240, 92, 254},
- {28, 24, 185, 166, 223, 248, 116, 255, 110, 61},
- {175, 138, 205, 12, 194, 168, 39, 245, 60, 97, 120},
- {41, 153, 158, 91, 61, 42, 142, 213, 97, 178, 100, 242},
- {156, 97, 192, 252, 95, 9, 157, 119, 138, 45, 18, 186, 83, 185},
- {83, 195, 100, 39, 188, 75, 66, 61, 241, 213, 109, 129, 94, 254, 225, 48,
- 90, 188},
- {15, 195, 244, 9, 233, 71, 168, 2, 188, 160, 153, 145, 253, 79, 108, 82, 27,
- 174, 186, 172},
- {52, 190, 88, 205, 109, 39, 176, 21, 155, 197, 251, 223, 155, 21, 5, 172,
- 254, 124, 12, 181, 184, 96, 50, 193},
- {211, 231, 43, 97, 71, 96, 103, 174, 37, 151, 170, 53, 75, 34, 249, 121, 17,
- 138, 110, 213, 141, 136, 120, 151, 233, 168, 93, 255},
- {245, 127, 242, 218, 130, 250, 162, 181, 102, 120, 84, 179, 220, 251, 80,
- 182, 229, 18, 2, 4, 68, 33, 101, 137, 95, 119, 115, 44, 175, 184, 59, 25,
- 225, 98, 81, 112},
- {77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133, 242, 8, 175,
- 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1, 253, 57, 54, 101, 248, 202,
- 69, 50, 150, 177, 226, 5, 9, 5},
- {245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231, 205, 188, 237, 87,
- 191, 106, 16, 147, 118, 23, 37, 90, 170, 205, 131, 88, 120, 100, 66, 138,
- 186, 240, 82, 44, 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19},
- {175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192, 215, 235,
- 150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234, 117, 203, 29, 232,
- 144, 238, 22, 150, 201, 117, 62, 207, 164, 13, 137, 245, 127, 67, 247, 28,
- 155, 43, 203, 107, 233, 53, 143, 46},
- {242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143, 108, 196, 37,
- 185, 112, 134, 230, 245, 63, 197, 190, 250, 106, 185, 221, 175, 64, 114,
- 71, 161, 44, 147, 6, 27, 218, 51, 63, 87, 10, 40, 130, 188, 17, 163, 31,
- 176, 170, 4, 107, 232, 7, 94, 166, 224, 124, 86, 47, 11, 204},
- {220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36, 73, 127,
- 213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213, 15, 160, 227,
- 236, 66, 139, 153, 185, 202, 167, 179, 25, 220, 232, 96, 210, 231, 136,
- 223, 239, 181, 241, 59, 52, 172, 25, 49, 232, 211, 189, 64, 54, 108, 153,
- 132, 63, 96, 103, 82, 186}};
+namespace {
+
+const uint8_t FACTOR_SETS[] = {5, 7, 10, 11, 12, 14, 18, 20,
+ 24, 28, 36, 42, 48, 56, 62, 68};
+
+const uint8_t FACTORS_0[5] = {228, 48, 15, 111, 62};
+const uint8_t FACTORS_1[7] = {23, 68, 144, 134, 240, 92, 254};
+const uint8_t FACTORS_2[10] = {28, 24, 185, 166, 223, 248, 116, 255, 110, 61};
+const uint8_t FACTORS_3[11] = {175, 138, 205, 12, 194, 168,
+ 39, 245, 60, 97, 120};
+
+const uint8_t FACTORS_4[12] = {41, 153, 158, 91, 61, 42,
+ 142, 213, 97, 178, 100, 242};
+
+const uint8_t FACTORS_5[14] = {156, 97, 192, 252, 95, 9, 157,
+ 119, 138, 45, 18, 186, 83, 185};
+
+const uint8_t FACTORS_6[18] = {83, 195, 100, 39, 188, 75, 66, 61, 241,
+ 213, 109, 129, 94, 254, 225, 48, 90, 188};
+
+const uint8_t FACTORS_7[20] = {15, 195, 244, 9, 233, 71, 168, 2, 188, 160,
+ 153, 145, 253, 79, 108, 82, 27, 174, 186, 172};
+
+const uint8_t FACTORS_8[24] = {52, 190, 88, 205, 109, 39, 176, 21,
+ 155, 197, 251, 223, 155, 21, 5, 172,
+ 254, 124, 12, 181, 184, 96, 50, 193};
+
+const uint8_t FACTORS_9[28] = {211, 231, 43, 97, 71, 96, 103, 174, 37, 151,
+ 170, 53, 75, 34, 249, 121, 17, 138, 110, 213,
+ 141, 136, 120, 151, 233, 168, 93, 255};
+
+const uint8_t FACTORS_10[36] = {245, 127, 242, 218, 130, 250, 162, 181, 102,
+ 120, 84, 179, 220, 251, 80, 182, 229, 18,
+ 2, 4, 68, 33, 101, 137, 95, 119, 115,
+ 44, 175, 184, 59, 25, 225, 98, 81, 112};
+
+const uint8_t FACTORS_11[42] = {
+ 77, 193, 137, 31, 19, 38, 22, 153, 247, 105, 122, 2, 245, 133,
+ 242, 8, 175, 95, 100, 9, 167, 105, 214, 111, 57, 121, 21, 1,
+ 253, 57, 54, 101, 248, 202, 69, 50, 150, 177, 226, 5, 9, 5};
+
+const uint8_t FACTORS_12[48] = {
+ 245, 132, 172, 223, 96, 32, 117, 22, 238, 133, 238, 231,
+ 205, 188, 237, 87, 191, 106, 16, 147, 118, 23, 37, 90,
+ 170, 205, 131, 88, 120, 100, 66, 138, 186, 240, 82, 44,
+ 176, 87, 187, 147, 160, 175, 69, 213, 92, 253, 225, 19};
+
+const uint8_t FACTORS_13[56] = {
+ 175, 9, 223, 238, 12, 17, 220, 208, 100, 29, 175, 170, 230, 192,
+ 215, 235, 150, 159, 36, 223, 38, 200, 132, 54, 228, 146, 218, 234,
+ 117, 203, 29, 232, 144, 238, 22, 150, 201, 117, 62, 207, 164, 13,
+ 137, 245, 127, 67, 247, 28, 155, 43, 203, 107, 233, 53, 143, 46};
+
+const uint8_t FACTORS_14[62] = {
+ 242, 93, 169, 50, 144, 210, 39, 118, 202, 188, 201, 189, 143,
+ 108, 196, 37, 185, 112, 134, 230, 245, 63, 197, 190, 250, 106,
+ 185, 221, 175, 64, 114, 71, 161, 44, 147, 6, 27, 218, 51,
+ 63, 87, 10, 40, 130, 188, 17, 163, 31, 176, 170, 4, 107,
+ 232, 7, 94, 166, 224, 124, 86, 47, 11, 204};
+
+const uint8_t FACTORS_15[68] = {
+ 220, 228, 173, 89, 251, 149, 159, 56, 89, 33, 147, 244, 154, 36,
+ 73, 127, 213, 136, 248, 180, 234, 197, 158, 177, 68, 122, 93, 213,
+ 15, 160, 227, 236, 66, 139, 153, 185, 202, 167, 179, 25, 220, 232,
+ 96, 210, 231, 136, 223, 239, 181, 241, 59, 52, 172, 25, 49, 232,
+ 211, 189, 64, 54, 108, 153, 132, 63, 96, 103, 82, 186};
+
+const uint8_t* const FACTORS[16] = {
+ FACTORS_0, FACTORS_1, FACTORS_2, FACTORS_3, FACTORS_4, FACTORS_5,
+ FACTORS_6, FACTORS_7, FACTORS_8, FACTORS_9, FACTORS_10, FACTORS_11,
+ FACTORS_12, FACTORS_13, FACTORS_14, FACTORS_15};
+
+} // namespace
+
int32_t CBC_ErrorCorrection::MODULO_VALUE = 0x12D;
int32_t CBC_ErrorCorrection::LOG[256] = {0};
int32_t CBC_ErrorCorrection::ALOG[256] = {0};
diff --git a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h
index a4264b6306..1ed8c34a23 100644
--- a/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h
+++ b/xfa/fxbarcode/datamatrix/BC_ErrorCorrection.h
@@ -19,8 +19,6 @@ class CBC_ErrorCorrection {
int32_t& e);
private:
- static int32_t FACTOR_SETS[];
- static int32_t FACTORS[][100];
static int32_t MODULO_VALUE;
static int32_t LOG[256];
static int32_t ALOG[256];
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/fxbarcode/pdf417/BC_PDF417.cpp
index e57a79e17e..15b448b37b 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417.cpp
@@ -28,9 +28,7 @@
#include "xfa/fxbarcode/pdf417/BC_PDF417HighLevelEncoder.h"
#include "xfa/fxbarcode/utils.h"
-int32_t CBC_PDF417::START_PATTERN = 0x1fea8;
-int32_t CBC_PDF417::STOP_PATTERN = 0x3fa29;
-int32_t CBC_PDF417::CODEWORD_TABLE[][1000] = {
+const int32_t CBC_PDF417::CODEWORD_TABLE[][929] = {
{0x1d5c0, 0x1eaf0, 0x1f57c, 0x1d4e0, 0x1ea78, 0x1f53e, 0x1a8c0, 0x1d470,
0x1a860, 0x15040, 0x1a830, 0x15020, 0x1adc0, 0x1d6f0, 0x1eb7c, 0x1ace0,
0x1d678, 0x1eb3e, 0x158c0, 0x1ac70, 0x15860, 0x15dc0, 0x1aef0, 0x1d77c,
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417.h b/xfa/fxbarcode/pdf417/BC_PDF417.h
index fe279db21b..1aec33a964 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417.h
@@ -30,9 +30,9 @@ class CBC_PDF417 {
void setCompact(FX_BOOL compact);
private:
- static int32_t START_PATTERN;
- static int32_t STOP_PATTERN;
- static int32_t CODEWORD_TABLE[][1000];
+ static const int32_t START_PATTERN = 0x1fea8;
+ static const int32_t STOP_PATTERN = 0x3fa29;
+ static const int32_t CODEWORD_TABLE[][929];
static FX_FLOAT PREFERRED_RATIO;
static FX_FLOAT DEFAULT_MODULE_WIDTH;
static FX_FLOAT HEIGHT;
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp
index dfbbc70264..53eabefd95 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.cpp
@@ -27,7 +27,11 @@
#define SYMBOL_TABLE_Length 2787
-FX_FLOAT CBC_PDF417CodewordDecoder::RATIOS_TABLE[2787][8] = {{0}};
+namespace {
+
+FX_FLOAT RATIOS_TABLE[SYMBOL_TABLE_Length][8] = {{0}};
+
+} // namespace
CBC_PDF417CodewordDecoder::CBC_PDF417CodewordDecoder() {}
CBC_PDF417CodewordDecoder::~CBC_PDF417CodewordDecoder() {}
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h
index 920409df84..e5f8c0b144 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417CodewordDecoder.h
@@ -18,7 +18,6 @@ class CBC_PDF417CodewordDecoder {
static int32_t getDecodedValue(CFX_Int32Array& moduleBitCount);
private:
- static FX_FLOAT RATIOS_TABLE[][8];
static CFX_Int32Array* sampleBitCounts(CFX_Int32Array& moduleBitCount);
static int32_t getDecodedCodewordValue(CFX_Int32Array& moduleBitCount);
static int32_t getBitValue(CFX_Int32Array& moduleBitCount);
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Common.cpp b/xfa/fxbarcode/pdf417/BC_PDF417Common.cpp
index fa4647db84..92c641d1bd 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417Common.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417Common.cpp
@@ -22,16 +22,9 @@
#include "xfa/fxbarcode/pdf417/BC_PDF417Common.h"
-int32_t CBC_PDF417Common::NUMBER_OF_CODEWORDS = 929;
-int32_t CBC_PDF417Common::MAX_CODEWORDS_IN_BARCODE = NUMBER_OF_CODEWORDS - 1;
-int32_t CBC_PDF417Common::MIN_ROWS_IN_BARCODE = 3;
-int32_t CBC_PDF417Common::MAX_ROWS_IN_BARCODE = 90;
-int32_t CBC_PDF417Common::MAX_CODEWORDS_IN_ROW = 32;
-int32_t CBC_PDF417Common::MODULES_IN_CODEWORD = 17;
-int32_t CBC_PDF417Common::MODULES_IN_STOP_PATTERN = 18;
-int32_t CBC_PDF417Common::BARS_IN_MODULE = 8;
-CFX_Int32Array* CBC_PDF417Common::EMPTY_INT_ARRAY = NULL;
-int32_t CBC_PDF417Common::SYMBOL_TABLE[] = {
+CFX_Int32Array* CBC_PDF417Common::EMPTY_INT_ARRAY = nullptr;
+
+const int32_t CBC_PDF417Common::SYMBOL_TABLE[] = {
0x1025e, 0x1027a, 0x1029e, 0x102bc, 0x102f2, 0x102f4, 0x1032e, 0x1034e,
0x1035c, 0x10396, 0x103a6, 0x103ac, 0x10422, 0x10428, 0x10436, 0x10442,
0x10444, 0x10448, 0x10450, 0x1045e, 0x10466, 0x1046c, 0x1047a, 0x10482,
@@ -381,7 +374,8 @@ int32_t CBC_PDF417Common::SYMBOL_TABLE[] = {
0x1faec, 0x1fb16, 0x1fb26, 0x1fb2c, 0x1fb3a, 0x1fb46, 0x1fb4c, 0x1fb58,
0x1fb6e, 0x1fb72, 0x1fb74, 0x1fb8a, 0x1fb92, 0x1fb94, 0x1fba2, 0x1fba4,
0x1fba8, 0x1fbb6, 0x1fbda};
-int32_t CBC_PDF417Common::CODEWORD_TABLE[] = {
+
+const uint16_t CBC_PDF417Common::CODEWORD_TABLE[] = {
2627, 1819, 2622, 2621, 1813, 1812, 2729, 2724, 2723, 2779, 2774, 2773,
902, 896, 908, 868, 865, 861, 859, 2511, 873, 871, 1780, 835,
2493, 825, 2491, 842, 837, 844, 1764, 1762, 811, 810, 809, 2483,
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417Common.h b/xfa/fxbarcode/pdf417/BC_PDF417Common.h
index 61e93ab759..7e272b8a36 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417Common.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417Common.h
@@ -15,16 +15,16 @@ class CBC_PDF417Common {
virtual ~CBC_PDF417Common();
static int32_t getBitCountSum(CFX_Int32Array& moduleBitCount);
static int32_t getCodeword(FX_DWORD symbol);
- static int32_t NUMBER_OF_CODEWORDS;
- static int32_t MAX_CODEWORDS_IN_BARCODE;
- static int32_t MIN_ROWS_IN_BARCODE;
- static int32_t MAX_ROWS_IN_BARCODE;
- static int32_t MAX_CODEWORDS_IN_ROW;
- static int32_t MODULES_IN_CODEWORD;
- static int32_t MODULES_IN_STOP_PATTERN;
- static int32_t BARS_IN_MODULE;
- static int32_t SYMBOL_TABLE[];
- static int32_t CODEWORD_TABLE[];
+ static const int32_t NUMBER_OF_CODEWORDS = 929;
+ static const int32_t MAX_CODEWORDS_IN_BARCODE = NUMBER_OF_CODEWORDS - 1;
+ static const int32_t MIN_ROWS_IN_BARCODE = 3;
+ static const int32_t MAX_ROWS_IN_BARCODE = 90;
+ static const int32_t MAX_CODEWORDS_IN_ROW = 32;
+ static const int32_t MODULES_IN_CODEWORD = 17;
+ static const int32_t MODULES_IN_STOP_PATTERN = 18;
+ static const int32_t BARS_IN_MODULE = 8;
+ static const int32_t SYMBOL_TABLE[];
+ static const uint16_t CODEWORD_TABLE[];
private:
static CFX_Int32Array* EMPTY_INT_ARRAY;
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
index 0d4f2ffdb3..cbdfffac60 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
+++ b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.cpp
@@ -23,80 +23,103 @@
#include "xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h"
#include "xfa/fxbarcode/utils.h"
-int32_t CBC_PDF417ErrorCorrection::EC_COEFFICIENTS[][2500] = {
- {27, 917},
- {522, 568, 723, 809},
- {237, 308, 436, 284, 646, 653, 428, 379},
- {274, 562, 232, 755, 599, 524, 801, 132, 295, 116, 442, 428, 295, 42, 176,
- 65},
- {361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677, 742, 687, 284, 193,
- 517, 273, 494, 263, 147, 593, 800, 571, 320, 803, 133, 231, 390, 685, 330,
- 63, 410},
- {539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733, 877, 381,
- 612, 723, 476, 462, 172, 430, 609, 858, 822, 543, 376, 511, 400, 672, 762,
- 283, 184, 440, 35, 519, 31, 460, 594, 225, 535, 517, 352, 605, 158, 651,
- 201, 488, 502, 648, 733, 717, 83, 404, 97, 280, 771, 840, 629, 4, 381, 843,
- 623, 264, 543},
- {521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749,
- 415, 822, 93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908,
- 490, 704, 516, 258, 457, 907, 594, 723, 674, 292, 272, 96, 684, 432, 686,
- 606, 860, 569, 193, 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379,
- 712, 463, 646, 776, 171, 491, 297, 763, 156, 732, 95, 270, 447, 90, 507,
- 48, 228, 821, 808, 898, 784, 663, 627, 378, 382, 262, 380, 602, 754, 336,
- 89, 614, 87, 432, 670, 616, 157, 374, 242, 726, 600, 269, 375, 898, 845,
- 454, 354, 130, 814, 587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517,
- 834, 315, 550, 86, 801, 4, 108, 539},
- {524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138,
- 720, 858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280,
- 828, 757, 710, 814, 919, 89, 68, 569, 11, 204, 796, 605, 540, 913, 801,
- 700, 799, 137, 439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257,
- 284, 549, 209, 884, 315, 70, 329, 793, 490, 274, 877, 162, 749, 812, 684,
- 461, 334, 376, 849, 521, 307, 291, 803, 712, 19, 358, 399, 908, 103, 511,
- 51, 8, 517, 225, 289, 470, 637, 731, 66, 255, 917, 269, 463, 830, 730, 433,
- 848, 585, 136, 538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49, 802, 580,
- 355, 588, 188, 462, 10, 134, 628, 320, 479, 130, 739, 71, 263, 318, 374,
- 601, 192, 605, 142, 673, 687, 234, 722, 384, 177, 752, 607, 640, 455, 193,
- 689, 707, 805, 641, 48, 60, 732, 621, 895, 544, 261, 852, 655, 309, 697,
- 755, 756, 60, 231, 773, 434, 421, 726, 528, 503, 118, 49, 795, 32, 144,
- 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73, 914, 342, 126, 32, 681,
- 331, 792, 620, 60, 609, 441, 180, 791, 893, 754, 605, 383, 228, 749, 760,
- 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532, 609, 829, 189, 20,
- 167, 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173, 404, 251, 688, 95,
- 497, 555, 642, 543, 307, 159, 924, 558, 648, 55, 497, 10},
- {352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350,
- 492, 197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193,
- 352, 781, 846, 75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640,
- 268, 794, 534, 539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37,
- 858, 916, 552, 41, 542, 289, 122, 272, 383, 800, 485, 98, 752, 472, 761,
- 107, 784, 860, 658, 741, 290, 204, 681, 407, 855, 85, 99, 62, 482, 180, 20,
- 297, 451, 593, 913, 142, 808, 684, 287, 536, 561, 76, 653, 899, 729, 567,
- 744, 390, 513, 192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610, 384,
- 168, 190, 826, 328, 596, 786, 303, 570, 381, 415, 641, 156, 237, 151, 429,
- 531, 207, 676, 710, 89, 168, 304, 402, 40, 708, 575, 162, 864, 229, 65,
- 861, 841, 512, 164, 477, 221, 92, 358, 785, 288, 357, 850, 836, 827, 736,
- 707, 94, 8, 494, 114, 521, 2, 499, 851, 543, 152, 729, 771, 95, 248, 361,
- 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669, 45, 902, 452, 167,
- 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578, 37, 124, 298, 332,
- 552, 43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911, 283, 711, 472,
- 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408, 842, 383,
- 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, 159, 672, 729, 624,
- 59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365, 181, 772,
- 677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289, 536, 35,
- 777, 618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751, 331, 247,
- 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830, 922, 437, 519,
- 644, 905, 789, 420, 305, 441, 207, 300, 892, 827, 141, 537, 381, 662, 513,
- 56, 252, 341, 242, 797, 838, 837, 720, 224, 307, 631, 61, 87, 560, 310,
- 756, 665, 397, 808, 851, 309, 473, 795, 378, 31, 647, 915, 459, 806, 590,
- 731, 425, 216, 548, 249, 321, 881, 699, 535, 673, 782, 210, 815, 905, 303,
- 843, 922, 281, 73, 469, 791, 660, 162, 498, 308, 155, 422, 907, 817, 187,
- 62, 16, 425, 535, 336, 286, 437, 375, 273, 610, 296, 183, 923, 116, 667,
- 751, 353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742, 330, 5, 39, 923,
- 311, 424, 242, 749, 321, 54, 669, 316, 342, 299, 534, 105, 667, 488, 640,
- 672, 576, 540, 316, 486, 721, 610, 46, 656, 447, 171, 616, 464, 190, 531,
- 297, 321, 762, 752, 533, 175, 134, 14, 381, 433, 717, 45, 111, 20, 596,
- 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780, 407, 164, 332, 899,
- 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849, 647, 63, 310, 863,
- 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121, 303, 263}};
+namespace {
+
+const uint16_t EC_LEVEL_0_COEFFICIENTS[2] = {27, 917};
+const uint16_t EC_LEVEL_1_COEFFICIENTS[4] = {522, 568, 723, 809};
+const uint16_t EC_LEVEL_2_COEFFICIENTS[8] = {237, 308, 436, 284,
+ 646, 653, 428, 379};
+
+const uint16_t EC_LEVEL_3_COEFFICIENTS[16] = {274, 562, 232, 755, 599, 524,
+ 801, 132, 295, 116, 442, 428,
+ 295, 42, 176, 65};
+
+const uint16_t EC_LEVEL_4_COEFFICIENTS[32] = {
+ 361, 575, 922, 525, 176, 586, 640, 321, 536, 742, 677,
+ 742, 687, 284, 193, 517, 273, 494, 263, 147, 593, 800,
+ 571, 320, 803, 133, 231, 390, 685, 330, 63, 410};
+
+const uint16_t EC_LEVEL_5_COEFFICIENTS[64] = {
+ 539, 422, 6, 93, 862, 771, 453, 106, 610, 287, 107, 505, 733,
+ 877, 381, 612, 723, 476, 462, 172, 430, 609, 858, 822, 543, 376,
+ 511, 400, 672, 762, 283, 184, 440, 35, 519, 31, 460, 594, 225,
+ 535, 517, 352, 605, 158, 651, 201, 488, 502, 648, 733, 717, 83,
+ 404, 97, 280, 771, 840, 629, 4, 381, 843, 623, 264, 543};
+
+const uint16_t EC_LEVEL_6_COEFFICIENTS[128] = {
+ 521, 310, 864, 547, 858, 580, 296, 379, 53, 779, 897, 444, 400, 925, 749,
+ 415, 822, 93, 217, 208, 928, 244, 583, 620, 246, 148, 447, 631, 292, 908,
+ 490, 704, 516, 258, 457, 907, 594, 723, 674, 292, 272, 96, 684, 432, 686,
+ 606, 860, 569, 193, 219, 129, 186, 236, 287, 192, 775, 278, 173, 40, 379,
+ 712, 463, 646, 776, 171, 491, 297, 763, 156, 732, 95, 270, 447, 90, 507,
+ 48, 228, 821, 808, 898, 784, 663, 627, 378, 382, 262, 380, 602, 754, 336,
+ 89, 614, 87, 432, 670, 616, 157, 374, 242, 726, 600, 269, 375, 898, 845,
+ 454, 354, 130, 814, 587, 804, 34, 211, 330, 539, 297, 827, 865, 37, 517,
+ 834, 315, 550, 86, 801, 4, 108, 539};
+
+const uint16_t EC_LEVEL_7_COEFFICIENTS[256] = {
+ 524, 894, 75, 766, 882, 857, 74, 204, 82, 586, 708, 250, 905, 786, 138,
+ 720, 858, 194, 311, 913, 275, 190, 375, 850, 438, 733, 194, 280, 201, 280,
+ 828, 757, 710, 814, 919, 89, 68, 569, 11, 204, 796, 605, 540, 913, 801,
+ 700, 799, 137, 439, 418, 592, 668, 353, 859, 370, 694, 325, 240, 216, 257,
+ 284, 549, 209, 884, 315, 70, 329, 793, 490, 274, 877, 162, 749, 812, 684,
+ 461, 334, 376, 849, 521, 307, 291, 803, 712, 19, 358, 399, 908, 103, 511,
+ 51, 8, 517, 225, 289, 470, 637, 731, 66, 255, 917, 269, 463, 830, 730,
+ 433, 848, 585, 136, 538, 906, 90, 2, 290, 743, 199, 655, 903, 329, 49,
+ 802, 580, 355, 588, 188, 462, 10, 134, 628, 320, 479, 130, 739, 71, 263,
+ 318, 374, 601, 192, 605, 142, 673, 687, 234, 722, 384, 177, 752, 607, 640,
+ 455, 193, 689, 707, 805, 641, 48, 60, 732, 621, 895, 544, 261, 852, 655,
+ 309, 697, 755, 756, 60, 231, 773, 434, 421, 726, 528, 503, 118, 49, 795,
+ 32, 144, 500, 238, 836, 394, 280, 566, 319, 9, 647, 550, 73, 914, 342,
+ 126, 32, 681, 331, 792, 620, 60, 609, 441, 180, 791, 893, 754, 605, 383,
+ 228, 749, 760, 213, 54, 297, 134, 54, 834, 299, 922, 191, 910, 532, 609,
+ 829, 189, 20, 167, 29, 872, 449, 83, 402, 41, 656, 505, 579, 481, 173,
+ 404, 251, 688, 95, 497, 555, 642, 543, 307, 159, 924, 558, 648, 55, 497,
+ 10};
+
+const uint16_t EC_LEVEL_8_COEFFICIENTS[512] = {
+ 352, 77, 373, 504, 35, 599, 428, 207, 409, 574, 118, 498, 285, 380, 350,
+ 492, 197, 265, 920, 155, 914, 299, 229, 643, 294, 871, 306, 88, 87, 193,
+ 352, 781, 846, 75, 327, 520, 435, 543, 203, 666, 249, 346, 781, 621, 640,
+ 268, 794, 534, 539, 781, 408, 390, 644, 102, 476, 499, 290, 632, 545, 37,
+ 858, 916, 552, 41, 542, 289, 122, 272, 383, 800, 485, 98, 752, 472, 761,
+ 107, 784, 860, 658, 741, 290, 204, 681, 407, 855, 85, 99, 62, 482, 180,
+ 20, 297, 451, 593, 913, 142, 808, 684, 287, 536, 561, 76, 653, 899, 729,
+ 567, 744, 390, 513, 192, 516, 258, 240, 518, 794, 395, 768, 848, 51, 610,
+ 384, 168, 190, 826, 328, 596, 786, 303, 570, 381, 415, 641, 156, 237, 151,
+ 429, 531, 207, 676, 710, 89, 168, 304, 402, 40, 708, 575, 162, 864, 229,
+ 65, 861, 841, 512, 164, 477, 221, 92, 358, 785, 288, 357, 850, 836, 827,
+ 736, 707, 94, 8, 494, 114, 521, 2, 499, 851, 543, 152, 729, 771, 95,
+ 248, 361, 578, 323, 856, 797, 289, 51, 684, 466, 533, 820, 669, 45, 902,
+ 452, 167, 342, 244, 173, 35, 463, 651, 51, 699, 591, 452, 578, 37, 124,
+ 298, 332, 552, 43, 427, 119, 662, 777, 475, 850, 764, 364, 578, 911, 283,
+ 711, 472, 420, 245, 288, 594, 394, 511, 327, 589, 777, 699, 688, 43, 408,
+ 842, 383, 721, 521, 560, 644, 714, 559, 62, 145, 873, 663, 713, 159, 672,
+ 729, 624, 59, 193, 417, 158, 209, 563, 564, 343, 693, 109, 608, 563, 365,
+ 181, 772, 677, 310, 248, 353, 708, 410, 579, 870, 617, 841, 632, 860, 289,
+ 536, 35, 777, 618, 586, 424, 833, 77, 597, 346, 269, 757, 632, 695, 751,
+ 331, 247, 184, 45, 787, 680, 18, 66, 407, 369, 54, 492, 228, 613, 830,
+ 922, 437, 519, 644, 905, 789, 420, 305, 441, 207, 300, 892, 827, 141, 537,
+ 381, 662, 513, 56, 252, 341, 242, 797, 838, 837, 720, 224, 307, 631, 61,
+ 87, 560, 310, 756, 665, 397, 808, 851, 309, 473, 795, 378, 31, 647, 915,
+ 459, 806, 590, 731, 425, 216, 548, 249, 321, 881, 699, 535, 673, 782, 210,
+ 815, 905, 303, 843, 922, 281, 73, 469, 791, 660, 162, 498, 308, 155, 422,
+ 907, 817, 187, 62, 16, 425, 535, 336, 286, 437, 375, 273, 610, 296, 183,
+ 923, 116, 667, 751, 353, 62, 366, 691, 379, 687, 842, 37, 357, 720, 742,
+ 330, 5, 39, 923, 311, 424, 242, 749, 321, 54, 669, 316, 342, 299, 534,
+ 105, 667, 488, 640, 672, 576, 540, 316, 486, 721, 610, 46, 656, 447, 171,
+ 616, 464, 190, 531, 297, 321, 762, 752, 533, 175, 134, 14, 381, 433, 717,
+ 45, 111, 20, 596, 284, 736, 138, 646, 411, 877, 669, 141, 919, 45, 780,
+ 407, 164, 332, 899, 165, 726, 600, 325, 498, 655, 357, 752, 768, 223, 849,
+ 647, 63, 310, 863, 251, 366, 304, 282, 738, 675, 410, 389, 244, 31, 121,
+ 303, 263};
+
+const uint16_t* const EC_COEFFICIENTS[9] = {
+ EC_LEVEL_0_COEFFICIENTS, EC_LEVEL_1_COEFFICIENTS, EC_LEVEL_2_COEFFICIENTS,
+ EC_LEVEL_3_COEFFICIENTS, EC_LEVEL_4_COEFFICIENTS, EC_LEVEL_5_COEFFICIENTS,
+ EC_LEVEL_6_COEFFICIENTS, EC_LEVEL_7_COEFFICIENTS, EC_LEVEL_8_COEFFICIENTS};
+
+} // namespace
CBC_PDF417ErrorCorrection::CBC_PDF417ErrorCorrection() {}
CBC_PDF417ErrorCorrection::~CBC_PDF417ErrorCorrection() {}
@@ -109,6 +132,7 @@ int32_t CBC_PDF417ErrorCorrection::getErrorCorrectionCodewordCount(
}
return 1 << (errorCorrectionLevel + 1);
}
+
int32_t CBC_PDF417ErrorCorrection::getRecommendedMinimumErrorCorrectionLevel(
int32_t n,
int32_t& e) {
@@ -131,6 +155,7 @@ int32_t CBC_PDF417ErrorCorrection::getRecommendedMinimumErrorCorrectionLevel(
e = BCExceptionNoRecommendationPossible;
return -1;
}
+
CFX_WideString CBC_PDF417ErrorCorrection::generateErrorCorrection(
CFX_WideString dataCodewords,
int32_t errorCorrectionLevel,
diff --git a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h
index 9a2a0c63ef..39a7442036 100644
--- a/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h
+++ b/xfa/fxbarcode/pdf417/BC_PDF417ErrorCorrection.h
@@ -22,9 +22,6 @@ class CBC_PDF417ErrorCorrection {
static CFX_WideString generateErrorCorrection(CFX_WideString dataCodewords,
int32_t errorCorrectionLevel,
int32_t& e);
-
- private:
- static int32_t EC_COEFFICIENTS[][2500];
};
#endif // XFA_FXBARCODE_PDF417_BC_PDF417ERRORCORRECTION_H_