| 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 "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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 m_pStream->readInteger(&pPageInfo->m_dwHeight) != 0 || | 370 m_pStream->readInteger(&pPageInfo->m_dwHeight) != 0 || |
| 371 m_pStream->readInteger(&pPageInfo->m_dwResolutionX) != 0 || | 371 m_pStream->readInteger(&pPageInfo->m_dwResolutionX) != 0 || |
| 372 m_pStream->readInteger(&pPageInfo->m_dwResolutionY) != 0 || | 372 m_pStream->readInteger(&pPageInfo->m_dwResolutionY) != 0 || |
| 373 m_pStream->read1Byte(&pPageInfo->m_cFlags) != 0 || | 373 m_pStream->read1Byte(&pPageInfo->m_cFlags) != 0 || |
| 374 m_pStream->readShortInteger(&wTemp) != 0) { | 374 m_pStream->readShortInteger(&wTemp) != 0) { |
| 375 return JBIG2_ERROR_TOO_SHORT; | 375 return JBIG2_ERROR_TOO_SHORT; |
| 376 } | 376 } |
| 377 pPageInfo->m_bIsStriped = !!(wTemp & 0x8000); | 377 pPageInfo->m_bIsStriped = !!(wTemp & 0x8000); |
| 378 pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff; | 378 pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff; |
| 379 bool bMaxHeight = (pPageInfo->m_dwHeight == 0xffffffff); | 379 bool bMaxHeight = (pPageInfo->m_dwHeight == 0xffffffff); |
| 380 if (bMaxHeight && pPageInfo->m_bIsStriped != TRUE) | 380 if (bMaxHeight && pPageInfo->m_bIsStriped != true) |
| 381 pPageInfo->m_bIsStriped = TRUE; | 381 pPageInfo->m_bIsStriped = true; |
| 382 | 382 |
| 383 if (!m_bBufSpecified) { | 383 if (!m_bBufSpecified) { |
| 384 uint32_t height = | 384 uint32_t height = |
| 385 bMaxHeight ? pPageInfo->m_wMaxStripeSize : pPageInfo->m_dwHeight; | 385 bMaxHeight ? pPageInfo->m_wMaxStripeSize : pPageInfo->m_dwHeight; |
| 386 m_pPage.reset(new CJBig2_Image(pPageInfo->m_dwWidth, height)); | 386 m_pPage.reset(new CJBig2_Image(pPageInfo->m_dwWidth, height)); |
| 387 } | 387 } |
| 388 | 388 |
| 389 if (!m_pPage->m_pData) { | 389 if (!m_pPage->m_pData) { |
| 390 m_ProcessingStatus = FXCODEC_STATUS_ERROR; | 390 m_ProcessingStatus = FXCODEC_STATUS_ERROR; |
| 391 return JBIG2_ERROR_TOO_SHORT; | 391 return JBIG2_ERROR_TOO_SHORT; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 } | 575 } |
| 576 } else { | 576 } else { |
| 577 if (bUseGbContext) | 577 if (bUseGbContext) |
| 578 gbContext.resize(gbContextSize); | 578 gbContext.resize(gbContextSize); |
| 579 if (bUseGrContext) | 579 if (bUseGrContext) |
| 580 grContext.resize(grContextSize); | 580 grContext.resize(grContextSize); |
| 581 } | 581 } |
| 582 | 582 |
| 583 CJBig2_CacheKey key = | 583 CJBig2_CacheKey key = |
| 584 CJBig2_CacheKey(pSegment->m_dwObjNum, pSegment->m_dwDataOffset); | 584 CJBig2_CacheKey(pSegment->m_dwObjNum, pSegment->m_dwDataOffset); |
| 585 FX_BOOL cache_hit = false; | 585 bool cache_hit = false; |
| 586 pSegment->m_nResultType = JBIG2_SYMBOL_DICT_POINTER; | 586 pSegment->m_nResultType = JBIG2_SYMBOL_DICT_POINTER; |
| 587 if (m_bIsGlobal && key.first != 0) { | 587 if (m_bIsGlobal && key.first != 0) { |
| 588 for (auto it = m_pSymbolDictCache->begin(); it != m_pSymbolDictCache->end(); | 588 for (auto it = m_pSymbolDictCache->begin(); it != m_pSymbolDictCache->end(); |
| 589 ++it) { | 589 ++it) { |
| 590 if (it->first == key) { | 590 if (it->first == key) { |
| 591 std::unique_ptr<CJBig2_SymbolDict> copy(it->second->DeepCopy()); | 591 std::unique_ptr<CJBig2_SymbolDict> copy(it->second->DeepCopy()); |
| 592 pSegment->m_Result.sd = copy.release(); | 592 pSegment->m_Result.sd = copy.release(); |
| 593 m_pSymbolDictCache->push_front( | 593 m_pSymbolDictCache->push_front( |
| 594 CJBig2_CachePair(key, std::move(it->second))); | 594 CJBig2_CachePair(key, std::move(it->second))); |
| 595 m_pSymbolDictCache->erase(it); | 595 m_pSymbolDictCache->erase(it); |
| (...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 SBSYMCODES[CURTEMP].code = CURCODE; | 1386 SBSYMCODES[CURTEMP].code = CURCODE; |
| 1387 CURCODE = CURCODE + 1; | 1387 CURCODE = CURCODE + 1; |
| 1388 } | 1388 } |
| 1389 CURTEMP = CURTEMP + 1; | 1389 CURTEMP = CURTEMP + 1; |
| 1390 } | 1390 } |
| 1391 CURLEN = CURLEN + 1; | 1391 CURLEN = CURLEN + 1; |
| 1392 } | 1392 } |
| 1393 FX_Free(LENCOUNT); | 1393 FX_Free(LENCOUNT); |
| 1394 FX_Free(FIRSTCODE); | 1394 FX_Free(FIRSTCODE); |
| 1395 } | 1395 } |
| OLD | NEW |