Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Side by Side Diff: core/fxcodec/jbig2/JBig2_Context.cpp

Issue 2178613002: Remove CFX_Deletable (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@fix3
Patch Set: address comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxcodec/jbig2/JBig2_Context.h ('k') | core/fxcrt/include/fx_memory.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "core/fxcodec/jbig2/JBig2_Context.h" 7 #include "core/fxcodec/jbig2/JBig2_Context.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 CJBig2_CacheKey key = 584 CJBig2_CacheKey key =
585 CJBig2_CacheKey(pSegment->m_dwObjNum, pSegment->m_dwDataOffset); 585 CJBig2_CacheKey(pSegment->m_dwObjNum, pSegment->m_dwDataOffset);
586 FX_BOOL cache_hit = false; 586 FX_BOOL cache_hit = false;
587 pSegment->m_nResultType = JBIG2_SYMBOL_DICT_POINTER; 587 pSegment->m_nResultType = JBIG2_SYMBOL_DICT_POINTER;
588 if (m_bIsGlobal && key.first != 0) { 588 if (m_bIsGlobal && key.first != 0) {
589 for (auto it = m_pSymbolDictCache->begin(); it != m_pSymbolDictCache->end(); 589 for (auto it = m_pSymbolDictCache->begin(); it != m_pSymbolDictCache->end();
590 ++it) { 590 ++it) {
591 if (it->first == key) { 591 if (it->first == key) {
592 std::unique_ptr<CJBig2_SymbolDict> copy(it->second->DeepCopy()); 592 std::unique_ptr<CJBig2_SymbolDict> copy(it->second->DeepCopy());
593 pSegment->m_Result.sd = copy.release(); 593 pSegment->m_Result.sd = copy.release();
594 m_pSymbolDictCache->push_front(*it); 594 m_pSymbolDictCache->push_front(
595 CJBig2_CachePair(key, std::move(it->second)));
595 m_pSymbolDictCache->erase(it); 596 m_pSymbolDictCache->erase(it);
596 cache_hit = true; 597 cache_hit = true;
597 break; 598 break;
598 } 599 }
599 } 600 }
600 } 601 }
601 if (!cache_hit) { 602 if (!cache_hit) {
602 if (bUseGbContext) { 603 if (bUseGbContext) {
603 std::unique_ptr<CJBig2_ArithDecoder> pArithDecoder( 604 std::unique_ptr<CJBig2_ArithDecoder> pArithDecoder(
604 new CJBig2_ArithDecoder(m_pStream.get())); 605 new CJBig2_ArithDecoder(m_pStream.get()));
605 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Arith( 606 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Arith(
606 pArithDecoder.get(), &gbContext, &grContext); 607 pArithDecoder.get(), &gbContext, &grContext);
607 if (!pSegment->m_Result.sd) 608 if (!pSegment->m_Result.sd)
608 return JBIG2_ERROR_FATAL; 609 return JBIG2_ERROR_FATAL;
609 610
610 m_pStream->alignByte(); 611 m_pStream->alignByte();
611 m_pStream->offset(2); 612 m_pStream->offset(2);
612 } else { 613 } else {
613 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Huffman( 614 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Huffman(
614 m_pStream.get(), &gbContext, &grContext, pPause); 615 m_pStream.get(), &gbContext, &grContext, pPause);
615 if (!pSegment->m_Result.sd) 616 if (!pSegment->m_Result.sd)
616 return JBIG2_ERROR_FATAL; 617 return JBIG2_ERROR_FATAL;
617 m_pStream->alignByte(); 618 m_pStream->alignByte();
618 } 619 }
619 if (m_bIsGlobal) { 620 if (m_bIsGlobal) {
620 std::unique_ptr<CJBig2_SymbolDict> value = 621 std::unique_ptr<CJBig2_SymbolDict> value =
621 pSegment->m_Result.sd->DeepCopy(); 622 pSegment->m_Result.sd->DeepCopy();
622 int size = pdfium::CollectionSize<int>(*m_pSymbolDictCache); 623 int size = pdfium::CollectionSize<int>(*m_pSymbolDictCache);
623 while (size >= kSymbolDictCacheMaxSize) { 624 while (size >= kSymbolDictCacheMaxSize) {
624 delete m_pSymbolDictCache->back().second;
625 m_pSymbolDictCache->pop_back(); 625 m_pSymbolDictCache->pop_back();
626 --size; 626 --size;
627 } 627 }
628 m_pSymbolDictCache->push_front(CJBig2_CachePair(key, value.release())); 628 m_pSymbolDictCache->push_front(CJBig2_CachePair(key, std::move(value)));
629 } 629 }
630 } 630 }
631 if (wFlags & 0x0200) { 631 if (wFlags & 0x0200) {
632 if (bUseGbContext) 632 if (bUseGbContext)
633 pSegment->m_Result.sd->SetGbContext(gbContext); 633 pSegment->m_Result.sd->SetGbContext(gbContext);
634 if (bUseGrContext) 634 if (bUseGrContext)
635 pSegment->m_Result.sd->SetGrContext(grContext); 635 pSegment->m_Result.sd->SetGrContext(grContext);
636 } 636 }
637 return JBIG2_SUCCESS; 637 return JBIG2_SUCCESS;
638 } 638 }
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 SBSYMCODES[CURTEMP].code = CURCODE; 1387 SBSYMCODES[CURTEMP].code = CURCODE;
1388 CURCODE = CURCODE + 1; 1388 CURCODE = CURCODE + 1;
1389 } 1389 }
1390 CURTEMP = CURTEMP + 1; 1390 CURTEMP = CURTEMP + 1;
1391 } 1391 }
1392 CURLEN = CURLEN + 1; 1392 CURLEN = CURLEN + 1;
1393 } 1393 }
1394 FX_Free(LENCOUNT); 1394 FX_Free(LENCOUNT);
1395 FX_Free(FIRSTCODE); 1395 FX_Free(FIRSTCODE);
1396 } 1396 }
OLDNEW
« no previous file with comments | « core/fxcodec/jbig2/JBig2_Context.h ('k') | core/fxcrt/include/fx_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698