summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2015-09-02 13:52:56 -0700
committerLei Zhang <thestig@chromium.org>2015-09-02 13:52:56 -0700
commit9df5d9701ddf75f8050566132694bf435efb3ca0 (patch)
tree3465a71175c842f49ba1c945bc27ae0db5826e16 /core/src
parent870b5b6793fa261f0c6f31f026010d2d715968bf (diff)
downloadpdfium-9df5d9701ddf75f8050566132694bf435efb3ca0.tar.xz
Remove dead JBig2 code.
R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1328643002 .
Diffstat (limited to 'core/src')
-rw-r--r--core/src/fxcodec/codec/codec_int.h20
-rw-r--r--core/src/fxcodec/codec/fx_codec_jbig.cpp119
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Context.cpp70
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Context.h7
-rw-r--r--core/src/fxcodec/jbig2/JBig2_GeneralDecoder.cpp451
-rw-r--r--core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h24
-rw-r--r--core/src/fxcodec/jbig2/JBig2_HuffmanTable.h4
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Image.cpp554
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Image.h11
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Segment.cpp9
-rw-r--r--core/src/fxcodec/jbig2/JBig2_Segment.h2
11 files changed, 5 insertions, 1266 deletions
diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h
index ebd34cac26..7dafd27c15 100644
--- a/core/src/fxcodec/codec/codec_int.h
+++ b/core/src/fxcodec/codec/codec_int.h
@@ -315,19 +315,6 @@ class CCodec_Jbig2Module : public ICodec_Jbig2Module {
~CCodec_Jbig2Module() override;
// ICodec_Jbig2Module
- FX_BOOL Decode(FX_DWORD width,
- FX_DWORD height,
- const uint8_t* src_buf,
- FX_DWORD src_size,
- const uint8_t* global_data,
- FX_DWORD global_size,
- uint8_t* dest_buf,
- FX_DWORD dest_pitch) override;
- FX_BOOL Decode(IFX_FileRead* file_ptr,
- FX_DWORD& width,
- FX_DWORD& height,
- FX_DWORD& pitch,
- uint8_t*& dest_buf) override;
void* CreateJbig2Context() override;
FXCODEC_STATUS StartDecode(void* pJbig2Context,
FX_DWORD width,
@@ -339,13 +326,6 @@ class CCodec_Jbig2Module : public ICodec_Jbig2Module {
uint8_t* dest_buf,
FX_DWORD dest_pitch,
IFX_Pause* pPause) override;
- FXCODEC_STATUS StartDecode(void* pJbig2Context,
- IFX_FileRead* file_ptr,
- FX_DWORD& width,
- FX_DWORD& height,
- FX_DWORD& pitch,
- uint8_t*& dest_buf,
- IFX_Pause* pPause) override;
FXCODEC_STATUS ContinueDecode(void* pJbig2Context,
IFX_Pause* pPause) override;
void DestroyJbig2Context(void* pJbig2Context) override;
diff --git a/core/src/fxcodec/codec/fx_codec_jbig.cpp b/core/src/fxcodec/codec/fx_codec_jbig.cpp
index 1551060b60..b95461b3e5 100644
--- a/core/src/fxcodec/codec/fx_codec_jbig.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jbig.cpp
@@ -22,69 +22,6 @@ void CCodec_Jbig2Module::DestroyJbig2Context(void* pJbig2Content) {
}
pJbig2Content = NULL;
}
-FX_BOOL CCodec_Jbig2Module::Decode(FX_DWORD width,
- FX_DWORD height,
- const uint8_t* src_buf,
- FX_DWORD src_size,
- const uint8_t* global_data,
- FX_DWORD global_size,
- uint8_t* dest_buf,
- FX_DWORD dest_pitch) {
- FXSYS_memset(dest_buf, 0, height * dest_pitch);
- CJBig2_Context* pContext = CJBig2_Context::CreateContext(
- &m_Module, (uint8_t*)global_data, global_size, (uint8_t*)src_buf,
- src_size, JBIG2_EMBED_STREAM, &m_SymbolDictCache);
- if (pContext == NULL) {
- return FALSE;
- }
- int ret = pContext->getFirstPage(dest_buf, width, height, dest_pitch, NULL);
- CJBig2_Context::DestroyContext(pContext);
- if (ret != JBIG2_SUCCESS) {
- return FALSE;
- }
- int dword_size = height * dest_pitch / 4;
- FX_DWORD* dword_buf = (FX_DWORD*)dest_buf;
- for (int i = 0; i < dword_size; i++) {
- dword_buf[i] = ~dword_buf[i];
- }
- return TRUE;
-}
-FX_BOOL CCodec_Jbig2Module::Decode(IFX_FileRead* file_ptr,
- FX_DWORD& width,
- FX_DWORD& height,
- FX_DWORD& pitch,
- uint8_t*& dest_buf) {
- CJBig2_Context* pContext = NULL;
- CJBig2_Image* dest_image = NULL;
- FX_DWORD src_size = (FX_DWORD)file_ptr->GetSize();
- uint8_t* src_buf = FX_Alloc(uint8_t, src_size);
- int ret = 0;
- if (!file_ptr->ReadBlock(src_buf, 0, src_size)) {
- goto failed;
- }
- pContext =
- CJBig2_Context::CreateContext(&m_Module, NULL, 0, src_buf, src_size,
- JBIG2_FILE_STREAM, &m_SymbolDictCache);
- if (pContext == NULL) {
- goto failed;
- }
- ret = pContext->getFirstPage(&dest_image, NULL);
- CJBig2_Context::DestroyContext(pContext);
- if (ret != JBIG2_SUCCESS) {
- goto failed;
- }
- width = (FX_DWORD)dest_image->m_nWidth;
- height = (FX_DWORD)dest_image->m_nHeight;
- pitch = (FX_DWORD)dest_image->m_nStride;
- dest_buf = dest_image->m_pData;
- dest_image->m_bNeedFree = FALSE;
- delete dest_image;
- FX_Free(src_buf);
- return TRUE;
-failed:
- FX_Free(src_buf);
- return FALSE;
-}
FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context,
FX_DWORD width,
FX_DWORD height,
@@ -134,62 +71,6 @@ FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context,
}
return m_pJbig2Context->m_pContext->GetProcessiveStatus();
}
-FXCODEC_STATUS CCodec_Jbig2Module::StartDecode(void* pJbig2Context,
- IFX_FileRead* file_ptr,
- FX_DWORD& width,
- FX_DWORD& height,
- FX_DWORD& pitch,
- uint8_t*& dest_buf,
- IFX_Pause* pPause) {
- if (!pJbig2Context) {
- return FXCODEC_STATUS_ERR_PARAMS;
- }
- CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
- m_pJbig2Context->m_bFileReader = TRUE;
- m_pJbig2Context->m_dest_image = NULL;
- m_pJbig2Context->m_src_size = (FX_DWORD)file_ptr->GetSize();
- m_pJbig2Context->m_src_buf = FX_Alloc(uint8_t, m_pJbig2Context->m_src_size);
- int ret = 0;
- if (!file_ptr->ReadBlock((void*)m_pJbig2Context->m_src_buf, 0,
- m_pJbig2Context->m_src_size)) {
- goto failed;
- }
- m_pJbig2Context->m_pContext = CJBig2_Context::CreateContext(
- &m_Module, NULL, 0, m_pJbig2Context->m_src_buf,
- m_pJbig2Context->m_src_size, JBIG2_FILE_STREAM, &m_SymbolDictCache,
- pPause);
- if (m_pJbig2Context->m_pContext == NULL) {
- goto failed;
- }
- ret = m_pJbig2Context->m_pContext->getFirstPage(
- &m_pJbig2Context->m_dest_image, pPause);
- if (m_pJbig2Context->m_pContext->GetProcessiveStatus() ==
- FXCODEC_STATUS_DECODE_TOBECONTINUE) {
- width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth;
- height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight;
- pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride;
- dest_buf = m_pJbig2Context->m_dest_image->m_pData;
- m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE;
- return FXCODEC_STATUS_DECODE_TOBECONTINUE;
- }
- CJBig2_Context::DestroyContext(m_pJbig2Context->m_pContext);
- m_pJbig2Context->m_pContext = NULL;
- if (ret != JBIG2_SUCCESS) {
- goto failed;
- }
- width = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nWidth;
- height = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nHeight;
- pitch = (FX_DWORD)m_pJbig2Context->m_dest_image->m_nStride;
- dest_buf = m_pJbig2Context->m_dest_image->m_pData;
- m_pJbig2Context->m_dest_image->m_bNeedFree = FALSE;
- delete m_pJbig2Context->m_dest_image;
- FX_Free(m_pJbig2Context->m_src_buf);
- return FXCODEC_STATUS_DECODE_FINISH;
-failed:
- FX_Free(m_pJbig2Context->m_src_buf);
- m_pJbig2Context->m_src_buf = NULL;
- return FXCODEC_STATUS_ERROR;
-}
FXCODEC_STATUS CCodec_Jbig2Module::ContinueDecode(void* pJbig2Context,
IFX_Pause* pPause) {
CCodec_Jbig2Context* m_pJbig2Context = (CCodec_Jbig2Context*)pJbig2Context;
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.cpp b/core/src/fxcodec/jbig2/JBig2_Context.cpp
index 4a08c21949..c66c2ebaea 100644
--- a/core/src/fxcodec/jbig2/JBig2_Context.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Context.cpp
@@ -17,11 +17,6 @@
// difference for typical JBIG2 documents.
const int kSymbolDictCacheMaxSize = 2;
-void OutputBitmap(CJBig2_Image* pImage) {
- if (!pImage) {
- return;
- }
-}
CJBig2_Context* CJBig2_Context::CreateContext(
CJBig2_Module* pModule,
uint8_t* pGlobalData,
@@ -170,7 +165,6 @@ int32_t CJBig2_Context::decode_SquentialOrgnazation(IFX_Pause* pPause) {
} else {
m_pStream->offset(4);
}
- OutputBitmap(m_pPage);
m_pSegment = NULL;
if (m_pStream->getByteLeft() > 0 && m_pPage && pPause &&
pPause->NeedToPauseNow()) {
@@ -303,41 +297,6 @@ int32_t CJBig2_Context::Continue(IFX_Pause* pPause) {
}
return nRet;
}
-int32_t CJBig2_Context::getNextPage(uint8_t* pBuf,
- int32_t width,
- int32_t height,
- int32_t stride,
- IFX_Pause* pPause) {
- int32_t nRet = JBIG2_ERROR_STREAM_TYPE;
- m_bFirstPage = FALSE;
- m_PauseStep = 0;
- delete m_pPage;
- JBIG2_ALLOC(m_pPage, CJBig2_Image(width, height, stride, pBuf));
- m_bBufSpecified = TRUE;
- if (m_pPage && pPause && pPause->NeedToPauseNow()) {
- m_PauseStep = 1;
- m_ProcessiveStatus = FXCODEC_STATUS_DECODE_TOBECONTINUE;
- return nRet;
- }
- return Continue(pPause);
- switch (m_nStreamType) {
- case JBIG2_FILE_STREAM:
- nRet = decodeFile(pPause);
- break;
- case JBIG2_SQUENTIAL_STREAM:
- nRet = decode_SquentialOrgnazation(pPause);
- break;
- case JBIG2_RANDOM_STREAM:
- nRet = decode_RandomOrgnazation(pPause);
- break;
- case JBIG2_EMBED_STREAM:
- nRet = decode_EmbedOrgnazation(pPause);
- break;
- default:
- return JBIG2_ERROR_STREAM_TYPE;
- }
- return nRet;
-}
int32_t CJBig2_Context::getFirstPage(CJBig2_Image** image, IFX_Pause* pPause) {
int32_t nRet;
m_bFirstPage = TRUE;
@@ -351,34 +310,6 @@ int32_t CJBig2_Context::getFirstPage(CJBig2_Image** image, IFX_Pause* pPause) {
m_bBufSpecified = FALSE;
return Continue(pPause);
}
-int32_t CJBig2_Context::getNextPage(CJBig2_Image** image, IFX_Pause* pPause) {
- int32_t nRet;
- m_bBufSpecified = FALSE;
- m_bFirstPage = FALSE;
- m_PauseStep = 0;
- switch (m_nStreamType) {
- case JBIG2_FILE_STREAM:
- nRet = decodeFile(pPause);
- break;
- case JBIG2_SQUENTIAL_STREAM:
- nRet = decode_SquentialOrgnazation(pPause);
- break;
- case JBIG2_RANDOM_STREAM:
- nRet = decode_RandomOrgnazation(pPause);
- break;
- case JBIG2_EMBED_STREAM:
- nRet = decode_EmbedOrgnazation(pPause);
- break;
- default:
- return JBIG2_ERROR_STREAM_TYPE;
- }
- if (nRet == JBIG2_SUCCESS) {
- *image = m_pPage;
- m_pPage = NULL;
- return JBIG2_SUCCESS;
- }
- return nRet;
-}
CJBig2_Segment* CJBig2_Context::findSegmentByNumber(FX_DWORD dwNumber) {
CJBig2_Segment* pSeg;
int32_t i;
@@ -1556,7 +1487,6 @@ int32_t CJBig2_Context::parseGenericRegion(CJBig2_Segment* pSegment,
} else {
m_ProcessiveStatus = m_pGRD->Continue_decode(pPause);
}
- OutputBitmap(pSegment->m_Result.im);
if (m_ProcessiveStatus == FXCODEC_STATUS_DECODE_TOBECONTINUE) {
if (pSegment->m_cFlags.s.type != 36) {
if (!m_bBufSpecified) {
diff --git a/core/src/fxcodec/jbig2/JBig2_Context.h b/core/src/fxcodec/jbig2/JBig2_Context.h
index 25261a17bf..eb0ceb0eb9 100644
--- a/core/src/fxcodec/jbig2/JBig2_Context.h
+++ b/core/src/fxcodec/jbig2/JBig2_Context.h
@@ -56,15 +56,8 @@ class CJBig2_Context : public CJBig2_Object {
int32_t stride,
IFX_Pause* pPause);
- int32_t getNextPage(uint8_t* pBuf,
- int32_t width,
- int32_t height,
- int32_t stride,
- IFX_Pause* pPause);
-
int32_t getFirstPage(CJBig2_Image** image, IFX_Pause* pPause);
- int32_t getNextPage(CJBig2_Image** image, IFX_Pause* pPause);
int32_t Continue(IFX_Pause* pPause);
FXCODEC_STATUS GetProcessiveStatus() { return m_ProcessiveStatus; }
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) {
diff --git a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h
index 0b087a0ec1..36839100fa 100644
--- a/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h
+++ b/core/src/fxcodec/jbig2/JBig2_GeneralDecoder.h
@@ -99,48 +99,24 @@ class CJBig2_GRDProc : public CJBig2_Object {
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause);
- CJBig2_Image* decode_Arith_Template0_opt(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
- CJBig2_Image* decode_Arith_Template0_opt2(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
CJBig2_Image* decode_Arith_Template0_opt3(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
CJBig2_Image* decode_Arith_Template0_unopt(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
- CJBig2_Image* decode_Arith_Template1_opt(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
- CJBig2_Image* decode_Arith_Template1_opt2(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
CJBig2_Image* decode_Arith_Template1_opt3(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
CJBig2_Image* decode_Arith_Template1_unopt(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
- CJBig2_Image* decode_Arith_Template2_opt(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
- CJBig2_Image* decode_Arith_Template2_opt2(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
CJBig2_Image* decode_Arith_Template2_opt3(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
CJBig2_Image* decode_Arith_Template2_unopt(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
- CJBig2_Image* decode_Arith_Template3_opt(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
- CJBig2_Image* decode_Arith_Template3_opt2(CJBig2_ArithDecoder* pArithDecoder,
- JBig2ArithCtx* gbContext);
-
CJBig2_Image* decode_Arith_Template3_opt3(CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext);
diff --git a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h
index e6f1592fc4..64c52176be 100644
--- a/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h
+++ b/core/src/fxcodec/jbig2/JBig2_HuffmanTable.h
@@ -17,8 +17,6 @@ class CJBig2_HuffmanTable : public CJBig2_Object {
~CJBig2_HuffmanTable();
- void init();
-
int parseFromStandardTable(const JBig2TableLine* pTable,
int nLines,
FX_BOOL bHTOOB);
@@ -28,6 +26,8 @@ class CJBig2_HuffmanTable : public CJBig2_Object {
FX_BOOL isOK() { return m_bOK; }
private:
+ void init();
+
FX_BOOL HTOOB;
int NTEMP;
int* CODES;
diff --git a/core/src/fxcodec/jbig2/JBig2_Image.cpp b/core/src/fxcodec/jbig2/JBig2_Image.cpp
index 772e4e5f62..f1adfc6152 100644
--- a/core/src/fxcodec/jbig2/JBig2_Image.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Image.cpp
@@ -129,547 +129,7 @@ FX_BOOL CJBig2_Image::composeTo(CJBig2_Image* pDst,
}
return composeTo_opt2(pDst, x, y, op, pSrcRect);
}
-FX_BOOL CJBig2_Image::composeTo_unopt(CJBig2_Image* pDst,
- int32_t x,
- int32_t y,
- JBig2ComposeOp op) {
- int32_t w, h, dx, dy;
- int32_t i, j;
- w = m_nWidth;
- h = m_nHeight;
- dx = dy = 0;
- if (x < 0) {
- dx += -x;
- w -= -x;
- x = 0;
- }
- if (y < 0) {
- dy += -y;
- h -= -y;
- y = 0;
- }
- if (x + w > pDst->m_nWidth) {
- w = pDst->m_nWidth - x;
- }
- if (y + h > pDst->m_nHeight) {
- h = pDst->m_nHeight - y;
- }
- switch (op) {
- case JBIG2_COMPOSE_OR:
- for (j = 0; j < h; j++) {
- for (i = 0; i < w; i++) {
- pDst->setPixel(
- x + i, y + j,
- (getPixel(i + dx, j + dy) | pDst->getPixel(x + i, y + j)) & 1);
- }
- }
- break;
- case JBIG2_COMPOSE_AND:
- for (j = 0; j < h; j++) {
- for (i = 0; i < w; i++) {
- pDst->setPixel(
- x + i, y + j,
- (getPixel(i + dx, j + dy) & pDst->getPixel(x + i, y + j)) & 1);
- }
- }
- break;
- case JBIG2_COMPOSE_XOR:
- for (j = 0; j < h; j++) {
- for (i = 0; i < w; i++) {
- pDst->setPixel(
- x + i, y + j,
- (getPixel(i + dx, j + dy) ^ pDst->getPixel(x + i, y + j)) & 1);
- }
- }
- break;
- case JBIG2_COMPOSE_XNOR:
- for (j = 0; j < h; j++) {
- for (i = 0; i < w; i++) {
- pDst->setPixel(
- x + i, y + j,
- (~(getPixel(i + dx, j + dy) ^ pDst->getPixel(x + i, y + j))) & 1);
- }
- }
- break;
- case JBIG2_COMPOSE_REPLACE:
- for (j = 0; j < h; j++) {
- for (i = 0; i < w; i++) {
- pDst->setPixel(x + i, y + j, getPixel(i + dx, j + dy));
- }
- }
- break;
- }
- return TRUE;
-}
-FX_BOOL CJBig2_Image::composeTo_opt(CJBig2_Image* pDst,
- int32_t x,
- int32_t y,
- JBig2ComposeOp op) {
- int32_t x0, x1, y0, y1, xx, yy;
- uint8_t *pLineSrc, *pLineDst, *srcPtr, *destPtr;
- FX_DWORD src0, src1, src, dest, s1, s2, m1, m2, m3;
- FX_BOOL oneByte;
- if (!m_pData) {
- return FALSE;
- }
- if (y < 0) {
- y0 = -y;
- } else {
- y0 = 0;
- }
- if (y + m_nHeight > pDst->m_nHeight) {
- y1 = pDst->m_nHeight - y;
- } else {
- y1 = m_nHeight;
- }
- if (y0 >= y1) {
- return FALSE;
- }
- if (x >= 0) {
- x0 = x & ~7;
- } else {
- x0 = 0;
- }
- x1 = x + m_nWidth;
- if (x1 > pDst->m_nWidth) {
- x1 = pDst->m_nWidth;
- }
- if (x0 >= x1) {
- return FALSE;
- }
- s1 = x & 7;
- s2 = 8 - s1;
- m1 = 0xff >> (x1 & 7);
- m2 = 0xff << (((x1 & 7) == 0) ? 0 : 8 - (x1 & 7));
- m3 = (0xff >> s1) & m2;
- oneByte = x0 == ((x1 - 1) & ~7);
- pLineDst = pDst->m_pData + y * pDst->m_nStride;
- pLineSrc = m_pData + y0 * m_nStride;
- if (oneByte) {
- if (x >= 0) {
- switch (op) {
- case JBIG2_COMPOSE_OR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- dest = *destPtr;
- dest |= (*srcPtr >> s1) & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_AND: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- dest = *destPtr;
- dest &= ((0xff00 | *srcPtr) >> s1) | m1;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- dest = *destPtr;
- dest ^= (*srcPtr >> s1) & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XNOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- dest = *destPtr;
- dest ^= ((*srcPtr ^ 0xff) >> s1) & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_REPLACE: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- dest = *destPtr;
- dest = (dest & ~m3) | ((*srcPtr >> s1) & m3);
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- }
- } else {
- switch (op) {
- case JBIG2_COMPOSE_OR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- dest = *destPtr;
- dest |= *srcPtr & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_AND: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- dest = *destPtr;
- dest &= *srcPtr | m1;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- dest = *destPtr;
- dest ^= *srcPtr & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XNOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- dest = *destPtr;
- dest ^= (*srcPtr ^ 0xff) & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_REPLACE: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- dest = *destPtr;
- dest = (*srcPtr & m2) | (dest & m1);
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- }
- }
- } else {
- if (x >= 0) {
- switch (op) {
- case JBIG2_COMPOSE_OR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- src1 = *srcPtr++;
- dest = *destPtr;
- dest |= src1 >> s1;
- *destPtr++ = (uint8_t)dest;
- xx = x0 + 8;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest |= src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest |= src & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_AND: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- src1 = *srcPtr++;
- dest = *destPtr;
- dest &= (0xff00 | src1) >> s1;
- *destPtr++ = (uint8_t)dest;
- xx = x0 + 8;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest &= src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest &= src | m1;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- src1 = *srcPtr++;
- dest = *destPtr;
- dest ^= src1 >> s1;
- *destPtr++ = (uint8_t)dest;
- xx = x0 + 8;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= src & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XNOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- src1 = *srcPtr++;
- dest = *destPtr;
- dest ^= (src1 ^ 0xff) >> s1;
- *destPtr++ = (uint8_t)dest;
- xx = x0 + 8;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= src ^ 0xff;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= (src ^ 0xff) & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_REPLACE: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst + (x >> 3);
- srcPtr = pLineSrc;
- src1 = *srcPtr++;
- dest = *destPtr;
- dest = (dest & (0xff << s2)) | (src1 >> s1);
- *destPtr++ = (uint8_t)dest;
- xx = x0 + 8;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest = src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest = (src & m2) | (dest & m1);
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- }
- } else {
- switch (op) {
- case JBIG2_COMPOSE_OR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- src1 = *srcPtr++;
- xx = x0;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest |= src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest |= src & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_AND: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- src1 = *srcPtr++;
- xx = x0;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest &= src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest &= src | m1;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- src1 = *srcPtr++;
- xx = x0;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= src & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_XNOR: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- src1 = *srcPtr++;
- xx = x0;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= src ^ 0xff;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest ^= (src ^ 0xff) & m2;
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- case JBIG2_COMPOSE_REPLACE: {
- for (yy = y0; yy < y1; ++yy) {
- destPtr = pLineDst;
- srcPtr = pLineSrc + (-x >> 3);
- src1 = *srcPtr++;
- xx = x0;
- for (; xx < x1 - 8; xx += 8) {
- dest = *destPtr;
- src0 = src1;
- src1 = *srcPtr++;
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest = src;
- *destPtr++ = (uint8_t)dest;
- }
- dest = *destPtr;
- src0 = src1;
- if (srcPtr - pLineSrc < m_nStride) {
- src1 = *srcPtr++;
- } else {
- src1 = 0;
- }
- src = (((src0 << 8) | src1) >> s1) & 0xff;
- dest = (src & m2) | (dest & m1);
- *destPtr = (uint8_t)dest;
- pLineDst += pDst->m_nStride;
- pLineSrc += m_nStride;
- }
- } break;
- }
- }
- }
- return TRUE;
-}
FX_BOOL CJBig2_Image::composeFrom(int32_t x,
int32_t y,
CJBig2_Image* pSrc,
@@ -689,20 +149,6 @@ FX_BOOL CJBig2_Image::composeFrom(int32_t x,
}
return pSrc->composeTo(this, x, y, op, pSrcRect);
}
-CJBig2_Image* CJBig2_Image::subImage_unopt(int32_t x,
- int32_t y,
- int32_t w,
- int32_t h) {
- CJBig2_Image* pImage;
- int32_t i, j;
- JBIG2_ALLOC(pImage, CJBig2_Image(w, h));
- for (j = 0; j < h; j++) {
- for (i = 0; i < w; i++) {
- pImage->setPixel(i, j, getPixel(x + i, y + j));
- }
- }
- return pImage;
-}
#define JBIG2_GETDWORD(buf) \
((FX_DWORD)(((buf)[0] << 24) | ((buf)[1] << 16) | ((buf)[2] << 8) | (buf)[3]))
CJBig2_Image* CJBig2_Image::subImage(int32_t x,
diff --git a/core/src/fxcodec/jbig2/JBig2_Image.h b/core/src/fxcodec/jbig2/JBig2_Image.h
index 47215eaa3d..c5d27f36b5 100644
--- a/core/src/fxcodec/jbig2/JBig2_Image.h
+++ b/core/src/fxcodec/jbig2/JBig2_Image.h
@@ -44,16 +44,6 @@ class CJBig2_Image : public CJBig2_Object {
JBig2ComposeOp op,
const FX_RECT* pSrcRect);
- FX_BOOL composeTo_unopt(CJBig2_Image* pDst,
- int32_t x,
- int32_t y,
- JBig2ComposeOp op);
-
- FX_BOOL composeTo_opt(CJBig2_Image* pDst,
- int32_t x,
- int32_t y,
- JBig2ComposeOp op);
-
FX_BOOL composeTo_opt2(CJBig2_Image* pDst,
int32_t x,
int32_t y,
@@ -73,7 +63,6 @@ class CJBig2_Image : public CJBig2_Object {
CJBig2_Image* pSrc,
JBig2ComposeOp op,
const FX_RECT* pSrcRect);
- CJBig2_Image* subImage_unopt(int32_t x, int32_t y, int32_t w, int32_t h);
CJBig2_Image* subImage(int32_t x, int32_t y, int32_t w, int32_t h);
diff --git a/core/src/fxcodec/jbig2/JBig2_Segment.cpp b/core/src/fxcodec/jbig2/JBig2_Segment.cpp
index afbf71a3df..39e4fafaa1 100644
--- a/core/src/fxcodec/jbig2/JBig2_Segment.cpp
+++ b/core/src/fxcodec/jbig2/JBig2_Segment.cpp
@@ -6,12 +6,6 @@
#include "JBig2_Segment.h"
CJBig2_Segment::CJBig2_Segment() {
- init();
-}
-CJBig2_Segment::~CJBig2_Segment() {
- clean();
-}
-void CJBig2_Segment::init() {
m_dwNumber = 0;
m_cFlags.c = 0;
m_nReferred_to_segment_count = 0;
@@ -24,6 +18,9 @@ void CJBig2_Segment::init() {
m_nResultType = JBIG2_VOID_POINTER;
m_Result.vd = NULL;
}
+CJBig2_Segment::~CJBig2_Segment() {
+ clean();
+}
void CJBig2_Segment::clean() {
if (m_pReferred_to_segment_numbers) {
m_pModule->JBig2_Free(m_pReferred_to_segment_numbers);
diff --git a/core/src/fxcodec/jbig2/JBig2_Segment.h b/core/src/fxcodec/jbig2/JBig2_Segment.h
index c9c6d59cd7..82cd8384a0 100644
--- a/core/src/fxcodec/jbig2/JBig2_Segment.h
+++ b/core/src/fxcodec/jbig2/JBig2_Segment.h
@@ -34,8 +34,6 @@ class CJBig2_Segment : public CJBig2_Object {
~CJBig2_Segment();
- void init();
-
void clean();
public: