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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. 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') | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.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 <map> 7 #include <map>
8 #include <list> 8 #include <list>
9 #include "JBig2_Context.h" 9 #include "JBig2_Context.h"
10 10
(...skipping 29 matching lines...) Expand all
40 JBIG2_EMBED_STREAM, pSymbolDictCache, pPause)); 40 JBIG2_EMBED_STREAM, pSymbolDictCache, pPause));
41 } else { 41 } else {
42 m_pGlobalContext = NULL; 42 m_pGlobalContext = NULL;
43 } 43 }
44 JBIG2_ALLOC(m_pStream, CJBig2_BitStream(pData, dwLength)); 44 JBIG2_ALLOC(m_pStream, CJBig2_BitStream(pData, dwLength));
45 m_nStreamType = nStreamType; 45 m_nStreamType = nStreamType;
46 m_nState = JBIG2_OUT_OF_PAGE; 46 m_nState = JBIG2_OUT_OF_PAGE;
47 JBIG2_ALLOC(m_pSegmentList, CJBig2_List<CJBig2_Segment>); 47 JBIG2_ALLOC(m_pSegmentList, CJBig2_List<CJBig2_Segment>);
48 JBIG2_ALLOC(m_pPageInfoList, CJBig2_List<JBig2PageInfo>(1)); 48 JBIG2_ALLOC(m_pPageInfoList, CJBig2_List<JBig2PageInfo>(1));
49 m_pPage = NULL; 49 m_pPage = NULL;
50 m_bBufSpecified = FALSE; 50 m_bBufSpecified = false;
51 m_pPause = pPause; 51 m_pPause = pPause;
52 m_nSegmentDecoded = 0; 52 m_nSegmentDecoded = 0;
53 m_PauseStep = 10; 53 m_PauseStep = 10;
54 m_pArithDecoder = NULL; 54 m_pArithDecoder = NULL;
55 m_pGRD = NULL; 55 m_pGRD = NULL;
56 m_gbContext = NULL; 56 m_gbContext = NULL;
57 m_pSegment = NULL; 57 m_pSegment = NULL;
58 m_dwOffset = 0; 58 m_dwOffset = 0;
59 m_ProcessiveStatus = FXCODEC_STATUS_FRAME_READY; 59 m_ProcessiveStatus = FXCODEC_STATUS_FRAME_READY;
60 m_pSymbolDictCache = pSymbolDictCache; 60 m_pSymbolDictCache = pSymbolDictCache;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 int32_t CJBig2_Context::getFirstPage(uint8_t *pBuf, int32_t width, int32_t heigh t, int32_t stride, IFX_Pause* pPause) 224 int32_t CJBig2_Context::getFirstPage(uint8_t *pBuf, int32_t width, int32_t heigh t, int32_t stride, IFX_Pause* pPause)
225 { 225 {
226 int32_t nRet = 0; 226 int32_t nRet = 0;
227 if(m_pGlobalContext) { 227 if(m_pGlobalContext) {
228 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause); 228 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause);
229 if(nRet != JBIG2_SUCCESS) { 229 if(nRet != JBIG2_SUCCESS) {
230 m_ProcessiveStatus = FXCODEC_STATUS_ERROR; 230 m_ProcessiveStatus = FXCODEC_STATUS_ERROR;
231 return nRet; 231 return nRet;
232 } 232 }
233 } 233 }
234 m_bFirstPage = TRUE; 234 m_bFirstPage = true;
235 m_PauseStep = 0; 235 m_PauseStep = 0;
236 delete m_pPage; 236 delete m_pPage;
237 JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf)); 237 JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf));
238 m_bBufSpecified = TRUE; 238 m_bBufSpecified = true;
239 if(m_pPage && pPause && pPause->NeedToPauseNow()) { 239 if(m_pPage && pPause && pPause->NeedToPauseNow()) {
240 m_PauseStep = 1; 240 m_PauseStep = 1;
241 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; 241 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE;
242 return nRet; 242 return nRet;
243 } 243 }
244 int ret = Continue(pPause); 244 int ret = Continue(pPause);
245 return ret; 245 return ret;
246 } 246 }
247 int32_t CJBig2_Context::Continue(IFX_Pause* pPause) 247 int32_t CJBig2_Context::Continue(IFX_Pause* pPause)
248 { 248 {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 if(nRet == JBIG2_SUCCESS) { 291 if(nRet == JBIG2_SUCCESS) {
292 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_FINISH; 292 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_FINISH;
293 } else { 293 } else {
294 m_ProcessiveStatus = FXCODEC_STATUS_ERROR; 294 m_ProcessiveStatus = FXCODEC_STATUS_ERROR;
295 } 295 }
296 return nRet; 296 return nRet;
297 } 297 }
298 int32_t CJBig2_Context::getNextPage(uint8_t *pBuf, int32_t width, int32_t height , int32_t stride, IFX_Pause* pPause) 298 int32_t CJBig2_Context::getNextPage(uint8_t *pBuf, int32_t width, int32_t height , int32_t stride, IFX_Pause* pPause)
299 { 299 {
300 int32_t nRet = JBIG2_ERROR_STREAM_TYPE; 300 int32_t nRet = JBIG2_ERROR_STREAM_TYPE;
301 m_bFirstPage = FALSE; 301 m_bFirstPage = false;
302 m_PauseStep = 0; 302 m_PauseStep = 0;
303 delete m_pPage; 303 delete m_pPage;
304 JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf)); 304 JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf));
305 m_bBufSpecified = TRUE; 305 m_bBufSpecified = true;
306 if(m_pPage && pPause && pPause->NeedToPauseNow()) { 306 if(m_pPage && pPause && pPause->NeedToPauseNow()) {
307 m_PauseStep = 1; 307 m_PauseStep = 1;
308 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; 308 m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE;
309 return nRet; 309 return nRet;
310 } 310 }
311 return Continue(pPause); 311 return Continue(pPause);
312 switch(m_nStreamType) { 312 switch(m_nStreamType) {
313 case JBIG2_FILE_STREAM: 313 case JBIG2_FILE_STREAM:
314 nRet = decodeFile(pPause); 314 nRet = decodeFile(pPause);
315 break; 315 break;
316 case JBIG2_SQUENTIAL_STREAM: 316 case JBIG2_SQUENTIAL_STREAM:
317 nRet = decode_SquentialOrgnazation(pPause); 317 nRet = decode_SquentialOrgnazation(pPause);
318 break; 318 break;
319 case JBIG2_RANDOM_STREAM: 319 case JBIG2_RANDOM_STREAM:
320 nRet = decode_RandomOrgnazation(pPause); 320 nRet = decode_RandomOrgnazation(pPause);
321 break; 321 break;
322 case JBIG2_EMBED_STREAM: 322 case JBIG2_EMBED_STREAM:
323 nRet = decode_EmbedOrgnazation(pPause); 323 nRet = decode_EmbedOrgnazation(pPause);
324 break; 324 break;
325 default: 325 default:
326 return JBIG2_ERROR_STREAM_TYPE; 326 return JBIG2_ERROR_STREAM_TYPE;
327 } 327 }
328 return nRet; 328 return nRet;
329 } 329 }
330 int32_t CJBig2_Context::getFirstPage(CJBig2_Image **image, IFX_Pause* pPause) 330 int32_t CJBig2_Context::getFirstPage(CJBig2_Image **image, IFX_Pause* pPause)
331 { 331 {
332 int32_t nRet; 332 int32_t nRet;
333 m_bFirstPage = TRUE; 333 m_bFirstPage = true;
334 m_PauseStep = 0; 334 m_PauseStep = 0;
335 if(m_pGlobalContext) { 335 if(m_pGlobalContext) {
336 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause); 336 nRet = m_pGlobalContext->decode_EmbedOrgnazation(pPause);
337 if(nRet != JBIG2_SUCCESS) { 337 if(nRet != JBIG2_SUCCESS) {
338 return nRet; 338 return nRet;
339 } 339 }
340 } 340 }
341 m_bBufSpecified = FALSE; 341 m_bBufSpecified = false;
342 return Continue(pPause); 342 return Continue(pPause);
343 } 343 }
344 int32_t CJBig2_Context::getNextPage(CJBig2_Image **image, IFX_Pause* pPause) 344 int32_t CJBig2_Context::getNextPage(CJBig2_Image **image, IFX_Pause* pPause)
345 { 345 {
346 int32_t nRet; 346 int32_t nRet;
347 m_bBufSpecified = FALSE; 347 m_bBufSpecified = false;
348 m_bFirstPage = FALSE; 348 m_bFirstPage = false;
349 m_PauseStep = 0; 349 m_PauseStep = 0;
350 switch(m_nStreamType) { 350 switch(m_nStreamType) {
351 case JBIG2_FILE_STREAM: 351 case JBIG2_FILE_STREAM:
352 nRet = decodeFile(pPause); 352 nRet = decodeFile(pPause);
353 break; 353 break;
354 case JBIG2_SQUENTIAL_STREAM: 354 case JBIG2_SQUENTIAL_STREAM:
355 nRet = decode_SquentialOrgnazation(pPause); 355 nRet = decode_SquentialOrgnazation(pPause);
356 break; 356 break;
357 case JBIG2_RANDOM_STREAM: 357 case JBIG2_RANDOM_STREAM:
358 nRet = decode_RandomOrgnazation(pPause); 358 nRet = decode_RandomOrgnazation(pPause);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 return JBIG2_ERROR_FATAL; 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 bool bUsed;
605 CJBig2_Image ** SDINSYMS = NULL; 605 CJBig2_Image ** SDINSYMS = NULL;
606 CJBig2_SDDProc *pSymbolDictDecoder; 606 CJBig2_SDDProc *pSymbolDictDecoder;
607 JBig2ArithCtx *gbContext = NULL, *grContext = NULL; 607 JBig2ArithCtx *gbContext = NULL, *grContext = NULL;
608 CJBig2_ArithDecoder *pArithDecoder; 608 CJBig2_ArithDecoder *pArithDecoder;
609 JBIG2_ALLOC(pSymbolDictDecoder, CJBig2_SDDProc()); 609 JBIG2_ALLOC(pSymbolDictDecoder, CJBig2_SDDProc());
610 uint8_t *key = pSegment->m_pData; 610 uint8_t *key = pSegment->m_pData;
611 FX_BOOL cache_hit = false; 611 bool cache_hit = false;
612 if(m_pStream->readShortInteger(&wFlags) != 0) { 612 if(m_pStream->readShortInteger(&wFlags) != 0) {
613 m_pModule->JBig2_Error("symbol dictionary segment : data header too shor t."); 613 m_pModule->JBig2_Error("symbol dictionary segment : data header too shor t.");
614 nRet = JBIG2_ERROR_TOO_SHORT; 614 nRet = JBIG2_ERROR_TOO_SHORT;
615 goto failed; 615 goto failed;
616 } 616 }
617 pSymbolDictDecoder->SDHUFF = wFlags & 0x0001; 617 pSymbolDictDecoder->SDHUFF = wFlags & 0x0001;
618 pSymbolDictDecoder->SDREFAGG = (wFlags >> 1) & 0x0001; 618 pSymbolDictDecoder->SDREFAGG = (wFlags >> 1) & 0x0001;
619 pSymbolDictDecoder->SDTEMPLATE = (wFlags >> 10) & 0x0003; 619 pSymbolDictDecoder->SDTEMPLATE = (wFlags >> 10) & 0x0003;
620 pSymbolDictDecoder->SDRTEMPLATE = (wFlags >> 12) & 0x0003; 620 pSymbolDictDecoder->SDRTEMPLATE = (wFlags >> 12) & 0x0003;
621 cSDHUFFDH = (wFlags >> 2) & 0x0003; 621 cSDHUFFDH = (wFlags >> 2) & 0x0003;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
824 m_pSymbolDictCache->push_front(CJBig2_CachePair(key, value)); 824 m_pSymbolDictCache->push_front(CJBig2_CachePair(key, value));
825 } 825 }
826 } 826 }
827 if(wFlags & 0x0200) { 827 if(wFlags & 0x0200) {
828 pSegment->m_Result.sd->m_bContextRetained = TRUE; 828 pSegment->m_Result.sd->m_bContextRetained = true;
829 if(pSymbolDictDecoder->SDHUFF == 0) { 829 if(pSymbolDictDecoder->SDHUFF == 0) {
830 pSegment->m_Result.sd->m_gbContext = gbContext; 830 pSegment->m_Result.sd->m_gbContext = gbContext;
831 } 831 }
832 if(pSymbolDictDecoder->SDREFAGG == 1) { 832 if(pSymbolDictDecoder->SDREFAGG == 1) {
833 pSegment->m_Result.sd->m_grContext = grContext; 833 pSegment->m_Result.sd->m_grContext = grContext;
834 } 834 }
835 bUsed = TRUE; 835 bUsed = true;
836 } else { 836 } else {
837 bUsed = FALSE; 837 bUsed = false;
838 } 838 }
839 delete pSymbolDictDecoder; 839 delete pSymbolDictDecoder;
840 if(SDINSYMS) { 840 if(SDINSYMS) {
841 m_pModule->JBig2_Free(SDINSYMS); 841 m_pModule->JBig2_Free(SDINSYMS);
842 } 842 }
843 delete Table_B1; 843 delete Table_B1;
844 delete Table_B2; 844 delete Table_B2;
845 delete Table_B3; 845 delete Table_B3;
846 delete Table_B4; 846 delete Table_B4;
847 delete Table_B5; 847 delete Table_B5;
848 if(bUsed == FALSE) { 848 if(bUsed == false) {
849 if(gbContext) { 849 if(gbContext) {
850 m_pModule->JBig2_Free(gbContext); 850 m_pModule->JBig2_Free(gbContext);
851 } 851 }
852 if(grContext) { 852 if(grContext) {
853 m_pModule->JBig2_Free(grContext); 853 m_pModule->JBig2_Free(grContext);
854 } 854 }
855 } 855 }
856 return JBIG2_SUCCESS; 856 return JBIG2_SUCCESS;
857 failed: 857 failed:
858 delete pSymbolDictDecoder; 858 delete pSymbolDictDecoder;
859 if(SDINSYMS) { 859 if(SDINSYMS) {
860 m_pModule->JBig2_Free(SDINSYMS); 860 m_pModule->JBig2_Free(SDINSYMS);
861 } 861 }
862 delete Table_B1; 862 delete Table_B1;
863 delete Table_B2; 863 delete Table_B2;
864 delete Table_B3; 864 delete Table_B3;
865 delete Table_B4; 865 delete Table_B4;
866 delete Table_B5; 866 delete Table_B5;
867 if(gbContext) { 867 if(gbContext) {
868 m_pModule->JBig2_Free(gbContext); 868 m_pModule->JBig2_Free(gbContext);
869 } 869 }
870 if(grContext) { 870 if(grContext) {
871 m_pModule->JBig2_Free(grContext); 871 m_pModule->JBig2_Free(grContext);
872 } 872 }
873 return nRet; 873 return nRet;
874 } 874 }
875 875
876 FX_BOOL CJBig2_Context::parseTextRegion(CJBig2_Segment *pSegment) 876 int32_t CJBig2_Context::parseTextRegion(CJBig2_Segment *pSegment)
877 { 877 {
878 FX_DWORD dwTemp; 878 FX_DWORD dwTemp;
879 FX_WORD wFlags; 879 FX_WORD wFlags;
880 int32_t i, nIndex, nRet; 880 int32_t i, nIndex, nRet;
881 JBig2RegionInfo ri; 881 JBig2RegionInfo ri;
882 CJBig2_Segment *pSeg; 882 CJBig2_Segment *pSeg;
883 CJBig2_Image **SBSYMS = NULL; 883 CJBig2_Image **SBSYMS = NULL;
884 JBig2HuffmanCode *SBSYMCODES = NULL; 884 JBig2HuffmanCode *SBSYMCODES = NULL;
885 uint8_t cSBHUFFFS, cSBHUFFDS, cSBHUFFDT, cSBHUFFRDW, cSBHUFFRDH, cSBHUFFRDX, cSBHUFFRDY, cSBHUFFRSIZE; 885 uint8_t cSBHUFFFS, cSBHUFFDS, cSBHUFFDT, cSBHUFFRDW, cSBHUFFRDH, cSBHUFFRDX, cSBHUFFRDY, cSBHUFFRSIZE;
886 CJBig2_HuffmanTable *Table_B1 = NULL, 886 CJBig2_HuffmanTable *Table_B1 = NULL,
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 delete Table_B9; 1232 delete Table_B9;
1233 delete Table_B10; 1233 delete Table_B10;
1234 delete Table_B11; 1234 delete Table_B11;
1235 delete Table_B12; 1235 delete Table_B12;
1236 delete Table_B13; 1236 delete Table_B13;
1237 delete Table_B14; 1237 delete Table_B14;
1238 delete Table_B15; 1238 delete Table_B15;
1239 return nRet; 1239 return nRet;
1240 } 1240 }
1241 1241
1242 FX_BOOL CJBig2_Context::parsePatternDict(CJBig2_Segment *pSegment, IFX_Pause* pP ause) 1242 int32_t CJBig2_Context::parsePatternDict(CJBig2_Segment *pSegment, IFX_Pause* pP ause)
1243 { 1243 {
1244 FX_DWORD dwTemp; 1244 FX_DWORD dwTemp;
1245 uint8_t cFlags; 1245 uint8_t cFlags;
1246 JBig2ArithCtx *gbContext; 1246 JBig2ArithCtx *gbContext;
1247 CJBig2_ArithDecoder *pArithDecoder; 1247 CJBig2_ArithDecoder *pArithDecoder;
1248 CJBig2_PDDProc *pPDD; 1248 CJBig2_PDDProc *pPDD;
1249 int32_t nRet; 1249 int32_t nRet;
1250 JBIG2_ALLOC(pPDD, CJBig2_PDDProc()); 1250 JBIG2_ALLOC(pPDD, CJBig2_PDDProc());
1251 if((m_pStream->read1Byte(&cFlags) != 0) 1251 if((m_pStream->read1Byte(&cFlags) != 0)
1252 || (m_pStream->read1Byte(&pPDD->HDPW) != 0) 1252 || (m_pStream->read1Byte(&pPDD->HDPW) != 0)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 }
1296 FX_BOOL CJBig2_Context::parseHalftoneRegion(CJBig2_Segment *pSegment, IFX_Pause* pPause) 1296 int32_t CJBig2_Context::parseHalftoneRegion(CJBig2_Segment *pSegment, IFX_Pause* pPause)
1297 { 1297 {
1298 FX_DWORD dwTemp; 1298 FX_DWORD dwTemp;
1299 uint8_t cFlags; 1299 uint8_t cFlags;
1300 JBig2RegionInfo ri; 1300 JBig2RegionInfo ri;
1301 CJBig2_Segment *pSeg; 1301 CJBig2_Segment *pSeg;
1302 CJBig2_PatternDict *pPatternDict; 1302 CJBig2_PatternDict *pPatternDict;
1303 JBig2ArithCtx *gbContext; 1303 JBig2ArithCtx *gbContext;
1304 CJBig2_ArithDecoder *pArithDecoder; 1304 CJBig2_ArithDecoder *pArithDecoder;
1305 CJBig2_HTRDProc *pHRD; 1305 CJBig2_HTRDProc *pHRD;
1306 int32_t nRet; 1306 int32_t nRet;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
1380 delete pSegment->m_Result.im; 1380 delete pSegment->m_Result.im;
1381 pSegment->m_Result.im = NULL; 1381 pSegment->m_Result.im = NULL;
1382 } 1382 }
1383 delete pHRD; 1383 delete pHRD;
1384 return JBIG2_SUCCESS; 1384 return JBIG2_SUCCESS;
1385 failed: 1385 failed:
1386 delete pHRD; 1386 delete pHRD;
1387 return nRet; 1387 return nRet;
1388 } 1388 }
1389 1389
1390 FX_BOOL CJBig2_Context::parseGenericRegion(CJBig2_Segment *pSegment, IFX_Pause* pPause) 1390 int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment *pSegment, IFX_Pause* pPause)
1391 { 1391 {
1392 FX_DWORD dwTemp; 1392 FX_DWORD dwTemp;
1393 uint8_t cFlags; 1393 uint8_t cFlags;
1394 int32_t i, nRet; 1394 int32_t i, nRet;
1395 if(m_pGRD == NULL) { 1395 if(m_pGRD == NULL) {
1396 JBIG2_ALLOC(m_pGRD, CJBig2_GRDProc()); 1396 JBIG2_ALLOC(m_pGRD, CJBig2_GRDProc());
1397 if((parseRegionInfo(&m_ri) != JBIG2_SUCCESS) 1397 if((parseRegionInfo(&m_ri) != JBIG2_SUCCESS)
1398 || (m_pStream->read1Byte(&cFlags) != 0)) { 1398 || (m_pStream->read1Byte(&cFlags) != 0)) {
1399 m_pModule->JBig2_Error("generic region segment : data header too sho rt."); 1399 m_pModule->JBig2_Error("generic region segment : data header too sho rt.");
1400 nRet = JBIG2_ERROR_TOO_SHORT; 1400 nRet = JBIG2_ERROR_TOO_SHORT;
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 } 1497 }
1498 delete m_pGRD; 1498 delete m_pGRD;
1499 m_pGRD = NULL; 1499 m_pGRD = NULL;
1500 return JBIG2_SUCCESS; 1500 return JBIG2_SUCCESS;
1501 failed: 1501 failed:
1502 delete m_pGRD; 1502 delete m_pGRD;
1503 m_pGRD = NULL; 1503 m_pGRD = NULL;
1504 return nRet; 1504 return nRet;
1505 } 1505 }
1506 1506
1507 FX_BOOL CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment *pSegment) 1507 int32_t CJBig2_Context::parseGenericRefinementRegion(CJBig2_Segment *pSegment)
1508 { 1508 {
1509 FX_DWORD dwTemp; 1509 FX_DWORD dwTemp;
1510 JBig2RegionInfo ri; 1510 JBig2RegionInfo ri;
1511 CJBig2_Segment *pSeg; 1511 CJBig2_Segment *pSeg;
1512 int32_t i, nRet; 1512 int32_t i, nRet;
1513 uint8_t cFlags; 1513 uint8_t cFlags;
1514 JBig2ArithCtx *grContext; 1514 JBig2ArithCtx *grContext;
1515 CJBig2_GRRDProc *pGRRD; 1515 CJBig2_GRRDProc *pGRRD;
1516 CJBig2_ArithDecoder *pArithDecoder; 1516 CJBig2_ArithDecoder *pArithDecoder;
1517 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc()); 1517 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 int32_t 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_FATAL; 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)
1612 || (m_pStream->read1Byte(&pRI->flags) != 0)) { 1612 || (m_pStream->read1Byte(&pRI->flags) != 0)) {
1613 return JBIG2_ERROR_TOO_SHORT; 1613 return JBIG2_ERROR_TOO_SHORT;
1614 } 1614 }
1615 return JBIG2_SUCCESS; 1615 return JBIG2_SUCCESS;
1616 } 1616 }
1617 JBig2HuffmanCode *CJBig2_Context::decodeSymbolIDHuffmanTable(CJBig2_BitStream *p Stream, 1617 JBig2HuffmanCode *CJBig2_Context::decodeSymbolIDHuffmanTable(CJBig2_BitStream *p Stream,
1618 FX_DWORD SBNUMSYMS) 1618 FX_DWORD SBNUMSYMS)
1619 { 1619 {
1620 JBig2HuffmanCode *SBSYMCODES; 1620 JBig2HuffmanCode *SBSYMCODES;
1621 int32_t runcodes[35], runcodes_len[35], runcode; 1621 int32_t runcodes[35];
1622 int32_t i, j, nTemp, nVal, nBits; 1622 int32_t runcodes_len[35];
1623 int32_t runcode;
1624 int32_t i;
1625 int32_t j;
1626 int32_t nVal;
1627 int32_t nBits;
1623 int32_t run; 1628 int32_t run;
1629 FX_DWORD nTemp;
1624 SBSYMCODES = (JBig2HuffmanCode*)m_pModule->JBig2_Malloc2(sizeof(JBig2Huffman Code), SBNUMSYMS); 1630 SBSYMCODES = (JBig2HuffmanCode*)m_pModule->JBig2_Malloc2(sizeof(JBig2Huffman Code), SBNUMSYMS);
1625 for (i = 0; i < 35; i ++) { 1631 for (i = 0; i < 35; i ++) {
1626 if(pStream->readNBits(4, &runcodes_len[i]) != 0) { 1632 if(pStream->readNBits(4, &runcodes_len[i]) != 0) {
1627 goto failed; 1633 goto failed;
1628 } 1634 }
1629 } 1635 }
1630 huffman_assign_code(runcodes, runcodes_len, 35); 1636 huffman_assign_code(runcodes, runcodes_len, 35);
1631 i = 0; 1637 i = 0;
1632 while(i < (int)SBNUMSYMS) { 1638 while(i < (int)SBNUMSYMS) {
1633 nVal = 0; 1639 nVal = 0;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 SBSYMCODES[CURTEMP].code = CURCODE; 1760 SBSYMCODES[CURTEMP].code = CURCODE;
1755 CURCODE = CURCODE + 1; 1761 CURCODE = CURCODE + 1;
1756 } 1762 }
1757 CURTEMP = CURTEMP + 1; 1763 CURTEMP = CURTEMP + 1;
1758 } 1764 }
1759 CURLEN = CURLEN + 1; 1765 CURLEN = CURLEN + 1;
1760 } 1766 }
1761 m_pModule->JBig2_Free(LENCOUNT); 1767 m_pModule->JBig2_Free(LENCOUNT);
1762 m_pModule->JBig2_Free(FIRSTCODE); 1768 m_pModule->JBig2_Free(FIRSTCODE);
1763 } 1769 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_Context.h ('k') | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698