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

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

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase Created 4 years 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/codec/fx_codec_jbig.cpp ('k') | core/fxcodec/jbig2/JBig2_HtrdProc.cpp » ('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>
11 #include <utility> 11 #include <utility>
12 #include <vector> 12 #include <vector>
13 13
14 #include "core/fpdfapi/parser/cpdf_stream.h" 14 #include "core/fpdfapi/parser/cpdf_stream.h"
15 #include "core/fpdfapi/parser/cpdf_stream_acc.h" 15 #include "core/fpdfapi/parser/cpdf_stream_acc.h"
16 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h" 16 #include "core/fxcodec/jbig2/JBig2_ArithDecoder.h"
17 #include "core/fxcodec/jbig2/JBig2_BitStream.h" 17 #include "core/fxcodec/jbig2/JBig2_BitStream.h"
18 #include "core/fxcodec/jbig2/JBig2_GrdProc.h" 18 #include "core/fxcodec/jbig2/JBig2_GrdProc.h"
19 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h" 19 #include "core/fxcodec/jbig2/JBig2_GrrdProc.h"
20 #include "core/fxcodec/jbig2/JBig2_HtrdProc.h" 20 #include "core/fxcodec/jbig2/JBig2_HtrdProc.h"
21 #include "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h" 21 #include "core/fxcodec/jbig2/JBig2_HuffmanTable_Standard.h"
22 #include "core/fxcodec/jbig2/JBig2_PddProc.h" 22 #include "core/fxcodec/jbig2/JBig2_PddProc.h"
23 #include "core/fxcodec/jbig2/JBig2_SddProc.h" 23 #include "core/fxcodec/jbig2/JBig2_SddProc.h"
24 #include "core/fxcodec/jbig2/JBig2_TrdProc.h" 24 #include "core/fxcodec/jbig2/JBig2_TrdProc.h"
25 #include "third_party/base/ptr_util.h"
25 #include "third_party/base/stl_util.h" 26 #include "third_party/base/stl_util.h"
26 27
27 namespace { 28 namespace {
28 29
29 size_t GetHuffContextSize(uint8_t val) { 30 size_t GetHuffContextSize(uint8_t val) {
30 return val == 0 ? 65536 : val == 1 ? 8192 : 1024; 31 return val == 0 ? 65536 : val == 1 ? 8192 : 1024;
31 } 32 }
32 33
33 size_t GetRefAggContextSize(bool val) { 34 size_t GetRefAggContextSize(bool val) {
34 return val ? 1024 : 8192; 35 return val ? 1024 : 8192;
(...skipping 18 matching lines...) Expand all
53 : m_nSegmentDecoded(0), 54 : m_nSegmentDecoded(0),
54 m_bInPage(false), 55 m_bInPage(false),
55 m_bBufSpecified(false), 56 m_bBufSpecified(false),
56 m_PauseStep(10), 57 m_PauseStep(10),
57 m_pPause(pPause), 58 m_pPause(pPause),
58 m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY), 59 m_ProcessingStatus(FXCODEC_STATUS_FRAME_READY),
59 m_dwOffset(0), 60 m_dwOffset(0),
60 m_pSymbolDictCache(pSymbolDictCache), 61 m_pSymbolDictCache(pSymbolDictCache),
61 m_bIsGlobal(bIsGlobal) { 62 m_bIsGlobal(bIsGlobal) {
62 if (pGlobalStream && (pGlobalStream->GetSize() > 0)) { 63 if (pGlobalStream && (pGlobalStream->GetSize() > 0)) {
63 m_pGlobalContext.reset(new CJBig2_Context(nullptr, pGlobalStream, 64 m_pGlobalContext = pdfium::MakeUnique<CJBig2_Context>(
64 pSymbolDictCache, pPause, true)); 65 nullptr, pGlobalStream, pSymbolDictCache, pPause, true);
65 } 66 }
66 m_pStream.reset(new CJBig2_BitStream(pSrcStream)); 67 m_pStream = pdfium::MakeUnique<CJBig2_BitStream>(pSrcStream);
67 } 68 }
68 69
69 CJBig2_Context::~CJBig2_Context() {} 70 CJBig2_Context::~CJBig2_Context() {}
70 71
71 int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) { 72 int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
72 int32_t nRet; 73 int32_t nRet;
73 if (m_pStream->getByteLeft() <= 0) 74 if (m_pStream->getByteLeft() <= 0)
74 return JBIG2_END_OF_FILE; 75 return JBIG2_END_OF_FILE;
75 76
76 while (m_pStream->getByteLeft() >= JBIG2_MIN_SEGMENT_SIZE) { 77 while (m_pStream->getByteLeft() >= JBIG2_MIN_SEGMENT_SIZE) {
77 if (!m_pSegment) { 78 if (!m_pSegment) {
78 m_pSegment.reset(new CJBig2_Segment); 79 m_pSegment = pdfium::MakeUnique<CJBig2_Segment>();
79 nRet = parseSegmentHeader(m_pSegment.get()); 80 nRet = parseSegmentHeader(m_pSegment.get());
80 if (nRet != JBIG2_SUCCESS) { 81 if (nRet != JBIG2_SUCCESS) {
81 m_pSegment.reset(); 82 m_pSegment.reset();
82 return nRet; 83 return nRet;
83 } 84 }
84 m_dwOffset = m_pStream->getOffset(); 85 m_dwOffset = m_pStream->getOffset();
85 } 86 }
86 nRet = parseSegmentData(m_pSegment.get(), pPause); 87 nRet = parseSegmentData(m_pSegment.get(), pPause);
87 if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) { 88 if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
88 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; 89 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 IFX_Pause* pPause) { 166 IFX_Pause* pPause) {
166 int32_t nRet = 0; 167 int32_t nRet = 0;
167 if (m_pGlobalContext) { 168 if (m_pGlobalContext) {
168 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause); 169 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause);
169 if (nRet != JBIG2_SUCCESS) { 170 if (nRet != JBIG2_SUCCESS) {
170 m_ProcessingStatus = FXCODEC_STATUS_ERROR; 171 m_ProcessingStatus = FXCODEC_STATUS_ERROR;
171 return nRet; 172 return nRet;
172 } 173 }
173 } 174 }
174 m_PauseStep = 0; 175 m_PauseStep = 0;
175 m_pPage.reset(new CJBig2_Image(width, height, stride, pBuf)); 176 m_pPage = pdfium::MakeUnique<CJBig2_Image>(width, height, stride, pBuf);
176 m_bBufSpecified = true; 177 m_bBufSpecified = true;
177 if (pPause && pPause->NeedToPauseNow()) { 178 if (pPause && pPause->NeedToPauseNow()) {
178 m_PauseStep = 1; 179 m_PauseStep = 1;
179 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; 180 m_ProcessingStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE;
180 return nRet; 181 return nRet;
181 } 182 }
182 return Continue(pPause); 183 return Continue(pPause);
183 } 184 }
184 185
185 int32_t CJBig2_Context::Continue(IFX_Pause* pPause) { 186 int32_t CJBig2_Context::Continue(IFX_Pause* pPause) {
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 } 377 }
377 pPageInfo->m_bIsStriped = !!(wTemp & 0x8000); 378 pPageInfo->m_bIsStriped = !!(wTemp & 0x8000);
378 pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff; 379 pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff;
379 bool bMaxHeight = (pPageInfo->m_dwHeight == 0xffffffff); 380 bool bMaxHeight = (pPageInfo->m_dwHeight == 0xffffffff);
380 if (bMaxHeight && pPageInfo->m_bIsStriped != true) 381 if (bMaxHeight && pPageInfo->m_bIsStriped != true)
381 pPageInfo->m_bIsStriped = true; 382 pPageInfo->m_bIsStriped = true;
382 383
383 if (!m_bBufSpecified) { 384 if (!m_bBufSpecified) {
384 uint32_t height = 385 uint32_t height =
385 bMaxHeight ? pPageInfo->m_wMaxStripeSize : pPageInfo->m_dwHeight; 386 bMaxHeight ? pPageInfo->m_wMaxStripeSize : pPageInfo->m_dwHeight;
386 m_pPage.reset(new CJBig2_Image(pPageInfo->m_dwWidth, height)); 387 m_pPage =
388 pdfium::MakeUnique<CJBig2_Image>(pPageInfo->m_dwWidth, height);
387 } 389 }
388 390
389 if (!m_pPage->m_pData) { 391 if (!m_pPage->m_pData) {
390 m_ProcessingStatus = FXCODEC_STATUS_ERROR; 392 m_ProcessingStatus = FXCODEC_STATUS_ERROR;
391 return JBIG2_ERROR_TOO_SHORT; 393 return JBIG2_ERROR_TOO_SHORT;
392 } 394 }
393 395
394 m_pPage->fill((pPageInfo->m_cFlags & 4) ? 1 : 0); 396 m_pPage->fill((pPageInfo->m_cFlags & 4) ? 1 : 0);
395 m_PageInfoList.push_back(pPageInfo.release()); 397 m_PageInfoList.push_back(pPageInfo.release());
396 m_bInPage = true; 398 m_bInPage = true;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 std::unique_ptr<CJBig2_HuffmanTable> Table_B2; 492 std::unique_ptr<CJBig2_HuffmanTable> Table_B2;
491 std::unique_ptr<CJBig2_HuffmanTable> Table_B3; 493 std::unique_ptr<CJBig2_HuffmanTable> Table_B3;
492 std::unique_ptr<CJBig2_HuffmanTable> Table_B4; 494 std::unique_ptr<CJBig2_HuffmanTable> Table_B4;
493 std::unique_ptr<CJBig2_HuffmanTable> Table_B5; 495 std::unique_ptr<CJBig2_HuffmanTable> Table_B5;
494 if (pSymbolDictDecoder->SDHUFF == 1) { 496 if (pSymbolDictDecoder->SDHUFF == 1) {
495 if (cSDHUFFDH == 2 || cSDHUFFDW == 2) 497 if (cSDHUFFDH == 2 || cSDHUFFDW == 2)
496 return JBIG2_ERROR_FATAL; 498 return JBIG2_ERROR_FATAL;
497 499
498 int32_t nIndex = 0; 500 int32_t nIndex = 0;
499 if (cSDHUFFDH == 0) { 501 if (cSDHUFFDH == 0) {
500 Table_B4.reset(new CJBig2_HuffmanTable( 502 Table_B4 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
501 HuffmanTable_B4, HuffmanTable_B4_Size, HuffmanTable_HTOOB_B4)); 503 HuffmanTable_B4, HuffmanTable_B4_Size, HuffmanTable_HTOOB_B4);
502 pSymbolDictDecoder->SDHUFFDH = Table_B4.get(); 504 pSymbolDictDecoder->SDHUFFDH = Table_B4.get();
503 } else if (cSDHUFFDH == 1) { 505 } else if (cSDHUFFDH == 1) {
504 Table_B5.reset(new CJBig2_HuffmanTable( 506 Table_B5 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
505 HuffmanTable_B5, HuffmanTable_B5_Size, HuffmanTable_HTOOB_B5)); 507 HuffmanTable_B5, HuffmanTable_B5_Size, HuffmanTable_HTOOB_B5);
506 pSymbolDictDecoder->SDHUFFDH = Table_B5.get(); 508 pSymbolDictDecoder->SDHUFFDH = Table_B5.get();
507 } else { 509 } else {
508 CJBig2_Segment* pSeg = 510 CJBig2_Segment* pSeg =
509 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 511 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
510 if (!pSeg) 512 if (!pSeg)
511 return JBIG2_ERROR_FATAL; 513 return JBIG2_ERROR_FATAL;
512 pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht; 514 pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht;
513 } 515 }
514 if (cSDHUFFDW == 0) { 516 if (cSDHUFFDW == 0) {
515 Table_B2.reset(new CJBig2_HuffmanTable( 517 Table_B2 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
516 HuffmanTable_B2, HuffmanTable_B2_Size, HuffmanTable_HTOOB_B2)); 518 HuffmanTable_B2, HuffmanTable_B2_Size, HuffmanTable_HTOOB_B2);
517 pSymbolDictDecoder->SDHUFFDW = Table_B2.get(); 519 pSymbolDictDecoder->SDHUFFDW = Table_B2.get();
518 } else if (cSDHUFFDW == 1) { 520 } else if (cSDHUFFDW == 1) {
519 Table_B3.reset(new CJBig2_HuffmanTable( 521 Table_B3 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
520 HuffmanTable_B3, HuffmanTable_B3_Size, HuffmanTable_HTOOB_B3)); 522 HuffmanTable_B3, HuffmanTable_B3_Size, HuffmanTable_HTOOB_B3);
521 pSymbolDictDecoder->SDHUFFDW = Table_B3.get(); 523 pSymbolDictDecoder->SDHUFFDW = Table_B3.get();
522 } else { 524 } else {
523 CJBig2_Segment* pSeg = 525 CJBig2_Segment* pSeg =
524 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 526 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
525 if (!pSeg) 527 if (!pSeg)
526 return JBIG2_ERROR_FATAL; 528 return JBIG2_ERROR_FATAL;
527 pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht; 529 pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht;
528 } 530 }
529 if (cSDHUFFBMSIZE == 0) { 531 if (cSDHUFFBMSIZE == 0) {
530 Table_B1.reset(new CJBig2_HuffmanTable( 532 Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
531 HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1)); 533 HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
532 pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1.get(); 534 pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1.get();
533 } else { 535 } else {
534 CJBig2_Segment* pSeg = 536 CJBig2_Segment* pSeg =
535 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 537 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
536 if (!pSeg) 538 if (!pSeg)
537 return JBIG2_ERROR_FATAL; 539 return JBIG2_ERROR_FATAL;
538 pSymbolDictDecoder->SDHUFFBMSIZE = pSeg->m_Result.ht; 540 pSymbolDictDecoder->SDHUFFBMSIZE = pSeg->m_Result.ht;
539 } 541 }
540 if (pSymbolDictDecoder->SDREFAGG == 1) { 542 if (pSymbolDictDecoder->SDREFAGG == 1) {
541 if (cSDHUFFAGGINST == 0) { 543 if (cSDHUFFAGGINST == 0) {
542 if (!Table_B1) { 544 if (!Table_B1) {
543 Table_B1.reset(new CJBig2_HuffmanTable( 545 Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
544 HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1)); 546 HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
545 } 547 }
546 pSymbolDictDecoder->SDHUFFAGGINST = Table_B1.get(); 548 pSymbolDictDecoder->SDHUFFAGGINST = Table_B1.get();
547 } else { 549 } else {
548 CJBig2_Segment* pSeg = 550 CJBig2_Segment* pSeg =
549 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 551 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
550 if (!pSeg) 552 if (!pSeg)
551 return JBIG2_ERROR_FATAL; 553 return JBIG2_ERROR_FATAL;
552 pSymbolDictDecoder->SDHUFFAGGINST = pSeg->m_Result.ht; 554 pSymbolDictDecoder->SDHUFFAGGINST = pSeg->m_Result.ht;
553 } 555 }
554 } 556 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 std::unique_ptr<CJBig2_HuffmanTable> Table_B13; 754 std::unique_ptr<CJBig2_HuffmanTable> Table_B13;
753 std::unique_ptr<CJBig2_HuffmanTable> Table_B14; 755 std::unique_ptr<CJBig2_HuffmanTable> Table_B14;
754 std::unique_ptr<CJBig2_HuffmanTable> Table_B15; 756 std::unique_ptr<CJBig2_HuffmanTable> Table_B15;
755 if (pTRD->SBHUFF == 1) { 757 if (pTRD->SBHUFF == 1) {
756 if (cSBHUFFFS == 2 || cSBHUFFRDW == 2 || cSBHUFFRDH == 2 || 758 if (cSBHUFFFS == 2 || cSBHUFFRDW == 2 || cSBHUFFRDH == 2 ||
757 cSBHUFFRDX == 2 || cSBHUFFRDY == 2) { 759 cSBHUFFRDX == 2 || cSBHUFFRDY == 2) {
758 return JBIG2_ERROR_FATAL; 760 return JBIG2_ERROR_FATAL;
759 } 761 }
760 int32_t nIndex = 0; 762 int32_t nIndex = 0;
761 if (cSBHUFFFS == 0) { 763 if (cSBHUFFFS == 0) {
762 Table_B6.reset(new CJBig2_HuffmanTable( 764 Table_B6 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
763 HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6)); 765 HuffmanTable_B6, HuffmanTable_B6_Size, HuffmanTable_HTOOB_B6);
764 pTRD->SBHUFFFS = Table_B6.get(); 766 pTRD->SBHUFFFS = Table_B6.get();
765 } else if (cSBHUFFFS == 1) { 767 } else if (cSBHUFFFS == 1) {
766 Table_B7.reset(new CJBig2_HuffmanTable( 768 Table_B7 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
767 HuffmanTable_B7, HuffmanTable_B7_Size, HuffmanTable_HTOOB_B7)); 769 HuffmanTable_B7, HuffmanTable_B7_Size, HuffmanTable_HTOOB_B7);
768 pTRD->SBHUFFFS = Table_B7.get(); 770 pTRD->SBHUFFFS = Table_B7.get();
769 } else { 771 } else {
770 CJBig2_Segment* pSeg = 772 CJBig2_Segment* pSeg =
771 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 773 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
772 if (!pSeg) 774 if (!pSeg)
773 return JBIG2_ERROR_FATAL; 775 return JBIG2_ERROR_FATAL;
774 pTRD->SBHUFFFS = pSeg->m_Result.ht; 776 pTRD->SBHUFFFS = pSeg->m_Result.ht;
775 } 777 }
776 if (cSBHUFFDS == 0) { 778 if (cSBHUFFDS == 0) {
777 Table_B8.reset(new CJBig2_HuffmanTable( 779 Table_B8 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
778 HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8)); 780 HuffmanTable_B8, HuffmanTable_B8_Size, HuffmanTable_HTOOB_B8);
779 pTRD->SBHUFFDS = Table_B8.get(); 781 pTRD->SBHUFFDS = Table_B8.get();
780 } else if (cSBHUFFDS == 1) { 782 } else if (cSBHUFFDS == 1) {
781 Table_B9.reset(new CJBig2_HuffmanTable( 783 Table_B9 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
782 HuffmanTable_B9, HuffmanTable_B9_Size, HuffmanTable_HTOOB_B9)); 784 HuffmanTable_B9, HuffmanTable_B9_Size, HuffmanTable_HTOOB_B9);
783 pTRD->SBHUFFDS = Table_B9.get(); 785 pTRD->SBHUFFDS = Table_B9.get();
784 } else if (cSBHUFFDS == 2) { 786 } else if (cSBHUFFDS == 2) {
785 Table_B10.reset(new CJBig2_HuffmanTable( 787 Table_B10 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
786 HuffmanTable_B10, HuffmanTable_B10_Size, HuffmanTable_HTOOB_B10)); 788 HuffmanTable_B10, HuffmanTable_B10_Size, HuffmanTable_HTOOB_B10);
787 pTRD->SBHUFFDS = Table_B10.get(); 789 pTRD->SBHUFFDS = Table_B10.get();
788 } else { 790 } else {
789 CJBig2_Segment* pSeg = 791 CJBig2_Segment* pSeg =
790 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 792 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
791 if (!pSeg) 793 if (!pSeg)
792 return JBIG2_ERROR_FATAL; 794 return JBIG2_ERROR_FATAL;
793 pTRD->SBHUFFDS = pSeg->m_Result.ht; 795 pTRD->SBHUFFDS = pSeg->m_Result.ht;
794 } 796 }
795 if (cSBHUFFDT == 0) { 797 if (cSBHUFFDT == 0) {
796 Table_B11.reset(new CJBig2_HuffmanTable( 798 Table_B11 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
797 HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11)); 799 HuffmanTable_B11, HuffmanTable_B11_Size, HuffmanTable_HTOOB_B11);
798 pTRD->SBHUFFDT = Table_B11.get(); 800 pTRD->SBHUFFDT = Table_B11.get();
799 } else if (cSBHUFFDT == 1) { 801 } else if (cSBHUFFDT == 1) {
800 Table_B12.reset(new CJBig2_HuffmanTable( 802 Table_B12 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
801 HuffmanTable_B12, HuffmanTable_B12_Size, HuffmanTable_HTOOB_B12)); 803 HuffmanTable_B12, HuffmanTable_B12_Size, HuffmanTable_HTOOB_B12);
802 pTRD->SBHUFFDT = Table_B12.get(); 804 pTRD->SBHUFFDT = Table_B12.get();
803 } else if (cSBHUFFDT == 2) { 805 } else if (cSBHUFFDT == 2) {
804 Table_B13.reset(new CJBig2_HuffmanTable( 806 Table_B13 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
805 HuffmanTable_B13, HuffmanTable_B13_Size, HuffmanTable_HTOOB_B13)); 807 HuffmanTable_B13, HuffmanTable_B13_Size, HuffmanTable_HTOOB_B13);
806 pTRD->SBHUFFDT = Table_B13.get(); 808 pTRD->SBHUFFDT = Table_B13.get();
807 } else { 809 } else {
808 CJBig2_Segment* pSeg = 810 CJBig2_Segment* pSeg =
809 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 811 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
810 if (!pSeg) 812 if (!pSeg)
811 return JBIG2_ERROR_FATAL; 813 return JBIG2_ERROR_FATAL;
812 pTRD->SBHUFFDT = pSeg->m_Result.ht; 814 pTRD->SBHUFFDT = pSeg->m_Result.ht;
813 } 815 }
814 if (cSBHUFFRDW == 0) { 816 if (cSBHUFFRDW == 0) {
815 Table_B14.reset(new CJBig2_HuffmanTable( 817 Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
816 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14)); 818 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
817 pTRD->SBHUFFRDW = Table_B14.get(); 819 pTRD->SBHUFFRDW = Table_B14.get();
818 } else if (cSBHUFFRDW == 1) { 820 } else if (cSBHUFFRDW == 1) {
819 Table_B15.reset(new CJBig2_HuffmanTable( 821 Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
820 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); 822 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
821 pTRD->SBHUFFRDW = Table_B15.get(); 823 pTRD->SBHUFFRDW = Table_B15.get();
822 } else { 824 } else {
823 CJBig2_Segment* pSeg = 825 CJBig2_Segment* pSeg =
824 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 826 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
825 if (!pSeg) 827 if (!pSeg)
826 return JBIG2_ERROR_FATAL; 828 return JBIG2_ERROR_FATAL;
827 pTRD->SBHUFFRDW = pSeg->m_Result.ht; 829 pTRD->SBHUFFRDW = pSeg->m_Result.ht;
828 } 830 }
829 if (cSBHUFFRDH == 0) { 831 if (cSBHUFFRDH == 0) {
830 if (!Table_B14) { 832 if (!Table_B14) {
831 Table_B14.reset(new CJBig2_HuffmanTable( 833 Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
832 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14)); 834 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
833 } 835 }
834 pTRD->SBHUFFRDH = Table_B14.get(); 836 pTRD->SBHUFFRDH = Table_B14.get();
835 } else if (cSBHUFFRDH == 1) { 837 } else if (cSBHUFFRDH == 1) {
836 if (!Table_B15) { 838 if (!Table_B15) {
837 Table_B15.reset(new CJBig2_HuffmanTable( 839 Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
838 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); 840 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
839 } 841 }
840 pTRD->SBHUFFRDH = Table_B15.get(); 842 pTRD->SBHUFFRDH = Table_B15.get();
841 } else { 843 } else {
842 CJBig2_Segment* pSeg = 844 CJBig2_Segment* pSeg =
843 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 845 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
844 if (!pSeg) 846 if (!pSeg)
845 return JBIG2_ERROR_FATAL; 847 return JBIG2_ERROR_FATAL;
846 pTRD->SBHUFFRDH = pSeg->m_Result.ht; 848 pTRD->SBHUFFRDH = pSeg->m_Result.ht;
847 } 849 }
848 if (cSBHUFFRDX == 0) { 850 if (cSBHUFFRDX == 0) {
849 if (!Table_B14) { 851 if (!Table_B14) {
850 Table_B14.reset(new CJBig2_HuffmanTable( 852 Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
851 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14)); 853 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
852 } 854 }
853 pTRD->SBHUFFRDX = Table_B14.get(); 855 pTRD->SBHUFFRDX = Table_B14.get();
854 } else if (cSBHUFFRDX == 1) { 856 } else if (cSBHUFFRDX == 1) {
855 if (!Table_B15) { 857 if (!Table_B15) {
856 Table_B15.reset(new CJBig2_HuffmanTable( 858 Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
857 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); 859 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
858 } 860 }
859 pTRD->SBHUFFRDX = Table_B15.get(); 861 pTRD->SBHUFFRDX = Table_B15.get();
860 } else { 862 } else {
861 CJBig2_Segment* pSeg = 863 CJBig2_Segment* pSeg =
862 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 864 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
863 if (!pSeg) 865 if (!pSeg)
864 return JBIG2_ERROR_FATAL; 866 return JBIG2_ERROR_FATAL;
865 pTRD->SBHUFFRDX = pSeg->m_Result.ht; 867 pTRD->SBHUFFRDX = pSeg->m_Result.ht;
866 } 868 }
867 if (cSBHUFFRDY == 0) { 869 if (cSBHUFFRDY == 0) {
868 if (!Table_B14) { 870 if (!Table_B14) {
869 Table_B14.reset(new CJBig2_HuffmanTable( 871 Table_B14 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
870 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14)); 872 HuffmanTable_B14, HuffmanTable_B14_Size, HuffmanTable_HTOOB_B14);
871 } 873 }
872 pTRD->SBHUFFRDY = Table_B14.get(); 874 pTRD->SBHUFFRDY = Table_B14.get();
873 } else if (cSBHUFFRDY == 1) { 875 } else if (cSBHUFFRDY == 1) {
874 if (!Table_B15) { 876 if (!Table_B15) {
875 Table_B15.reset(new CJBig2_HuffmanTable( 877 Table_B15 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
876 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15)); 878 HuffmanTable_B15, HuffmanTable_B15_Size, HuffmanTable_HTOOB_B15);
877 } 879 }
878 pTRD->SBHUFFRDY = Table_B15.get(); 880 pTRD->SBHUFFRDY = Table_B15.get();
879 } else { 881 } else {
880 CJBig2_Segment* pSeg = 882 CJBig2_Segment* pSeg =
881 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 883 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
882 if (!pSeg) 884 if (!pSeg)
883 return JBIG2_ERROR_FATAL; 885 return JBIG2_ERROR_FATAL;
884 pTRD->SBHUFFRDY = pSeg->m_Result.ht; 886 pTRD->SBHUFFRDY = pSeg->m_Result.ht;
885 } 887 }
886 if (cSBHUFFRSIZE == 0) { 888 if (cSBHUFFRSIZE == 0) {
887 Table_B1.reset(new CJBig2_HuffmanTable( 889 Table_B1 = pdfium::MakeUnique<CJBig2_HuffmanTable>(
888 HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1)); 890 HuffmanTable_B1, HuffmanTable_B1_Size, HuffmanTable_HTOOB_B1);
889 pTRD->SBHUFFRSIZE = Table_B1.get(); 891 pTRD->SBHUFFRSIZE = Table_B1.get();
890 } else { 892 } else {
891 CJBig2_Segment* pSeg = 893 CJBig2_Segment* pSeg =
892 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 894 findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
893 if (!pSeg) 895 if (!pSeg)
894 return JBIG2_ERROR_FATAL; 896 return JBIG2_ERROR_FATAL;
895 pTRD->SBHUFFRSIZE = pSeg->m_Result.ht; 897 pTRD->SBHUFFRSIZE = pSeg->m_Result.ht;
896 } 898 }
897 } 899 }
898 std::unique_ptr<JBig2ArithCtx, FxFreeDeleter> grContext; 900 std::unique_ptr<JBig2ArithCtx, FxFreeDeleter> grContext;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 pGRD->USESKIP = 0; 1090 pGRD->USESKIP = 0;
1089 m_pGRD = std::move(pGRD); 1091 m_pGRD = std::move(pGRD);
1090 } 1092 }
1091 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; 1093 pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
1092 if (m_pGRD->MMR == 0) { 1094 if (m_pGRD->MMR == 0) {
1093 if (m_gbContext.empty()) { 1095 if (m_gbContext.empty()) {
1094 const size_t size = GetHuffContextSize(m_pGRD->GBTEMPLATE); 1096 const size_t size = GetHuffContextSize(m_pGRD->GBTEMPLATE);
1095 m_gbContext.resize(size); 1097 m_gbContext.resize(size);
1096 } 1098 }
1097 if (!m_pArithDecoder) { 1099 if (!m_pArithDecoder) {
1098 m_pArithDecoder.reset(new CJBig2_ArithDecoder(m_pStream.get())); 1100 m_pArithDecoder =
1101 pdfium::MakeUnique<CJBig2_ArithDecoder>(m_pStream.get());
1099 m_ProcessingStatus = m_pGRD->Start_decode_Arith(&pSegment->m_Result.im, 1102 m_ProcessingStatus = m_pGRD->Start_decode_Arith(&pSegment->m_Result.im,
1100 m_pArithDecoder.get(), 1103 m_pArithDecoder.get(),
1101 &m_gbContext[0], pPause); 1104 &m_gbContext[0], pPause);
1102 } else { 1105 } else {
1103 m_ProcessingStatus = m_pGRD->Continue_decode(pPause); 1106 m_ProcessingStatus = m_pGRD->Continue_decode(pPause);
1104 } 1107 }
1105 if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) { 1108 if (m_ProcessingStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
1106 if (pSegment->m_cFlags.s.type != 36) { 1109 if (pSegment->m_cFlags.s.type != 36) {
1107 if (!m_bBufSpecified) { 1110 if (!m_bBufSpecified) {
1108 JBig2PageInfo* pPageInfo = m_PageInfoList.back(); 1111 JBig2PageInfo* pPageInfo = m_PageInfoList.back();
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 SBSYMCODES[CURTEMP].code = CURCODE; 1389 SBSYMCODES[CURTEMP].code = CURCODE;
1387 CURCODE = CURCODE + 1; 1390 CURCODE = CURCODE + 1;
1388 } 1391 }
1389 CURTEMP = CURTEMP + 1; 1392 CURTEMP = CURTEMP + 1;
1390 } 1393 }
1391 CURLEN = CURLEN + 1; 1394 CURLEN = CURLEN + 1;
1392 } 1395 }
1393 FX_Free(LENCOUNT); 1396 FX_Free(LENCOUNT);
1394 FX_Free(FIRSTCODE); 1397 FX_Free(FIRSTCODE);
1395 } 1398 }
OLDNEW
« no previous file with comments | « core/fxcodec/codec/fx_codec_jbig.cpp ('k') | core/fxcodec/jbig2/JBig2_HtrdProc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698