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 static const int kSymbolDictCacheMaxSize = 2; | 25 |
| 26 // Disable until we can figure out how to clear cache between documents. |
| 27 static const int kSymbolDictCacheMaxSize = 0; |
26 | 28 |
27 CJBig2_Context* CJBig2_Context::CreateContext( | 29 CJBig2_Context* CJBig2_Context::CreateContext( |
28 const uint8_t* pGlobalData, | 30 const uint8_t* pGlobalData, |
29 FX_DWORD dwGlobalLength, | 31 FX_DWORD dwGlobalLength, |
30 const uint8_t* pData, | 32 const uint8_t* pData, |
31 FX_DWORD dwLength, | 33 FX_DWORD dwLength, |
32 std::list<CJBig2_CachePair>* pSymbolDictCache, | 34 std::list<CJBig2_CachePair>* pSymbolDictCache, |
33 IFX_Pause* pPause) { | 35 IFX_Pause* pPause) { |
34 return new CJBig2_Context(pGlobalData, dwGlobalLength, pData, dwLength, | 36 return new CJBig2_Context(pGlobalData, dwGlobalLength, pData, dwLength, |
35 pSymbolDictCache, pPause); | 37 pSymbolDictCache, pPause); |
(...skipping 1528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 SBSYMCODES[CURTEMP].code = CURCODE; | 1566 SBSYMCODES[CURTEMP].code = CURCODE; |
1565 CURCODE = CURCODE + 1; | 1567 CURCODE = CURCODE + 1; |
1566 } | 1568 } |
1567 CURTEMP = CURTEMP + 1; | 1569 CURTEMP = CURTEMP + 1; |
1568 } | 1570 } |
1569 CURLEN = CURLEN + 1; | 1571 CURLEN = CURLEN + 1; |
1570 } | 1572 } |
1571 FX_Free(LENCOUNT); | 1573 FX_Free(LENCOUNT); |
1572 FX_Free(FIRSTCODE); | 1574 FX_Free(FIRSTCODE); |
1573 } | 1575 } |
OLD | NEW |