summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2016-03-21 12:26:54 -0700
committerTom Sepez <tsepez@chromium.org>2016-03-21 12:26:54 -0700
commit4161c5ca6c5438476bf07b6dacfafb61ea611cc5 (patch)
tree76b021ad93546c362d6e6089c18e362aebe247aa /core/fxcodec/jbig2
parenta98600aeb8d815c297834aa5006f5c3ea20dde6d (diff)
downloadpdfium-chromium/2688.tar.xz
Make a few more const tables smaller.chromium/2689chromium/2688
Remove some tables from .h file (risk of duplication). R=ochang@chromium.org Review URL: https://codereview.chromium.org/1814233005 .
Diffstat (limited to 'core/fxcodec/jbig2')
-rw-r--r--core/fxcodec/jbig2/JBig2_Context.cpp115
-rw-r--r--core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp117
-rw-r--r--core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h144
-rw-r--r--core/fxcodec/jbig2/JBig2_SddProc.cpp58
4 files changed, 245 insertions, 189 deletions
diff --git a/core/fxcodec/jbig2/JBig2_Context.cpp b/core/fxcodec/jbig2/JBig2_Context.cpp
index 805a102c74..7060f3522b 100644
--- a/core/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/fxcodec/jbig2/JBig2_Context.cpp
@@ -513,14 +513,12 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
int32_t nIndex = 0;
if (cSDHUFFDH == 0) {
- Table_B4.reset(new CJBig2_HuffmanTable(HuffmanTable_B4,
- FX_ArraySize(HuffmanTable_B4),
- HuffmanTable_HTOOB_B4));
+ Table_B4.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B4, HuffmanTable_B4_Size, HuffmanTable_HTOOB_B4));
pSymbolDictDecoder->SDHUFFDH = Table_B4.get();
} else if (cSDHUFFDH == 1) {
- Table_B5.reset(new CJBig2_HuffmanTable(HuffmanTable_B5,
- FX_ArraySize(HuffmanTable_B5),
- HuffmanTable_HTOOB_B5));
+ Table_B5.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B5, HuffmanTable_B5_Size, HuffmanTable_HTOOB_B5));
pSymbolDictDecoder->SDHUFFDH = Table_B5.get();
} else {
CJBig2_Segment* pSeg =
@@ -530,14 +528,12 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht;
}
if (cSDHUFFDW == 0) {
- Table_B2.reset(new CJBig2_HuffmanTable(HuffmanTable_B2,
- FX_ArraySize(HuffmanTable_B2),
- HuffmanTable_HTOOB_B2));
+ Table_B2.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B2, HuffmanTable_B2_Size, HuffmanTable_HTOOB_B2));
pSymbolDictDecoder->SDHUFFDW = Table_B2.get();
} else if (cSDHUFFDW == 1) {
- Table_B3.reset(new CJBig2_HuffmanTable(HuffmanTable_B3,
- FX_ArraySize(HuffmanTable_B3),
- HuffmanTable_HTOOB_B3));
+ Table_B3.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B3, HuffmanTable_B3_Size, HuffmanTable_HTOOB_B3));
pSymbolDictDecoder->SDHUFFDW = Table_B3.get();
} else {
CJBig2_Segment* pSeg =
@@ -547,9 +543,8 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht;
}
if (cSDHUFFBMSIZE == 0) {
- Table_B1.reset(new CJBig2_HuffmanTable(HuffmanTable_B1,
- FX_ArraySize(HuffmanTable_B1),
- HuffmanTable_HTOOB_B1));
+ Table_B1.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
@@ -561,9 +556,8 @@ int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
if (pSymbolDictDecoder->SDREFAGG == 1) {
if (cSDHUFFAGGINST == 0) {
if (!Table_B1) {
- Table_B1.reset(new CJBig2_HuffmanTable(HuffmanTable_B1,
- FX_ArraySize(HuffmanTable_B1),
- HuffmanTable_HTOOB_B1));
+ Table_B1.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
}
pSymbolDictDecoder->SDHUFFAGGINST = Table_B1.get();
} else {
@@ -781,14 +775,12 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
int32_t nIndex = 0;
if (cSBHUFFFS == 0) {
- Table_B6.reset(new CJBig2_HuffmanTable(HuffmanTable_B6,
- FX_ArraySize(HuffmanTable_B6),
- HuffmanTable_HTOOB_B6));
+ Table_B6.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6));
pTRD->SBHUFFFS = Table_B6.get();
} else if (cSBHUFFFS == 1) {
- Table_B7.reset(new CJBig2_HuffmanTable(HuffmanTable_B7,
- FX_ArraySize(HuffmanTable_B7),
- HuffmanTable_HTOOB_B7));
+ Table_B7.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B7, HuffmanTable_B7_Size, HuffmanTable_HTOOB_B7));
pTRD->SBHUFFFS = Table_B7.get();
} else {
CJBig2_Segment* pSeg =
@@ -798,19 +790,16 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFFS = pSeg->m_Result.ht;
}
if (cSBHUFFDS == 0) {
- Table_B8.reset(new CJBig2_HuffmanTable(HuffmanTable_B8,
- FX_ArraySize(HuffmanTable_B8),
- HuffmanTable_HTOOB_B8));
+ Table_B8.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8));
pTRD->SBHUFFDS = Table_B8.get();
} else if (cSBHUFFDS == 1) {
- Table_B9.reset(new CJBig2_HuffmanTable(HuffmanTable_B9,
- FX_ArraySize(HuffmanTable_B9),
- HuffmanTable_HTOOB_B9));
+ Table_B9.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B9, HuffmanTable_B9_Size, HuffmanTable_HTOOB_B9));
pTRD->SBHUFFDS = Table_B9.get();
} else if (cSBHUFFDS == 2) {
- Table_B10.reset(new CJBig2_HuffmanTable(HuffmanTable_B10,
- FX_ArraySize(HuffmanTable_B10),
- HuffmanTable_HTOOB_B10));
+ Table_B10.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B10, HuffmanTable_B10_Size, HuffmanTable_HTOOB_B10));
pTRD->SBHUFFDS = Table_B10.get();
} else {
CJBig2_Segment* pSeg =
@@ -820,19 +809,16 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDS = pSeg->m_Result.ht;
}
if (cSBHUFFDT == 0) {
- Table_B11.reset(new CJBig2_HuffmanTable(HuffmanTable_B11,
- FX_ArraySize(HuffmanTable_B11),
- HuffmanTable_HTOOB_B11));
+ Table_B11.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11));
pTRD->SBHUFFDT = Table_B11.get();
} else if (cSBHUFFDT == 1) {
- Table_B12.reset(new CJBig2_HuffmanTable(HuffmanTable_B12,
- FX_ArraySize(HuffmanTable_B12),
- HuffmanTable_HTOOB_B12));
+ Table_B12.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B12, HuffmanTable_B12_Size, HuffmanTable_HTOOB_B12));
pTRD->SBHUFFDT = Table_B12.get();
} else if (cSBHUFFDT == 2) {
- Table_B13.reset(new CJBig2_HuffmanTable(HuffmanTable_B13,
- FX_ArraySize(HuffmanTable_B13),
- HuffmanTable_HTOOB_B13));
+ Table_B13.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B13, HuffmanTable_B13_Size, HuffmanTable_HTOOB_B13));
pTRD->SBHUFFDT = Table_B13.get();
} else {
CJBig2_Segment* pSeg =
@@ -842,14 +828,12 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFDT = pSeg->m_Result.ht;
}
if (cSBHUFFRDW == 0) {
- Table_B14.reset(new CJBig2_HuffmanTable(HuffmanTable_B14,
- FX_ArraySize(HuffmanTable_B14),
- HuffmanTable_HTOOB_B14));
+ Table_B14.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
pTRD->SBHUFFRDW = Table_B14.get();
} else if (cSBHUFFRDW == 1) {
- Table_B15.reset(new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
- HuffmanTable_HTOOB_B15));
+ Table_B15.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
pTRD->SBHUFFRDW = Table_B15.get();
} else {
CJBig2_Segment* pSeg =
@@ -860,16 +844,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDH == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(HuffmanTable_B14,
- FX_ArraySize(HuffmanTable_B14),
- HuffmanTable_HTOOB_B14));
+ Table_B14.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
}
pTRD->SBHUFFRDH = Table_B14.get();
} else if (cSBHUFFRDH == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
- HuffmanTable_HTOOB_B15));
+ Table_B15.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
}
pTRD->SBHUFFRDH = Table_B15.get();
} else {
@@ -881,16 +863,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDX == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(HuffmanTable_B14,
- FX_ArraySize(HuffmanTable_B14),
- HuffmanTable_HTOOB_B14));
+ Table_B14.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
}
pTRD->SBHUFFRDX = Table_B14.get();
} else if (cSBHUFFRDX == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
- HuffmanTable_HTOOB_B15));
+ Table_B15.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
}
pTRD->SBHUFFRDX = Table_B15.get();
} else {
@@ -902,16 +882,14 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
}
if (cSBHUFFRDY == 0) {
if (!Table_B14) {
- Table_B14.reset(new CJBig2_HuffmanTable(HuffmanTable_B14,
- FX_ArraySize(HuffmanTable_B14),
- HuffmanTable_HTOOB_B14));
+ Table_B14.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14));
}
pTRD->SBHUFFRDY = Table_B14.get();
} else if (cSBHUFFRDY == 1) {
if (!Table_B15) {
- Table_B15.reset(new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
- HuffmanTable_HTOOB_B15));
+ Table_B15.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15));
}
pTRD->SBHUFFRDY = Table_B15.get();
} else {
@@ -922,9 +900,8 @@ int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment* pSegment) {
pTRD->SBHUFFRDY = pSeg->m_Result.ht;
}
if (cSBHUFFRSIZE == 0) {
- Table_B1.reset(new CJBig2_HuffmanTable(HuffmanTable_B1,
- FX_ArraySize(HuffmanTable_B1),
- HuffmanTable_HTOOB_B1));
+ Table_B1.reset(new CJBig2_HuffmanTable(
+ HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1));
pTRD->SBHUFFRSIZE = Table_B1.get();
} else {
CJBig2_Segment* pSeg =
diff --git a/core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp b/core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp
new file mode 100644
index 0000000000..8187534d4e
--- /dev/null
+++ b/core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp
@@ -0,0 +1,117 @@
+// Copyright 2016 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
+
+#include "core/include/fxcrt/fx_basic.h"
+#include "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h"
+
+const bool HuffmanTable_HTOOB_B1 = false;
+const JBig2TableLine HuffmanTable_B1[] = {{1, 4, 0},
+ {2, 8, 16},
+ {3, 16, 272},
+ {0, 32, -1},
+ {3, 32, 65808}};
+const size_t HuffmanTable_B1_Size = FX_ArraySize(HuffmanTable_B1);
+
+const bool HuffmanTable_HTOOB_B2 = true;
+const JBig2TableLine HuffmanTable_B2[] = {{1, 0, 0}, {2, 0, 1}, {3, 0, 2},
+ {4, 3, 3}, {5, 6, 11}, {0, 32, -1},
+ {6, 32, 75}, {6, 0, 0}};
+const size_t HuffmanTable_B2_Size = FX_ArraySize(HuffmanTable_B2);
+
+const bool HuffmanTable_HTOOB_B3 = true;
+const JBig2TableLine HuffmanTable_B3[] = {
+ {8, 8, -256}, {1, 0, 0}, {2, 0, 1}, {3, 0, 2}, {4, 3, 3},
+ {5, 6, 11}, {8, 32, -257}, {7, 32, 75}, {6, 0, 0}};
+const size_t HuffmanTable_B3_Size = FX_ArraySize(HuffmanTable_B3);
+
+const bool HuffmanTable_HTOOB_B4 = false;
+const JBig2TableLine HuffmanTable_B4[] = {
+ {1, 0, 1}, {2, 0, 2}, {3, 0, 3}, {4, 3, 4},
+ {5, 6, 12}, {0, 32, -1}, {5, 32, 76},
+};
+const size_t HuffmanTable_B4_Size = FX_ArraySize(HuffmanTable_B4);
+
+const bool HuffmanTable_HTOOB_B5 = false;
+const JBig2TableLine HuffmanTable_B5[] = {{7, 8, -255}, {1, 0, 1}, {2, 0, 2},
+ {3, 0, 3}, {4, 3, 4}, {5, 6, 12},
+ {7, 32, -256}, {6, 32, 76}};
+const size_t HuffmanTable_B5_Size = FX_ArraySize(HuffmanTable_B5);
+
+const bool HuffmanTable_HTOOB_B6 = false;
+const JBig2TableLine HuffmanTable_B6[] = {
+ {5, 10, -2048}, {4, 9, -1024}, {4, 8, -512}, {4, 7, -256}, {5, 6, -128},
+ {5, 5, -64}, {4, 5, -32}, {2, 7, 0}, {3, 7, 128}, {3, 8, 256},
+ {4, 9, 512}, {4, 10, 1024}, {6, 32, -2049}, {6, 32, 2048}};
+const size_t HuffmanTable_B6_Size = FX_ArraySize(HuffmanTable_B6);
+
+const bool HuffmanTable_HTOOB_B7 = false;
+const JBig2TableLine HuffmanTable_B7[] = {
+ {4, 9, -1024}, {3, 8, -512}, {4, 7, -256}, {5, 6, -128}, {5, 5, -64},
+ {4, 5, -32}, {4, 5, 0}, {5, 5, 32}, {5, 6, 64}, {4, 7, 128},
+ {3, 8, 256}, {3, 9, 512}, {3, 10, 1024}, {5, 32, -1025}, {5, 32, 2048},
+};
+const size_t HuffmanTable_B7_Size = FX_ArraySize(HuffmanTable_B7);
+
+const bool HuffmanTable_HTOOB_B8 = true;
+const JBig2TableLine HuffmanTable_B8[] = {
+ {8, 3, -15}, {9, 1, -7}, {8, 1, -5}, {9, 0, -3}, {7, 0, -2},
+ {4, 0, -1}, {2, 1, 0}, {5, 0, 2}, {6, 0, 3}, {3, 4, 4},
+ {6, 1, 20}, {4, 4, 22}, {4, 5, 38}, {5, 6, 70}, {5, 7, 134},
+ {6, 7, 262}, {7, 8, 390}, {6, 10, 646}, {9, 32, -16}, {9, 32, 1670},
+ {2, 0, 0}};
+const size_t HuffmanTable_B8_Size = FX_ArraySize(HuffmanTable_B8);
+
+const bool HuffmanTable_HTOOB_B9 = true;
+const JBig2TableLine HuffmanTable_B9[] = {
+ {8, 4, -31}, {9, 2, -15}, {8, 2, -11}, {9, 1, -7}, {7, 1, -5},
+ {4, 1, -3}, {3, 1, -1}, {3, 1, 1}, {5, 1, 3}, {6, 1, 5},
+ {3, 5, 7}, {6, 2, 39}, {4, 5, 43}, {4, 6, 75}, {5, 7, 139},
+ {5, 8, 267}, {6, 8, 523}, {7, 9, 779}, {6, 11, 1291}, {9, 32, -32},
+ {9, 32, 3339}, {2, 0, 0}};
+const size_t HuffmanTable_B9_Size = FX_ArraySize(HuffmanTable_B9);
+
+const bool HuffmanTable_HTOOB_B10 = true;
+const JBig2TableLine HuffmanTable_B10[] = {
+ {7, 4, -21}, {8, 0, -5}, {7, 0, -4}, {5, 0, -3}, {2, 2, -2},
+ {5, 0, 2}, {6, 0, 3}, {7, 0, 4}, {8, 0, 5}, {2, 6, 6},
+ {5, 5, 70}, {6, 5, 102}, {6, 6, 134}, {6, 7, 198}, {6, 8, 326},
+ {6, 9, 582}, {6, 10, 1094}, {7, 11, 2118}, {8, 32, -22}, {8, 32, 4166},
+ {2, 0, 0}};
+const size_t HuffmanTable_B10_Size = FX_ArraySize(HuffmanTable_B10);
+
+const bool HuffmanTable_HTOOB_B11 = false;
+const JBig2TableLine HuffmanTable_B11[] = {
+ {1, 0, 1}, {2, 1, 2}, {4, 0, 4}, {4, 1, 5}, {5, 1, 7},
+ {5, 2, 9}, {6, 2, 13}, {7, 2, 17}, {7, 3, 21}, {7, 4, 29},
+ {7, 5, 45}, {7, 6, 77}, {0, 32, 0}, {7, 32, 141}};
+const size_t HuffmanTable_B11_Size = FX_ArraySize(HuffmanTable_B11);
+
+const bool HuffmanTable_HTOOB_B12 = false;
+const JBig2TableLine HuffmanTable_B12[] = {
+ {1, 0, 1}, {2, 0, 2}, {3, 1, 3}, {5, 0, 5}, {5, 1, 6},
+ {6, 1, 8}, {7, 0, 10}, {7, 1, 11}, {7, 2, 13}, {7, 3, 17},
+ {7, 4, 25}, {8, 5, 41}, {0, 32, 0}, {8, 32, 73}};
+const size_t HuffmanTable_B12_Size = FX_ArraySize(HuffmanTable_B12);
+
+const bool HuffmanTable_HTOOB_B13 = false;
+const JBig2TableLine HuffmanTable_B13[] = {
+ {1, 0, 1}, {3, 0, 2}, {4, 0, 3}, {5, 0, 4}, {4, 1, 5},
+ {3, 3, 7}, {6, 1, 15}, {6, 2, 17}, {6, 3, 21}, {6, 4, 29},
+ {6, 5, 45}, {7, 6, 77}, {0, 32, 0}, {7, 32, 141}};
+const size_t HuffmanTable_B13_Size = FX_ArraySize(HuffmanTable_B13);
+
+const bool HuffmanTable_HTOOB_B14 = false;
+const JBig2TableLine HuffmanTable_B14[] = {{3, 0, -2}, {3, 0, -1}, {1, 0, 0},
+ {3, 0, 1}, {3, 0, 2}, {0, 32, -3},
+ {0, 32, 3}};
+const size_t HuffmanTable_B14_Size = FX_ArraySize(HuffmanTable_B14);
+
+const bool HuffmanTable_HTOOB_B15 = false;
+const JBig2TableLine HuffmanTable_B15[] = {
+ {7, 4, -24}, {6, 2, -8}, {5, 1, -4}, {4, 0, -2}, {3, 0, -1},
+ {1, 0, 0}, {3, 0, 1}, {4, 0, 2}, {5, 1, 3}, {6, 2, 5},
+ {7, 4, 9}, {7, 32, -25}, {7, 32, 25}};
+const size_t HuffmanTable_B15_Size = FX_ArraySize(HuffmanTable_B15);
diff --git a/core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h b/core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h
index 0b768654f5..31b8197d66 100644
--- a/core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h
+++ b/core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h
@@ -10,89 +10,69 @@
#include "core/include/fxcrt/fx_system.h"
struct JBig2TableLine {
- int PREFLEN;
- int RANDELEN;
- int RANGELOW;
+ uint8_t PREFLEN;
+ uint8_t RANDELEN;
+ int32_t RANGELOW;
};
-const bool HuffmanTable_HTOOB_B1 = false;
-const JBig2TableLine HuffmanTable_B1[] = {{1, 4, 0},
- {2, 8, 16},
- {3, 16, 272},
- {0, 32, -1},
- {3, 32, 65808}};
-const bool HuffmanTable_HTOOB_B2 = true;
-const JBig2TableLine HuffmanTable_B2[] = {{1, 0, 0}, {2, 0, 1}, {3, 0, 2},
- {4, 3, 3}, {5, 6, 11}, {0, 32, -1},
- {6, 32, 75}, {6, 0, 0}};
-const bool HuffmanTable_HTOOB_B3 = true;
-const JBig2TableLine HuffmanTable_B3[] = {
- {8, 8, -256}, {1, 0, 0}, {2, 0, 1}, {3, 0, 2}, {4, 3, 3},
- {5, 6, 11}, {8, 32, -257}, {7, 32, 75}, {6, 0, 0}};
-const bool HuffmanTable_HTOOB_B4 = false;
-const JBig2TableLine HuffmanTable_B4[] = {
- {1, 0, 1}, {2, 0, 2}, {3, 0, 3}, {4, 3, 4},
- {5, 6, 12}, {0, 32, -1}, {5, 32, 76},
-};
-const bool HuffmanTable_HTOOB_B5 = false;
-const JBig2TableLine HuffmanTable_B5[] = {{7, 8, -255}, {1, 0, 1}, {2, 0, 2},
- {3, 0, 3}, {4, 3, 4}, {5, 6, 12},
- {7, 32, -256}, {6, 32, 76}};
-const bool HuffmanTable_HTOOB_B6 = false;
-const JBig2TableLine HuffmanTable_B6[] = {
- {5, 10, -2048}, {4, 9, -1024}, {4, 8, -512}, {4, 7, -256}, {5, 6, -128},
- {5, 5, -64}, {4, 5, -32}, {2, 7, 0}, {3, 7, 128}, {3, 8, 256},
- {4, 9, 512}, {4, 10, 1024}, {6, 32, -2049}, {6, 32, 2048}};
-const bool HuffmanTable_HTOOB_B7 = false;
-const JBig2TableLine HuffmanTable_B7[] = {
- {4, 9, -1024}, {3, 8, -512}, {4, 7, -256}, {5, 6, -128}, {5, 5, -64},
- {4, 5, -32}, {4, 5, 0}, {5, 5, 32}, {5, 6, 64}, {4, 7, 128},
- {3, 8, 256}, {3, 9, 512}, {3, 10, 1024}, {5, 32, -1025}, {5, 32, 2048},
-};
-const bool HuffmanTable_HTOOB_B8 = true;
-const JBig2TableLine HuffmanTable_B8[] = {
- {8, 3, -15}, {9, 1, -7}, {8, 1, -5}, {9, 0, -3}, {7, 0, -2},
- {4, 0, -1}, {2, 1, 0}, {5, 0, 2}, {6, 0, 3}, {3, 4, 4},
- {6, 1, 20}, {4, 4, 22}, {4, 5, 38}, {5, 6, 70}, {5, 7, 134},
- {6, 7, 262}, {7, 8, 390}, {6, 10, 646}, {9, 32, -16}, {9, 32, 1670},
- {2, 0, 0}};
-const bool HuffmanTable_HTOOB_B9 = true;
-const JBig2TableLine HuffmanTable_B9[] = {
- {8, 4, -31}, {9, 2, -15}, {8, 2, -11}, {9, 1, -7}, {7, 1, -5},
- {4, 1, -3}, {3, 1, -1}, {3, 1, 1}, {5, 1, 3}, {6, 1, 5},
- {3, 5, 7}, {6, 2, 39}, {4, 5, 43}, {4, 6, 75}, {5, 7, 139},
- {5, 8, 267}, {6, 8, 523}, {7, 9, 779}, {6, 11, 1291}, {9, 32, -32},
- {9, 32, 3339}, {2, 0, 0}};
-const bool HuffmanTable_HTOOB_B10 = true;
-const JBig2TableLine HuffmanTable_B10[] = {
- {7, 4, -21}, {8, 0, -5}, {7, 0, -4}, {5, 0, -3}, {2, 2, -2},
- {5, 0, 2}, {6, 0, 3}, {7, 0, 4}, {8, 0, 5}, {2, 6, 6},
- {5, 5, 70}, {6, 5, 102}, {6, 6, 134}, {6, 7, 198}, {6, 8, 326},
- {6, 9, 582}, {6, 10, 1094}, {7, 11, 2118}, {8, 32, -22}, {8, 32, 4166},
- {2, 0, 0}};
-const bool HuffmanTable_HTOOB_B11 = false;
-const JBig2TableLine HuffmanTable_B11[] = {
- {1, 0, 1}, {2, 1, 2}, {4, 0, 4}, {4, 1, 5}, {5, 1, 7},
- {5, 2, 9}, {6, 2, 13}, {7, 2, 17}, {7, 3, 21}, {7, 4, 29},
- {7, 5, 45}, {7, 6, 77}, {0, 32, 0}, {7, 32, 141}};
-const bool HuffmanTable_HTOOB_B12 = false;
-const JBig2TableLine HuffmanTable_B12[] = {
- {1, 0, 1}, {2, 0, 2}, {3, 1, 3}, {5, 0, 5}, {5, 1, 6},
- {6, 1, 8}, {7, 0, 10}, {7, 1, 11}, {7, 2, 13}, {7, 3, 17},
- {7, 4, 25}, {8, 5, 41}, {0, 32, 0}, {8, 32, 73}};
-const bool HuffmanTable_HTOOB_B13 = false;
-const JBig2TableLine HuffmanTable_B13[] = {
- {1, 0, 1}, {3, 0, 2}, {4, 0, 3}, {5, 0, 4}, {4, 1, 5},
- {3, 3, 7}, {6, 1, 15}, {6, 2, 17}, {6, 3, 21}, {6, 4, 29},
- {6, 5, 45}, {7, 6, 77}, {0, 32, 0}, {7, 32, 141}};
-const bool HuffmanTable_HTOOB_B14 = false;
-const JBig2TableLine HuffmanTable_B14[] = {{3, 0, -2}, {3, 0, -1}, {1, 0, 0},
- {3, 0, 1}, {3, 0, 2}, {0, 32, -3},
- {0, 32, 3}};
-const bool HuffmanTable_HTOOB_B15 = false;
-const JBig2TableLine HuffmanTable_B15[] = {
- {7, 4, -24}, {6, 2, -8}, {5, 1, -4}, {4, 0, -2}, {3, 0, -1},
- {1, 0, 0}, {3, 0, 1}, {4, 0, 2}, {5, 1, 3}, {6, 2, 5},
- {7, 4, 9}, {7, 32, -25}, {7, 32, 25}};
+extern const bool HuffmanTable_HTOOB_B1;
+extern const JBig2TableLine HuffmanTable_B1[];
+extern const size_t HuffmanTable_B1_Size;
+
+extern const bool HuffmanTable_HTOOB_B2;
+extern const JBig2TableLine HuffmanTable_B2[];
+extern const size_t HuffmanTable_B2_Size;
+
+extern const bool HuffmanTable_HTOOB_B3;
+extern const JBig2TableLine HuffmanTable_B3[];
+extern const size_t HuffmanTable_B3_Size;
+
+extern const bool HuffmanTable_HTOOB_B4;
+extern const JBig2TableLine HuffmanTable_B4[];
+extern const size_t HuffmanTable_B4_Size;
+
+extern const bool HuffmanTable_HTOOB_B5;
+extern const JBig2TableLine HuffmanTable_B5[];
+extern const size_t HuffmanTable_B5_Size;
+
+extern const bool HuffmanTable_HTOOB_B6;
+extern const JBig2TableLine HuffmanTable_B6[];
+extern const size_t HuffmanTable_B6_Size;
+
+extern const bool HuffmanTable_HTOOB_B7;
+extern const JBig2TableLine HuffmanTable_B7[];
+extern const size_t HuffmanTable_B7_Size;
+
+extern const bool HuffmanTable_HTOOB_B8;
+extern const JBig2TableLine HuffmanTable_B8[];
+extern const size_t HuffmanTable_B8_Size;
+
+extern const bool HuffmanTable_HTOOB_B9;
+extern const JBig2TableLine HuffmanTable_B9[];
+extern const size_t HuffmanTable_B9_Size;
+
+extern const bool HuffmanTable_HTOOB_B10;
+extern const JBig2TableLine HuffmanTable_B10[];
+extern const size_t HuffmanTable_B10_Size;
+
+extern const bool HuffmanTable_HTOOB_B11;
+extern const JBig2TableLine HuffmanTable_B11[];
+extern const size_t HuffmanTable_B11_Size;
+
+extern const bool HuffmanTable_HTOOB_B12;
+extern const JBig2TableLine HuffmanTable_B12[];
+extern const size_t HuffmanTable_B12_Size;
+
+extern const bool HuffmanTable_HTOOB_B13;
+extern const JBig2TableLine HuffmanTable_B13[];
+extern const size_t HuffmanTable_B13_Size;
+
+extern const bool HuffmanTable_HTOOB_B14;
+extern const JBig2TableLine HuffmanTable_B14[];
+extern const size_t HuffmanTable_B14_Size;
+
+extern const bool HuffmanTable_HTOOB_B15;
+extern const JBig2TableLine HuffmanTable_B15[];
+extern const size_t HuffmanTable_B15_Size;
#endif // CORE_FXCODEC_JBIG2_JBIG2_HUFFMANTABLE_STANDARD_H_
diff --git a/core/fxcodec/jbig2/JBig2_SddProc.cpp b/core/fxcodec/jbig2/JBig2_SddProc.cpp
index 80079b93a5..cd6471d2ee 100644
--- a/core/fxcodec/jbig2/JBig2_SddProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_SddProc.cpp
@@ -140,33 +140,25 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Arith(
pDecoder->REFCORNER = JBIG2_CORNER_TOPLEFT;
pDecoder->SBDSOFFSET = 0;
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFFS(new CJBig2_HuffmanTable(
- HuffmanTable_B6, FX_ArraySize(HuffmanTable_B6),
- HuffmanTable_HTOOB_B6));
+ HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFDS(new CJBig2_HuffmanTable(
- HuffmanTable_B8, FX_ArraySize(HuffmanTable_B8),
- HuffmanTable_HTOOB_B8));
+ HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFDT(new CJBig2_HuffmanTable(
- HuffmanTable_B11, FX_ArraySize(HuffmanTable_B11),
- HuffmanTable_HTOOB_B11));
+ HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDW(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDH(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDX(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDY(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRSIZE(
- new CJBig2_HuffmanTable(HuffmanTable_B1,
- FX_ArraySize(HuffmanTable_B1),
+ new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size,
HuffmanTable_HTOOB_B1));
pDecoder->SBHUFFFS = SBHUFFFS.get();
pDecoder->SBHUFFDS = SBHUFFDS.get();
@@ -397,33 +389,25 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
pDecoder->REFCORNER = JBIG2_CORNER_TOPLEFT;
pDecoder->SBDSOFFSET = 0;
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFFS(new CJBig2_HuffmanTable(
- HuffmanTable_B6, FX_ArraySize(HuffmanTable_B6),
- HuffmanTable_HTOOB_B6));
+ HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFDS(new CJBig2_HuffmanTable(
- HuffmanTable_B8, FX_ArraySize(HuffmanTable_B8),
- HuffmanTable_HTOOB_B8));
+ HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFDT(new CJBig2_HuffmanTable(
- HuffmanTable_B11, FX_ArraySize(HuffmanTable_B11),
- HuffmanTable_HTOOB_B11));
+ HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDW(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDH(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDX(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDY(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRSIZE(
- new CJBig2_HuffmanTable(HuffmanTable_B1,
- FX_ArraySize(HuffmanTable_B1),
+ new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size,
HuffmanTable_HTOOB_B1));
pDecoder->SBHUFFFS = SBHUFFFS.get();
pDecoder->SBHUFFDS = SBHUFFDS.get();
@@ -478,12 +462,10 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
}
FX_Free(SBSYMCODES);
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRDX(
- new CJBig2_HuffmanTable(HuffmanTable_B15,
- FX_ArraySize(HuffmanTable_B15),
+ new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size,
HuffmanTable_HTOOB_B15));
std::unique_ptr<CJBig2_HuffmanTable> SBHUFFRSIZE(
- new CJBig2_HuffmanTable(HuffmanTable_B1,
- FX_ArraySize(HuffmanTable_B1),
+ new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size,
HuffmanTable_HTOOB_B1));
if ((pHuffmanDecoder->decodeAValue(SBHUFFRDX.get(), &RDXI) != 0) ||
(pHuffmanDecoder->decodeAValue(SBHUFFRDX.get(), &RDYI) != 0) ||
@@ -573,8 +555,8 @@ CJBig2_SymbolDict* CJBig2_SDDProc::decode_Huffman(
}
EXINDEX = 0;
CUREXFLAG = 0;
- pTable.reset(new CJBig2_HuffmanTable(
- HuffmanTable_B1, FX_ArraySize(HuffmanTable_B1), HuffmanTable_HTOOB_B1));
+ pTable.reset(new CJBig2_HuffmanTable(HuffmanTable_B1, HuffmanTable_B1_Size,
+ HuffmanTable_HTOOB_B1));
EXFLAGS = FX_Alloc(FX_BOOL, SDNUMINSYMS + SDNUMNEWSYMS);
while (EXINDEX < SDNUMINSYMS + SDNUMNEWSYMS) {
if (pHuffmanDecoder->decodeAValue(pTable.get(), (int*)&EXRUNLENGTH) != 0) {