diff options
author | Lei Zhang <thestig@chromium.org> | 2015-08-20 14:35:53 -0700 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2015-08-20 14:35:53 -0700 |
commit | 7830e9e38d4155335b7287f8edb2b3a6cece5b01 (patch) | |
tree | 579ef82f8c47872416aff19d8f5d8c4e65c4bfc2 /core/src | |
parent | c3f4894a6862c74b9ab32b4ec38c531de6ecd83c (diff) | |
download | pdfium-7830e9e38d4155335b7287f8edb2b3a6cece5b01.tar.xz |
Remove a bunch of dead JBIG2 code.
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/1293393002 .
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp | 793 | ||||
-rw-r--r-- | core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h | 71 |
2 files changed, 36 insertions, 828 deletions
diff --git a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp index 415d919f25..33b88bf2ba 100644 --- a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp +++ b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp @@ -1059,268 +1059,6 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_unopt( } return GBREG; } -CJBig2_Image* CJBig2_GRDProc::decode_Arith_V2( - CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext) { - FX_BOOL LTP, SLTP, bVal; - FX_DWORD CONTEXT; - CJBig2_Image* GBREG; - FX_DWORD line1, line2, line3; - LTP = 0; - JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); - GBREG->fill(0); - for (FX_DWORD h = 0; h < GBH; h++) { - if (TPGDON) { - switch (GBTEMPLATE) { - case 0: - CONTEXT = 0x9b25; - break; - case 1: - CONTEXT = 0x0795; - break; - case 2: - CONTEXT = 0x00e5; - break; - case 3: - CONTEXT = 0x0195; - break; - } - SLTP = pArithDecoder->DECODE(&gbContext[CONTEXT]); - LTP = LTP ^ SLTP; - } - if (LTP == 1) { - GBREG->copyLine(h, h - 1); - } else { - switch (GBTEMPLATE) { - case 0: { - line1 = GBREG->getPixel(1, h - 2); - line1 |= GBREG->getPixel(0, h - 2) << 1; - line2 = GBREG->getPixel(2, h - 1); - line2 |= GBREG->getPixel(1, h - 1) << 1; - line2 |= GBREG->getPixel(0, h - 1) << 2; - line3 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, h)) { - bVal = 0; - } else { - CONTEXT = line3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 4; - CONTEXT |= line2 << 5; - CONTEXT |= GBREG->getPixel(w + GBAT[2], h + GBAT[3]) << 10; - CONTEXT |= GBREG->getPixel(w + GBAT[4], h + GBAT[5]) << 11; - CONTEXT |= line1 << 12; - CONTEXT |= GBREG->getPixel(w + GBAT[6], h + GBAT[7]) << 15; - bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, h, bVal); - } - line1 = ((line1 << 1) | GBREG->getPixel(w + 2, h - 2)) & 0x07; - line2 = ((line2 << 1) | GBREG->getPixel(w + 3, h - 1)) & 0x1f; - line3 = ((line3 << 1) | bVal) & 0x0f; - } - } break; - case 1: { - line1 = GBREG->getPixel(2, h - 2); - line1 |= GBREG->getPixel(1, h - 2) << 1; - line1 |= GBREG->getPixel(0, h - 2) << 2; - line2 = GBREG->getPixel(2, h - 1); - line2 |= GBREG->getPixel(1, h - 1) << 1; - line2 |= GBREG->getPixel(0, h - 1) << 2; - line3 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, h)) { - bVal = 0; - } else { - CONTEXT = line3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 3; - CONTEXT |= line2 << 4; - CONTEXT |= line1 << 9; - bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, h, bVal); - } - line1 = ((line1 << 1) | GBREG->getPixel(w + 3, h - 2)) & 0x0f; - line2 = ((line2 << 1) | GBREG->getPixel(w + 3, h - 1)) & 0x1f; - line3 = ((line3 << 1) | bVal) & 0x07; - } - } break; - case 2: { - line1 = GBREG->getPixel(1, h - 2); - line1 |= GBREG->getPixel(0, h - 2) << 1; - line2 = GBREG->getPixel(1, h - 1); - line2 |= GBREG->getPixel(0, h - 1) << 1; - line3 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, h)) { - bVal = 0; - } else { - CONTEXT = line3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 2; - CONTEXT |= line2 << 3; - CONTEXT |= line1 << 7; - bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, h, bVal); - } - line1 = ((line1 << 1) | GBREG->getPixel(w + 2, h - 2)) & 0x07; - line2 = ((line2 << 1) | GBREG->getPixel(w + 2, h - 1)) & 0x0f; - line3 = ((line3 << 1) | bVal) & 0x03; - } - } break; - case 3: { - line1 = GBREG->getPixel(1, h - 1); - line1 |= GBREG->getPixel(0, h - 1) << 1; - line2 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, h)) { - bVal = 0; - } else { - CONTEXT = line2; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 4; - CONTEXT |= line1 << 5; - bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, h, bVal); - } - line1 = ((line1 << 1) | GBREG->getPixel(w + 2, h - 1)) & 0x1f; - line2 = ((line2 << 1) | bVal) & 0x0f; - } - } break; - } - } - } - return GBREG; -} -CJBig2_Image* CJBig2_GRDProc::decode_Arith_V1( - CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext) { - FX_BOOL LTP, SLTP, bVal; - FX_DWORD CONTEXT = 0; - CJBig2_Image* GBREG; - LTP = 0; - JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); - GBREG->fill(0); - for (FX_DWORD h = 0; h < GBH; h++) { - if (TPGDON) { - switch (GBTEMPLATE) { - case 0: - CONTEXT = 0x9b25; - break; - case 1: - CONTEXT = 0x0795; - break; - case 2: - CONTEXT = 0x00e5; - break; - case 3: - CONTEXT = 0x0195; - break; - } - SLTP = pArithDecoder->DECODE(&gbContext[CONTEXT]); - LTP = LTP ^ SLTP; - } - if (LTP == 1) { - for (FX_DWORD w = 0; w < GBW; w++) { - GBREG->setPixel(w, h, GBREG->getPixel(w, h - 1)); - } - } else { - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, h)) { - GBREG->setPixel(w, h, 0); - } else { - CONTEXT = 0; - switch (GBTEMPLATE) { - case 0: - CONTEXT |= GBREG->getPixel(w - 1, h); - CONTEXT |= GBREG->getPixel(w - 2, h) << 1; - CONTEXT |= GBREG->getPixel(w - 3, h) << 2; - CONTEXT |= GBREG->getPixel(w - 4, h) << 3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 4; - CONTEXT |= GBREG->getPixel(w + 2, h - 1) << 5; - CONTEXT |= GBREG->getPixel(w + 1, h - 1) << 6; - CONTEXT |= GBREG->getPixel(w, h - 1) << 7; - CONTEXT |= GBREG->getPixel(w - 1, h - 1) << 8; - CONTEXT |= GBREG->getPixel(w - 2, h - 1) << 9; - CONTEXT |= GBREG->getPixel(w + GBAT[2], h + GBAT[3]) << 10; - CONTEXT |= GBREG->getPixel(w + GBAT[4], h + GBAT[5]) << 11; - CONTEXT |= GBREG->getPixel(w + 1, h - 2) << 12; - CONTEXT |= GBREG->getPixel(w, h - 2) << 13; - CONTEXT |= GBREG->getPixel(w - 1, h - 2) << 14; - CONTEXT |= GBREG->getPixel(w + GBAT[6], h + GBAT[7]) << 15; - break; - case 1: - CONTEXT |= GBREG->getPixel(w - 1, h); - CONTEXT |= GBREG->getPixel(w - 2, h) << 1; - CONTEXT |= GBREG->getPixel(w - 3, h) << 2; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 3; - CONTEXT |= GBREG->getPixel(w + 2, h - 1) << 4; - CONTEXT |= GBREG->getPixel(w + 1, h - 1) << 5; - CONTEXT |= GBREG->getPixel(w, h - 1) << 6; - CONTEXT |= GBREG->getPixel(w - 1, h - 1) << 7; - CONTEXT |= GBREG->getPixel(w - 2, h - 1) << 8; - CONTEXT |= GBREG->getPixel(w + 2, h - 2) << 9; - CONTEXT |= GBREG->getPixel(w + 1, h - 2) << 10; - CONTEXT |= GBREG->getPixel(w, h - 2) << 11; - CONTEXT |= GBREG->getPixel(w - 1, h - 2) << 12; - break; - case 2: - CONTEXT |= GBREG->getPixel(w - 1, h); - CONTEXT |= GBREG->getPixel(w - 2, h) << 1; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 2; - CONTEXT |= GBREG->getPixel(w + 1, h - 1) << 3; - CONTEXT |= GBREG->getPixel(w, h - 1) << 4; - CONTEXT |= GBREG->getPixel(w - 1, h - 1) << 5; - CONTEXT |= GBREG->getPixel(w - 2, h - 1) << 6; - CONTEXT |= GBREG->getPixel(w + 1, h - 2) << 7; - CONTEXT |= GBREG->getPixel(w, h - 2) << 8; - CONTEXT |= GBREG->getPixel(w - 1, h - 2) << 9; - break; - case 3: - CONTEXT |= GBREG->getPixel(w - 1, h); - CONTEXT |= GBREG->getPixel(w - 2, h) << 1; - CONTEXT |= GBREG->getPixel(w - 3, h) << 2; - CONTEXT |= GBREG->getPixel(w - 4, h) << 3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 4; - CONTEXT |= GBREG->getPixel(w + 1, h - 1) << 5; - CONTEXT |= GBREG->getPixel(w, h - 1) << 6; - CONTEXT |= GBREG->getPixel(w - 1, h - 1) << 7; - CONTEXT |= GBREG->getPixel(w - 2, h - 1) << 8; - CONTEXT |= GBREG->getPixel(w - 3, h - 1) << 9; - break; - } - bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]); - GBREG->setPixel(w, h, bVal); - } - } - } - } - return GBREG; -} -CJBig2_Image* CJBig2_GRDProc::decode_MMR(CJBig2_BitStream* pStream) { - int bitpos, i; - CJBig2_Image* pImage; - JBIG2_ALLOC(pImage, CJBig2_Image(GBW, GBH)); - if (pImage->m_pData == NULL) { - delete pImage; - m_pModule->JBig2_Error( - "Generic region decoding procedure: Create Image Failed with width = " - "%d, height = %d\n", - GBW, GBH); - return NULL; - } - bitpos = (int)pStream->getBitPos(); - _FaxG4Decode(m_pModule, pStream->getBuf(), pStream->getLength(), &bitpos, - pImage->m_pData, GBW, GBH, pImage->m_nStride); - pStream->setBitPos(bitpos); - for (i = 0; (FX_DWORD)i < pImage->m_nStride * GBH; i++) { - pImage->m_pData[i] = ~pImage->m_pData[i]; - } - return pImage; -} CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* grContext) { if (GRW == 0 || GRH == 0) { @@ -1832,176 +1570,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt( } return GRREG; } -CJBig2_Image* CJBig2_GRRDProc::decode_V1(CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* grContext) { - FX_BOOL LTP, SLTP, bVal; - FX_BOOL TPGRPIX, TPGRVAL; - FX_DWORD CONTEXT; - CJBig2_Image* GRREG; - LTP = 0; - JBIG2_ALLOC(GRREG, CJBig2_Image(GRW, GRH)); - GRREG->fill(0); - for (FX_DWORD h = 0; h < GRH; h++) { - if (TPGRON) { - switch (GRTEMPLATE) { - case 0: - CONTEXT = 0x0010; - break; - case 1: - CONTEXT = 0x0008; - break; - } - SLTP = pArithDecoder->DECODE(&grContext[CONTEXT]); - LTP = LTP ^ SLTP; - } - if (LTP == 0) { - for (FX_DWORD w = 0; w < GRW; w++) { - CONTEXT = 0; - switch (GRTEMPLATE) { - case 0: - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY + 1); - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY + 1) - << 1; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX - 1, - h - GRREFERENCEDY + 1) - << 2; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, h - GRREFERENCEDY) - << 3; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY) - << 4; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX - 1, h - GRREFERENCEDY) - << 5; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY - 1) - << 6; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY - 1) - << 7; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + GRAT[2], - h - GRREFERENCEDY + GRAT[3]) - << 8; - CONTEXT |= GRREG->getPixel(w - 1, h) << 9; - CONTEXT |= GRREG->getPixel(w + 1, h - 1) << 10; - CONTEXT |= GRREG->getPixel(w, h - 1) << 11; - CONTEXT |= GRREG->getPixel(w + GRAT[0], h + GRAT[1]) << 12; - break; - case 1: - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY + 1); - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY + 1) - << 1; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, h - GRREFERENCEDY) - << 2; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY) - << 3; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX - 1, h - GRREFERENCEDY) - << 4; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY - 1) - << 5; - CONTEXT |= GRREG->getPixel(w - 1, h) << 6; - CONTEXT |= GRREG->getPixel(w + 1, h - 1) << 7; - CONTEXT |= GRREG->getPixel(w, h - 1) << 8; - CONTEXT |= GRREG->getPixel(w - 1, h - 1) << 9; - break; - } - bVal = pArithDecoder->DECODE(&grContext[CONTEXT]); - GRREG->setPixel(w, h, bVal); - } - } else { - for (FX_DWORD w = 0; w < GRW; w++) { - bVal = GRREFERENCE->getPixel(w, h); - if (TPGRON && (bVal == GRREFERENCE->getPixel(w - 1, h - 1)) && - (bVal == GRREFERENCE->getPixel(w, h - 1)) && - (bVal == GRREFERENCE->getPixel(w + 1, h - 1)) && - (bVal == GRREFERENCE->getPixel(w - 1, h)) && - (bVal == GRREFERENCE->getPixel(w + 1, h)) && - (bVal == GRREFERENCE->getPixel(w - 1, h + 1)) && - (bVal == GRREFERENCE->getPixel(w, h + 1)) && - (bVal == GRREFERENCE->getPixel(w + 1, h + 1))) { - TPGRPIX = 1; - TPGRVAL = bVal; - } else { - TPGRPIX = 0; - } - if (TPGRPIX) { - GRREG->setPixel(w, h, TPGRVAL); - } else { - CONTEXT = 0; - switch (GRTEMPLATE) { - case 0: - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY + 1); - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX, - h - GRREFERENCEDY + 1) - << 1; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX - 1, - h - GRREFERENCEDY + 1) - << 2; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY) - << 3; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY) - << 4; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX - 1, - h - GRREFERENCEDY) - << 5; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY - 1) - << 6; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX, - h - GRREFERENCEDY - 1) - << 7; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + GRAT[2], - h - GRREFERENCEDY + GRAT[3]) - << 8; - CONTEXT |= GRREG->getPixel(w - 1, h) << 9; - CONTEXT |= GRREG->getPixel(w + 1, h - 1) << 10; - CONTEXT |= GRREG->getPixel(w, h - 1) << 11; - CONTEXT |= GRREG->getPixel(w + GRAT[0], h + GRAT[1]) << 12; - break; - case 1: - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY + 1); - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX, - h - GRREFERENCEDY + 1) - << 1; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + 1, - h - GRREFERENCEDY) - << 2; - CONTEXT |= - GRREFERENCE->getPixel(w - GRREFERENCEDX, h - GRREFERENCEDY) - << 3; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX - 1, - h - GRREFERENCEDY) - << 4; - CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX, - h - GRREFERENCEDY - 1) - << 5; - CONTEXT |= GRREG->getPixel(w - 1, h) << 6; - CONTEXT |= GRREG->getPixel(w + 1, h - 1) << 7; - CONTEXT |= GRREG->getPixel(w, h - 1) << 8; - CONTEXT |= GRREG->getPixel(w - 1, h - 1) << 9; - break; - } - bVal = pArithDecoder->DECODE(&grContext[CONTEXT]); - GRREG->setPixel(w, h, bVal); - } - } - } - } - return GRREG; -} + CJBig2_Image* CJBig2_TRDProc::decode_Huffman(CJBig2_BitStream* pStream, JBig2ArithCtx* grContext) { int32_t STRIPT, FIRSTS; @@ -3722,341 +3291,6 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith(IFX_Pause* pPause) { } return m_ProssiveStatus; } -FXCODEC_STATUS CJBig2_GRDProc::Start_decode_Arith_V2( - CJBig2_Image** pImage, - CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext, - IFX_Pause* pPause) { - if (GBW == 0 || GBH == 0) { - *pImage = NULL; - m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; - return FXCODEC_STATUS_DECODE_FINISH; - } - if (*pImage == NULL) { - JBIG2_ALLOC((*pImage), CJBig2_Image(GBW, GBH)); - } - if ((*pImage)->m_pData == NULL) { - delete *pImage; - *pImage = NULL; - m_pModule->JBig2_Error( - "Generic region decoding procedure: Create Image Failed with width = " - "%d, height = %d\n", - GBW, GBH); - m_ProssiveStatus = FXCODEC_STATUS_ERROR; - return FXCODEC_STATUS_ERROR; - } - m_ProssiveStatus = FXCODEC_STATUS_DECODE_READY; - m_DecodeType = 2; - m_pPause = pPause; - m_pImage = pImage; - (*m_pImage)->fill(0); - LTP = 0; - m_loopIndex = 0; - m_pArithDecoder = pArithDecoder; - m_gbContext = gbContext; - return decode_Arith_V2(pPause); -} -FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_V2(IFX_Pause* pPause) { - FX_BOOL SLTP, bVal; - FX_DWORD CONTEXT; - CJBig2_Image* GBREG = *m_pImage; - FX_DWORD line1, line2, line3; - LTP = 0; - JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH)); - GBREG->fill(0); - for (; m_loopIndex < GBH; m_loopIndex++) { - if (TPGDON) { - switch (GBTEMPLATE) { - case 0: - CONTEXT = 0x9b25; - break; - case 1: - CONTEXT = 0x0795; - break; - case 2: - CONTEXT = 0x00e5; - break; - case 3: - CONTEXT = 0x0195; - break; - } - SLTP = m_pArithDecoder->DECODE(&m_gbContext[CONTEXT]); - LTP = LTP ^ SLTP; - } - if (LTP == 1) { - GBREG->copyLine(m_loopIndex, m_loopIndex - 1); - } else { - switch (GBTEMPLATE) { - case 0: { - line1 = GBREG->getPixel(1, m_loopIndex - 2); - line1 |= GBREG->getPixel(0, m_loopIndex - 2) << 1; - line2 = GBREG->getPixel(2, m_loopIndex - 1); - line2 |= GBREG->getPixel(1, m_loopIndex - 1) << 1; - line2 |= GBREG->getPixel(0, m_loopIndex - 1) << 2; - line3 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, m_loopIndex)) { - bVal = 0; - } else { - CONTEXT = line3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 4; - CONTEXT |= line2 << 5; - CONTEXT |= GBREG->getPixel(w + GBAT[2], m_loopIndex + GBAT[3]) - << 10; - CONTEXT |= GBREG->getPixel(w + GBAT[4], m_loopIndex + GBAT[5]) - << 11; - CONTEXT |= line1 << 12; - CONTEXT |= GBREG->getPixel(w + GBAT[6], m_loopIndex + GBAT[7]) - << 15; - bVal = m_pArithDecoder->DECODE(&m_gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, m_loopIndex, bVal); - } - line1 = - ((line1 << 1) | GBREG->getPixel(w + 2, m_loopIndex - 2)) & 0x07; - line2 = - ((line2 << 1) | GBREG->getPixel(w + 3, m_loopIndex - 1)) & 0x1f; - line3 = ((line3 << 1) | bVal) & 0x0f; - } - } break; - case 1: { - line1 = GBREG->getPixel(2, m_loopIndex - 2); - line1 |= GBREG->getPixel(1, m_loopIndex - 2) << 1; - line1 |= GBREG->getPixel(0, m_loopIndex - 2) << 2; - line2 = GBREG->getPixel(2, m_loopIndex - 1); - line2 |= GBREG->getPixel(1, m_loopIndex - 1) << 1; - line2 |= GBREG->getPixel(0, m_loopIndex - 1) << 2; - line3 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, m_loopIndex)) { - bVal = 0; - } else { - CONTEXT = line3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 3; - CONTEXT |= line2 << 4; - CONTEXT |= line1 << 9; - bVal = m_pArithDecoder->DECODE(&m_gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, m_loopIndex, bVal); - } - line1 = - ((line1 << 1) | GBREG->getPixel(w + 3, m_loopIndex - 2)) & 0x0f; - line2 = - ((line2 << 1) | GBREG->getPixel(w + 3, m_loopIndex - 1)) & 0x1f; - line3 = ((line3 << 1) | bVal) & 0x07; - } - } break; - case 2: { - line1 = GBREG->getPixel(1, m_loopIndex - 2); - line1 |= GBREG->getPixel(0, m_loopIndex - 2) << 1; - line2 = GBREG->getPixel(1, m_loopIndex - 1); - line2 |= GBREG->getPixel(0, m_loopIndex - 1) << 1; - line3 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, m_loopIndex)) { - bVal = 0; - } else { - CONTEXT = line3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 2; - CONTEXT |= line2 << 3; - CONTEXT |= line1 << 7; - bVal = m_pArithDecoder->DECODE(&m_gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, m_loopIndex, bVal); - } - line1 = - ((line1 << 1) | GBREG->getPixel(w + 2, m_loopIndex - 2)) & 0x07; - line2 = - ((line2 << 1) | GBREG->getPixel(w + 2, m_loopIndex - 1)) & 0x0f; - line3 = ((line3 << 1) | bVal) & 0x03; - } - } break; - case 3: { - line1 = GBREG->getPixel(1, m_loopIndex - 1); - line1 |= GBREG->getPixel(0, m_loopIndex - 1) << 1; - line2 = 0; - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, m_loopIndex)) { - bVal = 0; - } else { - CONTEXT = line2; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 4; - CONTEXT |= line1 << 5; - bVal = m_pArithDecoder->DECODE(&m_gbContext[CONTEXT]); - } - if (bVal) { - GBREG->setPixel(w, m_loopIndex, bVal); - } - line1 = - ((line1 << 1) | GBREG->getPixel(w + 2, m_loopIndex - 1)) & 0x1f; - line2 = ((line2 << 1) | bVal) & 0x0f; - } - } break; - } - } - if (pPause && pPause->NeedToPauseNow()) { - m_loopIndex++; - m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; - return FXCODEC_STATUS_DECODE_TOBECONTINUE; - } - } - m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; - return FXCODEC_STATUS_DECODE_FINISH; -} -FXCODEC_STATUS CJBig2_GRDProc::Start_decode_Arith_V1( - CJBig2_Image** pImage, - CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext, - IFX_Pause* pPause) { - if (GBW == 0 || GBH == 0) { - *pImage = NULL; - m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; - return FXCODEC_STATUS_DECODE_FINISH; - } - if (*pImage == NULL) { - JBIG2_ALLOC((*pImage), CJBig2_Image(GBW, GBH)); - } - if ((*pImage)->m_pData == NULL) { - delete *pImage; - *pImage = NULL; - m_pModule->JBig2_Error( - "Generic region decoding procedure: Create Image Failed with width = " - "%d, height = %d\n", - GBW, GBH); - m_ProssiveStatus = FXCODEC_STATUS_ERROR; - return FXCODEC_STATUS_ERROR; - } - m_ProssiveStatus = FXCODEC_STATUS_DECODE_READY; - m_pPause = pPause; - m_pImage = pImage; - m_DecodeType = 3; - (*m_pImage)->fill(0); - LTP = 0; - m_loopIndex = 0; - m_pArithDecoder = pArithDecoder; - m_gbContext = gbContext; - return decode_Arith_V1(pPause); -} -FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_V1(IFX_Pause* pPause) { - FX_BOOL SLTP, bVal; - FX_DWORD CONTEXT = 0; - CJBig2_Image* GBREG = (*m_pImage); - for (; m_loopIndex < GBH; m_loopIndex++) { - if (TPGDON) { - switch (GBTEMPLATE) { - case 0: - CONTEXT = 0x9b25; - break; - case 1: - CONTEXT = 0x0795; - break; - case 2: - CONTEXT = 0x00e5; - break; - case 3: - CONTEXT = 0x0195; - break; - } - SLTP = m_pArithDecoder->DECODE(&m_gbContext[CONTEXT]); - LTP = LTP ^ SLTP; - } - if (LTP == 1) { - for (FX_DWORD w = 0; w < GBW; w++) { - GBREG->setPixel(w, m_loopIndex, GBREG->getPixel(w, m_loopIndex - 1)); - } - } else { - for (FX_DWORD w = 0; w < GBW; w++) { - if (USESKIP && SKIP->getPixel(w, m_loopIndex)) { - GBREG->setPixel(w, m_loopIndex, 0); - } else { - CONTEXT = 0; - switch (GBTEMPLATE) { - case 0: - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex); - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex) << 1; - CONTEXT |= GBREG->getPixel(w - 3, m_loopIndex) << 2; - CONTEXT |= GBREG->getPixel(w - 4, m_loopIndex) << 3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 4; - CONTEXT |= GBREG->getPixel(w + 2, m_loopIndex - 1) << 5; - CONTEXT |= GBREG->getPixel(w + 1, m_loopIndex - 1) << 6; - CONTEXT |= GBREG->getPixel(w, m_loopIndex - 1) << 7; - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex - 1) << 8; - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex - 1) << 9; - CONTEXT |= GBREG->getPixel(w + GBAT[2], m_loopIndex + GBAT[3]) - << 10; - CONTEXT |= GBREG->getPixel(w + GBAT[4], m_loopIndex + GBAT[5]) - << 11; - CONTEXT |= GBREG->getPixel(w + 1, m_loopIndex - 2) << 12; - CONTEXT |= GBREG->getPixel(w, m_loopIndex - 2) << 13; - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex - 2) << 14; - CONTEXT |= GBREG->getPixel(w + GBAT[6], m_loopIndex + GBAT[7]) - << 15; - break; - case 1: - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex); - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex) << 1; - CONTEXT |= GBREG->getPixel(w - 3, m_loopIndex) << 2; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 3; - CONTEXT |= GBREG->getPixel(w + 2, m_loopIndex - 1) << 4; - CONTEXT |= GBREG->getPixel(w + 1, m_loopIndex - 1) << 5; - CONTEXT |= GBREG->getPixel(w, m_loopIndex - 1) << 6; - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex - 1) << 7; - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex - 1) << 8; - CONTEXT |= GBREG->getPixel(w + 2, m_loopIndex - 2) << 9; - CONTEXT |= GBREG->getPixel(w + 1, m_loopIndex - 2) << 10; - CONTEXT |= GBREG->getPixel(w, m_loopIndex - 2) << 11; - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex - 2) << 12; - break; - case 2: - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex); - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex) << 1; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 2; - CONTEXT |= GBREG->getPixel(w + 1, m_loopIndex - 1) << 3; - CONTEXT |= GBREG->getPixel(w, m_loopIndex - 1) << 4; - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex - 1) << 5; - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex - 1) << 6; - CONTEXT |= GBREG->getPixel(w + 1, m_loopIndex - 2) << 7; - CONTEXT |= GBREG->getPixel(w, m_loopIndex - 2) << 8; - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex - 2) << 9; - break; - case 3: - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex); - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex) << 1; - CONTEXT |= GBREG->getPixel(w - 3, m_loopIndex) << 2; - CONTEXT |= GBREG->getPixel(w - 4, m_loopIndex) << 3; - CONTEXT |= GBREG->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) - << 4; - CONTEXT |= GBREG->getPixel(w + 1, m_loopIndex - 1) << 5; - CONTEXT |= GBREG->getPixel(w, m_loopIndex - 1) << 6; - CONTEXT |= GBREG->getPixel(w - 1, m_loopIndex - 1) << 7; - CONTEXT |= GBREG->getPixel(w - 2, m_loopIndex - 1) << 8; - CONTEXT |= GBREG->getPixel(w - 3, m_loopIndex - 1) << 9; - break; - } - bVal = m_pArithDecoder->DECODE(&m_gbContext[CONTEXT]); - GBREG->setPixel(w, m_loopIndex, bVal); - } - } - } - if (pPause && pPause->NeedToPauseNow()) { - m_loopIndex++; - m_ProssiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE; - return FXCODEC_STATUS_DECODE_TOBECONTINUE; - } - } - m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; - return FXCODEC_STATUS_DECODE_FINISH; -} FXCODEC_STATUS CJBig2_GRDProc::Start_decode_MMR(CJBig2_Image** pImage, CJBig2_BitStream* pStream, IFX_Pause* pPause) { @@ -4082,26 +3316,19 @@ FXCODEC_STATUS CJBig2_GRDProc::Start_decode_MMR(CJBig2_Image** pImage, m_ProssiveStatus = FXCODEC_STATUS_DECODE_FINISH; return m_ProssiveStatus; } -FXCODEC_STATUS CJBig2_GRDProc::decode_MMR() { - return m_ProssiveStatus; -} + FXCODEC_STATUS CJBig2_GRDProc::Continue_decode(IFX_Pause* pPause) { - if (m_ProssiveStatus != FXCODEC_STATUS_DECODE_TOBECONTINUE) { + if (m_ProssiveStatus != FXCODEC_STATUS_DECODE_TOBECONTINUE) + return m_ProssiveStatus; + + if (m_DecodeType != 1) { + m_ProssiveStatus = FXCODEC_STATUS_ERROR; return m_ProssiveStatus; } - switch (m_DecodeType) { - case 1: - return decode_Arith(pPause); - case 2: - return decode_Arith_V2(pPause); - case 3: - return decode_Arith_V1(pPause); - case 4: - return decode_MMR(); - } - m_ProssiveStatus = FXCODEC_STATUS_ERROR; - return m_ProssiveStatus; + + return decode_Arith(pPause); } + FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template0_opt3( CJBig2_Image* pImage, CJBig2_ArithDecoder* pArithDecoder, diff --git a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h index eb90f6b183..1b933d7443 100644 --- a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h +++ b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h @@ -17,12 +17,14 @@ class CJBig2_HuffmanTable; class CJBig2_Image; class CJBig2_PatternDict; -typedef enum { + +enum JBig2Corner { JBIG2_CORNER_BOTTOMLEFT = 0, JBIG2_CORNER_TOPLEFT = 1, JBIG2_CORNER_BOTTOMRIGHT = 2, JBIG2_CORNER_TOPRIGHT = 3 -} JBig2Corner; +}; + class CJBig2_GRDProc : public CJBig2_Object { public: CJBig2_GRDProc() { @@ -40,36 +42,27 @@ class CJBig2_GRDProc : public CJBig2_Object { CJBig2_Image* decode_Arith(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext); - CJBig2_Image* decode_Arith_V2(CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext); - - CJBig2_Image* decode_Arith_V1(CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext); - - CJBig2_Image* decode_MMR(CJBig2_BitStream* pStream); FXCODEC_STATUS Start_decode_Arith(CJBig2_Image** pImage, CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext, IFX_Pause* pPause = NULL); - FXCODEC_STATUS Start_decode_Arith_V2(CJBig2_Image** pImage, - CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext, - IFX_Pause* pPause = NULL); - FXCODEC_STATUS Start_decode_Arith_V1(CJBig2_Image** pImage, - CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* gbContext, - IFX_Pause* pPause = NULL); FXCODEC_STATUS Start_decode_MMR(CJBig2_Image** pImage, CJBig2_BitStream* pStream, IFX_Pause* pPause = NULL); FXCODEC_STATUS Continue_decode(IFX_Pause* pPause); FX_RECT GetReplaceRect() { return m_ReplaceRect; } + FX_BOOL MMR; + FX_DWORD GBW; + FX_DWORD GBH; + uint8_t GBTEMPLATE; + FX_BOOL TPGDON; + FX_BOOL USESKIP; + CJBig2_Image* SKIP; + char GBAT[8]; + private: FXCODEC_STATUS decode_Arith(IFX_Pause* pPause); - FXCODEC_STATUS decode_Arith_V2(IFX_Pause* pPause); - FXCODEC_STATUS decode_Arith_V1(IFX_Pause* pPause); - FXCODEC_STATUS decode_MMR(); FXCODEC_STATUS decode_Arith_Template0_opt3(CJBig2_Image* pImage, CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext, @@ -106,18 +99,6 @@ class CJBig2_GRDProc : public CJBig2_Object { CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext, IFX_Pause* pPause); - FX_DWORD m_loopIndex; - uint8_t* m_pLine; - IFX_Pause* m_pPause; - FXCODEC_STATUS m_ProssiveStatus; - CJBig2_Image** m_pImage; - CJBig2_ArithDecoder* m_pArithDecoder; - JBig2ArithCtx* m_gbContext; - FX_WORD m_DecodeType; - FX_BOOL LTP; - FX_RECT m_ReplaceRect; - - private: CJBig2_Image* decode_Arith_Template0_opt(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext); @@ -166,16 +147,18 @@ class CJBig2_GRDProc : public CJBig2_Object { CJBig2_Image* decode_Arith_Template3_unopt(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* gbContext); - public: - FX_BOOL MMR; - FX_DWORD GBW; - FX_DWORD GBH; - uint8_t GBTEMPLATE; - FX_BOOL TPGDON; - FX_BOOL USESKIP; - CJBig2_Image* SKIP; - signed char GBAT[8]; + FX_DWORD m_loopIndex; + uint8_t* m_pLine; + IFX_Pause* m_pPause; + FXCODEC_STATUS m_ProssiveStatus; + CJBig2_Image** m_pImage; + CJBig2_ArithDecoder* m_pArithDecoder; + JBig2ArithCtx* m_gbContext; + FX_WORD m_DecodeType; + FX_BOOL LTP; + FX_RECT m_ReplaceRect; }; + class CJBig2_GRRDProc : public CJBig2_Object { public: CJBig2_Image* decode(CJBig2_ArithDecoder* pArithDecoder, @@ -193,10 +176,6 @@ class CJBig2_GRRDProc : public CJBig2_Object { CJBig2_Image* decode_Template1_opt(CJBig2_ArithDecoder* pArithDecoder, JBig2ArithCtx* grContext); - CJBig2_Image* decode_V1(CJBig2_ArithDecoder* pArithDecoder, - JBig2ArithCtx* grContext); - - public: FX_DWORD GRW; FX_DWORD GRH; FX_BOOL GRTEMPLATE; @@ -206,11 +185,13 @@ class CJBig2_GRRDProc : public CJBig2_Object { FX_BOOL TPGRON; signed char GRAT[4]; }; + typedef struct { CJBig2_ArithIntDecoder *IADT, *IAFS, *IADS, *IAIT, *IARI, *IARDW, *IARDH, *IARDX, *IARDY; CJBig2_ArithIaidDecoder* IAID; } JBig2IntDecoderState; + class CJBig2_TRDProc : public CJBig2_Object { public: CJBig2_Image* decode_Huffman(CJBig2_BitStream* pStream, |