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

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

Issue 1247213002: _FETAL => _FATAL. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 5 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/src/fxcodec/jbig2/JBig2_Context.h ('k') | no next file » | 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 <map> 7 #include <map>
8 #include <list> 8 #include <list>
9 #include "JBig2_Context.h" 9 #include "JBig2_Context.h"
10 10
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 break; 584 break;
585 default: 585 default:
586 break; 586 break;
587 } 587 }
588 return JBIG2_SUCCESS; 588 return JBIG2_SUCCESS;
589 failed1: 589 failed1:
590 m_pModule->JBig2_Error("segment data too short."); 590 m_pModule->JBig2_Error("segment data too short.");
591 return JBIG2_ERROR_TOO_SHORT; 591 return JBIG2_ERROR_TOO_SHORT;
592 failed2: 592 failed2:
593 m_pModule->JBig2_Error("segment syntax error."); 593 m_pModule->JBig2_Error("segment syntax error.");
594 return JBIG2_ERROR_FETAL; 594 return JBIG2_ERROR_FATAL;
595 } 595 }
596 int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment *pSegment, IFX_Pause* pPa use) 596 int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment *pSegment, IFX_Pause* pPa use)
597 { 597 {
598 FX_DWORD dwTemp; 598 FX_DWORD dwTemp;
599 FX_WORD wFlags; 599 FX_WORD wFlags;
600 uint8_t cSDHUFFDH, cSDHUFFDW, cSDHUFFBMSIZE, cSDHUFFAGGINST; 600 uint8_t cSDHUFFDH, cSDHUFFDW, cSDHUFFBMSIZE, cSDHUFFAGGINST;
601 CJBig2_HuffmanTable *Table_B1 = NULL, *Table_B2 = NULL, *Table_B3 = NULL, *T able_B4 = NULL, *Table_B5 = NULL; 601 CJBig2_HuffmanTable *Table_B1 = NULL, *Table_B2 = NULL, *Table_B3 = NULL, *T able_B4 = NULL, *Table_B5 = NULL;
602 int32_t i, nIndex, nRet; 602 int32_t i, nIndex, nRet;
603 CJBig2_Segment *pSeg = NULL, *pLRSeg = NULL; 603 CJBig2_Segment *pSeg = NULL, *pLRSeg = NULL;
604 FX_BOOL bUsed; 604 FX_BOOL bUsed;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 } 653 }
654 if (pSymbolDictDecoder->SDNUMEXSYMS > JBIG2_MAX_EXPORT_SYSMBOLS 654 if (pSymbolDictDecoder->SDNUMEXSYMS > JBIG2_MAX_EXPORT_SYSMBOLS
655 || pSymbolDictDecoder->SDNUMNEWSYMS > JBIG2_MAX_NEW_SYSMBOLS) { 655 || pSymbolDictDecoder->SDNUMNEWSYMS > JBIG2_MAX_NEW_SYSMBOLS) {
656 m_pModule->JBig2_Error("symbol dictionary segment : too many export/new symbols."); 656 m_pModule->JBig2_Error("symbol dictionary segment : too many export/new symbols.");
657 nRet = JBIG2_ERROR_LIMIT; 657 nRet = JBIG2_ERROR_LIMIT;
658 goto failed; 658 goto failed;
659 } 659 }
660 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 660 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
661 if(!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) { 661 if(!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) {
662 m_pModule->JBig2_Error("symbol dictionary segment : can't find refer ed to segments"); 662 m_pModule->JBig2_Error("symbol dictionary segment : can't find refer ed to segments");
663 nRet = JBIG2_ERROR_FETAL; 663 nRet = JBIG2_ERROR_FATAL;
664 goto failed; 664 goto failed;
665 } 665 }
666 } 666 }
667 pSymbolDictDecoder->SDNUMINSYMS = 0; 667 pSymbolDictDecoder->SDNUMINSYMS = 0;
668 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 668 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
669 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]); 669 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
670 if(pSeg->m_cFlags.s.type == 0) { 670 if(pSeg->m_cFlags.s.type == 0) {
671 pSymbolDictDecoder->SDNUMINSYMS += pSeg->m_Result.sd->SDNUMEXSYMS; 671 pSymbolDictDecoder->SDNUMINSYMS += pSeg->m_Result.sd->SDNUMEXSYMS;
672 pLRSeg = pSeg; 672 pLRSeg = pSeg;
673 } 673 }
(...skipping 10 matching lines...) Expand all
684 JBIG2_memcpy(SDINSYMS + dwTemp, pSeg->m_Result.sd->SDEXSYMS, 684 JBIG2_memcpy(SDINSYMS + dwTemp, pSeg->m_Result.sd->SDEXSYMS,
685 pSeg->m_Result.sd->SDNUMEXSYMS * sizeof(CJBig2_Imag e*)); 685 pSeg->m_Result.sd->SDNUMEXSYMS * sizeof(CJBig2_Imag e*));
686 dwTemp += pSeg->m_Result.sd->SDNUMEXSYMS; 686 dwTemp += pSeg->m_Result.sd->SDNUMEXSYMS;
687 } 687 }
688 } 688 }
689 } 689 }
690 pSymbolDictDecoder->SDINSYMS = SDINSYMS; 690 pSymbolDictDecoder->SDINSYMS = SDINSYMS;
691 if(pSymbolDictDecoder->SDHUFF == 1) { 691 if(pSymbolDictDecoder->SDHUFF == 1) {
692 if((cSDHUFFDH == 2) || (cSDHUFFDW == 2)) { 692 if((cSDHUFFDH == 2) || (cSDHUFFDW == 2)) {
693 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFDH=2 or SD HUFFDW=2 is not permitted."); 693 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFDH=2 or SD HUFFDW=2 is not permitted.");
694 nRet = JBIG2_ERROR_FETAL; 694 nRet = JBIG2_ERROR_FATAL;
695 goto failed; 695 goto failed;
696 } 696 }
697 nIndex = 0; 697 nIndex = 0;
698 if(cSDHUFFDH == 0) { 698 if(cSDHUFFDH == 0) {
699 JBIG2_ALLOC(Table_B4, CJBig2_HuffmanTable(HuffmanTable_B4, 699 JBIG2_ALLOC(Table_B4, CJBig2_HuffmanTable(HuffmanTable_B4,
700 sizeof(HuffmanTable_B4) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B4)); 700 sizeof(HuffmanTable_B4) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B4));
701 pSymbolDictDecoder->SDHUFFDH = Table_B4; 701 pSymbolDictDecoder->SDHUFFDH = Table_B4;
702 } else if(cSDHUFFDH == 1) { 702 } else if(cSDHUFFDH == 1) {
703 JBIG2_ALLOC(Table_B5, CJBig2_HuffmanTable(HuffmanTable_B5, 703 JBIG2_ALLOC(Table_B5, CJBig2_HuffmanTable(HuffmanTable_B5,
704 sizeof(HuffmanTable_B5) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B5)); 704 sizeof(HuffmanTable_B5) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B5));
705 pSymbolDictDecoder->SDHUFFDH = Table_B5; 705 pSymbolDictDecoder->SDHUFFDH = Table_B5;
706 } else { 706 } else {
707 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 707 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
708 if(!pSeg) { 708 if(!pSeg) {
709 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFDH can 't find user supplied table."); 709 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFDH can 't find user supplied table.");
710 nRet = JBIG2_ERROR_FETAL; 710 nRet = JBIG2_ERROR_FATAL;
711 goto failed; 711 goto failed;
712 } 712 }
713 pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht; 713 pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht;
714 } 714 }
715 if(cSDHUFFDW == 0) { 715 if(cSDHUFFDW == 0) {
716 JBIG2_ALLOC(Table_B2, CJBig2_HuffmanTable(HuffmanTable_B2, 716 JBIG2_ALLOC(Table_B2, CJBig2_HuffmanTable(HuffmanTable_B2,
717 sizeof(HuffmanTable_B2) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B2)); 717 sizeof(HuffmanTable_B2) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B2));
718 pSymbolDictDecoder->SDHUFFDW = Table_B2; 718 pSymbolDictDecoder->SDHUFFDW = Table_B2;
719 } else if(cSDHUFFDW == 1) { 719 } else if(cSDHUFFDW == 1) {
720 JBIG2_ALLOC(Table_B3, CJBig2_HuffmanTable(HuffmanTable_B3, 720 JBIG2_ALLOC(Table_B3, CJBig2_HuffmanTable(HuffmanTable_B3,
721 sizeof(HuffmanTable_B3) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B3)); 721 sizeof(HuffmanTable_B3) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B3));
722 pSymbolDictDecoder->SDHUFFDW = Table_B3; 722 pSymbolDictDecoder->SDHUFFDW = Table_B3;
723 } else { 723 } else {
724 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 724 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
725 if(!pSeg) { 725 if(!pSeg) {
726 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFDW can 't find user supplied table."); 726 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFDW can 't find user supplied table.");
727 nRet = JBIG2_ERROR_FETAL; 727 nRet = JBIG2_ERROR_FATAL;
728 goto failed; 728 goto failed;
729 } 729 }
730 pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht; 730 pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht;
731 } 731 }
732 if(cSDHUFFBMSIZE == 0) { 732 if(cSDHUFFBMSIZE == 0) {
733 JBIG2_ALLOC(Table_B1, CJBig2_HuffmanTable(HuffmanTable_B1, 733 JBIG2_ALLOC(Table_B1, CJBig2_HuffmanTable(HuffmanTable_B1,
734 sizeof(HuffmanTable_B1) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B1)); 734 sizeof(HuffmanTable_B1) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B1));
735 pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1; 735 pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1;
736 } else { 736 } else {
737 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 737 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
738 if(!pSeg) { 738 if(!pSeg) {
739 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFBMSIZE can't find user supplied table."); 739 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFBMSIZE can't find user supplied table.");
740 nRet = JBIG2_ERROR_FETAL; 740 nRet = JBIG2_ERROR_FATAL;
741 goto failed; 741 goto failed;
742 } 742 }
743 pSymbolDictDecoder->SDHUFFBMSIZE = pSeg->m_Result.ht; 743 pSymbolDictDecoder->SDHUFFBMSIZE = pSeg->m_Result.ht;
744 } 744 }
745 if(pSymbolDictDecoder->SDREFAGG == 1) { 745 if(pSymbolDictDecoder->SDREFAGG == 1) {
746 if(cSDHUFFAGGINST == 0) { 746 if(cSDHUFFAGGINST == 0) {
747 if(!Table_B1) { 747 if(!Table_B1) {
748 JBIG2_ALLOC(Table_B1, CJBig2_HuffmanTable(HuffmanTable_B1, 748 JBIG2_ALLOC(Table_B1, CJBig2_HuffmanTable(HuffmanTable_B1,
749 sizeof(HuffmanTable_B1) / sizeof(JBig2TableLine) , HuffmanTable_HTOOB_B1)); 749 sizeof(HuffmanTable_B1) / sizeof(JBig2TableLine) , HuffmanTable_HTOOB_B1));
750 } 750 }
751 pSymbolDictDecoder->SDHUFFAGGINST = Table_B1; 751 pSymbolDictDecoder->SDHUFFAGGINST = Table_B1;
752 } else { 752 } else {
753 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++) ; 753 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++) ;
754 if(!pSeg) { 754 if(!pSeg) {
755 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFAG GINST can't find user supplied table."); 755 m_pModule->JBig2_Error("symbol dictionary segment : SDHUFFAG GINST can't find user supplied table.");
756 nRet = JBIG2_ERROR_FETAL; 756 nRet = JBIG2_ERROR_FATAL;
757 goto failed; 757 goto failed;
758 } 758 }
759 pSymbolDictDecoder->SDHUFFAGGINST = pSeg->m_Result.ht; 759 pSymbolDictDecoder->SDHUFFAGGINST = pSeg->m_Result.ht;
760 } 760 }
761 } 761 }
762 } 762 }
763 if((wFlags & 0x0100) && pLRSeg && pLRSeg->m_Result.sd->m_bContextRetained) { 763 if((wFlags & 0x0100) && pLRSeg && pLRSeg->m_Result.sd->m_bContextRetained) {
764 if (pSymbolDictDecoder->SDHUFF == 0) { 764 if (pSymbolDictDecoder->SDHUFF == 0) {
765 dwTemp = pSymbolDictDecoder->SDTEMPLATE == 0 ? 65536 : pSymbolDictDe coder->SDTEMPLATE == 1 ? 765 dwTemp = pSymbolDictDecoder->SDTEMPLATE == 0 ? 65536 : pSymbolDictDe coder->SDTEMPLATE == 1 ?
766 8192 : 1024; 766 8192 : 1024;
(...skipping 28 matching lines...) Expand all
795 cache_hit = true; 795 cache_hit = true;
796 break; 796 break;
797 } 797 }
798 } 798 }
799 if (!cache_hit) { 799 if (!cache_hit) {
800 if(pSymbolDictDecoder->SDHUFF == 0) { 800 if(pSymbolDictDecoder->SDHUFF == 0) {
801 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream)); 801 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream));
802 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Arith(pArithDecod er, gbContext, grContext); 802 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Arith(pArithDecod er, gbContext, grContext);
803 delete pArithDecoder; 803 delete pArithDecoder;
804 if(pSegment->m_Result.sd == NULL) { 804 if(pSegment->m_Result.sd == NULL) {
805 nRet = JBIG2_ERROR_FETAL; 805 nRet = JBIG2_ERROR_FATAL;
806 goto failed; 806 goto failed;
807 } 807 }
808 m_pStream->alignByte(); 808 m_pStream->alignByte();
809 m_pStream->offset(2); 809 m_pStream->offset(2);
810 } else { 810 } else {
811 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Huffman(m_pStream , gbContext, grContext, pPause); 811 pSegment->m_Result.sd = pSymbolDictDecoder->decode_Huffman(m_pStream , gbContext, grContext, pPause);
812 if(pSegment->m_Result.sd == NULL) { 812 if(pSegment->m_Result.sd == NULL) {
813 nRet = JBIG2_ERROR_FETAL; 813 nRet = JBIG2_ERROR_FATAL;
814 goto failed; 814 goto failed;
815 } 815 }
816 m_pStream->alignByte(); 816 m_pStream->alignByte();
817 } 817 }
818 CJBig2_SymbolDict *value = pSegment->m_Result.sd->DeepCopy(); 818 CJBig2_SymbolDict *value = pSegment->m_Result.sd->DeepCopy();
819 if (value && kSymbolDictCacheMaxSize > 0) { 819 if (value && kSymbolDictCacheMaxSize > 0) {
820 while (m_pSymbolDictCache->size() >= kSymbolDictCacheMaxSize) { 820 while (m_pSymbolDictCache->size() >= kSymbolDictCacheMaxSize) {
821 delete m_pSymbolDictCache->back().second; 821 delete m_pSymbolDictCache->back().second;
822 m_pSymbolDictCache->pop_back(); 822 m_pSymbolDictCache->pop_back();
823 } 823 }
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 } 944 }
945 } 945 }
946 if(m_pStream->readInteger(&pTRD->SBNUMINSTANCES) != 0) { 946 if(m_pStream->readInteger(&pTRD->SBNUMINSTANCES) != 0) {
947 m_pModule->JBig2_Error("text region segment : data header too short."); 947 m_pModule->JBig2_Error("text region segment : data header too short.");
948 nRet = JBIG2_ERROR_TOO_SHORT; 948 nRet = JBIG2_ERROR_TOO_SHORT;
949 goto failed; 949 goto failed;
950 } 950 }
951 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 951 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
952 if(!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) { 952 if(!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) {
953 m_pModule->JBig2_Error("text region segment : can't find refered to segments"); 953 m_pModule->JBig2_Error("text region segment : can't find refered to segments");
954 nRet = JBIG2_ERROR_FETAL; 954 nRet = JBIG2_ERROR_FATAL;
955 goto failed; 955 goto failed;
956 } 956 }
957 } 957 }
958 pTRD->SBNUMSYMS = 0; 958 pTRD->SBNUMSYMS = 0;
959 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 959 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
960 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]); 960 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
961 if(pSeg->m_cFlags.s.type == 0) { 961 if(pSeg->m_cFlags.s.type == 0) {
962 pTRD->SBNUMSYMS += pSeg->m_Result.sd->SDNUMEXSYMS; 962 pTRD->SBNUMSYMS += pSeg->m_Result.sd->SDNUMEXSYMS;
963 } 963 }
964 } 964 }
(...skipping 10 matching lines...) Expand all
975 } 975 }
976 } 976 }
977 pTRD->SBSYMS = SBSYMS; 977 pTRD->SBSYMS = SBSYMS;
978 } else { 978 } else {
979 pTRD->SBSYMS = NULL; 979 pTRD->SBSYMS = NULL;
980 } 980 }
981 if(pTRD->SBHUFF == 1) { 981 if(pTRD->SBHUFF == 1) {
982 SBSYMCODES = decodeSymbolIDHuffmanTable(m_pStream, pTRD->SBNUMSYMS); 982 SBSYMCODES = decodeSymbolIDHuffmanTable(m_pStream, pTRD->SBNUMSYMS);
983 if(SBSYMCODES == NULL) { 983 if(SBSYMCODES == NULL) {
984 m_pModule->JBig2_Error("text region segment: symbol ID huffman table decode failure!"); 984 m_pModule->JBig2_Error("text region segment: symbol ID huffman table decode failure!");
985 nRet = JBIG2_ERROR_FETAL; 985 nRet = JBIG2_ERROR_FATAL;
986 goto failed; 986 goto failed;
987 } 987 }
988 m_pStream->alignByte(); 988 m_pStream->alignByte();
989 pTRD->SBSYMCODES = SBSYMCODES; 989 pTRD->SBSYMCODES = SBSYMCODES;
990 } else { 990 } else {
991 dwTemp = 0; 991 dwTemp = 0;
992 while((FX_DWORD)(1 << dwTemp) < pTRD->SBNUMSYMS) { 992 while((FX_DWORD)(1 << dwTemp) < pTRD->SBNUMSYMS) {
993 dwTemp ++; 993 dwTemp ++;
994 } 994 }
995 pTRD->SBSYMCODELEN = (uint8_t)dwTemp; 995 pTRD->SBSYMCODELEN = (uint8_t)dwTemp;
996 } 996 }
997 if(pTRD->SBHUFF == 1) { 997 if(pTRD->SBHUFF == 1) {
998 if((cSBHUFFFS == 2) || (cSBHUFFRDW == 2) || (cSBHUFFRDH == 2) 998 if((cSBHUFFFS == 2) || (cSBHUFFRDW == 2) || (cSBHUFFRDH == 2)
999 || (cSBHUFFRDX == 2) || (cSBHUFFRDY == 2)) { 999 || (cSBHUFFRDX == 2) || (cSBHUFFRDY == 2)) {
1000 m_pModule->JBig2_Error("text region segment : SBHUFFFS=2 or SBHUFFRD W=2 or " 1000 m_pModule->JBig2_Error("text region segment : SBHUFFFS=2 or SBHUFFRD W=2 or "
1001 "SBHUFFRDH=2 or SBHUFFRDX=2 or SBHUFFRDY=2 is not permitted"); 1001 "SBHUFFRDH=2 or SBHUFFRDX=2 or SBHUFFRDY=2 is not permitted");
1002 nRet = JBIG2_ERROR_FETAL; 1002 nRet = JBIG2_ERROR_FATAL;
1003 goto failed; 1003 goto failed;
1004 } 1004 }
1005 nIndex = 0; 1005 nIndex = 0;
1006 if(cSBHUFFFS == 0) { 1006 if(cSBHUFFFS == 0) {
1007 JBIG2_ALLOC(Table_B6, CJBig2_HuffmanTable(HuffmanTable_B6, 1007 JBIG2_ALLOC(Table_B6, CJBig2_HuffmanTable(HuffmanTable_B6,
1008 sizeof(HuffmanTable_B6) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B6)); 1008 sizeof(HuffmanTable_B6) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B6));
1009 pTRD->SBHUFFFS = Table_B6; 1009 pTRD->SBHUFFFS = Table_B6;
1010 } else if(cSBHUFFFS == 1) { 1010 } else if(cSBHUFFFS == 1) {
1011 JBIG2_ALLOC(Table_B7, CJBig2_HuffmanTable(HuffmanTable_B7, 1011 JBIG2_ALLOC(Table_B7, CJBig2_HuffmanTable(HuffmanTable_B7,
1012 sizeof(HuffmanTable_B7) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B7)); 1012 sizeof(HuffmanTable_B7) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B7));
1013 pTRD->SBHUFFFS = Table_B7; 1013 pTRD->SBHUFFFS = Table_B7;
1014 } else { 1014 } else {
1015 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1015 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1016 if(!pSeg) { 1016 if(!pSeg) {
1017 m_pModule->JBig2_Error("text region segment : SBHUFFFS can't fin d user supplied table"); 1017 m_pModule->JBig2_Error("text region segment : SBHUFFFS can't fin d user supplied table");
1018 nRet = JBIG2_ERROR_FETAL; 1018 nRet = JBIG2_ERROR_FATAL;
1019 goto failed; 1019 goto failed;
1020 } 1020 }
1021 pTRD->SBHUFFFS = pSeg->m_Result.ht; 1021 pTRD->SBHUFFFS = pSeg->m_Result.ht;
1022 } 1022 }
1023 if(cSBHUFFDS == 0) { 1023 if(cSBHUFFDS == 0) {
1024 JBIG2_ALLOC(Table_B8, CJBig2_HuffmanTable(HuffmanTable_B8, 1024 JBIG2_ALLOC(Table_B8, CJBig2_HuffmanTable(HuffmanTable_B8,
1025 sizeof(HuffmanTable_B8) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B8)); 1025 sizeof(HuffmanTable_B8) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B8));
1026 pTRD->SBHUFFDS = Table_B8; 1026 pTRD->SBHUFFDS = Table_B8;
1027 } else if(cSBHUFFDS == 1) { 1027 } else if(cSBHUFFDS == 1) {
1028 JBIG2_ALLOC(Table_B9, CJBig2_HuffmanTable(HuffmanTable_B9, 1028 JBIG2_ALLOC(Table_B9, CJBig2_HuffmanTable(HuffmanTable_B9,
1029 sizeof(HuffmanTable_B9) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B9)); 1029 sizeof(HuffmanTable_B9) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B9));
1030 pTRD->SBHUFFDS = Table_B9; 1030 pTRD->SBHUFFDS = Table_B9;
1031 } else if(cSBHUFFDS == 2) { 1031 } else if(cSBHUFFDS == 2) {
1032 JBIG2_ALLOC(Table_B10, CJBig2_HuffmanTable(HuffmanTable_B10, 1032 JBIG2_ALLOC(Table_B10, CJBig2_HuffmanTable(HuffmanTable_B10,
1033 sizeof(HuffmanTable_B10) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B10)); 1033 sizeof(HuffmanTable_B10) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B10));
1034 pTRD->SBHUFFDS = Table_B10; 1034 pTRD->SBHUFFDS = Table_B10;
1035 } else { 1035 } else {
1036 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1036 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1037 if(!pSeg) { 1037 if(!pSeg) {
1038 m_pModule->JBig2_Error("text region segment : SBHUFFDS can't fin d user supplied table"); 1038 m_pModule->JBig2_Error("text region segment : SBHUFFDS can't fin d user supplied table");
1039 nRet = JBIG2_ERROR_FETAL; 1039 nRet = JBIG2_ERROR_FATAL;
1040 goto failed; 1040 goto failed;
1041 } 1041 }
1042 pTRD->SBHUFFDS = pSeg->m_Result.ht; 1042 pTRD->SBHUFFDS = pSeg->m_Result.ht;
1043 } 1043 }
1044 if(cSBHUFFDT == 0) { 1044 if(cSBHUFFDT == 0) {
1045 JBIG2_ALLOC(Table_B11, CJBig2_HuffmanTable(HuffmanTable_B11, 1045 JBIG2_ALLOC(Table_B11, CJBig2_HuffmanTable(HuffmanTable_B11,
1046 sizeof(HuffmanTable_B11) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B11)); 1046 sizeof(HuffmanTable_B11) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B11));
1047 pTRD->SBHUFFDT = Table_B11; 1047 pTRD->SBHUFFDT = Table_B11;
1048 } else if(cSBHUFFDT == 1) { 1048 } else if(cSBHUFFDT == 1) {
1049 JBIG2_ALLOC(Table_B12, CJBig2_HuffmanTable(HuffmanTable_B12, 1049 JBIG2_ALLOC(Table_B12, CJBig2_HuffmanTable(HuffmanTable_B12,
1050 sizeof(HuffmanTable_B12) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B12)); 1050 sizeof(HuffmanTable_B12) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B12));
1051 pTRD->SBHUFFDT = Table_B12; 1051 pTRD->SBHUFFDT = Table_B12;
1052 } else if(cSBHUFFDT == 2) { 1052 } else if(cSBHUFFDT == 2) {
1053 JBIG2_ALLOC(Table_B13, CJBig2_HuffmanTable(HuffmanTable_B13, 1053 JBIG2_ALLOC(Table_B13, CJBig2_HuffmanTable(HuffmanTable_B13,
1054 sizeof(HuffmanTable_B13) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B13)); 1054 sizeof(HuffmanTable_B13) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B13));
1055 pTRD->SBHUFFDT = Table_B13; 1055 pTRD->SBHUFFDT = Table_B13;
1056 } else { 1056 } else {
1057 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1057 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1058 if(!pSeg) { 1058 if(!pSeg) {
1059 m_pModule->JBig2_Error("text region segment : SBHUFFDT can't fin d user supplied table"); 1059 m_pModule->JBig2_Error("text region segment : SBHUFFDT can't fin d user supplied table");
1060 nRet = JBIG2_ERROR_FETAL; 1060 nRet = JBIG2_ERROR_FATAL;
1061 goto failed; 1061 goto failed;
1062 } 1062 }
1063 pTRD->SBHUFFDT = pSeg->m_Result.ht; 1063 pTRD->SBHUFFDT = pSeg->m_Result.ht;
1064 } 1064 }
1065 if(cSBHUFFRDW == 0) { 1065 if(cSBHUFFRDW == 0) {
1066 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14, 1066 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14,
1067 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B14)); 1067 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B14));
1068 pTRD->SBHUFFRDW = Table_B14; 1068 pTRD->SBHUFFRDW = Table_B14;
1069 } else if(cSBHUFFRDW == 1) { 1069 } else if(cSBHUFFRDW == 1) {
1070 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15, 1070 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15,
1071 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B15)); 1071 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), Huffm anTable_HTOOB_B15));
1072 pTRD->SBHUFFRDW = Table_B15; 1072 pTRD->SBHUFFRDW = Table_B15;
1073 } else { 1073 } else {
1074 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1074 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1075 if(!pSeg) { 1075 if(!pSeg) {
1076 m_pModule->JBig2_Error("text region segment : SBHUFFRDW can't fi nd user supplied table"); 1076 m_pModule->JBig2_Error("text region segment : SBHUFFRDW can't fi nd user supplied table");
1077 nRet = JBIG2_ERROR_FETAL; 1077 nRet = JBIG2_ERROR_FATAL;
1078 goto failed; 1078 goto failed;
1079 } 1079 }
1080 pTRD->SBHUFFRDW = pSeg->m_Result.ht; 1080 pTRD->SBHUFFRDW = pSeg->m_Result.ht;
1081 } 1081 }
1082 if(cSBHUFFRDH == 0) { 1082 if(cSBHUFFRDH == 0) {
1083 if(!Table_B14) { 1083 if(!Table_B14) {
1084 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14, 1084 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14,
1085 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B14)); 1085 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B14));
1086 } 1086 }
1087 pTRD->SBHUFFRDH = Table_B14; 1087 pTRD->SBHUFFRDH = Table_B14;
1088 } else if(cSBHUFFRDH == 1) { 1088 } else if(cSBHUFFRDH == 1) {
1089 if(!Table_B15) { 1089 if(!Table_B15) {
1090 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15, 1090 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15,
1091 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B15)); 1091 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B15));
1092 } 1092 }
1093 pTRD->SBHUFFRDH = Table_B15; 1093 pTRD->SBHUFFRDH = Table_B15;
1094 } else { 1094 } else {
1095 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1095 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1096 if(!pSeg) { 1096 if(!pSeg) {
1097 m_pModule->JBig2_Error("text region segment : SBHUFFRDH can't fi nd user supplied table"); 1097 m_pModule->JBig2_Error("text region segment : SBHUFFRDH can't fi nd user supplied table");
1098 nRet = JBIG2_ERROR_FETAL; 1098 nRet = JBIG2_ERROR_FATAL;
1099 goto failed; 1099 goto failed;
1100 } 1100 }
1101 pTRD->SBHUFFRDH = pSeg->m_Result.ht; 1101 pTRD->SBHUFFRDH = pSeg->m_Result.ht;
1102 } 1102 }
1103 if(cSBHUFFRDX == 0) { 1103 if(cSBHUFFRDX == 0) {
1104 if(!Table_B14) { 1104 if(!Table_B14) {
1105 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14, 1105 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14,
1106 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B14)); 1106 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B14));
1107 } 1107 }
1108 pTRD->SBHUFFRDX = Table_B14; 1108 pTRD->SBHUFFRDX = Table_B14;
1109 } else if(cSBHUFFRDX == 1) { 1109 } else if(cSBHUFFRDX == 1) {
1110 if(!Table_B15) { 1110 if(!Table_B15) {
1111 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15, 1111 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15,
1112 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B15)); 1112 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B15));
1113 } 1113 }
1114 pTRD->SBHUFFRDX = Table_B15; 1114 pTRD->SBHUFFRDX = Table_B15;
1115 } else { 1115 } else {
1116 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1116 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1117 if(!pSeg) { 1117 if(!pSeg) {
1118 m_pModule->JBig2_Error("text region segment : SBHUFFRDX can't fi nd user supplied table"); 1118 m_pModule->JBig2_Error("text region segment : SBHUFFRDX can't fi nd user supplied table");
1119 nRet = JBIG2_ERROR_FETAL; 1119 nRet = JBIG2_ERROR_FATAL;
1120 goto failed; 1120 goto failed;
1121 } 1121 }
1122 pTRD->SBHUFFRDX = pSeg->m_Result.ht; 1122 pTRD->SBHUFFRDX = pSeg->m_Result.ht;
1123 } 1123 }
1124 if(cSBHUFFRDY == 0) { 1124 if(cSBHUFFRDY == 0) {
1125 if(!Table_B14) { 1125 if(!Table_B14) {
1126 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14, 1126 JBIG2_ALLOC(Table_B14, CJBig2_HuffmanTable(HuffmanTable_B14,
1127 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B14)); 1127 sizeof(HuffmanTable_B14) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B14));
1128 } 1128 }
1129 pTRD->SBHUFFRDY = Table_B14; 1129 pTRD->SBHUFFRDY = Table_B14;
1130 } else if(cSBHUFFRDY == 1) { 1130 } else if(cSBHUFFRDY == 1) {
1131 if(!Table_B15) { 1131 if(!Table_B15) {
1132 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15, 1132 JBIG2_ALLOC(Table_B15, CJBig2_HuffmanTable(HuffmanTable_B15,
1133 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B15)); 1133 sizeof(HuffmanTable_B15) / sizeof(JBig2TableLine), H uffmanTable_HTOOB_B15));
1134 } 1134 }
1135 pTRD->SBHUFFRDY = Table_B15; 1135 pTRD->SBHUFFRDY = Table_B15;
1136 } else { 1136 } else {
1137 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1137 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1138 if(!pSeg) { 1138 if(!pSeg) {
1139 m_pModule->JBig2_Error("text region segment : SBHUFFRDY can't fi nd user supplied table"); 1139 m_pModule->JBig2_Error("text region segment : SBHUFFRDY can't fi nd user supplied table");
1140 nRet = JBIG2_ERROR_FETAL; 1140 nRet = JBIG2_ERROR_FATAL;
1141 goto failed; 1141 goto failed;
1142 } 1142 }
1143 pTRD->SBHUFFRDY = pSeg->m_Result.ht; 1143 pTRD->SBHUFFRDY = pSeg->m_Result.ht;
1144 } 1144 }
1145 if(cSBHUFFRSIZE == 0) { 1145 if(cSBHUFFRSIZE == 0) {
1146 JBIG2_ALLOC(Table_B1, CJBig2_HuffmanTable(HuffmanTable_B1, 1146 JBIG2_ALLOC(Table_B1, CJBig2_HuffmanTable(HuffmanTable_B1,
1147 sizeof(HuffmanTable_B1) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B1)); 1147 sizeof(HuffmanTable_B1) / sizeof(JBig2TableLine), Huffma nTable_HTOOB_B1));
1148 pTRD->SBHUFFRSIZE = Table_B1; 1148 pTRD->SBHUFFRSIZE = Table_B1;
1149 } else { 1149 } else {
1150 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1150 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1151 if(!pSeg) { 1151 if(!pSeg) {
1152 m_pModule->JBig2_Error("text region segment : SBHUFFRSIZE can't find user supplied table"); 1152 m_pModule->JBig2_Error("text region segment : SBHUFFRSIZE can't find user supplied table");
1153 nRet = JBIG2_ERROR_FETAL; 1153 nRet = JBIG2_ERROR_FATAL;
1154 goto failed; 1154 goto failed;
1155 } 1155 }
1156 pTRD->SBHUFFRSIZE = pSeg->m_Result.ht; 1156 pTRD->SBHUFFRSIZE = pSeg->m_Result.ht;
1157 } 1157 }
1158 } 1158 }
1159 if(pTRD->SBREFINE == 1) { 1159 if(pTRD->SBREFINE == 1) {
1160 dwTemp = pTRD->SBRTEMPLATE ? 1 << 10 : 1 << 13; 1160 dwTemp = pTRD->SBRTEMPLATE ? 1 << 10 : 1 << 13;
1161 grContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCt x), dwTemp); 1161 grContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCt x), dwTemp);
1162 JBIG2_memset(grContext, 0, sizeof(JBig2ArithCtx)*dwTemp); 1162 JBIG2_memset(grContext, 0, sizeof(JBig2ArithCtx)*dwTemp);
1163 } 1163 }
1164 if(pTRD->SBHUFF == 0) { 1164 if(pTRD->SBHUFF == 0) {
1165 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream)); 1165 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream));
1166 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; 1166 pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
1167 pSegment->m_Result.im = pTRD->decode_Arith(pArithDecoder, grContext); 1167 pSegment->m_Result.im = pTRD->decode_Arith(pArithDecoder, grContext);
1168 delete pArithDecoder; 1168 delete pArithDecoder;
1169 if(pSegment->m_Result.im == NULL) { 1169 if(pSegment->m_Result.im == NULL) {
1170 nRet = JBIG2_ERROR_FETAL; 1170 nRet = JBIG2_ERROR_FATAL;
1171 goto failed; 1171 goto failed;
1172 } 1172 }
1173 m_pStream->alignByte(); 1173 m_pStream->alignByte();
1174 m_pStream->offset(2); 1174 m_pStream->offset(2);
1175 } else { 1175 } else {
1176 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; 1176 pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
1177 pSegment->m_Result.im = pTRD->decode_Huffman(m_pStream, grContext); 1177 pSegment->m_Result.im = pTRD->decode_Huffman(m_pStream, grContext);
1178 if(pSegment->m_Result.im == NULL) { 1178 if(pSegment->m_Result.im == NULL) {
1179 nRet = JBIG2_ERROR_FETAL; 1179 nRet = JBIG2_ERROR_FATAL;
1180 goto failed; 1180 goto failed;
1181 } 1181 }
1182 m_pStream->alignByte(); 1182 m_pStream->alignByte();
1183 } 1183 }
1184 if(pSegment->m_cFlags.s.type != 4) { 1184 if(pSegment->m_cFlags.s.type != 4) {
1185 if(!m_bBufSpecified) { 1185 if(!m_bBufSpecified) {
1186 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast(); 1186 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast();
1187 if ((pPageInfo->m_bIsStriped == 1) && (ri.y + ri.height > m_pPage->m _nHeight)) { 1187 if ((pPageInfo->m_bIsStriped == 1) && (ri.y + ri.height > m_pPage->m _nHeight)) {
1188 m_pPage->expand(ri.y + ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0); 1188 m_pPage->expand(ri.y + ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0);
1189 } 1189 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 pSegment->m_nResultType = JBIG2_PATTERN_DICT_POINTER; 1266 pSegment->m_nResultType = JBIG2_PATTERN_DICT_POINTER;
1267 if(pPDD->HDMMR == 0) { 1267 if(pPDD->HDMMR == 0) {
1268 dwTemp = pPDD->HDTEMPLATE == 0 ? 65536 : pPDD->HDTEMPLATE == 1 ? 8192 : 1024; 1268 dwTemp = pPDD->HDTEMPLATE == 0 ? 65536 : pPDD->HDTEMPLATE == 1 ? 8192 : 1024;
1269 gbContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCt x), dwTemp); 1269 gbContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCt x), dwTemp);
1270 JBIG2_memset(gbContext, 0, sizeof(JBig2ArithCtx)*dwTemp); 1270 JBIG2_memset(gbContext, 0, sizeof(JBig2ArithCtx)*dwTemp);
1271 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream)); 1271 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream));
1272 pSegment->m_Result.pd = pPDD->decode_Arith(pArithDecoder, gbContext, pPa use); 1272 pSegment->m_Result.pd = pPDD->decode_Arith(pArithDecoder, gbContext, pPa use);
1273 delete pArithDecoder; 1273 delete pArithDecoder;
1274 if(pSegment->m_Result.pd == NULL) { 1274 if(pSegment->m_Result.pd == NULL) {
1275 m_pModule->JBig2_Free(gbContext); 1275 m_pModule->JBig2_Free(gbContext);
1276 nRet = JBIG2_ERROR_FETAL; 1276 nRet = JBIG2_ERROR_FATAL;
1277 goto failed; 1277 goto failed;
1278 } 1278 }
1279 m_pModule->JBig2_Free(gbContext); 1279 m_pModule->JBig2_Free(gbContext);
1280 m_pStream->alignByte(); 1280 m_pStream->alignByte();
1281 m_pStream->offset(2); 1281 m_pStream->offset(2);
1282 } else { 1282 } else {
1283 pSegment->m_Result.pd = pPDD->decode_MMR(m_pStream, pPause); 1283 pSegment->m_Result.pd = pPDD->decode_MMR(m_pStream, pPause);
1284 if(pSegment->m_Result.pd == NULL) { 1284 if(pSegment->m_Result.pd == NULL) {
1285 nRet = JBIG2_ERROR_FETAL; 1285 nRet = JBIG2_ERROR_FATAL;
1286 goto failed; 1286 goto failed;
1287 } 1287 }
1288 m_pStream->alignByte(); 1288 m_pStream->alignByte();
1289 } 1289 }
1290 delete pPDD; 1290 delete pPDD;
1291 return JBIG2_SUCCESS; 1291 return JBIG2_SUCCESS;
1292 failed: 1292 failed:
1293 delete pPDD; 1293 delete pPDD;
1294 return nRet; 1294 return nRet;
1295 } 1295 }
(...skipping 23 matching lines...) Expand all
1319 } 1319 }
1320 pHRD->HBW = ri.width; 1320 pHRD->HBW = ri.width;
1321 pHRD->HBH = ri.height; 1321 pHRD->HBH = ri.height;
1322 pHRD->HMMR = cFlags & 0x01; 1322 pHRD->HMMR = cFlags & 0x01;
1323 pHRD->HTEMPLATE = (cFlags >> 1) & 0x03; 1323 pHRD->HTEMPLATE = (cFlags >> 1) & 0x03;
1324 pHRD->HENABLESKIP = (cFlags >> 3) & 0x01; 1324 pHRD->HENABLESKIP = (cFlags >> 3) & 0x01;
1325 pHRD->HCOMBOP = (JBig2ComposeOp)((cFlags >> 4) & 0x07); 1325 pHRD->HCOMBOP = (JBig2ComposeOp)((cFlags >> 4) & 0x07);
1326 pHRD->HDEFPIXEL = (cFlags >> 7) & 0x01; 1326 pHRD->HDEFPIXEL = (cFlags >> 7) & 0x01;
1327 if(pSegment->m_nReferred_to_segment_count != 1) { 1327 if(pSegment->m_nReferred_to_segment_count != 1) {
1328 m_pModule->JBig2_Error("halftone region segment : refered to segment cou nt not equals 1"); 1328 m_pModule->JBig2_Error("halftone region segment : refered to segment cou nt not equals 1");
1329 nRet = JBIG2_ERROR_FETAL; 1329 nRet = JBIG2_ERROR_FATAL;
1330 goto failed; 1330 goto failed;
1331 } 1331 }
1332 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]); 1332 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]);
1333 if( (pSeg == NULL) || (pSeg->m_cFlags.s.type != 16)) { 1333 if( (pSeg == NULL) || (pSeg->m_cFlags.s.type != 16)) {
1334 m_pModule->JBig2_Error("halftone region segment : refered to segment is not pattern dict"); 1334 m_pModule->JBig2_Error("halftone region segment : refered to segment is not pattern dict");
1335 nRet = JBIG2_ERROR_FETAL; 1335 nRet = JBIG2_ERROR_FATAL;
1336 goto failed; 1336 goto failed;
1337 } 1337 }
1338 pPatternDict = pSeg->m_Result.pd; 1338 pPatternDict = pSeg->m_Result.pd;
1339 if((pPatternDict == NULL) || (pPatternDict->NUMPATS == 0)) { 1339 if((pPatternDict == NULL) || (pPatternDict->NUMPATS == 0)) {
1340 m_pModule->JBig2_Error("halftone region segment : has no patterns input" ); 1340 m_pModule->JBig2_Error("halftone region segment : has no patterns input" );
1341 nRet = JBIG2_ERROR_FETAL; 1341 nRet = JBIG2_ERROR_FATAL;
1342 goto failed; 1342 goto failed;
1343 } 1343 }
1344 pHRD->HNUMPATS = pPatternDict->NUMPATS; 1344 pHRD->HNUMPATS = pPatternDict->NUMPATS;
1345 pHRD->HPATS = pPatternDict->HDPATS; 1345 pHRD->HPATS = pPatternDict->HDPATS;
1346 pHRD->HPW = pPatternDict->HDPATS[0]->m_nWidth; 1346 pHRD->HPW = pPatternDict->HDPATS[0]->m_nWidth;
1347 pHRD->HPH = pPatternDict->HDPATS[0]->m_nHeight; 1347 pHRD->HPH = pPatternDict->HDPATS[0]->m_nHeight;
1348 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; 1348 pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
1349 if(pHRD->HMMR == 0) { 1349 if(pHRD->HMMR == 0) {
1350 dwTemp = pHRD->HTEMPLATE == 0 ? 65536 : pHRD->HTEMPLATE == 1 ? 8192 : 10 24; 1350 dwTemp = pHRD->HTEMPLATE == 0 ? 65536 : pHRD->HTEMPLATE == 1 ? 8192 : 10 24;
1351 gbContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCt x), dwTemp); 1351 gbContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCt x), dwTemp);
1352 JBIG2_memset(gbContext, 0, sizeof(JBig2ArithCtx)*dwTemp); 1352 JBIG2_memset(gbContext, 0, sizeof(JBig2ArithCtx)*dwTemp);
1353 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream)); 1353 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream));
1354 pSegment->m_Result.im = pHRD->decode_Arith(pArithDecoder, gbContext, pPa use); 1354 pSegment->m_Result.im = pHRD->decode_Arith(pArithDecoder, gbContext, pPa use);
1355 delete pArithDecoder; 1355 delete pArithDecoder;
1356 if(pSegment->m_Result.im == NULL) { 1356 if(pSegment->m_Result.im == NULL) {
1357 m_pModule->JBig2_Free(gbContext); 1357 m_pModule->JBig2_Free(gbContext);
1358 nRet = JBIG2_ERROR_FETAL; 1358 nRet = JBIG2_ERROR_FATAL;
1359 goto failed; 1359 goto failed;
1360 } 1360 }
1361 m_pModule->JBig2_Free(gbContext); 1361 m_pModule->JBig2_Free(gbContext);
1362 m_pStream->alignByte(); 1362 m_pStream->alignByte();
1363 m_pStream->offset(2); 1363 m_pStream->offset(2);
1364 } else { 1364 } else {
1365 pSegment->m_Result.im = pHRD->decode_MMR(m_pStream, pPause); 1365 pSegment->m_Result.im = pHRD->decode_MMR(m_pStream, pPause);
1366 if(pSegment->m_Result.im == NULL) { 1366 if(pSegment->m_Result.im == NULL) {
1367 nRet = JBIG2_ERROR_FETAL; 1367 nRet = JBIG2_ERROR_FATAL;
1368 goto failed; 1368 goto failed;
1369 } 1369 }
1370 m_pStream->alignByte(); 1370 m_pStream->alignByte();
1371 } 1371 }
1372 if(pSegment->m_cFlags.s.type != 20) { 1372 if(pSegment->m_cFlags.s.type != 20) {
1373 if(!m_bBufSpecified) { 1373 if(!m_bBufSpecified) {
1374 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast(); 1374 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast();
1375 if ((pPageInfo->m_bIsStriped == 1) && (ri.y + ri.height > m_pPage->m _nHeight)) { 1375 if ((pPageInfo->m_bIsStriped == 1) && (ri.y + ri.height > m_pPage->m _nHeight)) {
1376 m_pPage->expand(ri.y + ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0); 1376 m_pPage->expand(ri.y + ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0);
1377 } 1377 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1455 } 1455 }
1456 FX_RECT Rect = m_pGRD->GetReplaceRect(); 1456 FX_RECT Rect = m_pGRD->GetReplaceRect();
1457 m_pPage->composeFrom(m_ri.x + Rect.left, m_ri.y + Rect.top, pSeg ment->m_Result.im, (JBig2ComposeOp)(m_ri.flags & 0x03), &Rect); 1457 m_pPage->composeFrom(m_ri.x + Rect.left, m_ri.y + Rect.top, pSeg ment->m_Result.im, (JBig2ComposeOp)(m_ri.flags & 0x03), &Rect);
1458 } 1458 }
1459 return JBIG2_SUCCESS; 1459 return JBIG2_SUCCESS;
1460 } else { 1460 } else {
1461 delete m_pArithDecoder; 1461 delete m_pArithDecoder;
1462 m_pArithDecoder = NULL; 1462 m_pArithDecoder = NULL;
1463 if(pSegment->m_Result.im == NULL) { 1463 if(pSegment->m_Result.im == NULL) {
1464 m_pModule->JBig2_Free(m_gbContext); 1464 m_pModule->JBig2_Free(m_gbContext);
1465 nRet = JBIG2_ERROR_FETAL; 1465 nRet = JBIG2_ERROR_FATAL;
1466 m_gbContext = NULL; 1466 m_gbContext = NULL;
1467 m_ProcessiveStatus = FXCODEC_STATUS_ERROR; 1467 m_ProcessiveStatus = FXCODEC_STATUS_ERROR;
1468 goto failed; 1468 goto failed;
1469 } 1469 }
1470 m_pModule->JBig2_Free(m_gbContext); 1470 m_pModule->JBig2_Free(m_gbContext);
1471 m_gbContext = NULL; 1471 m_gbContext = NULL;
1472 m_pStream->alignByte(); 1472 m_pStream->alignByte();
1473 m_pStream->offset(2); 1473 m_pStream->offset(2);
1474 } 1474 }
1475 } else { 1475 } else {
1476 FXCODEC_STATUS status = m_pGRD->Start_decode_MMR(&pSegment->m_Result.im, m_pStream, pPause); 1476 FXCODEC_STATUS status = m_pGRD->Start_decode_MMR(&pSegment->m_Result.im, m_pStream, pPause);
1477 while(status == FXCODEC_STATUS_DECODE_TOBECONTINUE) { 1477 while(status == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
1478 m_pGRD->Continue_decode(pPause); 1478 m_pGRD->Continue_decode(pPause);
1479 } 1479 }
1480 if(pSegment->m_Result.im == NULL) { 1480 if(pSegment->m_Result.im == NULL) {
1481 nRet = JBIG2_ERROR_FETAL; 1481 nRet = JBIG2_ERROR_FATAL;
1482 goto failed; 1482 goto failed;
1483 } 1483 }
1484 m_pStream->alignByte(); 1484 m_pStream->alignByte();
1485 } 1485 }
1486 if(pSegment->m_cFlags.s.type != 36) { 1486 if(pSegment->m_cFlags.s.type != 36) {
1487 if(!m_bBufSpecified) { 1487 if(!m_bBufSpecified) {
1488 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast(); 1488 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast();
1489 if ((pPageInfo->m_bIsStriped == 1) && (m_ri.y + m_ri.height > m_pPag e->m_nHeight)) { 1489 if ((pPageInfo->m_bIsStriped == 1) && (m_ri.y + m_ri.height > m_pPag e->m_nHeight)) {
1490 m_pPage->expand(m_ri.y + m_ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0); 1490 m_pPage->expand(m_ri.y + m_ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0);
1491 } 1491 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1533 goto failed; 1533 goto failed;
1534 } 1534 }
1535 } 1535 }
1536 } 1536 }
1537 pSeg = NULL; 1537 pSeg = NULL;
1538 if(pSegment->m_nReferred_to_segment_count > 0) { 1538 if(pSegment->m_nReferred_to_segment_count > 0) {
1539 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 1539 for(i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
1540 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[ 0]); 1540 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[ 0]);
1541 if(pSeg == NULL) { 1541 if(pSeg == NULL) {
1542 m_pModule->JBig2_Error("generic refinement region segment : can' t find refered to segments"); 1542 m_pModule->JBig2_Error("generic refinement region segment : can' t find refered to segments");
1543 nRet = JBIG2_ERROR_FETAL; 1543 nRet = JBIG2_ERROR_FATAL;
1544 goto failed; 1544 goto failed;
1545 } 1545 }
1546 if((pSeg->m_cFlags.s.type == 4) || (pSeg->m_cFlags.s.type == 20) 1546 if((pSeg->m_cFlags.s.type == 4) || (pSeg->m_cFlags.s.type == 20)
1547 || (pSeg->m_cFlags.s.type == 36) || (pSeg->m_cFlags.s.type = = 40)) { 1547 || (pSeg->m_cFlags.s.type == 36) || (pSeg->m_cFlags.s.type = = 40)) {
1548 break; 1548 break;
1549 } 1549 }
1550 } 1550 }
1551 if(i >= pSegment->m_nReferred_to_segment_count) { 1551 if(i >= pSegment->m_nReferred_to_segment_count) {
1552 m_pModule->JBig2_Error("generic refinement region segment : can't fi nd refered to intermediate region"); 1552 m_pModule->JBig2_Error("generic refinement region segment : can't fi nd refered to intermediate region");
1553 nRet = JBIG2_ERROR_FETAL; 1553 nRet = JBIG2_ERROR_FATAL;
1554 goto failed; 1554 goto failed;
1555 } 1555 }
1556 pGRRD->GRREFERENCE = pSeg->m_Result.im; 1556 pGRRD->GRREFERENCE = pSeg->m_Result.im;
1557 } else { 1557 } else {
1558 pGRRD->GRREFERENCE = m_pPage; 1558 pGRRD->GRREFERENCE = m_pPage;
1559 } 1559 }
1560 pGRRD->GRREFERENCEDX = 0; 1560 pGRRD->GRREFERENCEDX = 0;
1561 pGRRD->GRREFERENCEDY = 0; 1561 pGRRD->GRREFERENCEDY = 0;
1562 dwTemp = pGRRD->GRTEMPLATE ? 1 << 10 : 1 << 13; 1562 dwTemp = pGRRD->GRTEMPLATE ? 1 << 10 : 1 << 13;
1563 grContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), dwTemp); 1563 grContext = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), dwTemp);
1564 JBIG2_memset(grContext, 0, sizeof(JBig2ArithCtx)*dwTemp); 1564 JBIG2_memset(grContext, 0, sizeof(JBig2ArithCtx)*dwTemp);
1565 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream)); 1565 JBIG2_ALLOC(pArithDecoder, CJBig2_ArithDecoder(m_pStream));
1566 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; 1566 pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
1567 pSegment->m_Result.im = pGRRD->decode(pArithDecoder, grContext); 1567 pSegment->m_Result.im = pGRRD->decode(pArithDecoder, grContext);
1568 delete pArithDecoder; 1568 delete pArithDecoder;
1569 if(pSegment->m_Result.im == NULL) { 1569 if(pSegment->m_Result.im == NULL) {
1570 m_pModule->JBig2_Free(grContext); 1570 m_pModule->JBig2_Free(grContext);
1571 nRet = JBIG2_ERROR_FETAL; 1571 nRet = JBIG2_ERROR_FATAL;
1572 goto failed; 1572 goto failed;
1573 } 1573 }
1574 m_pModule->JBig2_Free(grContext); 1574 m_pModule->JBig2_Free(grContext);
1575 m_pStream->alignByte(); 1575 m_pStream->alignByte();
1576 m_pStream->offset(2); 1576 m_pStream->offset(2);
1577 if(pSegment->m_cFlags.s.type != 40) { 1577 if(pSegment->m_cFlags.s.type != 40) {
1578 if(!m_bBufSpecified) { 1578 if(!m_bBufSpecified) {
1579 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast(); 1579 JBig2PageInfo *pPageInfo = m_pPageInfoList->getLast();
1580 if ((pPageInfo->m_bIsStriped == 1) && (ri.y + ri.height > m_pPage->m _nHeight)) { 1580 if ((pPageInfo->m_bIsStriped == 1) && (ri.y + ri.height > m_pPage->m _nHeight)) {
1581 m_pPage->expand(ri.y + ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0); 1581 m_pPage->expand(ri.y + ri.height, (pPageInfo->m_cFlags & 4) ? 1 : 0);
1582 } 1582 }
1583 } 1583 }
1584 m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im, (JBig2ComposeOp) (ri.flags & 0x03)); 1584 m_pPage->composeFrom(ri.x, ri.y, pSegment->m_Result.im, (JBig2ComposeOp) (ri.flags & 0x03));
1585 delete pSegment->m_Result.im; 1585 delete pSegment->m_Result.im;
1586 pSegment->m_Result.im = NULL; 1586 pSegment->m_Result.im = NULL;
1587 } 1587 }
1588 delete pGRRD; 1588 delete pGRRD;
1589 return JBIG2_SUCCESS; 1589 return JBIG2_SUCCESS;
1590 failed: 1590 failed:
1591 delete pGRRD; 1591 delete pGRRD;
1592 return nRet; 1592 return nRet;
1593 } 1593 }
1594 FX_BOOL CJBig2_Context::parseTable(CJBig2_Segment *pSegment) 1594 FX_BOOL CJBig2_Context::parseTable(CJBig2_Segment *pSegment)
1595 { 1595 {
1596 pSegment->m_nResultType = JBIG2_HUFFMAN_TABLE_POINTER; 1596 pSegment->m_nResultType = JBIG2_HUFFMAN_TABLE_POINTER;
1597 JBIG2_ALLOC(pSegment->m_Result.ht, CJBig2_HuffmanTable(m_pStream)); 1597 JBIG2_ALLOC(pSegment->m_Result.ht, CJBig2_HuffmanTable(m_pStream));
1598 if(!pSegment->m_Result.ht->isOK()) { 1598 if(!pSegment->m_Result.ht->isOK()) {
1599 delete pSegment->m_Result.ht; 1599 delete pSegment->m_Result.ht;
1600 pSegment->m_Result.ht = NULL; 1600 pSegment->m_Result.ht = NULL;
1601 return JBIG2_ERROR_FETAL; 1601 return JBIG2_ERROR_FATAL;
1602 } 1602 }
1603 m_pStream->alignByte(); 1603 m_pStream->alignByte();
1604 return JBIG2_SUCCESS; 1604 return JBIG2_SUCCESS;
1605 } 1605 }
1606 int32_t CJBig2_Context::parseRegionInfo(JBig2RegionInfo *pRI) 1606 int32_t CJBig2_Context::parseRegionInfo(JBig2RegionInfo *pRI)
1607 { 1607 {
1608 if((m_pStream->readInteger((FX_DWORD*)&pRI->width) != 0) 1608 if((m_pStream->readInteger((FX_DWORD*)&pRI->width) != 0)
1609 || (m_pStream->readInteger((FX_DWORD*)&pRI->height) != 0) 1609 || (m_pStream->readInteger((FX_DWORD*)&pRI->height) != 0)
1610 || (m_pStream->readInteger((FX_DWORD*)&pRI->x) != 0) 1610 || (m_pStream->readInteger((FX_DWORD*)&pRI->x) != 0)
1611 || (m_pStream->readInteger((FX_DWORD*)&pRI->y) != 0) 1611 || (m_pStream->readInteger((FX_DWORD*)&pRI->y) != 0)
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 SBSYMCODES[CURTEMP].code = CURCODE; 1754 SBSYMCODES[CURTEMP].code = CURCODE;
1755 CURCODE = CURCODE + 1; 1755 CURCODE = CURCODE + 1;
1756 } 1756 }
1757 CURTEMP = CURTEMP + 1; 1757 CURTEMP = CURTEMP + 1;
1758 } 1758 }
1759 CURLEN = CURLEN + 1; 1759 CURLEN = CURLEN + 1;
1760 } 1760 }
1761 m_pModule->JBig2_Free(LENCOUNT); 1761 m_pModule->JBig2_Free(LENCOUNT);
1762 m_pModule->JBig2_Free(FIRSTCODE); 1762 m_pModule->JBig2_Free(FIRSTCODE);
1763 } 1763 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698