diff options
-rw-r--r-- | BUILD.gn | 1 | ||||
-rw-r--r-- | core/fpdfdoc/doc_vt.cpp | 222 | ||||
-rw-r--r-- | core/fxcodec/jbig2/JBig2_Context.cpp | 115 | ||||
-rw-r--r-- | core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp | 117 | ||||
-rw-r--r-- | core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h | 144 | ||||
-rw-r--r-- | core/fxcodec/jbig2/JBig2_SddProc.cpp | 58 | ||||
-rw-r--r-- | core/include/fxcrt/fx_arb.h | 16 | ||||
-rw-r--r-- | fpdfsdk/javascript/JS_Value.cpp | 13 | ||||
-rw-r--r-- | pdfium.gyp | 1 | ||||
-rw-r--r-- | xfa/fde/xml/fde_xml_imp.cpp | 25 | ||||
-rw-r--r-- | xfa/fgas/crt/fgas_codepage.h | 6 | ||||
-rw-r--r-- | xfa/fgas/font/fgas_fontutils.h | 8 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_linebreak.h | 2 | ||||
-rw-r--r-- | xfa/fgas/layout/fgas_unicode.h | 2 | ||||
-rw-r--r-- | xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp | 27 | ||||
-rw-r--r-- | xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffwidget.cpp | 4 |
17 files changed, 404 insertions, 363 deletions
@@ -502,6 +502,7 @@ static_library("fxcodec") { "core/fxcodec/jbig2/JBig2_HuffmanDecoder.h", "core/fxcodec/jbig2/JBig2_HuffmanTable.cpp", "core/fxcodec/jbig2/JBig2_HuffmanTable.h", + "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp", "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h", "core/fxcodec/jbig2/JBig2_Image.cpp", "core/fxcodec/jbig2/JBig2_Image.h", 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<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) { 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); diff --git a/fpdfsdk/javascript/JS_Value.cpp b/fpdfsdk/javascript/JS_Value.cpp index 8e5e463e61..1da1525d09 100644 --- a/fpdfsdk/javascript/JS_Value.cpp +++ b/fpdfsdk/javascript/JS_Value.cpp @@ -653,14 +653,13 @@ double _TimeFromYear(int y) { return 86400000.0 * _DayFromYear(y); } +static const uint16_t daysMonth[12] = {0, 31, 59, 90, 120, 151, + 181, 212, 243, 273, 304, 334}; +static const uint16_t leapDaysMonth[12] = {0, 31, 60, 91, 121, 152, + 182, 213, 244, 274, 305, 335}; + double _TimeFromYearMonth(int y, int m) { - static int daysMonth[12] = {0, 31, 59, 90, 120, 151, - 181, 212, 243, 273, 304, 334}; - static int leapDaysMonth[12] = {0, 31, 60, 91, 121, 152, - 182, 213, 244, 274, 305, 335}; - int* pMonth = daysMonth; - if (_isLeapYear(y)) - pMonth = leapDaysMonth; + const uint16_t* pMonth = _isLeapYear(y) ? leapDaysMonth : daysMonth; return _TimeFromYear(y) + ((double)pMonth[m]) * 86400000; } diff --git a/pdfium.gyp b/pdfium.gyp index df2018d109..a5a70a8033 100644 --- a/pdfium.gyp +++ b/pdfium.gyp @@ -512,6 +512,7 @@ 'core/fxcodec/jbig2/JBig2_HuffmanDecoder.h', 'core/fxcodec/jbig2/JBig2_HuffmanTable.cpp', 'core/fxcodec/jbig2/JBig2_HuffmanTable.h', + 'core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.cpp', 'core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h', 'core/fxcodec/jbig2/JBig2_Image.cpp', 'core/fxcodec/jbig2/JBig2_Image.h', diff --git a/xfa/fde/xml/fde_xml_imp.cpp b/xfa/fde/xml/fde_xml_imp.cpp index ce719dee3a..731f88db40 100644 --- a/xfa/fde/xml/fde_xml_imp.cpp +++ b/xfa/fde/xml/fde_xml_imp.cpp @@ -12,8 +12,7 @@ #include "xfa/fgas/crt/fgas_system.h" #define FDE_XMLVALIDCHARRANGENUM 5 - -static const FX_WCHAR g_XMLValidCharRange[FDE_XMLVALIDCHARRANGENUM][2] = { +static const uint16_t g_XMLValidCharRange[FDE_XMLVALIDCHARRANGENUM][2] = { {0x09, 0x09}, {0x0A, 0x0A}, {0x0D, 0x0D}, @@ -39,20 +38,20 @@ FX_BOOL FDE_IsXMLWhiteSpace(FX_WCHAR ch) { } struct FDE_XMLNAMECHAR { - FX_WCHAR wStart; - FX_WCHAR wEnd; - FX_BOOL bStartChar; + uint16_t wStart; + uint16_t wEnd; + bool bStartChar; }; #define FDE_XMLNAMECHARSNUM 20 -static FDE_XMLNAMECHAR g_XMLNameChars[FDE_XMLNAMECHARSNUM] = { - {L'-', L'.', FALSE}, {L'0', L'9', FALSE}, {L':', L':', FALSE}, - {L'A', L'Z', TRUE}, {L'_', L'_', TRUE}, {L'a', L'z', TRUE}, - {0xB7, 0xB7, FALSE}, {0xC0, 0xD6, TRUE}, {0xD8, 0xF6, TRUE}, - {0xF8, 0x02FF, TRUE}, {0x0300, 0x036F, FALSE}, {0x0370, 0x037D, TRUE}, - {0x037F, 0x1FFF, TRUE}, {0x200C, 0x200D, TRUE}, {0x203F, 0x2040, FALSE}, - {0x2070, 0x218F, TRUE}, {0x2C00, 0x2FEF, TRUE}, {0x3001, 0xD7FF, TRUE}, - {0xF900, 0xFDCF, TRUE}, {0xFDF0, 0xFFFD, TRUE}, +static const FDE_XMLNAMECHAR g_XMLNameChars[FDE_XMLNAMECHARSNUM] = { + {L'-', L'.', false}, {L'0', L'9', false}, {L':', L':', false}, + {L'A', L'Z', true}, {L'_', L'_', true}, {L'a', L'z', true}, + {0xB7, 0xB7, false}, {0xC0, 0xD6, true}, {0xD8, 0xF6, true}, + {0xF8, 0x02FF, true}, {0x0300, 0x036F, false}, {0x0370, 0x037D, true}, + {0x037F, 0x1FFF, true}, {0x200C, 0x200D, true}, {0x203F, 0x2040, false}, + {0x2070, 0x218F, true}, {0x2C00, 0x2FEF, true}, {0x3001, 0xD7FF, true}, + {0xF900, 0xFDCF, true}, {0xFDF0, 0xFFFD, true}, }; FX_BOOL FDE_IsXMLNameChar(FX_WCHAR ch, FX_BOOL bFirstChar) { diff --git a/xfa/fgas/crt/fgas_codepage.h b/xfa/fgas/crt/fgas_codepage.h index 479ad37417..ec01816386 100644 --- a/xfa/fgas/crt/fgas_codepage.h +++ b/xfa/fgas/crt/fgas_codepage.h @@ -163,7 +163,7 @@ int32_t FX_UTF8Decode(const FX_CHAR* pSrc, struct FX_STR2CPHASH { uint32_t uHash; - uint32_t uCodePage; + uint16_t uCodePage; }; struct FX_CHARSET_MAP { @@ -172,8 +172,8 @@ struct FX_CHARSET_MAP { }; struct FX_LANG2CPMAP { - FX_WORD wLanguage; - FX_WORD wCodepage; + uint16_t wLanguage; + uint16_t wCodepage; }; #endif // XFA_FGAS_CRT_FGAS_CODEPAGE_H_ diff --git a/xfa/fgas/font/fgas_fontutils.h b/xfa/fgas/font/fgas_fontutils.h index 75c50c8d4a..ab567aee6b 100644 --- a/xfa/fgas/font/fgas_fontutils.h +++ b/xfa/fgas/font/fgas_fontutils.h @@ -10,10 +10,10 @@ #include "core/include/fxcrt/fx_string.h" struct FGAS_FONTUSB { - FX_WCHAR wStartUnicode; - FX_WCHAR wEndUnicode; - FX_WORD wBitField; - FX_WORD wCodePage; + uint16_t wStartUnicode; + uint16_t wEndUnicode; + uint16_t wBitField; + uint16_t wCodePage; }; FX_DWORD FGAS_GetFontHashCode(FX_WORD wCodePage, FX_DWORD dwFontStyles); diff --git a/xfa/fgas/layout/fgas_linebreak.h b/xfa/fgas/layout/fgas_linebreak.h index dc80e0dd67..f1ecad74d0 100644 --- a/xfa/fgas/layout/fgas_linebreak.h +++ b/xfa/fgas/layout/fgas_linebreak.h @@ -10,7 +10,7 @@ #include "core/include/fxcrt/fx_system.h" #include "xfa/fgas/crt/fgas_utils.h" -enum FX_LINEBREAKTYPE { +enum FX_LINEBREAKTYPE : uint8_t { FX_LBT_UNKNOWN = 0x00, FX_LBT_DIRECT_BRK = 0x1A, FX_LBT_INDIRECT_BRK = 0x2B, diff --git a/xfa/fgas/layout/fgas_unicode.h b/xfa/fgas/layout/fgas_unicode.h index 536895d870..dd574026c9 100644 --- a/xfa/fgas/layout/fgas_unicode.h +++ b/xfa/fgas/layout/fgas_unicode.h @@ -26,7 +26,7 @@ typedef CFX_MassArrayTemplate<FX_TPO> CFX_TPOArray; void FX_TEXTLAYOUT_PieceSort(CFX_TPOArray& tpos, int32_t iStart, int32_t iEnd); struct FX_JAPCHARPROPERTYEX { - FX_WCHAR wChar; + uint16_t wChar; uint8_t uAlign; }; diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp index da647a9c53..f915e58aae 100644 --- a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp +++ b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.cpp @@ -24,18 +24,19 @@ #include "xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" #include "xfa/fxbarcode/utils.h" -const int32_t CBC_QRCoderFormatInformation::FORMAT_INFO_MASK_QR = 0X5412; -const int32_t CBC_QRCoderFormatInformation::FORMAT_INFO_DECODE_LOOKUP[32][2] = { - {0x5412, 0x00}, {0x5125, 0x01}, {0x5E7C, 0x02}, {0x5B4B, 0x03}, - {0x45F9, 0x04}, {0x40CE, 0x05}, {0x4F97, 0x06}, {0x4AA0, 0x07}, - {0x77C4, 0x08}, {0x72F3, 0x09}, {0x7DAA, 0x0A}, {0x789D, 0x0B}, - {0x662F, 0x0C}, {0x6318, 0x0D}, {0x6C41, 0x0E}, {0x6976, 0x0F}, - {0x1689, 0x10}, {0x13BE, 0x11}, {0x1CE7, 0x12}, {0x19D0, 0x13}, - {0x0762, 0x14}, {0x0255, 0x15}, {0x0D0C, 0x16}, {0x083B, 0x17}, - {0x355F, 0x18}, {0x3068, 0x19}, {0x3F31, 0x1A}, {0x3A06, 0x1B}, - {0x24B4, 0x1C}, {0x2183, 0x1D}, {0x2EDA, 0x1E}, {0x2BED, 0x1F}, +const uint16_t CBC_QRCoderFormatInformation::FORMAT_INFO_MASK_QR = 0X5412; +const uint16_t CBC_QRCoderFormatInformation::FORMAT_INFO_DECODE_LOOKUP[32][2] = + { + {0x5412, 0x00}, {0x5125, 0x01}, {0x5E7C, 0x02}, {0x5B4B, 0x03}, + {0x45F9, 0x04}, {0x40CE, 0x05}, {0x4F97, 0x06}, {0x4AA0, 0x07}, + {0x77C4, 0x08}, {0x72F3, 0x09}, {0x7DAA, 0x0A}, {0x789D, 0x0B}, + {0x662F, 0x0C}, {0x6318, 0x0D}, {0x6C41, 0x0E}, {0x6976, 0x0F}, + {0x1689, 0x10}, {0x13BE, 0x11}, {0x1CE7, 0x12}, {0x19D0, 0x13}, + {0x0762, 0x14}, {0x0255, 0x15}, {0x0D0C, 0x16}, {0x083B, 0x17}, + {0x355F, 0x18}, {0x3068, 0x19}, {0x3F31, 0x1A}, {0x3A06, 0x1B}, + {0x24B4, 0x1C}, {0x2183, 0x1D}, {0x2EDA, 0x1E}, {0x2BED, 0x1F}, }; -const int32_t CBC_QRCoderFormatInformation::BITS_SET_IN_HALF_BYTE[] = { +const uint8_t CBC_QRCoderFormatInformation::BITS_SET_IN_HALF_BYTE[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4}; CBC_QRCoderFormatInformation::CBC_QRCoderFormatInformation(int32_t formatInfo) { @@ -77,8 +78,8 @@ CBC_QRCoderFormatInformation::DoDecodeFormatInformation( int32_t bestDifference = (int32_t)FXSYS_nan(); int32_t bestFormatInfo = 0; for (int32_t i = 0; i < 32; i++) { - int32_t const* decodeInfo = &FORMAT_INFO_DECODE_LOOKUP[i][0]; - int32_t targetInfo = decodeInfo[0]; + uint16_t const* decodeInfo = &FORMAT_INFO_DECODE_LOOKUP[i][0]; + uint16_t targetInfo = decodeInfo[0]; if (targetInfo == maskedFormatInfo) { return new CBC_QRCoderFormatInformation(decodeInfo[1]); } diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h index 8f1590172e..a988d3bd6b 100644 --- a/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h +++ b/xfa/fxbarcode/qrcode/BC_QRCoderFormatInformation.h @@ -10,9 +10,9 @@ class CBC_QRCoderErrorCorrectionLevel; class CBC_QRCoderFormatInformation { private: - static const int32_t FORMAT_INFO_MASK_QR; - static const int32_t FORMAT_INFO_DECODE_LOOKUP[32][2]; - static const int32_t BITS_SET_IN_HALF_BYTE[16]; + static const uint16_t FORMAT_INFO_MASK_QR; + static const uint16_t FORMAT_INFO_DECODE_LOOKUP[32][2]; + static const uint8_t BITS_SET_IN_HALF_BYTE[16]; CBC_QRCoderErrorCorrectionLevel* m_errorCorrectLevl; uint8_t m_dataMask; diff --git a/xfa/fxfa/app/xfa_ffwidget.cpp b/xfa/fxfa/app/xfa_ffwidget.cpp index 93c1a3e349..d585e279ce 100644 --- a/xfa/fxfa/app/xfa_ffwidget.cpp +++ b/xfa/fxfa/app/xfa_ffwidget.cpp @@ -904,8 +904,10 @@ static int32_t XFA_Base64Decode(const FX_CHAR* pStr, uint8_t* pOutBuffer) { FX_Free(pBuffer); return j; } -static FX_CHAR g_base64_chars[] = + +static const FX_CHAR g_base64_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + FX_CHAR* XFA_Base64Encode(const uint8_t* buf, int32_t buf_len) { FX_CHAR* out = NULL; int i, j; |