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

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

Issue 1327983003: Remove CJBig2_Module::JBig2_Error and friends. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Created 5 years, 3 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
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 <list> 7 #include <list>
8 #include "JBig2_Context.h" 8 #include "JBig2_Context.h"
9 9
10 // Implement a very small least recently used (LRU) cache. It is very 10 // Implement a very small least recently used (LRU) cache. It is very
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 m_pPage = NULL; 78 m_pPage = NULL;
79 delete m_pStream; 79 delete m_pStream;
80 m_pStream = NULL; 80 m_pStream = NULL;
81 } 81 }
82 int32_t CJBig2_Context::decodeFile(IFX_Pause* pPause) { 82 int32_t CJBig2_Context::decodeFile(IFX_Pause* pPause) {
83 uint8_t cFlags; 83 uint8_t cFlags;
84 FX_DWORD dwTemp; 84 FX_DWORD dwTemp;
85 const uint8_t fileID[] = {0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A}; 85 const uint8_t fileID[] = {0x97, 0x4A, 0x42, 0x32, 0x0D, 0x0A, 0x1A, 0x0A};
86 int32_t nRet; 86 int32_t nRet;
87 if (m_pStream->getByteLeft() < 8) { 87 if (m_pStream->getByteLeft() < 8) {
88 m_pModule->JBig2_Error("file header too short.");
89 nRet = JBIG2_ERROR_TOO_SHORT; 88 nRet = JBIG2_ERROR_TOO_SHORT;
90 goto failed; 89 goto failed;
91 } 90 }
92 if (JBIG2_memcmp(m_pStream->getPointer(), fileID, 8) != 0) { 91 if (JBIG2_memcmp(m_pStream->getPointer(), fileID, 8) != 0) {
93 m_pModule->JBig2_Error("not jbig2 file");
94 nRet = JBIG2_ERROR_FILE_FORMAT; 92 nRet = JBIG2_ERROR_FILE_FORMAT;
95 goto failed; 93 goto failed;
96 } 94 }
97 m_pStream->offset(8); 95 m_pStream->offset(8);
98 if (m_pStream->read1Byte(&cFlags) != 0) { 96 if (m_pStream->read1Byte(&cFlags) != 0) {
99 m_pModule->JBig2_Error("file header too short.");
100 nRet = JBIG2_ERROR_TOO_SHORT; 97 nRet = JBIG2_ERROR_TOO_SHORT;
101 goto failed; 98 goto failed;
102 } 99 }
103 if (!(cFlags & 0x02)) { 100 if (!(cFlags & 0x02)) {
104 if (m_pStream->readInteger(&dwTemp) != 0) { 101 if (m_pStream->readInteger(&dwTemp) != 0) {
105 m_pModule->JBig2_Error("file header too short.");
106 nRet = JBIG2_ERROR_TOO_SHORT; 102 nRet = JBIG2_ERROR_TOO_SHORT;
107 goto failed; 103 goto failed;
108 } 104 }
109 if (dwTemp > 0) { 105 if (dwTemp > 0) {
110 m_PageInfoList.clear(); 106 m_PageInfoList.clear();
111 m_PageInfoList.resize(dwTemp); 107 m_PageInfoList.resize(dwTemp);
112 } 108 }
113 } 109 }
114 if (cFlags & 0x01) { 110 if (cFlags & 0x01) {
115 m_nStreamType = JBIG2_SQUENTIAL_STREAM; 111 m_nStreamType = JBIG2_SQUENTIAL_STREAM;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 338 }
343 cTemp = m_pStream->getCurByte(); 339 cTemp = m_pStream->getCurByte();
344 if ((cTemp >> 5) == 7) { 340 if ((cTemp >> 5) == 7) {
345 if (m_pStream->readInteger( 341 if (m_pStream->readInteger(
346 (FX_DWORD*)&pSegment->m_nReferred_to_segment_count) != 0) { 342 (FX_DWORD*)&pSegment->m_nReferred_to_segment_count) != 0) {
347 goto failed; 343 goto failed;
348 } 344 }
349 pSegment->m_nReferred_to_segment_count &= 0x1fffffff; 345 pSegment->m_nReferred_to_segment_count &= 0x1fffffff;
350 if (pSegment->m_nReferred_to_segment_count > 346 if (pSegment->m_nReferred_to_segment_count >
351 JBIG2_MAX_REFERRED_SEGMENT_COUNT) { 347 JBIG2_MAX_REFERRED_SEGMENT_COUNT) {
352 m_pModule->JBig2_Error("Too many referred segments.");
353 return JBIG2_ERROR_LIMIT; 348 return JBIG2_ERROR_LIMIT;
354 } 349 }
355 dwTemp = 5 + 4 + (pSegment->m_nReferred_to_segment_count + 1) / 8; 350 dwTemp = 5 + 4 + (pSegment->m_nReferred_to_segment_count + 1) / 8;
356 } else { 351 } else {
357 if (m_pStream->read1Byte(&cTemp) != 0) { 352 if (m_pStream->read1Byte(&cTemp) != 0) {
358 goto failed; 353 goto failed;
359 } 354 }
360 pSegment->m_nReferred_to_segment_count = cTemp >> 5; 355 pSegment->m_nReferred_to_segment_count = cTemp >> 5;
361 dwTemp = 5 + 1; 356 dwTemp = 5 + 1;
362 } 357 }
(...skipping 19 matching lines...) Expand all
382 pSegment->m_pReferred_to_segment_numbers[i] = wTemp; 377 pSegment->m_pReferred_to_segment_numbers[i] = wTemp;
383 break; 378 break;
384 case 4: 379 case 4:
385 if (m_pStream->readInteger(&dwTemp) != 0) { 380 if (m_pStream->readInteger(&dwTemp) != 0) {
386 goto failed; 381 goto failed;
387 } 382 }
388 pSegment->m_pReferred_to_segment_numbers[i] = dwTemp; 383 pSegment->m_pReferred_to_segment_numbers[i] = dwTemp;
389 break; 384 break;
390 } 385 }
391 if (pSegment->m_pReferred_to_segment_numbers[i] >= pSegment->m_dwNumber) { 386 if (pSegment->m_pReferred_to_segment_numbers[i] >= pSegment->m_dwNumber) {
392 m_pModule->JBig2_Error(
393 "The referred segment number is greater than this segment number.");
394 goto failed; 387 goto failed;
395 } 388 }
396 } 389 }
397 } 390 }
398 if (cPSize == 1) { 391 if (cPSize == 1) {
399 if (m_pStream->read1Byte(&cTemp) != 0) { 392 if (m_pStream->read1Byte(&cTemp) != 0) {
400 goto failed; 393 goto failed;
401 } 394 }
402 pSegment->m_dwPage_association = cTemp; 395 pSegment->m_dwPage_association = cTemp;
403 } else { 396 } else {
404 if (m_pStream->readInteger(&pSegment->m_dwPage_association) != 0) { 397 if (m_pStream->readInteger(&pSegment->m_dwPage_association) != 0) {
405 goto failed; 398 goto failed;
406 } 399 }
407 } 400 }
408 if (m_pStream->readInteger(&pSegment->m_dwData_length) != 0) { 401 if (m_pStream->readInteger(&pSegment->m_dwData_length) != 0) {
409 goto failed; 402 goto failed;
410 } 403 }
411 pSegment->m_pData = m_pStream->getPointer(); 404 pSegment->m_pData = m_pStream->getPointer();
412 pSegment->m_State = JBIG2_SEGMENT_DATA_UNPARSED; 405 pSegment->m_State = JBIG2_SEGMENT_DATA_UNPARSED;
413 return JBIG2_SUCCESS; 406 return JBIG2_SUCCESS;
414 failed: 407 failed:
415 m_pModule->JBig2_Error("header too short.");
416 return JBIG2_ERROR_TOO_SHORT; 408 return JBIG2_ERROR_TOO_SHORT;
417 } 409 }
418 int32_t CJBig2_Context::parseSegmentData(CJBig2_Segment* pSegment, 410 int32_t CJBig2_Context::parseSegmentData(CJBig2_Segment* pSegment,
419 IFX_Pause* pPause) { 411 IFX_Pause* pPause) {
420 int32_t ret = ProcessiveParseSegmentData(pSegment, pPause); 412 int32_t ret = ProcessiveParseSegmentData(pSegment, pPause);
421 while (m_ProcessiveStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE && 413 while (m_ProcessiveStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE &&
422 m_pStream->getByteLeft() > 0) { 414 m_pStream->getByteLeft() > 0) {
423 ret = ProcessiveParseSegmentData(pSegment, pPause); 415 ret = ProcessiveParseSegmentData(pSegment, pPause);
424 } 416 }
425 return ret; 417 return ret;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 (m_pStream->readInteger(&pPageInfo->m_dwResolutionX) != 0) || 463 (m_pStream->readInteger(&pPageInfo->m_dwResolutionX) != 0) ||
472 (m_pStream->readInteger(&pPageInfo->m_dwResolutionY) != 0) || 464 (m_pStream->readInteger(&pPageInfo->m_dwResolutionY) != 0) ||
473 (m_pStream->read1Byte(&pPageInfo->m_cFlags) != 0) || 465 (m_pStream->read1Byte(&pPageInfo->m_cFlags) != 0) ||
474 (m_pStream->readShortInteger(&wTemp) != 0)) { 466 (m_pStream->readShortInteger(&wTemp) != 0)) {
475 goto failed1; 467 goto failed1;
476 } 468 }
477 pPageInfo->m_bIsStriped = ((wTemp >> 15) & 1) ? 1 : 0; 469 pPageInfo->m_bIsStriped = ((wTemp >> 15) & 1) ? 1 : 0;
478 pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff; 470 pPageInfo->m_wMaxStripeSize = wTemp & 0x7fff;
479 if ((pPageInfo->m_dwHeight == 0xffffffff) && 471 if ((pPageInfo->m_dwHeight == 0xffffffff) &&
480 (pPageInfo->m_bIsStriped != TRUE)) { 472 (pPageInfo->m_bIsStriped != TRUE)) {
481 m_pModule->JBig2_Warn("page height = 0xffffffff buf stripe field is 0");
482 pPageInfo->m_bIsStriped = TRUE; 473 pPageInfo->m_bIsStriped = TRUE;
483 } 474 }
484 if (!m_bBufSpecified) { 475 if (!m_bBufSpecified) {
485 delete m_pPage; 476 delete m_pPage;
486 if (pPageInfo->m_dwHeight == 0xffffffff) { 477 if (pPageInfo->m_dwHeight == 0xffffffff) {
487 JBIG2_ALLOC(m_pPage, CJBig2_Image(pPageInfo->m_dwWidth, 478 JBIG2_ALLOC(m_pPage, CJBig2_Image(pPageInfo->m_dwWidth,
488 pPageInfo->m_wMaxStripeSize)); 479 pPageInfo->m_wMaxStripeSize));
489 } else { 480 } else {
490 JBIG2_ALLOC(m_pPage, CJBig2_Image(pPageInfo->m_dwWidth, 481 JBIG2_ALLOC(m_pPage, CJBig2_Image(pPageInfo->m_dwWidth,
491 pPageInfo->m_dwHeight)); 482 pPageInfo->m_dwHeight));
(...skipping 18 matching lines...) Expand all
510 case 53: 501 case 53:
511 return parseTable(pSegment); 502 return parseTable(pSegment);
512 case 62: 503 case 62:
513 m_pStream->offset(pSegment->m_dwData_length); 504 m_pStream->offset(pSegment->m_dwData_length);
514 break; 505 break;
515 default: 506 default:
516 break; 507 break;
517 } 508 }
518 return JBIG2_SUCCESS; 509 return JBIG2_SUCCESS;
519 failed1: 510 failed1:
520 m_pModule->JBig2_Error("segment data too short.");
521 return JBIG2_ERROR_TOO_SHORT; 511 return JBIG2_ERROR_TOO_SHORT;
522 failed2: 512 failed2:
523 m_pModule->JBig2_Error("segment syntax error.");
524 return JBIG2_ERROR_FATAL; 513 return JBIG2_ERROR_FATAL;
525 } 514 }
526 int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment, 515 int32_t CJBig2_Context::parseSymbolDict(CJBig2_Segment* pSegment,
527 IFX_Pause* pPause) { 516 IFX_Pause* pPause) {
528 FX_DWORD dwTemp; 517 FX_DWORD dwTemp;
529 FX_WORD wFlags; 518 FX_WORD wFlags;
530 uint8_t cSDHUFFDH, cSDHUFFDW, cSDHUFFBMSIZE, cSDHUFFAGGINST; 519 uint8_t cSDHUFFDH, cSDHUFFDW, cSDHUFFBMSIZE, cSDHUFFAGGINST;
531 CJBig2_HuffmanTable *Table_B1 = NULL, *Table_B2 = NULL, *Table_B3 = NULL, 520 CJBig2_HuffmanTable *Table_B1 = NULL, *Table_B2 = NULL, *Table_B3 = NULL,
532 *Table_B4 = NULL, *Table_B5 = NULL; 521 *Table_B4 = NULL, *Table_B5 = NULL;
533 int32_t i, nIndex, nRet; 522 int32_t i, nIndex, nRet;
534 CJBig2_Segment *pSeg = NULL, *pLRSeg = NULL; 523 CJBig2_Segment *pSeg = NULL, *pLRSeg = NULL;
535 FX_BOOL bUsed; 524 FX_BOOL bUsed;
536 CJBig2_Image** SDINSYMS = NULL; 525 CJBig2_Image** SDINSYMS = NULL;
537 CJBig2_SDDProc* pSymbolDictDecoder; 526 CJBig2_SDDProc* pSymbolDictDecoder;
538 JBig2ArithCtx *gbContext = NULL, *grContext = NULL; 527 JBig2ArithCtx *gbContext = NULL, *grContext = NULL;
539 CJBig2_ArithDecoder* pArithDecoder; 528 CJBig2_ArithDecoder* pArithDecoder;
540 JBIG2_ALLOC(pSymbolDictDecoder, CJBig2_SDDProc()); 529 JBIG2_ALLOC(pSymbolDictDecoder, CJBig2_SDDProc());
541 uint8_t* key = pSegment->m_pData; 530 uint8_t* key = pSegment->m_pData;
542 FX_BOOL cache_hit = false; 531 FX_BOOL cache_hit = false;
543 if (m_pStream->readShortInteger(&wFlags) != 0) { 532 if (m_pStream->readShortInteger(&wFlags) != 0) {
544 m_pModule->JBig2_Error(
545 "symbol dictionary segment : data header too short.");
546 nRet = JBIG2_ERROR_TOO_SHORT; 533 nRet = JBIG2_ERROR_TOO_SHORT;
547 goto failed; 534 goto failed;
548 } 535 }
549 pSymbolDictDecoder->SDHUFF = wFlags & 0x0001; 536 pSymbolDictDecoder->SDHUFF = wFlags & 0x0001;
550 pSymbolDictDecoder->SDREFAGG = (wFlags >> 1) & 0x0001; 537 pSymbolDictDecoder->SDREFAGG = (wFlags >> 1) & 0x0001;
551 pSymbolDictDecoder->SDTEMPLATE = (wFlags >> 10) & 0x0003; 538 pSymbolDictDecoder->SDTEMPLATE = (wFlags >> 10) & 0x0003;
552 pSymbolDictDecoder->SDRTEMPLATE = (wFlags >> 12) & 0x0003; 539 pSymbolDictDecoder->SDRTEMPLATE = (wFlags >> 12) & 0x0003;
553 cSDHUFFDH = (wFlags >> 2) & 0x0003; 540 cSDHUFFDH = (wFlags >> 2) & 0x0003;
554 cSDHUFFDW = (wFlags >> 4) & 0x0003; 541 cSDHUFFDW = (wFlags >> 4) & 0x0003;
555 cSDHUFFBMSIZE = (wFlags >> 6) & 0x0001; 542 cSDHUFFBMSIZE = (wFlags >> 6) & 0x0001;
556 cSDHUFFAGGINST = (wFlags >> 7) & 0x0001; 543 cSDHUFFAGGINST = (wFlags >> 7) & 0x0001;
557 if (pSymbolDictDecoder->SDHUFF == 0) { 544 if (pSymbolDictDecoder->SDHUFF == 0) {
558 if (pSymbolDictDecoder->SDTEMPLATE == 0) { 545 if (pSymbolDictDecoder->SDTEMPLATE == 0) {
559 dwTemp = 8; 546 dwTemp = 8;
560 } else { 547 } else {
561 dwTemp = 2; 548 dwTemp = 2;
562 } 549 }
563 for (i = 0; i < (int32_t)dwTemp; i++) { 550 for (i = 0; i < (int32_t)dwTemp; i++) {
564 if (m_pStream->read1Byte((uint8_t*)&pSymbolDictDecoder->SDAT[i]) != 0) { 551 if (m_pStream->read1Byte((uint8_t*)&pSymbolDictDecoder->SDAT[i]) != 0) {
565 m_pModule->JBig2_Error(
566 "symbol dictionary segment : data header too short.");
567 nRet = JBIG2_ERROR_TOO_SHORT; 552 nRet = JBIG2_ERROR_TOO_SHORT;
568 goto failed; 553 goto failed;
569 } 554 }
570 } 555 }
571 } 556 }
572 if ((pSymbolDictDecoder->SDREFAGG == 1) && 557 if ((pSymbolDictDecoder->SDREFAGG == 1) &&
573 (pSymbolDictDecoder->SDRTEMPLATE == 0)) { 558 (pSymbolDictDecoder->SDRTEMPLATE == 0)) {
574 for (i = 0; i < 4; i++) { 559 for (i = 0; i < 4; i++) {
575 if (m_pStream->read1Byte((uint8_t*)&pSymbolDictDecoder->SDRAT[i]) != 0) { 560 if (m_pStream->read1Byte((uint8_t*)&pSymbolDictDecoder->SDRAT[i]) != 0) {
576 m_pModule->JBig2_Error(
577 "symbol dictionary segment : data header too short.");
578 nRet = JBIG2_ERROR_TOO_SHORT; 561 nRet = JBIG2_ERROR_TOO_SHORT;
579 goto failed; 562 goto failed;
580 } 563 }
581 } 564 }
582 } 565 }
583 if ((m_pStream->readInteger(&pSymbolDictDecoder->SDNUMEXSYMS) != 0) || 566 if ((m_pStream->readInteger(&pSymbolDictDecoder->SDNUMEXSYMS) != 0) ||
584 (m_pStream->readInteger(&pSymbolDictDecoder->SDNUMNEWSYMS) != 0)) { 567 (m_pStream->readInteger(&pSymbolDictDecoder->SDNUMNEWSYMS) != 0)) {
585 m_pModule->JBig2_Error(
586 "symbol dictionary segment : data header too short.");
587 nRet = JBIG2_ERROR_TOO_SHORT; 568 nRet = JBIG2_ERROR_TOO_SHORT;
588 goto failed; 569 goto failed;
589 } 570 }
590 if (pSymbolDictDecoder->SDNUMEXSYMS > JBIG2_MAX_EXPORT_SYSMBOLS || 571 if (pSymbolDictDecoder->SDNUMEXSYMS > JBIG2_MAX_EXPORT_SYSMBOLS ||
591 pSymbolDictDecoder->SDNUMNEWSYMS > JBIG2_MAX_NEW_SYSMBOLS) { 572 pSymbolDictDecoder->SDNUMNEWSYMS > JBIG2_MAX_NEW_SYSMBOLS) {
592 m_pModule->JBig2_Error(
593 "symbol dictionary segment : too many export/new symbols.");
594 nRet = JBIG2_ERROR_LIMIT; 573 nRet = JBIG2_ERROR_LIMIT;
595 goto failed; 574 goto failed;
596 } 575 }
597 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 576 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
598 if (!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) { 577 if (!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) {
599 m_pModule->JBig2_Error(
600 "symbol dictionary segment : can't find refered to segments");
601 nRet = JBIG2_ERROR_FATAL; 578 nRet = JBIG2_ERROR_FATAL;
602 goto failed; 579 goto failed;
603 } 580 }
604 } 581 }
605 pSymbolDictDecoder->SDNUMINSYMS = 0; 582 pSymbolDictDecoder->SDNUMINSYMS = 0;
606 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 583 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
607 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]); 584 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
608 if (pSeg->m_cFlags.s.type == 0) { 585 if (pSeg->m_cFlags.s.type == 0) {
609 pSymbolDictDecoder->SDNUMINSYMS += pSeg->m_Result.sd->SDNUMEXSYMS; 586 pSymbolDictDecoder->SDNUMINSYMS += pSeg->m_Result.sd->SDNUMEXSYMS;
610 pLRSeg = pSeg; 587 pLRSeg = pSeg;
(...skipping 10 matching lines...) Expand all
621 if (pSeg->m_cFlags.s.type == 0) { 598 if (pSeg->m_cFlags.s.type == 0) {
622 JBIG2_memcpy(SDINSYMS + dwTemp, pSeg->m_Result.sd->SDEXSYMS, 599 JBIG2_memcpy(SDINSYMS + dwTemp, pSeg->m_Result.sd->SDEXSYMS,
623 pSeg->m_Result.sd->SDNUMEXSYMS * sizeof(CJBig2_Image*)); 600 pSeg->m_Result.sd->SDNUMEXSYMS * sizeof(CJBig2_Image*));
624 dwTemp += pSeg->m_Result.sd->SDNUMEXSYMS; 601 dwTemp += pSeg->m_Result.sd->SDNUMEXSYMS;
625 } 602 }
626 } 603 }
627 } 604 }
628 pSymbolDictDecoder->SDINSYMS = SDINSYMS; 605 pSymbolDictDecoder->SDINSYMS = SDINSYMS;
629 if (pSymbolDictDecoder->SDHUFF == 1) { 606 if (pSymbolDictDecoder->SDHUFF == 1) {
630 if ((cSDHUFFDH == 2) || (cSDHUFFDW == 2)) { 607 if ((cSDHUFFDH == 2) || (cSDHUFFDW == 2)) {
631 m_pModule->JBig2_Error(
632 "symbol dictionary segment : SDHUFFDH=2 or SDHUFFDW=2 is not "
633 "permitted.");
634 nRet = JBIG2_ERROR_FATAL; 608 nRet = JBIG2_ERROR_FATAL;
635 goto failed; 609 goto failed;
636 } 610 }
637 nIndex = 0; 611 nIndex = 0;
638 if (cSDHUFFDH == 0) { 612 if (cSDHUFFDH == 0) {
639 Table_B4 = new CJBig2_HuffmanTable(HuffmanTable_B4, 613 Table_B4 = new CJBig2_HuffmanTable(HuffmanTable_B4,
640 FX_ArraySize(HuffmanTable_B4), 614 FX_ArraySize(HuffmanTable_B4),
641 HuffmanTable_HTOOB_B4); 615 HuffmanTable_HTOOB_B4);
642 pSymbolDictDecoder->SDHUFFDH = Table_B4; 616 pSymbolDictDecoder->SDHUFFDH = Table_B4;
643 } else if (cSDHUFFDH == 1) { 617 } else if (cSDHUFFDH == 1) {
644 Table_B5 = new CJBig2_HuffmanTable(HuffmanTable_B5, 618 Table_B5 = new CJBig2_HuffmanTable(HuffmanTable_B5,
645 FX_ArraySize(HuffmanTable_B5), 619 FX_ArraySize(HuffmanTable_B5),
646 HuffmanTable_HTOOB_B5); 620 HuffmanTable_HTOOB_B5);
647 pSymbolDictDecoder->SDHUFFDH = Table_B5; 621 pSymbolDictDecoder->SDHUFFDH = Table_B5;
648 } else { 622 } else {
649 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 623 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
650 if (!pSeg) { 624 if (!pSeg) {
651 m_pModule->JBig2_Error(
652 "symbol dictionary segment : SDHUFFDH can't find user supplied "
653 "table.");
654 nRet = JBIG2_ERROR_FATAL; 625 nRet = JBIG2_ERROR_FATAL;
655 goto failed; 626 goto failed;
656 } 627 }
657 pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht; 628 pSymbolDictDecoder->SDHUFFDH = pSeg->m_Result.ht;
658 } 629 }
659 if (cSDHUFFDW == 0) { 630 if (cSDHUFFDW == 0) {
660 Table_B2 = new CJBig2_HuffmanTable(HuffmanTable_B2, 631 Table_B2 = new CJBig2_HuffmanTable(HuffmanTable_B2,
661 FX_ArraySize(HuffmanTable_B2), 632 FX_ArraySize(HuffmanTable_B2),
662 HuffmanTable_HTOOB_B2); 633 HuffmanTable_HTOOB_B2);
663 pSymbolDictDecoder->SDHUFFDW = Table_B2; 634 pSymbolDictDecoder->SDHUFFDW = Table_B2;
664 } else if (cSDHUFFDW == 1) { 635 } else if (cSDHUFFDW == 1) {
665 Table_B3 = new CJBig2_HuffmanTable(HuffmanTable_B3, 636 Table_B3 = new CJBig2_HuffmanTable(HuffmanTable_B3,
666 FX_ArraySize(HuffmanTable_B3), 637 FX_ArraySize(HuffmanTable_B3),
667 HuffmanTable_HTOOB_B3); 638 HuffmanTable_HTOOB_B3);
668 pSymbolDictDecoder->SDHUFFDW = Table_B3; 639 pSymbolDictDecoder->SDHUFFDW = Table_B3;
669 } else { 640 } else {
670 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 641 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
671 if (!pSeg) { 642 if (!pSeg) {
672 m_pModule->JBig2_Error(
673 "symbol dictionary segment : SDHUFFDW can't find user supplied "
674 "table.");
675 nRet = JBIG2_ERROR_FATAL; 643 nRet = JBIG2_ERROR_FATAL;
676 goto failed; 644 goto failed;
677 } 645 }
678 pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht; 646 pSymbolDictDecoder->SDHUFFDW = pSeg->m_Result.ht;
679 } 647 }
680 if (cSDHUFFBMSIZE == 0) { 648 if (cSDHUFFBMSIZE == 0) {
681 Table_B1 = new CJBig2_HuffmanTable(HuffmanTable_B1, 649 Table_B1 = new CJBig2_HuffmanTable(HuffmanTable_B1,
682 FX_ArraySize(HuffmanTable_B1), 650 FX_ArraySize(HuffmanTable_B1),
683 HuffmanTable_HTOOB_B1); 651 HuffmanTable_HTOOB_B1);
684 pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1; 652 pSymbolDictDecoder->SDHUFFBMSIZE = Table_B1;
685 } else { 653 } else {
686 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 654 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
687 if (!pSeg) { 655 if (!pSeg) {
688 m_pModule->JBig2_Error(
689 "symbol dictionary segment : SDHUFFBMSIZE can't find user supplied "
690 "table.");
691 nRet = JBIG2_ERROR_FATAL; 656 nRet = JBIG2_ERROR_FATAL;
692 goto failed; 657 goto failed;
693 } 658 }
694 pSymbolDictDecoder->SDHUFFBMSIZE = pSeg->m_Result.ht; 659 pSymbolDictDecoder->SDHUFFBMSIZE = pSeg->m_Result.ht;
695 } 660 }
696 if (pSymbolDictDecoder->SDREFAGG == 1) { 661 if (pSymbolDictDecoder->SDREFAGG == 1) {
697 if (cSDHUFFAGGINST == 0) { 662 if (cSDHUFFAGGINST == 0) {
698 if (!Table_B1) { 663 if (!Table_B1) {
699 Table_B1 = new CJBig2_HuffmanTable(HuffmanTable_B1, 664 Table_B1 = new CJBig2_HuffmanTable(HuffmanTable_B1,
700 FX_ArraySize(HuffmanTable_B1), 665 FX_ArraySize(HuffmanTable_B1),
701 HuffmanTable_HTOOB_B1); 666 HuffmanTable_HTOOB_B1);
702 } 667 }
703 pSymbolDictDecoder->SDHUFFAGGINST = Table_B1; 668 pSymbolDictDecoder->SDHUFFAGGINST = Table_B1;
704 } else { 669 } else {
705 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 670 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
706 if (!pSeg) { 671 if (!pSeg) {
707 m_pModule->JBig2_Error(
708 "symbol dictionary segment : SDHUFFAGGINST can't find user "
709 "supplied table.");
710 nRet = JBIG2_ERROR_FATAL; 672 nRet = JBIG2_ERROR_FATAL;
711 goto failed; 673 goto failed;
712 } 674 }
713 pSymbolDictDecoder->SDHUFFAGGINST = pSeg->m_Result.ht; 675 pSymbolDictDecoder->SDHUFFAGGINST = pSeg->m_Result.ht;
714 } 676 }
715 } 677 }
716 } 678 }
717 if ((wFlags & 0x0100) && pLRSeg && pLRSeg->m_Result.sd->m_bContextRetained) { 679 if ((wFlags & 0x0100) && pLRSeg && pLRSeg->m_Result.sd->m_bContextRetained) {
718 if (pSymbolDictDecoder->SDHUFF == 0) { 680 if (pSymbolDictDecoder->SDHUFF == 0) {
719 dwTemp = pSymbolDictDecoder->SDTEMPLATE == 0 681 dwTemp = pSymbolDictDecoder->SDTEMPLATE == 0
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 CJBig2_HuffmanTable *Table_B1 = NULL, *Table_B6 = NULL, *Table_B7 = NULL, 812 CJBig2_HuffmanTable *Table_B1 = NULL, *Table_B6 = NULL, *Table_B7 = NULL,
851 *Table_B8 = NULL, *Table_B9 = NULL, *Table_B10 = NULL, 813 *Table_B8 = NULL, *Table_B9 = NULL, *Table_B10 = NULL,
852 *Table_B11 = NULL, *Table_B12 = NULL, *Table_B13 = NULL, 814 *Table_B11 = NULL, *Table_B12 = NULL, *Table_B13 = NULL,
853 *Table_B14 = NULL, *Table_B15 = NULL; 815 *Table_B14 = NULL, *Table_B15 = NULL;
854 JBig2ArithCtx* grContext = NULL; 816 JBig2ArithCtx* grContext = NULL;
855 CJBig2_ArithDecoder* pArithDecoder; 817 CJBig2_ArithDecoder* pArithDecoder;
856 CJBig2_TRDProc* pTRD; 818 CJBig2_TRDProc* pTRD;
857 JBIG2_ALLOC(pTRD, CJBig2_TRDProc()); 819 JBIG2_ALLOC(pTRD, CJBig2_TRDProc());
858 if ((parseRegionInfo(&ri) != JBIG2_SUCCESS) || 820 if ((parseRegionInfo(&ri) != JBIG2_SUCCESS) ||
859 (m_pStream->readShortInteger(&wFlags) != 0)) { 821 (m_pStream->readShortInteger(&wFlags) != 0)) {
860 m_pModule->JBig2_Error("text region segment : data header too short.");
861 nRet = JBIG2_ERROR_TOO_SHORT; 822 nRet = JBIG2_ERROR_TOO_SHORT;
862 goto failed; 823 goto failed;
863 } 824 }
864 pTRD->SBW = ri.width; 825 pTRD->SBW = ri.width;
865 pTRD->SBH = ri.height; 826 pTRD->SBH = ri.height;
866 pTRD->SBHUFF = wFlags & 0x0001; 827 pTRD->SBHUFF = wFlags & 0x0001;
867 pTRD->SBREFINE = (wFlags >> 1) & 0x0001; 828 pTRD->SBREFINE = (wFlags >> 1) & 0x0001;
868 dwTemp = (wFlags >> 2) & 0x0003; 829 dwTemp = (wFlags >> 2) & 0x0003;
869 pTRD->SBSTRIPS = 1 << dwTemp; 830 pTRD->SBSTRIPS = 1 << dwTemp;
870 pTRD->REFCORNER = (JBig2Corner)((wFlags >> 4) & 0x0003); 831 pTRD->REFCORNER = (JBig2Corner)((wFlags >> 4) & 0x0003);
871 pTRD->TRANSPOSED = (wFlags >> 6) & 0x0001; 832 pTRD->TRANSPOSED = (wFlags >> 6) & 0x0001;
872 pTRD->SBCOMBOP = (JBig2ComposeOp)((wFlags >> 7) & 0x0003); 833 pTRD->SBCOMBOP = (JBig2ComposeOp)((wFlags >> 7) & 0x0003);
873 pTRD->SBDEFPIXEL = (wFlags >> 9) & 0x0001; 834 pTRD->SBDEFPIXEL = (wFlags >> 9) & 0x0001;
874 pTRD->SBDSOFFSET = (wFlags >> 10) & 0x001f; 835 pTRD->SBDSOFFSET = (wFlags >> 10) & 0x001f;
875 if (pTRD->SBDSOFFSET >= 0x0010) { 836 if (pTRD->SBDSOFFSET >= 0x0010) {
876 pTRD->SBDSOFFSET = pTRD->SBDSOFFSET - 0x0020; 837 pTRD->SBDSOFFSET = pTRD->SBDSOFFSET - 0x0020;
877 } 838 }
878 pTRD->SBRTEMPLATE = (wFlags >> 15) & 0x0001; 839 pTRD->SBRTEMPLATE = (wFlags >> 15) & 0x0001;
879 if (pTRD->SBHUFF == 1) { 840 if (pTRD->SBHUFF == 1) {
880 if (m_pStream->readShortInteger(&wFlags) != 0) { 841 if (m_pStream->readShortInteger(&wFlags) != 0) {
881 m_pModule->JBig2_Error("text region segment : data header too short.");
882 nRet = JBIG2_ERROR_TOO_SHORT; 842 nRet = JBIG2_ERROR_TOO_SHORT;
883 goto failed; 843 goto failed;
884 } 844 }
885 cSBHUFFFS = wFlags & 0x0003; 845 cSBHUFFFS = wFlags & 0x0003;
886 cSBHUFFDS = (wFlags >> 2) & 0x0003; 846 cSBHUFFDS = (wFlags >> 2) & 0x0003;
887 cSBHUFFDT = (wFlags >> 4) & 0x0003; 847 cSBHUFFDT = (wFlags >> 4) & 0x0003;
888 cSBHUFFRDW = (wFlags >> 6) & 0x0003; 848 cSBHUFFRDW = (wFlags >> 6) & 0x0003;
889 cSBHUFFRDH = (wFlags >> 8) & 0x0003; 849 cSBHUFFRDH = (wFlags >> 8) & 0x0003;
890 cSBHUFFRDX = (wFlags >> 10) & 0x0003; 850 cSBHUFFRDX = (wFlags >> 10) & 0x0003;
891 cSBHUFFRDY = (wFlags >> 12) & 0x0003; 851 cSBHUFFRDY = (wFlags >> 12) & 0x0003;
892 cSBHUFFRSIZE = (wFlags >> 14) & 0x0001; 852 cSBHUFFRSIZE = (wFlags >> 14) & 0x0001;
893 } 853 }
894 if ((pTRD->SBREFINE == 1) && (pTRD->SBRTEMPLATE == 0)) { 854 if ((pTRD->SBREFINE == 1) && (pTRD->SBRTEMPLATE == 0)) {
895 for (i = 0; i < 4; i++) { 855 for (i = 0; i < 4; i++) {
896 if (m_pStream->read1Byte((uint8_t*)&pTRD->SBRAT[i]) != 0) { 856 if (m_pStream->read1Byte((uint8_t*)&pTRD->SBRAT[i]) != 0) {
897 m_pModule->JBig2_Error("text region segment : data header too short.");
898 nRet = JBIG2_ERROR_TOO_SHORT; 857 nRet = JBIG2_ERROR_TOO_SHORT;
899 goto failed; 858 goto failed;
900 } 859 }
901 } 860 }
902 } 861 }
903 if (m_pStream->readInteger(&pTRD->SBNUMINSTANCES) != 0) { 862 if (m_pStream->readInteger(&pTRD->SBNUMINSTANCES) != 0) {
904 m_pModule->JBig2_Error("text region segment : data header too short.");
905 nRet = JBIG2_ERROR_TOO_SHORT; 863 nRet = JBIG2_ERROR_TOO_SHORT;
906 goto failed; 864 goto failed;
907 } 865 }
908 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 866 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
909 if (!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) { 867 if (!findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i])) {
910 m_pModule->JBig2_Error(
911 "text region segment : can't find refered to segments");
912 nRet = JBIG2_ERROR_FATAL; 868 nRet = JBIG2_ERROR_FATAL;
913 goto failed; 869 goto failed;
914 } 870 }
915 } 871 }
916 pTRD->SBNUMSYMS = 0; 872 pTRD->SBNUMSYMS = 0;
917 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 873 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
918 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]); 874 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[i]);
919 if (pSeg->m_cFlags.s.type == 0) { 875 if (pSeg->m_cFlags.s.type == 0) {
920 pTRD->SBNUMSYMS += pSeg->m_Result.sd->SDNUMEXSYMS; 876 pTRD->SBNUMSYMS += pSeg->m_Result.sd->SDNUMEXSYMS;
921 } 877 }
(...skipping 10 matching lines...) Expand all
932 dwTemp += pSeg->m_Result.sd->SDNUMEXSYMS; 888 dwTemp += pSeg->m_Result.sd->SDNUMEXSYMS;
933 } 889 }
934 } 890 }
935 pTRD->SBSYMS = SBSYMS; 891 pTRD->SBSYMS = SBSYMS;
936 } else { 892 } else {
937 pTRD->SBSYMS = NULL; 893 pTRD->SBSYMS = NULL;
938 } 894 }
939 if (pTRD->SBHUFF == 1) { 895 if (pTRD->SBHUFF == 1) {
940 SBSYMCODES = decodeSymbolIDHuffmanTable(m_pStream, pTRD->SBNUMSYMS); 896 SBSYMCODES = decodeSymbolIDHuffmanTable(m_pStream, pTRD->SBNUMSYMS);
941 if (SBSYMCODES == NULL) { 897 if (SBSYMCODES == NULL) {
942 m_pModule->JBig2_Error(
943 "text region segment: symbol ID huffman table decode failure!");
944 nRet = JBIG2_ERROR_FATAL; 898 nRet = JBIG2_ERROR_FATAL;
945 goto failed; 899 goto failed;
946 } 900 }
947 m_pStream->alignByte(); 901 m_pStream->alignByte();
948 pTRD->SBSYMCODES = SBSYMCODES; 902 pTRD->SBSYMCODES = SBSYMCODES;
949 } else { 903 } else {
950 dwTemp = 0; 904 dwTemp = 0;
951 while ((FX_DWORD)(1 << dwTemp) < pTRD->SBNUMSYMS) { 905 while ((FX_DWORD)(1 << dwTemp) < pTRD->SBNUMSYMS) {
952 dwTemp++; 906 dwTemp++;
953 } 907 }
954 pTRD->SBSYMCODELEN = (uint8_t)dwTemp; 908 pTRD->SBSYMCODELEN = (uint8_t)dwTemp;
955 } 909 }
956 if (pTRD->SBHUFF == 1) { 910 if (pTRD->SBHUFF == 1) {
957 if ((cSBHUFFFS == 2) || (cSBHUFFRDW == 2) || (cSBHUFFRDH == 2) || 911 if ((cSBHUFFFS == 2) || (cSBHUFFRDW == 2) || (cSBHUFFRDH == 2) ||
958 (cSBHUFFRDX == 2) || (cSBHUFFRDY == 2)) { 912 (cSBHUFFRDX == 2) || (cSBHUFFRDY == 2)) {
959 m_pModule->JBig2_Error(
960 "text region segment : SBHUFFFS=2 or SBHUFFRDW=2 or "
961 "SBHUFFRDH=2 or SBHUFFRDX=2 or SBHUFFRDY=2 is not permitted");
962 nRet = JBIG2_ERROR_FATAL; 913 nRet = JBIG2_ERROR_FATAL;
963 goto failed; 914 goto failed;
964 } 915 }
965 nIndex = 0; 916 nIndex = 0;
966 if (cSBHUFFFS == 0) { 917 if (cSBHUFFFS == 0) {
967 Table_B6 = new CJBig2_HuffmanTable(HuffmanTable_B6, 918 Table_B6 = new CJBig2_HuffmanTable(HuffmanTable_B6,
968 FX_ArraySize(HuffmanTable_B6), 919 FX_ArraySize(HuffmanTable_B6),
969 HuffmanTable_HTOOB_B6); 920 HuffmanTable_HTOOB_B6);
970 pTRD->SBHUFFFS = Table_B6; 921 pTRD->SBHUFFFS = Table_B6;
971 } else if (cSBHUFFFS == 1) { 922 } else if (cSBHUFFFS == 1) {
972 Table_B7 = new CJBig2_HuffmanTable(HuffmanTable_B7, 923 Table_B7 = new CJBig2_HuffmanTable(HuffmanTable_B7,
973 FX_ArraySize(HuffmanTable_B7), 924 FX_ArraySize(HuffmanTable_B7),
974 HuffmanTable_HTOOB_B7); 925 HuffmanTable_HTOOB_B7);
975 pTRD->SBHUFFFS = Table_B7; 926 pTRD->SBHUFFFS = Table_B7;
976 } else { 927 } else {
977 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 928 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
978 if (!pSeg) { 929 if (!pSeg) {
979 m_pModule->JBig2_Error(
980 "text region segment : SBHUFFFS can't find user supplied table");
981 nRet = JBIG2_ERROR_FATAL; 930 nRet = JBIG2_ERROR_FATAL;
982 goto failed; 931 goto failed;
983 } 932 }
984 pTRD->SBHUFFFS = pSeg->m_Result.ht; 933 pTRD->SBHUFFFS = pSeg->m_Result.ht;
985 } 934 }
986 if (cSBHUFFDS == 0) { 935 if (cSBHUFFDS == 0) {
987 Table_B8 = new CJBig2_HuffmanTable(HuffmanTable_B8, 936 Table_B8 = new CJBig2_HuffmanTable(HuffmanTable_B8,
988 FX_ArraySize(HuffmanTable_B8), 937 FX_ArraySize(HuffmanTable_B8),
989 HuffmanTable_HTOOB_B8); 938 HuffmanTable_HTOOB_B8);
990 pTRD->SBHUFFDS = Table_B8; 939 pTRD->SBHUFFDS = Table_B8;
991 } else if (cSBHUFFDS == 1) { 940 } else if (cSBHUFFDS == 1) {
992 Table_B9 = new CJBig2_HuffmanTable(HuffmanTable_B9, 941 Table_B9 = new CJBig2_HuffmanTable(HuffmanTable_B9,
993 FX_ArraySize(HuffmanTable_B9), 942 FX_ArraySize(HuffmanTable_B9),
994 HuffmanTable_HTOOB_B9); 943 HuffmanTable_HTOOB_B9);
995 pTRD->SBHUFFDS = Table_B9; 944 pTRD->SBHUFFDS = Table_B9;
996 } else if (cSBHUFFDS == 2) { 945 } else if (cSBHUFFDS == 2) {
997 Table_B10 = new CJBig2_HuffmanTable(HuffmanTable_B10, 946 Table_B10 = new CJBig2_HuffmanTable(HuffmanTable_B10,
998 FX_ArraySize(HuffmanTable_B10), 947 FX_ArraySize(HuffmanTable_B10),
999 HuffmanTable_HTOOB_B10); 948 HuffmanTable_HTOOB_B10);
1000 pTRD->SBHUFFDS = Table_B10; 949 pTRD->SBHUFFDS = Table_B10;
1001 } else { 950 } else {
1002 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 951 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1003 if (!pSeg) { 952 if (!pSeg) {
1004 m_pModule->JBig2_Error(
1005 "text region segment : SBHUFFDS can't find user supplied table");
1006 nRet = JBIG2_ERROR_FATAL; 953 nRet = JBIG2_ERROR_FATAL;
1007 goto failed; 954 goto failed;
1008 } 955 }
1009 pTRD->SBHUFFDS = pSeg->m_Result.ht; 956 pTRD->SBHUFFDS = pSeg->m_Result.ht;
1010 } 957 }
1011 if (cSBHUFFDT == 0) { 958 if (cSBHUFFDT == 0) {
1012 Table_B11 = new CJBig2_HuffmanTable(HuffmanTable_B11, 959 Table_B11 = new CJBig2_HuffmanTable(HuffmanTable_B11,
1013 FX_ArraySize(HuffmanTable_B11), 960 FX_ArraySize(HuffmanTable_B11),
1014 HuffmanTable_HTOOB_B11); 961 HuffmanTable_HTOOB_B11);
1015 pTRD->SBHUFFDT = Table_B11; 962 pTRD->SBHUFFDT = Table_B11;
1016 } else if (cSBHUFFDT == 1) { 963 } else if (cSBHUFFDT == 1) {
1017 Table_B12 = new CJBig2_HuffmanTable(HuffmanTable_B12, 964 Table_B12 = new CJBig2_HuffmanTable(HuffmanTable_B12,
1018 FX_ArraySize(HuffmanTable_B12), 965 FX_ArraySize(HuffmanTable_B12),
1019 HuffmanTable_HTOOB_B12); 966 HuffmanTable_HTOOB_B12);
1020 pTRD->SBHUFFDT = Table_B12; 967 pTRD->SBHUFFDT = Table_B12;
1021 } else if (cSBHUFFDT == 2) { 968 } else if (cSBHUFFDT == 2) {
1022 Table_B13 = new CJBig2_HuffmanTable(HuffmanTable_B13, 969 Table_B13 = new CJBig2_HuffmanTable(HuffmanTable_B13,
1023 FX_ArraySize(HuffmanTable_B13), 970 FX_ArraySize(HuffmanTable_B13),
1024 HuffmanTable_HTOOB_B13); 971 HuffmanTable_HTOOB_B13);
1025 pTRD->SBHUFFDT = Table_B13; 972 pTRD->SBHUFFDT = Table_B13;
1026 } else { 973 } else {
1027 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 974 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1028 if (!pSeg) { 975 if (!pSeg) {
1029 m_pModule->JBig2_Error(
1030 "text region segment : SBHUFFDT can't find user supplied table");
1031 nRet = JBIG2_ERROR_FATAL; 976 nRet = JBIG2_ERROR_FATAL;
1032 goto failed; 977 goto failed;
1033 } 978 }
1034 pTRD->SBHUFFDT = pSeg->m_Result.ht; 979 pTRD->SBHUFFDT = pSeg->m_Result.ht;
1035 } 980 }
1036 if (cSBHUFFRDW == 0) { 981 if (cSBHUFFRDW == 0) {
1037 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14, 982 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14,
1038 FX_ArraySize(HuffmanTable_B14), 983 FX_ArraySize(HuffmanTable_B14),
1039 HuffmanTable_HTOOB_B14); 984 HuffmanTable_HTOOB_B14);
1040 pTRD->SBHUFFRDW = Table_B14; 985 pTRD->SBHUFFRDW = Table_B14;
1041 } else if (cSBHUFFRDW == 1) { 986 } else if (cSBHUFFRDW == 1) {
1042 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15, 987 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15,
1043 FX_ArraySize(HuffmanTable_B15), 988 FX_ArraySize(HuffmanTable_B15),
1044 HuffmanTable_HTOOB_B15); 989 HuffmanTable_HTOOB_B15);
1045 pTRD->SBHUFFRDW = Table_B15; 990 pTRD->SBHUFFRDW = Table_B15;
1046 } else { 991 } else {
1047 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 992 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1048 if (!pSeg) { 993 if (!pSeg) {
1049 m_pModule->JBig2_Error(
1050 "text region segment : SBHUFFRDW can't find user supplied table");
1051 nRet = JBIG2_ERROR_FATAL; 994 nRet = JBIG2_ERROR_FATAL;
1052 goto failed; 995 goto failed;
1053 } 996 }
1054 pTRD->SBHUFFRDW = pSeg->m_Result.ht; 997 pTRD->SBHUFFRDW = pSeg->m_Result.ht;
1055 } 998 }
1056 if (cSBHUFFRDH == 0) { 999 if (cSBHUFFRDH == 0) {
1057 if (!Table_B14) { 1000 if (!Table_B14) {
1058 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14, 1001 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14,
1059 FX_ArraySize(HuffmanTable_B14), 1002 FX_ArraySize(HuffmanTable_B14),
1060 HuffmanTable_HTOOB_B14); 1003 HuffmanTable_HTOOB_B14);
1061 } 1004 }
1062 pTRD->SBHUFFRDH = Table_B14; 1005 pTRD->SBHUFFRDH = Table_B14;
1063 } else if (cSBHUFFRDH == 1) { 1006 } else if (cSBHUFFRDH == 1) {
1064 if (!Table_B15) { 1007 if (!Table_B15) {
1065 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15, 1008 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15,
1066 FX_ArraySize(HuffmanTable_B15), 1009 FX_ArraySize(HuffmanTable_B15),
1067 HuffmanTable_HTOOB_B15); 1010 HuffmanTable_HTOOB_B15);
1068 } 1011 }
1069 pTRD->SBHUFFRDH = Table_B15; 1012 pTRD->SBHUFFRDH = Table_B15;
1070 } else { 1013 } else {
1071 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1014 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1072 if (!pSeg) { 1015 if (!pSeg) {
1073 m_pModule->JBig2_Error(
1074 "text region segment : SBHUFFRDH can't find user supplied table");
1075 nRet = JBIG2_ERROR_FATAL; 1016 nRet = JBIG2_ERROR_FATAL;
1076 goto failed; 1017 goto failed;
1077 } 1018 }
1078 pTRD->SBHUFFRDH = pSeg->m_Result.ht; 1019 pTRD->SBHUFFRDH = pSeg->m_Result.ht;
1079 } 1020 }
1080 if (cSBHUFFRDX == 0) { 1021 if (cSBHUFFRDX == 0) {
1081 if (!Table_B14) { 1022 if (!Table_B14) {
1082 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14, 1023 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14,
1083 FX_ArraySize(HuffmanTable_B14), 1024 FX_ArraySize(HuffmanTable_B14),
1084 HuffmanTable_HTOOB_B14); 1025 HuffmanTable_HTOOB_B14);
1085 } 1026 }
1086 pTRD->SBHUFFRDX = Table_B14; 1027 pTRD->SBHUFFRDX = Table_B14;
1087 } else if (cSBHUFFRDX == 1) { 1028 } else if (cSBHUFFRDX == 1) {
1088 if (!Table_B15) { 1029 if (!Table_B15) {
1089 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15, 1030 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15,
1090 FX_ArraySize(HuffmanTable_B15), 1031 FX_ArraySize(HuffmanTable_B15),
1091 HuffmanTable_HTOOB_B15); 1032 HuffmanTable_HTOOB_B15);
1092 } 1033 }
1093 pTRD->SBHUFFRDX = Table_B15; 1034 pTRD->SBHUFFRDX = Table_B15;
1094 } else { 1035 } else {
1095 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1036 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1096 if (!pSeg) { 1037 if (!pSeg) {
1097 m_pModule->JBig2_Error(
1098 "text region segment : SBHUFFRDX can't find user supplied table");
1099 nRet = JBIG2_ERROR_FATAL; 1038 nRet = JBIG2_ERROR_FATAL;
1100 goto failed; 1039 goto failed;
1101 } 1040 }
1102 pTRD->SBHUFFRDX = pSeg->m_Result.ht; 1041 pTRD->SBHUFFRDX = pSeg->m_Result.ht;
1103 } 1042 }
1104 if (cSBHUFFRDY == 0) { 1043 if (cSBHUFFRDY == 0) {
1105 if (!Table_B14) { 1044 if (!Table_B14) {
1106 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14, 1045 Table_B14 = new CJBig2_HuffmanTable(HuffmanTable_B14,
1107 FX_ArraySize(HuffmanTable_B14), 1046 FX_ArraySize(HuffmanTable_B14),
1108 HuffmanTable_HTOOB_B14); 1047 HuffmanTable_HTOOB_B14);
1109 } 1048 }
1110 pTRD->SBHUFFRDY = Table_B14; 1049 pTRD->SBHUFFRDY = Table_B14;
1111 } else if (cSBHUFFRDY == 1) { 1050 } else if (cSBHUFFRDY == 1) {
1112 if (!Table_B15) { 1051 if (!Table_B15) {
1113 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15, 1052 Table_B15 = new CJBig2_HuffmanTable(HuffmanTable_B15,
1114 FX_ArraySize(HuffmanTable_B15), 1053 FX_ArraySize(HuffmanTable_B15),
1115 HuffmanTable_HTOOB_B15); 1054 HuffmanTable_HTOOB_B15);
1116 } 1055 }
1117 pTRD->SBHUFFRDY = Table_B15; 1056 pTRD->SBHUFFRDY = Table_B15;
1118 } else { 1057 } else {
1119 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1058 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1120 if (!pSeg) { 1059 if (!pSeg) {
1121 m_pModule->JBig2_Error(
1122 "text region segment : SBHUFFRDY can't find user supplied table");
1123 nRet = JBIG2_ERROR_FATAL; 1060 nRet = JBIG2_ERROR_FATAL;
1124 goto failed; 1061 goto failed;
1125 } 1062 }
1126 pTRD->SBHUFFRDY = pSeg->m_Result.ht; 1063 pTRD->SBHUFFRDY = pSeg->m_Result.ht;
1127 } 1064 }
1128 if (cSBHUFFRSIZE == 0) { 1065 if (cSBHUFFRSIZE == 0) {
1129 Table_B1 = new CJBig2_HuffmanTable(HuffmanTable_B1, 1066 Table_B1 = new CJBig2_HuffmanTable(HuffmanTable_B1,
1130 FX_ArraySize(HuffmanTable_B1), 1067 FX_ArraySize(HuffmanTable_B1),
1131 HuffmanTable_HTOOB_B1); 1068 HuffmanTable_HTOOB_B1);
1132 pTRD->SBHUFFRSIZE = Table_B1; 1069 pTRD->SBHUFFRSIZE = Table_B1;
1133 } else { 1070 } else {
1134 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++); 1071 pSeg = findReferredSegmentByTypeAndIndex(pSegment, 53, nIndex++);
1135 if (!pSeg) { 1072 if (!pSeg) {
1136 m_pModule->JBig2_Error(
1137 "text region segment : SBHUFFRSIZE can't find user supplied table");
1138 nRet = JBIG2_ERROR_FATAL; 1073 nRet = JBIG2_ERROR_FATAL;
1139 goto failed; 1074 goto failed;
1140 } 1075 }
1141 pTRD->SBHUFFRSIZE = pSeg->m_Result.ht; 1076 pTRD->SBHUFFRSIZE = pSeg->m_Result.ht;
1142 } 1077 }
1143 } 1078 }
1144 if (pTRD->SBREFINE == 1) { 1079 if (pTRD->SBREFINE == 1) {
1145 dwTemp = pTRD->SBRTEMPLATE ? 1 << 10 : 1 << 13; 1080 dwTemp = pTRD->SBRTEMPLATE ? 1 << 10 : 1 << 13;
1146 grContext = 1081 grContext =
1147 (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), dwTemp); 1082 (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), dwTemp);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1233 uint8_t cFlags; 1168 uint8_t cFlags;
1234 JBig2ArithCtx* gbContext; 1169 JBig2ArithCtx* gbContext;
1235 CJBig2_ArithDecoder* pArithDecoder; 1170 CJBig2_ArithDecoder* pArithDecoder;
1236 CJBig2_PDDProc* pPDD; 1171 CJBig2_PDDProc* pPDD;
1237 int32_t nRet; 1172 int32_t nRet;
1238 JBIG2_ALLOC(pPDD, CJBig2_PDDProc()); 1173 JBIG2_ALLOC(pPDD, CJBig2_PDDProc());
1239 if ((m_pStream->read1Byte(&cFlags) != 0) || 1174 if ((m_pStream->read1Byte(&cFlags) != 0) ||
1240 (m_pStream->read1Byte(&pPDD->HDPW) != 0) || 1175 (m_pStream->read1Byte(&pPDD->HDPW) != 0) ||
1241 (m_pStream->read1Byte(&pPDD->HDPH) != 0) || 1176 (m_pStream->read1Byte(&pPDD->HDPH) != 0) ||
1242 (m_pStream->readInteger(&pPDD->GRAYMAX) != 0)) { 1177 (m_pStream->readInteger(&pPDD->GRAYMAX) != 0)) {
1243 m_pModule->JBig2_Error(
1244 "pattern dictionary segment : data header too short.");
1245 nRet = JBIG2_ERROR_TOO_SHORT; 1178 nRet = JBIG2_ERROR_TOO_SHORT;
1246 goto failed; 1179 goto failed;
1247 } 1180 }
1248 if (pPDD->GRAYMAX > JBIG2_MAX_PATTERN_INDEX) { 1181 if (pPDD->GRAYMAX > JBIG2_MAX_PATTERN_INDEX) {
1249 m_pModule->JBig2_Error("pattern dictionary segment : too max gray max.");
1250 nRet = JBIG2_ERROR_LIMIT; 1182 nRet = JBIG2_ERROR_LIMIT;
1251 goto failed; 1183 goto failed;
1252 } 1184 }
1253 pPDD->HDMMR = cFlags & 0x01; 1185 pPDD->HDMMR = cFlags & 0x01;
1254 pPDD->HDTEMPLATE = (cFlags >> 1) & 0x03; 1186 pPDD->HDTEMPLATE = (cFlags >> 1) & 0x03;
1255 pSegment->m_nResultType = JBIG2_PATTERN_DICT_POINTER; 1187 pSegment->m_nResultType = JBIG2_PATTERN_DICT_POINTER;
1256 if (pPDD->HDMMR == 0) { 1188 if (pPDD->HDMMR == 0) {
1257 dwTemp = 1189 dwTemp =
1258 pPDD->HDTEMPLATE == 0 ? 65536 : pPDD->HDTEMPLATE == 1 ? 8192 : 1024; 1190 pPDD->HDTEMPLATE == 0 ? 65536 : pPDD->HDTEMPLATE == 1 ? 8192 : 1024;
1259 gbContext = 1191 gbContext =
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1298 int32_t nRet; 1230 int32_t nRet;
1299 JBIG2_ALLOC(pHRD, CJBig2_HTRDProc()); 1231 JBIG2_ALLOC(pHRD, CJBig2_HTRDProc());
1300 if ((parseRegionInfo(&ri) != JBIG2_SUCCESS) || 1232 if ((parseRegionInfo(&ri) != JBIG2_SUCCESS) ||
1301 (m_pStream->read1Byte(&cFlags) != 0) || 1233 (m_pStream->read1Byte(&cFlags) != 0) ||
1302 (m_pStream->readInteger(&pHRD->HGW) != 0) || 1234 (m_pStream->readInteger(&pHRD->HGW) != 0) ||
1303 (m_pStream->readInteger(&pHRD->HGH) != 0) || 1235 (m_pStream->readInteger(&pHRD->HGH) != 0) ||
1304 (m_pStream->readInteger((FX_DWORD*)&pHRD->HGX) != 0) || 1236 (m_pStream->readInteger((FX_DWORD*)&pHRD->HGX) != 0) ||
1305 (m_pStream->readInteger((FX_DWORD*)&pHRD->HGY) != 0) || 1237 (m_pStream->readInteger((FX_DWORD*)&pHRD->HGY) != 0) ||
1306 (m_pStream->readShortInteger(&pHRD->HRX) != 0) || 1238 (m_pStream->readShortInteger(&pHRD->HRX) != 0) ||
1307 (m_pStream->readShortInteger(&pHRD->HRY) != 0)) { 1239 (m_pStream->readShortInteger(&pHRD->HRY) != 0)) {
1308 m_pModule->JBig2_Error("halftone region segment : data header too short.");
1309 nRet = JBIG2_ERROR_TOO_SHORT; 1240 nRet = JBIG2_ERROR_TOO_SHORT;
1310 goto failed; 1241 goto failed;
1311 } 1242 }
1312 pHRD->HBW = ri.width; 1243 pHRD->HBW = ri.width;
1313 pHRD->HBH = ri.height; 1244 pHRD->HBH = ri.height;
1314 pHRD->HMMR = cFlags & 0x01; 1245 pHRD->HMMR = cFlags & 0x01;
1315 pHRD->HTEMPLATE = (cFlags >> 1) & 0x03; 1246 pHRD->HTEMPLATE = (cFlags >> 1) & 0x03;
1316 pHRD->HENABLESKIP = (cFlags >> 3) & 0x01; 1247 pHRD->HENABLESKIP = (cFlags >> 3) & 0x01;
1317 pHRD->HCOMBOP = (JBig2ComposeOp)((cFlags >> 4) & 0x07); 1248 pHRD->HCOMBOP = (JBig2ComposeOp)((cFlags >> 4) & 0x07);
1318 pHRD->HDEFPIXEL = (cFlags >> 7) & 0x01; 1249 pHRD->HDEFPIXEL = (cFlags >> 7) & 0x01;
1319 if (pSegment->m_nReferred_to_segment_count != 1) { 1250 if (pSegment->m_nReferred_to_segment_count != 1) {
1320 m_pModule->JBig2_Error(
1321 "halftone region segment : refered to segment count not equals 1");
1322 nRet = JBIG2_ERROR_FATAL; 1251 nRet = JBIG2_ERROR_FATAL;
1323 goto failed; 1252 goto failed;
1324 } 1253 }
1325 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]); 1254 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]);
1326 if ((pSeg == NULL) || (pSeg->m_cFlags.s.type != 16)) { 1255 if ((pSeg == NULL) || (pSeg->m_cFlags.s.type != 16)) {
1327 m_pModule->JBig2_Error(
1328 "halftone region segment : refered to segment is not pattern dict");
1329 nRet = JBIG2_ERROR_FATAL; 1256 nRet = JBIG2_ERROR_FATAL;
1330 goto failed; 1257 goto failed;
1331 } 1258 }
1332 pPatternDict = pSeg->m_Result.pd; 1259 pPatternDict = pSeg->m_Result.pd;
1333 if ((pPatternDict == NULL) || (pPatternDict->NUMPATS == 0)) { 1260 if ((pPatternDict == NULL) || (pPatternDict->NUMPATS == 0)) {
1334 m_pModule->JBig2_Error("halftone region segment : has no patterns input");
1335 nRet = JBIG2_ERROR_FATAL; 1261 nRet = JBIG2_ERROR_FATAL;
1336 goto failed; 1262 goto failed;
1337 } 1263 }
1338 pHRD->HNUMPATS = pPatternDict->NUMPATS; 1264 pHRD->HNUMPATS = pPatternDict->NUMPATS;
1339 pHRD->HPATS = pPatternDict->HDPATS; 1265 pHRD->HPATS = pPatternDict->HDPATS;
1340 pHRD->HPW = pPatternDict->HDPATS[0]->m_nWidth; 1266 pHRD->HPW = pPatternDict->HDPATS[0]->m_nWidth;
1341 pHRD->HPH = pPatternDict->HDPATS[0]->m_nHeight; 1267 pHRD->HPH = pPatternDict->HDPATS[0]->m_nHeight;
1342 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; 1268 pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
1343 if (pHRD->HMMR == 0) { 1269 if (pHRD->HMMR == 0) {
1344 dwTemp = pHRD->HTEMPLATE == 0 ? 65536 : pHRD->HTEMPLATE == 1 ? 8192 : 1024; 1270 dwTemp = pHRD->HTEMPLATE == 0 ? 65536 : pHRD->HTEMPLATE == 1 ? 8192 : 1024;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 1313
1388 int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment, 1314 int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
1389 IFX_Pause* pPause) { 1315 IFX_Pause* pPause) {
1390 FX_DWORD dwTemp; 1316 FX_DWORD dwTemp;
1391 uint8_t cFlags; 1317 uint8_t cFlags;
1392 int32_t i, nRet; 1318 int32_t i, nRet;
1393 if (m_pGRD == NULL) { 1319 if (m_pGRD == NULL) {
1394 JBIG2_ALLOC(m_pGRD, CJBig2_GRDProc()); 1320 JBIG2_ALLOC(m_pGRD, CJBig2_GRDProc());
1395 if ((parseRegionInfo(&m_ri) != JBIG2_SUCCESS) || 1321 if ((parseRegionInfo(&m_ri) != JBIG2_SUCCESS) ||
1396 (m_pStream->read1Byte(&cFlags) != 0)) { 1322 (m_pStream->read1Byte(&cFlags) != 0)) {
1397 m_pModule->JBig2_Error("generic region segment : data header too short.");
1398 nRet = JBIG2_ERROR_TOO_SHORT; 1323 nRet = JBIG2_ERROR_TOO_SHORT;
1399 goto failed; 1324 goto failed;
1400 } 1325 }
1401 if (m_ri.height < 0 || m_ri.width < 0) { 1326 if (m_ri.height < 0 || m_ri.width < 0) {
1402 m_pModule->JBig2_Error("generic region segment : wrong data.");
1403 nRet = JBIG2_FAILED; 1327 nRet = JBIG2_FAILED;
1404 goto failed; 1328 goto failed;
1405 } 1329 }
1406 m_pGRD->GBW = m_ri.width; 1330 m_pGRD->GBW = m_ri.width;
1407 m_pGRD->GBH = m_ri.height; 1331 m_pGRD->GBH = m_ri.height;
1408 m_pGRD->MMR = cFlags & 0x01; 1332 m_pGRD->MMR = cFlags & 0x01;
1409 m_pGRD->GBTEMPLATE = (cFlags >> 1) & 0x03; 1333 m_pGRD->GBTEMPLATE = (cFlags >> 1) & 0x03;
1410 m_pGRD->TPGDON = (cFlags >> 3) & 0x01; 1334 m_pGRD->TPGDON = (cFlags >> 3) & 0x01;
1411 if (m_pGRD->MMR == 0) { 1335 if (m_pGRD->MMR == 0) {
1412 if (m_pGRD->GBTEMPLATE == 0) { 1336 if (m_pGRD->GBTEMPLATE == 0) {
1413 for (i = 0; i < 8; i++) { 1337 for (i = 0; i < 8; i++) {
1414 if (m_pStream->read1Byte((uint8_t*)&m_pGRD->GBAT[i]) != 0) { 1338 if (m_pStream->read1Byte((uint8_t*)&m_pGRD->GBAT[i]) != 0) {
1415 m_pModule->JBig2_Error(
1416 "generic region segment : data header too short.");
1417 nRet = JBIG2_ERROR_TOO_SHORT; 1339 nRet = JBIG2_ERROR_TOO_SHORT;
1418 goto failed; 1340 goto failed;
1419 } 1341 }
1420 } 1342 }
1421 } else { 1343 } else {
1422 for (i = 0; i < 2; i++) { 1344 for (i = 0; i < 2; i++) {
1423 if (m_pStream->read1Byte((uint8_t*)&m_pGRD->GBAT[i]) != 0) { 1345 if (m_pStream->read1Byte((uint8_t*)&m_pGRD->GBAT[i]) != 0) {
1424 m_pModule->JBig2_Error(
1425 "generic region segment : data header too short.");
1426 nRet = JBIG2_ERROR_TOO_SHORT; 1346 nRet = JBIG2_ERROR_TOO_SHORT;
1427 goto failed; 1347 goto failed;
1428 } 1348 }
1429 } 1349 }
1430 } 1350 }
1431 } 1351 }
1432 m_pGRD->USESKIP = 0; 1352 m_pGRD->USESKIP = 0;
1433 } 1353 }
1434 pSegment->m_nResultType = JBIG2_IMAGE_POINTER; 1354 pSegment->m_nResultType = JBIG2_IMAGE_POINTER;
1435 if (m_pGRD->MMR == 0) { 1355 if (m_pGRD->MMR == 0) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 JBig2RegionInfo ri; 1440 JBig2RegionInfo ri;
1521 CJBig2_Segment* pSeg; 1441 CJBig2_Segment* pSeg;
1522 int32_t i, nRet; 1442 int32_t i, nRet;
1523 uint8_t cFlags; 1443 uint8_t cFlags;
1524 JBig2ArithCtx* grContext; 1444 JBig2ArithCtx* grContext;
1525 CJBig2_GRRDProc* pGRRD; 1445 CJBig2_GRRDProc* pGRRD;
1526 CJBig2_ArithDecoder* pArithDecoder; 1446 CJBig2_ArithDecoder* pArithDecoder;
1527 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc()); 1447 JBIG2_ALLOC(pGRRD, CJBig2_GRRDProc());
1528 if ((parseRegionInfo(&ri) != JBIG2_SUCCESS) || 1448 if ((parseRegionInfo(&ri) != JBIG2_SUCCESS) ||
1529 (m_pStream->read1Byte(&cFlags) != 0)) { 1449 (m_pStream->read1Byte(&cFlags) != 0)) {
1530 m_pModule->JBig2_Error(
1531 "generic refinement region segment : data header too short.");
1532 nRet = JBIG2_ERROR_TOO_SHORT; 1450 nRet = JBIG2_ERROR_TOO_SHORT;
1533 goto failed; 1451 goto failed;
1534 } 1452 }
1535 pGRRD->GRW = ri.width; 1453 pGRRD->GRW = ri.width;
1536 pGRRD->GRH = ri.height; 1454 pGRRD->GRH = ri.height;
1537 pGRRD->GRTEMPLATE = cFlags & 0x01; 1455 pGRRD->GRTEMPLATE = cFlags & 0x01;
1538 pGRRD->TPGRON = (cFlags >> 1) & 0x01; 1456 pGRRD->TPGRON = (cFlags >> 1) & 0x01;
1539 if (pGRRD->GRTEMPLATE == 0) { 1457 if (pGRRD->GRTEMPLATE == 0) {
1540 for (i = 0; i < 4; i++) { 1458 for (i = 0; i < 4; i++) {
1541 if (m_pStream->read1Byte((uint8_t*)&pGRRD->GRAT[i]) != 0) { 1459 if (m_pStream->read1Byte((uint8_t*)&pGRRD->GRAT[i]) != 0) {
1542 m_pModule->JBig2_Error(
1543 "generic refinement region segment : data header too short.");
1544 nRet = JBIG2_ERROR_TOO_SHORT; 1460 nRet = JBIG2_ERROR_TOO_SHORT;
1545 goto failed; 1461 goto failed;
1546 } 1462 }
1547 } 1463 }
1548 } 1464 }
1549 pSeg = NULL; 1465 pSeg = NULL;
1550 if (pSegment->m_nReferred_to_segment_count > 0) { 1466 if (pSegment->m_nReferred_to_segment_count > 0) {
1551 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) { 1467 for (i = 0; i < pSegment->m_nReferred_to_segment_count; i++) {
1552 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]); 1468 pSeg = findSegmentByNumber(pSegment->m_pReferred_to_segment_numbers[0]);
1553 if (pSeg == NULL) { 1469 if (pSeg == NULL) {
1554 m_pModule->JBig2_Error(
1555 "generic refinement region segment : can't find refered to "
1556 "segments");
1557 nRet = JBIG2_ERROR_FATAL; 1470 nRet = JBIG2_ERROR_FATAL;
1558 goto failed; 1471 goto failed;
1559 } 1472 }
1560 if ((pSeg->m_cFlags.s.type == 4) || (pSeg->m_cFlags.s.type == 20) || 1473 if ((pSeg->m_cFlags.s.type == 4) || (pSeg->m_cFlags.s.type == 20) ||
1561 (pSeg->m_cFlags.s.type == 36) || (pSeg->m_cFlags.s.type == 40)) { 1474 (pSeg->m_cFlags.s.type == 36) || (pSeg->m_cFlags.s.type == 40)) {
1562 break; 1475 break;
1563 } 1476 }
1564 } 1477 }
1565 if (i >= pSegment->m_nReferred_to_segment_count) { 1478 if (i >= pSegment->m_nReferred_to_segment_count) {
1566 m_pModule->JBig2_Error(
1567 "generic refinement region segment : can't find refered to "
1568 "intermediate region");
1569 nRet = JBIG2_ERROR_FATAL; 1479 nRet = JBIG2_ERROR_FATAL;
1570 goto failed; 1480 goto failed;
1571 } 1481 }
1572 pGRRD->GRREFERENCE = pSeg->m_Result.im; 1482 pGRRD->GRREFERENCE = pSeg->m_Result.im;
1573 } else { 1483 } else {
1574 pGRRD->GRREFERENCE = m_pPage; 1484 pGRRD->GRREFERENCE = m_pPage;
1575 } 1485 }
1576 pGRRD->GRREFERENCEDX = 0; 1486 pGRRD->GRREFERENCEDX = 0;
1577 pGRRD->GRREFERENCEDY = 0; 1487 pGRRD->GRREFERENCEDY = 0;
1578 dwTemp = pGRRD->GRTEMPLATE ? 1 << 10 : 1 << 13; 1488 dwTemp = pGRRD->GRTEMPLATE ? 1 << 10 : 1 << 13;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 SBSYMCODES[CURTEMP].code = CURCODE; 1687 SBSYMCODES[CURTEMP].code = CURCODE;
1778 CURCODE = CURCODE + 1; 1688 CURCODE = CURCODE + 1;
1779 } 1689 }
1780 CURTEMP = CURTEMP + 1; 1690 CURTEMP = CURTEMP + 1;
1781 } 1691 }
1782 CURLEN = CURLEN + 1; 1692 CURLEN = CURLEN + 1;
1783 } 1693 }
1784 m_pModule->JBig2_Free(LENCOUNT); 1694 m_pModule->JBig2_Free(LENCOUNT);
1785 m_pModule->JBig2_Free(FIRSTCODE); 1695 m_pModule->JBig2_Free(FIRSTCODE);
1786 } 1696 }
OLDNEW
« no previous file with comments | « no previous file | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp » ('j') | core/src/fxcodec/jbig2/JBig2_Module.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698