summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp')
-rw-r--r--core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp451
1 files changed, 0 insertions, 451 deletions
diff --git a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
index a4100320cb..a2dc397af2 100644
--- a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp
@@ -66,123 +66,6 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
}
}
}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt(
- 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) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x9b25]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- line1 = GBREG->getPixel(2, h - 2);
- line1 |= GBREG->getPixel(1, h - 2) << 1;
- line1 |= GBREG->getPixel(0, h - 2) << 2;
- line2 = GBREG->getPixel(3, h - 1);
- line2 |= GBREG->getPixel(2, h - 1) << 1;
- line2 |= GBREG->getPixel(1, h - 1) << 2;
- line2 |= GBREG->getPixel(0, h - 1) << 3;
- line3 = 0;
- for (FX_DWORD w = 0; w < GBW; w++) {
- if (USESKIP && SKIP->getPixel(w, h)) {
- bVal = 0;
- } else {
- CONTEXT = line3;
- CONTEXT |= line2 << 4;
- CONTEXT |= line1 << 11;
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- }
- if (bVal) {
- GBREG->setPixel(w, h, bVal);
- }
- line1 = ((line1 << 1) | GBREG->getPixel(w + 3, h - 2)) & 0x1f;
- line2 = ((line2 << 1) | GBREG->getPixel(w + 4, h - 1)) & 0x7f;
- line3 = ((line3 << 1) | bVal) & 0x0f;
- }
- }
- }
- return GBREG;
-}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt2(
- CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- FX_DWORD CONTEXT;
- CJBig2_Image* GBREG;
- FX_DWORD line1, line2;
- uint8_t *pLine, cVal;
- intptr_t nStride, nStride2;
- int32_t nBits, k;
- LTP = 0;
- JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH));
- if (GBREG->m_pData == NULL) {
- delete GBREG;
- m_pModule->JBig2_Error(
- "Generic region decoding procedure: Create Image Failed with width = "
- "%d, height = %d\n",
- GBW, GBH);
- return NULL;
- }
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- nStride2 = nStride << 1;
- for (FX_DWORD h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x9b25]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- line1 = (h > 1) ? pLine[-nStride2] << 6 : 0;
- line2 = (h > 0) ? pLine[-nStride] : 0;
- CONTEXT = (line1 & 0xf800) | (line2 & 0x07f0);
- for (FX_DWORD w = 0; w < GBW; w += 8) {
- if (w + 8 < GBW) {
- nBits = 8;
- if (h > 1) {
- line1 = (line1 << 8) | (pLine[-nStride2 + (w >> 3) + 1] << 6);
- }
- if (h > 0) {
- line2 = (line2 << 8) | (pLine[-nStride + (w >> 3) + 1]);
- }
- } else {
- nBits = GBW - w;
- if (h > 1) {
- line1 <<= 8;
- }
- if (h > 0) {
- line2 <<= 8;
- }
- }
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- if (USESKIP && SKIP->getPixel(w, h)) {
- bVal = 0;
- } else {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- }
- cVal |= bVal << (7 - k);
- CONTEXT = ((CONTEXT & 0x7bf7) << 1) | bVal |
- ((line1 >> (7 - k)) & 0x0800) |
- ((line2 >> (7 - k)) & 0x0010);
- }
- pLine[w >> 3] = cVal;
- }
- }
- pLine += nStride;
- }
- return GBREG;
-}
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
@@ -326,123 +209,6 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_unopt(
}
return GBREG;
}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt(
- 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) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0795]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- line1 = GBREG->getPixel(2, h - 2);
- line1 |= GBREG->getPixel(1, h - 2) << 1;
- line1 |= GBREG->getPixel(0, h - 2) << 2;
- line2 = GBREG->getPixel(3, h - 1);
- line2 |= GBREG->getPixel(2, h - 1) << 1;
- line2 |= GBREG->getPixel(1, h - 1) << 2;
- line2 |= GBREG->getPixel(0, h - 1) << 3;
- line3 = 0;
- for (FX_DWORD w = 0; w < GBW; w++) {
- if (USESKIP && SKIP->getPixel(w, h)) {
- bVal = 0;
- } else {
- CONTEXT = line3;
- CONTEXT |= line2 << 3;
- 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 + 4, h - 1)) & 0x3f;
- line3 = ((line3 << 1) | bVal) & 0x07;
- }
- }
- }
- return GBREG;
-}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt2(
- CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- FX_DWORD CONTEXT;
- CJBig2_Image* GBREG;
- FX_DWORD line1, line2;
- uint8_t *pLine, cVal;
- intptr_t nStride, nStride2;
- int32_t nBits, k;
- LTP = 0;
- JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH));
- if (GBREG->m_pData == NULL) {
- delete GBREG;
- m_pModule->JBig2_Error(
- "Generic region decoding procedure: Create Image Failed with width = "
- "%d, height = %d\n",
- GBW, GBH);
- return NULL;
- }
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- nStride2 = nStride << 1;
- for (FX_DWORD h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0795]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- line1 = (h > 1) ? pLine[-nStride2] << 4 : 0;
- line2 = (h > 0) ? pLine[-nStride] : 0;
- CONTEXT = (line1 & 0x1e00) | ((line2 >> 1) & 0x01f8);
- for (FX_DWORD w = 0; w < GBW; w += 8) {
- if (w + 8 < GBW) {
- nBits = 8;
- if (h > 1) {
- line1 = (line1 << 8) | (pLine[-nStride2 + (w >> 3) + 1] << 4);
- }
- if (h > 0) {
- line2 = (line2 << 8) | (pLine[-nStride + (w >> 3) + 1]);
- }
- } else {
- nBits = GBW - w;
- if (h > 1) {
- line1 <<= 8;
- }
- if (h > 0) {
- line2 <<= 8;
- }
- }
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- if (USESKIP && SKIP->getPixel(w, h)) {
- bVal = 0;
- } else {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- }
- cVal |= bVal << (7 - k);
- CONTEXT = ((CONTEXT & 0x0efb) << 1) | bVal |
- ((line1 >> (7 - k)) & 0x0200) |
- ((line2 >> (8 - k)) & 0x0008);
- }
- pLine[w >> 3] = cVal;
- }
- }
- pLine += nStride;
- }
- return GBREG;
-}
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
@@ -583,121 +349,6 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_unopt(
}
return GBREG;
}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt(
- 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) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- 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 |= line2 << 2;
- 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 + 3, h - 1)) & 0x1f;
- line3 = ((line3 << 1) | bVal) & 0x03;
- }
- }
- }
- return GBREG;
-}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt2(
- CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- FX_DWORD CONTEXT;
- CJBig2_Image* GBREG;
- FX_DWORD line1, line2;
- uint8_t *pLine, cVal;
- intptr_t nStride, nStride2;
- int32_t nBits, k;
- LTP = 0;
- JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH));
- if (GBREG->m_pData == NULL) {
- delete GBREG;
- m_pModule->JBig2_Error(
- "Generic region decoding procedure: Create Image Failed with width = "
- "%d, height = %d\n",
- GBW, GBH);
- return NULL;
- }
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- nStride2 = nStride << 1;
- for (FX_DWORD h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- line1 = (h > 1) ? pLine[-nStride2] << 1 : 0;
- line2 = (h > 0) ? pLine[-nStride] : 0;
- CONTEXT = (line1 & 0x0380) | ((line2 >> 3) & 0x007c);
- for (FX_DWORD w = 0; w < GBW; w += 8) {
- if (w + 8 < GBW) {
- nBits = 8;
- if (h > 1) {
- line1 = (line1 << 8) | (pLine[-nStride2 + (w >> 3) + 1] << 1);
- }
- if (h > 0) {
- line2 = (line2 << 8) | (pLine[-nStride + (w >> 3) + 1]);
- }
- } else {
- nBits = GBW - w;
- if (h > 1) {
- line1 <<= 8;
- }
- if (h > 0) {
- line2 <<= 8;
- }
- }
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- if (USESKIP && SKIP->getPixel(w, h)) {
- bVal = 0;
- } else {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- }
- cVal |= bVal << (7 - k);
- CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
- ((line1 >> (7 - k)) & 0x0080) |
- ((line2 >> (10 - k)) & 0x0004);
- }
- pLine[w >> 3] = cVal;
- }
- }
- pLine += nStride;
- }
- return GBREG;
-}
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
@@ -836,108 +487,6 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_unopt(
}
return GBREG;
}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt(
- CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- FX_DWORD CONTEXT;
- CJBig2_Image* GBREG;
- FX_DWORD line1, line2;
- LTP = 0;
- JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH));
- GBREG->fill(0);
- for (FX_DWORD h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0195]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- line1 = GBREG->getPixel(2, h - 1);
- line1 |= GBREG->getPixel(1, h - 1) << 1;
- line1 |= GBREG->getPixel(0, h - 1) << 2;
- line2 = 0;
- for (FX_DWORD w = 0; w < GBW; w++) {
- if (USESKIP && SKIP->getPixel(w, h)) {
- bVal = 0;
- } else {
- CONTEXT = line2;
- CONTEXT |= line1 << 4;
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- }
- if (bVal) {
- GBREG->setPixel(w, h, bVal);
- }
- line1 = ((line1 << 1) | GBREG->getPixel(w + 3, h - 1)) & 0x3f;
- line2 = ((line2 << 1) | bVal) & 0x0f;
- }
- }
- }
- return GBREG;
-}
-CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt2(
- CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- FX_DWORD CONTEXT;
- CJBig2_Image* GBREG;
- FX_DWORD line1;
- uint8_t *pLine, cVal;
- intptr_t nStride;
- int32_t nBits, k;
- LTP = 0;
- JBIG2_ALLOC(GBREG, CJBig2_Image(GBW, GBH));
- if (GBREG->m_pData == NULL) {
- delete GBREG;
- m_pModule->JBig2_Error(
- "Generic region decoding procedure: Create Image Failed with width = "
- "%d, height = %d\n",
- GBW, GBH);
- return NULL;
- }
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- for (FX_DWORD h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0195]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
- GBREG->copyLine(h, h - 1);
- } else {
- line1 = (h > 0) ? pLine[-nStride] : 0;
- CONTEXT = (line1 >> 1) & 0x03f0;
- for (FX_DWORD w = 0; w < GBW; w += 8) {
- if (w + 8 < GBW) {
- nBits = 8;
- if (h > 0) {
- line1 = (line1 << 8) | (pLine[-nStride + (w >> 3) + 1]);
- }
- } else {
- nBits = GBW - w;
- if (h > 0) {
- line1 <<= 8;
- }
- }
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- if (USESKIP && SKIP->getPixel(w, h)) {
- bVal = 0;
- } else {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- }
- cVal |= bVal << (7 - k);
- CONTEXT =
- ((CONTEXT & 0x01f7) << 1) | bVal | ((line1 >> (8 - k)) & 0x0010);
- }
- pLine[w >> 3] = cVal;
- }
- }
- pLine += nStride;
- }
- return GBREG;
-}
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {