OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "JBig2_Context.h" | 7 #include "JBig2_Context.h" |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 | 10 |
11 #include "JBig2_GrdProc.h" | 11 #include "JBig2_GrdProc.h" |
12 #include "JBig2_GrrdProc.h" | 12 #include "JBig2_GrrdProc.h" |
13 #include "JBig2_HtrdProc.h" | 13 #include "JBig2_HtrdProc.h" |
14 #include "JBig2_PddProc.h" | 14 #include "JBig2_PddProc.h" |
15 #include "JBig2_SddProc.h" | 15 #include "JBig2_SddProc.h" |
16 #include "JBig2_TrdProc.h" | 16 #include "JBig2_TrdProc.h" |
17 | 17 |
18 // Implement a very small least recently used (LRU) cache. It is very | 18 // Implement a very small least recently used (LRU) cache. It is very |
19 // common for a JBIG2 dictionary to span multiple pages in a PDF file, | 19 // common for a JBIG2 dictionary to span multiple pages in a PDF file, |
20 // and we do not want to decode the same dictionary over and over | 20 // and we do not want to decode the same dictionary over and over |
21 // again. We key off of the memory location of the dictionary. The | 21 // again. We key off of the memory location of the dictionary. The |
22 // list keeps track of the freshness of entries, with freshest ones | 22 // list keeps track of the freshness of entries, with freshest ones |
23 // at the front. Even a tiny cache size like 2 makes a dramatic | 23 // at the front. Even a tiny cache size like 2 makes a dramatic |
24 // difference for typical JBIG2 documents. | 24 // difference for typical JBIG2 documents. |
25 // | |
26 // Disabled until we can figure out how to clear cache between documents. | |
27 // https://code.google.com/p/pdfium/issues/detail?id=207 | |
25 static const int kSymbolDictCacheMaxSize = 2; | 28 static const int kSymbolDictCacheMaxSize = 2; |
Lei Zhang
2015/10/04 06:15:37
Uh, fail.
| |
26 | 29 |
27 CJBig2_Context* CJBig2_Context::CreateContext( | 30 CJBig2_Context* CJBig2_Context::CreateContext( |
28 const uint8_t* pGlobalData, | 31 const uint8_t* pGlobalData, |
29 FX_DWORD dwGlobalLength, | 32 FX_DWORD dwGlobalLength, |
30 const uint8_t* pData, | 33 const uint8_t* pData, |
31 FX_DWORD dwLength, | 34 FX_DWORD dwLength, |
32 std::list<CJBig2_CachePair>* pSymbolDictCache, | 35 std::list<CJBig2_CachePair>* pSymbolDictCache, |
33 IFX_Pause* pPause) { | 36 IFX_Pause* pPause) { |
34 return new CJBig2_Context(pGlobalData, dwGlobalLength, pData, dwLength, | 37 return new CJBig2_Context(pGlobalData, dwGlobalLength, pData, dwLength, |
35 pSymbolDictCache, pPause); | 38 pSymbolDictCache, pPause); |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1564 SBSYMCODES[CURTEMP].code = CURCODE; | 1567 SBSYMCODES[CURTEMP].code = CURCODE; |
1565 CURCODE = CURCODE + 1; | 1568 CURCODE = CURCODE + 1; |
1566 } | 1569 } |
1567 CURTEMP = CURTEMP + 1; | 1570 CURTEMP = CURTEMP + 1; |
1568 } | 1571 } |
1569 CURLEN = CURLEN + 1; | 1572 CURLEN = CURLEN + 1; |
1570 } | 1573 } |
1571 FX_Free(LENCOUNT); | 1574 FX_Free(LENCOUNT); |
1572 FX_Free(FIRSTCODE); | 1575 FX_Free(FIRSTCODE); |
1573 } | 1576 } |
OLD | NEW |