From 4161c5ca6c5438476bf07b6dacfafb61ea611cc5 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 21 Mar 2016 12:26:54 -0700 Subject: Make a few more const tables smaller. Remove some tables from .h file (risk of duplication). R=ochang@chromium.org Review URL: https://codereview.chromium.org/1814233005 . --- core/fpdfdoc/doc_vt.cpp | 222 ++++++++++----------- core/fxcodec/jbig2/JBig2_Context.cpp | 115 +++++------ core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp | 117 +++++++++++ core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h | 144 ++++++------- core/fxcodec/jbig2/JBig2_SddProc.cpp | 58 ++---- core/include/fxcrt/fx_arb.h | 16 +- 6 files changed, 355 insertions(+), 317 deletions(-) create mode 100644 core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp (limited to 'core') diff --git a/core/fpdfdoc/doc_vt.cpp b/core/fpdfdoc/doc_vt.cpp index dddc57f2dd..3c08e46080 100644 --- a/core/fpdfdoc/doc_vt.cpp +++ b/core/fpdfdoc/doc_vt.cpp @@ -395,44 +395,39 @@ CPVT_FloatRect CTypeset::Typeset() { OutputLines(); return m_rcRet; } -static int special_chars[128] = { - 0x0000, 0x000C, 0x0008, 0x000C, 0x0008, 0x0000, 0x0020, 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, 0x0008, 0x0008, 0x0000, - 0x0010, 0x0000, 0x0000, 0x0028, 0x000C, 0x0008, 0x0000, 0x0000, 0x0028, - 0x0028, 0x0028, 0x0028, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, 0x0002, - 0x0002, 0x0002, 0x0002, 0x0002, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, - 0x0008, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, - 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, - 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, - 0x0001, 0x000C, 0x0000, 0x0008, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, - 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, - 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, - 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x000C, 0x0000, 0x0008, - 0x0000, 0x0000, + +static const uint8_t special_chars[128] = { + 0x00, 0x0C, 0x08, 0x0C, 0x08, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x00, + 0x10, 0x00, 0x00, 0x28, 0x0C, 0x08, 0x00, 0x00, 0x28, 0x28, 0x28, 0x28, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x08, 0x08, + 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x0C, 0x00, 0x08, 0x00, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x0C, 0x00, 0x08, 0x00, 0x00, }; -static FX_BOOL IsLatin(FX_WORD word) { - if (word <= 0x007F) { - if (special_chars[word] & 0x0001) { - return TRUE; - } - } - if ((word >= 0x00C0 && word <= 0x00FF) || - (word >= 0x0100 && word <= 0x024F) || - (word >= 0x1E00 && word <= 0x1EFF) || - (word >= 0x2C60 && word <= 0x2C7F) || - (word >= 0xA720 && word <= 0xA7FF) || - (word >= 0xFF21 && word <= 0xFF3A) || - (word >= 0xFF41 && word <= 0xFF5A)) { - return TRUE; - } - return FALSE; + +static bool IsLatin(FX_WORD word) { + if (word <= 0x007F) + return !!(special_chars[word] & 0x01); + + return ((word >= 0x00C0 && word <= 0x00FF) || + (word >= 0x0100 && word <= 0x024F) || + (word >= 0x1E00 && word <= 0x1EFF) || + (word >= 0x2C60 && word <= 0x2C7F) || + (word >= 0xA720 && word <= 0xA7FF) || + (word >= 0xFF21 && word <= 0xFF3A) || + (word >= 0xFF41 && word <= 0xFF5A)); } -static FX_BOOL IsDigit(FX_DWORD word) { + +static bool IsDigit(FX_DWORD word) { return word >= 0x0030 && word <= 0x0039; } -static FX_BOOL IsCJK(FX_DWORD word) { + +static bool IsCJK(FX_DWORD word) { if ((word >= 0x1100 && word <= 0x11FF) || (word >= 0x2E80 && word <= 0x2FFF) || (word >= 0x3040 && word <= 0x9FBF) || @@ -441,134 +436,121 @@ static FX_BOOL IsCJK(FX_DWORD word) { (word >= 0xFE30 && word <= 0xFE4F) || (word >= 0x20000 && word <= 0x2A6DF) || (word >= 0x2F800 && word <= 0x2FA1F)) { - return TRUE; + return true; } if (word >= 0x3000 && word <= 0x303F) { - if (word == 0x3005 || word == 0x3006 || word == 0x3021 || word == 0x3022 || + return ( + word == 0x3005 || word == 0x3006 || word == 0x3021 || word == 0x3022 || word == 0x3023 || word == 0x3024 || word == 0x3025 || word == 0x3026 || word == 0x3027 || word == 0x3028 || word == 0x3029 || word == 0x3031 || - word == 0x3032 || word == 0x3033 || word == 0x3034 || word == 0x3035) { - return TRUE; - } - return FALSE; + word == 0x3032 || word == 0x3033 || word == 0x3034 || word == 0x3035); } - if (word >= 0xFF66 && word <= 0xFF9D) { - return TRUE; - } - return FALSE; + return word >= 0xFF66 && word <= 0xFF9D; } -static FX_BOOL IsPunctuation(FX_DWORD word) { - if (word <= 0x007F) { - if ((special_chars[word] >> 3) & 1) { - return TRUE; - } - } else if (word >= 0x0080 && word <= 0x00FF) { - if (word == 0x0082 || word == 0x0084 || word == 0x0085 || word == 0x0091 || - word == 0x0092 || word == 0x0093 || word <= 0x0094 || word == 0x0096 || - word == 0x00B4 || word == 0x00B8) { - return TRUE; - } - } else if (word >= 0x2000 && word <= 0x206F) { - if (word == 0x2010 || word == 0x2011 || word == 0x2012 || word == 0x2013 || + +static bool IsPunctuation(FX_DWORD word) { + if (word <= 0x007F) + return !!(special_chars[word] & 0x08); + + if (word >= 0x0080 && word <= 0x00FF) { + return (word == 0x0082 || word == 0x0084 || word == 0x0085 || + word == 0x0091 || word == 0x0092 || word == 0x0093 || + word <= 0x0094 || word == 0x0096 || word == 0x00B4 || + word == 0x00B8); + } + + if (word >= 0x2000 && word <= 0x206F) { + return ( + word == 0x2010 || word == 0x2011 || word == 0x2012 || word == 0x2013 || word == 0x2018 || word == 0x2019 || word == 0x201A || word == 0x201B || word == 0x201C || word == 0x201D || word == 0x201E || word == 0x201F || word == 0x2032 || word == 0x2033 || word == 0x2034 || word == 0x2035 || word == 0x2036 || word == 0x2037 || word == 0x203C || word == 0x203D || - word == 0x203E || word == 0x2044) { - return TRUE; - } - } else if (word >= 0x3000 && word <= 0x303F) { - if (word == 0x3001 || word == 0x3002 || word == 0x3003 || word == 0x3005 || + word == 0x203E || word == 0x2044); + } + + if (word >= 0x3000 && word <= 0x303F) { + return ( + word == 0x3001 || word == 0x3002 || word == 0x3003 || word == 0x3005 || word == 0x3009 || word == 0x300A || word == 0x300B || word == 0x300C || word == 0x300D || word == 0x300F || word == 0x300E || word == 0x3010 || word == 0x3011 || word == 0x3014 || word == 0x3015 || word == 0x3016 || word == 0x3017 || word == 0x3018 || word == 0x3019 || word == 0x301A || - word == 0x301B || word == 0x301D || word == 0x301E || word == 0x301F) { - return TRUE; - } - } else if (word >= 0xFE50 && word <= 0xFE6F) { - if ((word >= 0xFE50 && word <= 0xFE5E) || word == 0xFE63) { - return TRUE; - } - } else if (word >= 0xFF00 && word <= 0xFFEF) { - if (word == 0xFF01 || word == 0xFF02 || word == 0xFF07 || word == 0xFF08 || + word == 0x301B || word == 0x301D || word == 0x301E || word == 0x301F); + } + + if (word >= 0xFE50 && word <= 0xFE6F) + return (word >= 0xFE50 && word <= 0xFE5E) || word == 0xFE63; + + if (word >= 0xFF00 && word <= 0xFFEF) { + return ( + word == 0xFF01 || word == 0xFF02 || word == 0xFF07 || word == 0xFF08 || word == 0xFF09 || word == 0xFF0C || word == 0xFF0E || word == 0xFF0F || word == 0xFF1A || word == 0xFF1B || word == 0xFF1F || word == 0xFF3B || word == 0xFF3D || word == 0xFF40 || word == 0xFF5B || word == 0xFF5C || word == 0xFF5D || word == 0xFF61 || word == 0xFF62 || word == 0xFF63 || - word == 0xFF64 || word == 0xFF65 || word == 0xFF9E || word == 0xFF9F) { - return TRUE; - } + word == 0xFF64 || word == 0xFF65 || word == 0xFF9E || word == 0xFF9F); } - return FALSE; + + return false; } -static FX_BOOL IsConnectiveSymbol(FX_DWORD word) { - if (word <= 0x007F) { - if ((special_chars[word] >> 5) & 1) { - return TRUE; - } - } - return FALSE; + +static bool IsConnectiveSymbol(FX_DWORD word) { + return word <= 0x007F && (special_chars[word] & 0x20); } -static FX_BOOL IsOpenStylePunctuation(FX_DWORD word) { - if (word <= 0x007F) { - if ((special_chars[word] >> 2) & 1) { - return TRUE; - } - } else if (word == 0x300A || word == 0x300C || word == 0x300E || - word == 0x3010 || word == 0x3014 || word == 0x3016 || - word == 0x3018 || word == 0x301A || word == 0xFF08 || - word == 0xFF3B || word == 0xFF5B || word == 0xFF62) { - return TRUE; - } - return FALSE; + +static bool IsOpenStylePunctuation(FX_DWORD word) { + if (word <= 0x007F) + return !!(special_chars[word] & 0x04); + + return (word == 0x300A || word == 0x300C || word == 0x300E || + word == 0x3010 || word == 0x3014 || word == 0x3016 || + word == 0x3018 || word == 0x301A || word == 0xFF08 || + word == 0xFF3B || word == 0xFF5B || word == 0xFF62); } -static FX_BOOL IsCurrencySymbol(FX_WORD word) { - if (word == 0x0024 || word == 0x0080 || word == 0x00A2 || word == 0x00A3 || - word == 0x00A4 || word == 0x00A5 || (word >= 0x20A0 && word <= 0x20CF) || - word == 0xFE69 || word == 0xFF04 || word == 0xFFE0 || word == 0xFFE1 || - word == 0xFFE5 || word == 0xFFE6) { - return TRUE; - } - return FALSE; + +static bool IsCurrencySymbol(FX_WORD word) { + return (word == 0x0024 || word == 0x0080 || word == 0x00A2 || + word == 0x00A3 || word == 0x00A4 || word == 0x00A5 || + (word >= 0x20A0 && word <= 0x20CF) || word == 0xFE69 || + word == 0xFF04 || word == 0xFFE0 || word == 0xFFE1 || + word == 0xFFE5 || word == 0xFFE6); } -static FX_BOOL IsPrefixSymbol(FX_WORD word) { - if (IsCurrencySymbol(word)) { - return TRUE; - } - if (word == 0x2116) { - return TRUE; - } - return FALSE; + +static bool IsPrefixSymbol(FX_WORD word) { + return IsCurrencySymbol(word) || word == 0x2116; } -static FX_BOOL IsSpace(FX_WORD word) { + +static bool IsSpace(FX_WORD word) { return word == 0x0020 || word == 0x3000; } -static FX_BOOL NeedDivision(FX_WORD prevWord, FX_WORD curWord) { + +static bool NeedDivision(FX_WORD prevWord, FX_WORD curWord) { if ((IsLatin(prevWord) || IsDigit(prevWord)) && (IsLatin(curWord) || IsDigit(curWord))) { - return FALSE; + return false; } if (IsSpace(curWord) || IsPunctuation(curWord)) { - return FALSE; + return false; } if (IsConnectiveSymbol(prevWord) || IsConnectiveSymbol(curWord)) { - return FALSE; + return false; } if (IsSpace(prevWord) || IsPunctuation(prevWord)) { - return TRUE; + return true; } if (IsPrefixSymbol(prevWord)) { - return FALSE; + return false; } if (IsPrefixSymbol(curWord) || IsCJK(curWord)) { - return TRUE; + return true; } if (IsCJK(prevWord)) { - return TRUE; + return true; } - return FALSE; + return false; } + void CTypeset::SplitLines(FX_BOOL bTypeset, FX_FLOAT fFontSize) { ASSERT(m_pVT); ASSERT(m_pSection); 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 SBHUFFFS(new CJBig2_HuffmanTable( - HuffmanTable_B6, FX_ArraySize(HuffmanTable_B6), - HuffmanTable_HTOOB_B6)); + HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6)); std::unique_ptr SBHUFFDS(new CJBig2_HuffmanTable( - HuffmanTable_B8, FX_ArraySize(HuffmanTable_B8), - HuffmanTable_HTOOB_B8)); + HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8)); std::unique_ptr SBHUFFDT(new CJBig2_HuffmanTable( - HuffmanTable_B11, FX_ArraySize(HuffmanTable_B11), - HuffmanTable_HTOOB_B11)); + HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11)); std::unique_ptr SBHUFFRDW( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr SBHUFFRDH( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr SBHUFFRDX( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr SBHUFFRDY( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr 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 SBHUFFFS(new CJBig2_HuffmanTable( - HuffmanTable_B6, FX_ArraySize(HuffmanTable_B6), - HuffmanTable_HTOOB_B6)); + HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6)); std::unique_ptr SBHUFFDS(new CJBig2_HuffmanTable( - HuffmanTable_B8, FX_ArraySize(HuffmanTable_B8), - HuffmanTable_HTOOB_B8)); + HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8)); std::unique_ptr SBHUFFDT(new CJBig2_HuffmanTable( - HuffmanTable_B11, FX_ArraySize(HuffmanTable_B11), - HuffmanTable_HTOOB_B11)); + HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11)); std::unique_ptr SBHUFFRDW( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr SBHUFFRDH( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr SBHUFFRDX( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr SBHUFFRDY( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr 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 SBHUFFRDX( - new CJBig2_HuffmanTable(HuffmanTable_B15, - FX_ArraySize(HuffmanTable_B15), + new CJBig2_HuffmanTable(HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); std::unique_ptr 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) { diff --git a/core/include/fxcrt/fx_arb.h b/core/include/fxcrt/fx_arb.h index 112118d5f9..57391dea19 100644 --- a/core/include/fxcrt/fx_arb.h +++ b/core/include/fxcrt/fx_arb.h @@ -13,20 +13,20 @@ class IFX_ArabicChar; struct FX_ARBFORMTABLE { - FX_WCHAR wIsolated; - FX_WCHAR wFinal; - FX_WCHAR wInitial; - FX_WCHAR wMedial; + uint16_t wIsolated; + uint16_t wFinal; + uint16_t wInitial; + uint16_t wMedial; }; struct FX_ARAALEF { - FX_WCHAR wAlef; - FX_WCHAR wIsolated; + uint16_t wAlef; + uint16_t wIsolated; }; struct FX_ARASHADDA { - FX_WCHAR wShadda; - FX_WCHAR wIsolated; + uint16_t wShadda; + uint16_t wIsolated; }; const FX_ARBFORMTABLE* FX_GetArabicFormTable(FX_WCHAR unicode); -- cgit v1.2.3