summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_GrdProc.cpp
diff options
context:
space:
mode:
authorweili <weili@chromium.org>2016-06-07 11:28:31 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-07 11:28:31 -0700
commit98963398054a20287cf6b354932ef56ddb4da48c (patch)
treeb9a009dc12f7535e7fc798ee7e416e651272d863 /core/fxcodec/jbig2/JBig2_GrdProc.cpp
parent4997b22f84307521a62838f874928bf56cd3423c (diff)
downloadpdfium-98963398054a20287cf6b354932ef56ddb4da48c.tar.xz
Fix more code which has shadow variables
The code has local variables that shadow struct or class member variables. Also, when this happens, different variable names should be used instead of namespaces. These were discovered by /Wshadow warning flag in Clang. Review-Url: https://codereview.chromium.org/2034253003
Diffstat (limited to 'core/fxcodec/jbig2/JBig2_GrdProc.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_GrdProc.cpp759
1 files changed, 332 insertions, 427 deletions
diff --git a/core/fxcodec/jbig2/JBig2_GrdProc.cpp b/core/fxcodec/jbig2/JBig2_GrdProc.cpp
index 2391fb2b07..9527c1eaf8 100644
--- a/core/fxcodec/jbig2/JBig2_GrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_GrdProc.cpp
@@ -18,7 +18,7 @@ CJBig2_GRDProc::CJBig2_GRDProc()
m_pLine(nullptr),
m_pPause(nullptr),
m_DecodeType(0),
- LTP(0) {
+ m_LTP(FALSE) {
m_ReplaceRect.left = 0;
m_ReplaceRect.bottom = 0;
m_ReplaceRect.top = 0;
@@ -65,43 +65,35 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith(CJBig2_ArithDecoder* pArithDecoder,
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
- uint8_t *pLine, *pLine1, *pLine2, cVal;
- int32_t nStride, nStride2, k;
- int32_t nLineBytes, nBitsLeft, cc;
- LTP = 0;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
if (!GBREG->m_pData)
return nullptr;
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- nStride2 = nStride << 1;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+ FX_BOOL LTP = FALSE;
+ uint8_t* pLine = GBREG->m_pData;
+ int32_t nStride = GBREG->m_nStride;
+ int32_t nStride2 = nStride << 1;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
uint32_t height = GBH & 0x7fffffff;
for (uint32_t h = 0; h < height; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x9b25]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x9b25]);
+ if (LTP) {
GBREG->copyLine(h, h - 1);
} else {
if (h > 1) {
- pLine1 = pLine - nStride2;
- pLine2 = pLine - nStride;
- line1 = (*pLine1++) << 6;
- line2 = *pLine2++;
- CONTEXT = ((line1 & 0xf800) | (line2 & 0x07f0));
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = pLine - nStride2;
+ uint8_t* pLine2 = pLine - nStride;
+ uint32_t line1 = (*pLine1++) << 6;
+ uint32_t line2 = *pLine2++;
+ uint32_t CONTEXT = ((line1 & 0xf800) | (line2 & 0x07f0));
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | ((*pLine1++) << 6);
line2 = (line2 << 8) | (*pLine2++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = (((CONTEXT & 0x7bf7) << 1) | bVal |
((line1 >> k) & 0x0800) | ((line2 >> k) & 0x0010));
@@ -110,26 +102,26 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3(
}
line1 <<= 8;
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT =
(((CONTEXT & 0x7bf7) << 1) | bVal |
((line1 >> (7 - k)) & 0x0800) | ((line2 >> (7 - k)) & 0x0010));
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
} else {
- pLine2 = pLine - nStride;
- line2 = (h & 1) ? (*pLine2++) : 0;
- CONTEXT = (line2 & 0x07f0);
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine2 = pLine - nStride;
+ uint32_t line2 = (h & 1) ? (*pLine2++) : 0;
+ uint32_t CONTEXT = (line2 & 0x07f0);
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
if (h & 1) {
line2 = (line2 << 8) | (*pLine2++);
}
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT =
(((CONTEXT & 0x7bf7) << 1) | bVal | ((line2 >> k) & 0x0010));
@@ -137,14 +129,14 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3(
pLine[cc] = cVal;
}
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = (((CONTEXT & 0x7bf7) << 1) | bVal |
(((line2 >> (7 - k))) & 0x0010));
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
}
}
pLine += nStride;
@@ -155,31 +147,27 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_opt3(
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3;
- LTP = 0;
+ FX_BOOL LTP = FALSE;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
GBREG->fill(0);
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x9b25]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x9b25]);
+ if (LTP) {
GBREG->copyLine(h, h - 1);
} else {
- line1 = GBREG->getPixel(1, h - 2);
+ uint32_t line1 = GBREG->getPixel(1, h - 2);
line1 |= GBREG->getPixel(0, h - 2) << 1;
- line2 = GBREG->getPixel(2, h - 1);
+ uint32_t line2 = GBREG->getPixel(2, h - 1);
line2 |= GBREG->getPixel(1, h - 1) << 1;
line2 |= GBREG->getPixel(0, h - 1) << 2;
- line3 = 0;
+ uint32_t line3 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, h)) {
bVal = 0;
} else {
- CONTEXT = line3;
+ uint32_t 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;
@@ -203,42 +191,34 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template0_unopt(
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
- uint8_t *pLine, *pLine1, *pLine2, cVal;
- int32_t nStride, nStride2, k;
- int32_t nLineBytes, nBitsLeft, cc;
- LTP = 0;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
if (!GBREG->m_pData)
return nullptr;
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- nStride2 = nStride << 1;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+ FX_BOOL LTP = FALSE;
+ uint8_t* pLine = GBREG->m_pData;
+ int32_t nStride = GBREG->m_nStride;
+ int32_t nStride2 = nStride << 1;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0795]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x0795]);
+ if (LTP) {
GBREG->copyLine(h, h - 1);
} else {
if (h > 1) {
- pLine1 = pLine - nStride2;
- pLine2 = pLine - nStride;
- line1 = (*pLine1++) << 4;
- line2 = *pLine2++;
- CONTEXT = (line1 & 0x1e00) | ((line2 >> 1) & 0x01f8);
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = pLine - nStride2;
+ uint8_t* pLine2 = pLine - nStride;
+ uint32_t line1 = (*pLine1++) << 4;
+ uint32_t line2 = *pLine2++;
+ uint32_t CONTEXT = (line1 & 0x1e00) | ((line2 >> 1) & 0x01f8);
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | ((*pLine1++) << 4);
line2 = (line2 << 8) | (*pLine2++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x0efb) << 1) | bVal |
((line1 >> k) & 0x0200) | ((line2 >> (k + 1)) & 0x0008);
@@ -247,26 +227,26 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3(
}
line1 <<= 8;
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x0efb) << 1) | bVal |
((line1 >> (7 - k)) & 0x0200) |
((line2 >> (8 - k)) & 0x0008);
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
} else {
- pLine2 = pLine - nStride;
- line2 = (h & 1) ? (*pLine2++) : 0;
- CONTEXT = (line2 >> 1) & 0x01f8;
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine2 = pLine - nStride;
+ uint32_t line2 = (h & 1) ? (*pLine2++) : 0;
+ uint32_t CONTEXT = (line2 >> 1) & 0x01f8;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
if (h & 1) {
line2 = (line2 << 8) | (*pLine2++);
}
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x0efb) << 1) | bVal |
((line2 >> (k + 1)) & 0x0008);
@@ -274,14 +254,14 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3(
pLine[cc] = cVal;
}
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT =
((CONTEXT & 0x0efb) << 1) | bVal | ((line2 >> (8 - k)) & 0x0008);
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
}
}
pLine += nStride;
@@ -292,32 +272,28 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_opt3(
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3;
- LTP = 0;
+ FX_BOOL LTP = FALSE;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
GBREG->fill(0);
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0795]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x0795]);
+ if (LTP) {
GBREG->copyLine(h, h - 1);
} else {
- line1 = GBREG->getPixel(2, h - 2);
+ uint32_t 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);
+ uint32_t line2 = GBREG->getPixel(2, h - 1);
line2 |= GBREG->getPixel(1, h - 1) << 1;
line2 |= GBREG->getPixel(0, h - 1) << 2;
- line3 = 0;
+ uint32_t line3 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, h)) {
bVal = 0;
} else {
- CONTEXT = line3;
+ uint32_t CONTEXT = line3;
CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 3;
CONTEXT |= line2 << 4;
CONTEXT |= line1 << 9;
@@ -334,45 +310,38 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template1_unopt(
}
return GBREG.release();
}
+
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
- uint8_t *pLine, *pLine1, *pLine2, cVal;
- int32_t nStride, nStride2, k;
- int32_t nLineBytes, nBitsLeft, cc;
- LTP = 0;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
if (!GBREG->m_pData)
return nullptr;
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- nStride2 = nStride << 1;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+ FX_BOOL LTP = FALSE;
+ uint8_t* pLine = GBREG->m_pData;
+ int32_t nStride = GBREG->m_nStride;
+ int32_t nStride2 = nStride << 1;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x00e5]);
+ if (LTP) {
GBREG->copyLine(h, h - 1);
} else {
if (h > 1) {
- pLine1 = pLine - nStride2;
- pLine2 = pLine - nStride;
- line1 = (*pLine1++) << 1;
- line2 = *pLine2++;
- CONTEXT = (line1 & 0x0380) | ((line2 >> 3) & 0x007c);
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = pLine - nStride2;
+ uint8_t* pLine2 = pLine - nStride;
+ uint32_t line1 = (*pLine1++) << 1;
+ uint32_t line2 = *pLine2++;
+ uint32_t CONTEXT = (line1 & 0x0380) | ((line2 >> 3) & 0x007c);
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | ((*pLine1++) << 1);
line2 = (line2 << 8) | (*pLine2++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
((line1 >> k) & 0x0080) | ((line2 >> (k + 3)) & 0x0004);
@@ -381,26 +350,26 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3(
}
line1 <<= 8;
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
((line1 >> (7 - k)) & 0x0080) |
((line2 >> (10 - k)) & 0x0004);
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
} else {
- pLine2 = pLine - nStride;
- line2 = (h & 1) ? (*pLine2++) : 0;
- CONTEXT = (line2 >> 3) & 0x007c;
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine2 = pLine - nStride;
+ uint32_t line2 = (h & 1) ? (*pLine2++) : 0;
+ uint32_t CONTEXT = (line2 >> 3) & 0x007c;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
if (h & 1) {
line2 = (line2 << 8) | (*pLine2++);
}
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
((line2 >> (k + 3)) & 0x0004);
@@ -408,14 +377,14 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3(
pLine[cc] = cVal;
}
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
(((line2 >> (10 - k))) & 0x0004);
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
}
}
pLine += nStride;
@@ -426,30 +395,26 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_opt3(
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3;
- LTP = 0;
+ FX_BOOL LTP = FALSE;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
GBREG->fill(0);
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x00e5]);
+ if (LTP) {
GBREG->copyLine(h, h - 1);
} else {
- line1 = GBREG->getPixel(1, h - 2);
+ uint32_t line1 = GBREG->getPixel(1, h - 2);
line1 |= GBREG->getPixel(0, h - 2) << 1;
- line2 = GBREG->getPixel(1, h - 1);
+ uint32_t line2 = GBREG->getPixel(1, h - 1);
line2 |= GBREG->getPixel(0, h - 1) << 1;
- line3 = 0;
+ uint32_t line3 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, h)) {
bVal = 0;
} else {
- CONTEXT = line3;
+ uint32_t CONTEXT = line3;
CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 2;
CONTEXT |= line2 << 3;
CONTEXT |= line1 << 7;
@@ -470,38 +435,30 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template2_unopt(
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1;
- uint8_t *pLine, *pLine1, cVal;
- int32_t nStride, k;
- int32_t nLineBytes, nBitsLeft, cc;
- LTP = 0;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
if (!GBREG->m_pData)
return nullptr;
- pLine = GBREG->m_pData;
- nStride = GBREG->m_nStride;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+ FX_BOOL LTP = FALSE;
+ uint8_t* pLine = GBREG->m_pData;
+ int32_t nStride = GBREG->m_nStride;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0195]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x0195]);
+ if (LTP) {
GBREG->copyLine(h, h - 1);
} else {
if (h > 0) {
- pLine1 = pLine - nStride;
- line1 = *pLine1++;
- CONTEXT = (line1 >> 1) & 0x03f0;
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = pLine - nStride;
+ uint32_t line1 = *pLine1++;
+ uint32_t CONTEXT = (line1 >> 1) & 0x03f0;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | (*pLine1++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal |
((line1 >> (k + 1)) & 0x0010);
@@ -509,32 +466,32 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt3(
pLine[cc] = cVal;
}
line1 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT =
((CONTEXT & 0x01f7) << 1) | bVal | ((line1 >> (8 - k)) & 0x0010);
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
} else {
- CONTEXT = 0;
- for (cc = 0; cc < nLineBytes; cc++) {
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint32_t CONTEXT = 0;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal;
}
pLine[cc] = cVal;
}
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal;
}
- pLine[nLineBytes] = cVal;
+ pLine[nLineBytes] = cVal1;
}
}
pLine += nStride;
@@ -545,28 +502,24 @@ CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_opt3(
CJBig2_Image* CJBig2_GRDProc::decode_Arith_Template3_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
- LTP = 0;
+ FX_BOOL LTP = FALSE;
std::unique_ptr<CJBig2_Image> GBREG(new CJBig2_Image(GBW, GBH));
GBREG->fill(0);
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0195]);
- LTP = LTP ^ SLTP;
- }
+ if (TPGDON)
+ LTP = LTP ^ pArithDecoder->DECODE(&gbContext[0x0195]);
if (LTP == 1) {
GBREG->copyLine(h, h - 1);
} else {
- line1 = GBREG->getPixel(1, h - 1);
+ uint32_t line1 = GBREG->getPixel(1, h - 1);
line1 |= GBREG->getPixel(0, h - 1) << 1;
- line2 = 0;
+ uint32_t line2 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, h)) {
bVal = 0;
} else {
- CONTEXT = line2;
+ uint32_t CONTEXT = line2;
CONTEXT |= GBREG->getPixel(w + GBAT[0], h + GBAT[1]) << 4;
CONTEXT |= line1 << 5;
bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
@@ -606,7 +559,7 @@ FXCODEC_STATUS CJBig2_GRDProc::Start_decode_Arith(
(*m_pImage)->fill(0);
m_pArithDecoder = pArithDecoder;
m_gbContext = gbContext;
- LTP = 0;
+ m_LTP = FALSE;
m_pLine = nullptr;
m_loopIndex = 0;
return decode_Arith(pPause);
@@ -697,40 +650,32 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template0_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
- uint8_t *pLine1, *pLine2, cVal;
- int32_t nStride, nStride2, k;
- int32_t nLineBytes, nBitsLeft, cc;
if (!m_pLine) {
m_pLine = pImage->m_pData;
}
- nStride = pImage->m_nStride;
- nStride2 = nStride << 1;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+ int32_t nStride = pImage->m_nStride;
+ int32_t nStride2 = nStride << 1;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
uint32_t height = GBH & 0x7fffffff;
for (; m_loopIndex < height; m_loopIndex++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x9b25]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x9b25]);
+ if (m_LTP) {
pImage->copyLine(m_loopIndex, m_loopIndex - 1);
} else {
if (m_loopIndex > 1) {
- pLine1 = m_pLine - nStride2;
- pLine2 = m_pLine - nStride;
- line1 = (*pLine1++) << 6;
- line2 = *pLine2++;
- CONTEXT = ((line1 & 0xf800) | (line2 & 0x07f0));
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = m_pLine - nStride2;
+ uint8_t* pLine2 = m_pLine - nStride;
+ uint32_t line1 = (*pLine1++) << 6;
+ uint32_t line2 = *pLine2++;
+ uint32_t CONTEXT = ((line1 & 0xf800) | (line2 & 0x07f0));
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | ((*pLine1++) << 6);
line2 = (line2 << 8) | (*pLine2++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = (((CONTEXT & 0x7bf7) << 1) | bVal |
((line1 >> k) & 0x0800) | ((line2 >> k) & 0x0010));
@@ -739,26 +684,26 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template0_opt3(
}
line1 <<= 8;
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT =
(((CONTEXT & 0x7bf7) << 1) | bVal |
((line1 >> (7 - k)) & 0x0800) | ((line2 >> (7 - k)) & 0x0010));
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
} else {
- pLine2 = m_pLine - nStride;
- line2 = (m_loopIndex & 1) ? (*pLine2++) : 0;
- CONTEXT = (line2 & 0x07f0);
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine2 = m_pLine - nStride;
+ uint32_t line2 = (m_loopIndex & 1) ? (*pLine2++) : 0;
+ uint32_t CONTEXT = (line2 & 0x07f0);
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
if (m_loopIndex & 1) {
line2 = (line2 << 8) | (*pLine2++);
}
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT =
(((CONTEXT & 0x7bf7) << 1) | bVal | ((line2 >> k) & 0x0010));
@@ -766,14 +711,14 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template0_opt3(
m_pLine[cc] = cVal;
}
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = (((CONTEXT & 0x7bf7) << 1) | bVal |
((line2 >> (7 - k)) & 0x0010));
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
}
}
m_pLine += nStride;
@@ -792,28 +737,24 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template0_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3;
for (; m_loopIndex < GBH; m_loopIndex++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x9b25]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x9b25]);
+ if (m_LTP) {
pImage->copyLine(m_loopIndex, m_loopIndex - 1);
} else {
- line1 = pImage->getPixel(1, m_loopIndex - 2);
+ uint32_t line1 = pImage->getPixel(1, m_loopIndex - 2);
line1 |= pImage->getPixel(0, m_loopIndex - 2) << 1;
- line2 = pImage->getPixel(2, m_loopIndex - 1);
+ uint32_t line2 = pImage->getPixel(2, m_loopIndex - 1);
line2 |= pImage->getPixel(1, m_loopIndex - 1) << 1;
line2 |= pImage->getPixel(0, m_loopIndex - 1) << 2;
- line3 = 0;
+ uint32_t line3 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, m_loopIndex)) {
bVal = 0;
} else {
- CONTEXT = line3;
+ uint32_t CONTEXT = line3;
CONTEXT |= pImage->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) << 4;
CONTEXT |= line2 << 5;
CONTEXT |= pImage->getPixel(w + GBAT[2], m_loopIndex + GBAT[3]) << 10;
@@ -847,39 +788,31 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template1_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
- uint8_t *pLine1, *pLine2, cVal;
- int32_t nStride, nStride2, k;
- int32_t nLineBytes, nBitsLeft, cc;
if (!m_pLine) {
m_pLine = pImage->m_pData;
}
- nStride = pImage->m_nStride;
- nStride2 = nStride << 1;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+ int32_t nStride = pImage->m_nStride;
+ int32_t nStride2 = nStride << 1;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
for (; m_loopIndex < GBH; m_loopIndex++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0795]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x0795]);
+ if (m_LTP) {
pImage->copyLine(m_loopIndex, m_loopIndex - 1);
} else {
if (m_loopIndex > 1) {
- pLine1 = m_pLine - nStride2;
- pLine2 = m_pLine - nStride;
- line1 = (*pLine1++) << 4;
- line2 = *pLine2++;
- CONTEXT = (line1 & 0x1e00) | ((line2 >> 1) & 0x01f8);
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = m_pLine - nStride2;
+ uint8_t* pLine2 = m_pLine - nStride;
+ uint32_t line1 = (*pLine1++) << 4;
+ uint32_t line2 = *pLine2++;
+ uint32_t CONTEXT = (line1 & 0x1e00) | ((line2 >> 1) & 0x01f8);
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | ((*pLine1++) << 4);
line2 = (line2 << 8) | (*pLine2++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x0efb) << 1) | bVal |
((line1 >> k) & 0x0200) | ((line2 >> (k + 1)) & 0x0008);
@@ -888,26 +821,26 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template1_opt3(
}
line1 <<= 8;
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x0efb) << 1) | bVal |
((line1 >> (7 - k)) & 0x0200) |
((line2 >> (8 - k)) & 0x0008);
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
} else {
- pLine2 = m_pLine - nStride;
- line2 = (m_loopIndex & 1) ? (*pLine2++) : 0;
- CONTEXT = (line2 >> 1) & 0x01f8;
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine2 = m_pLine - nStride;
+ uint32_t line2 = (m_loopIndex & 1) ? (*pLine2++) : 0;
+ uint32_t CONTEXT = (line2 >> 1) & 0x01f8;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
if (m_loopIndex & 1) {
line2 = (line2 << 8) | (*pLine2++);
}
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x0efb) << 1) | bVal |
((line2 >> (k + 1)) & 0x0008);
@@ -915,14 +848,14 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template1_opt3(
m_pLine[cc] = cVal;
}
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT =
((CONTEXT & 0x0efb) << 1) | bVal | ((line2 >> (8 - k)) & 0x0008);
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
}
}
m_pLine += nStride;
@@ -941,29 +874,25 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template1_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3;
for (uint32_t h = 0; h < GBH; h++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0795]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x0795]);
+ if (m_LTP) {
pImage->copyLine(h, h - 1);
} else {
- line1 = pImage->getPixel(2, h - 2);
+ uint32_t line1 = pImage->getPixel(2, h - 2);
line1 |= pImage->getPixel(1, h - 2) << 1;
line1 |= pImage->getPixel(0, h - 2) << 2;
- line2 = pImage->getPixel(2, h - 1);
+ uint32_t line2 = pImage->getPixel(2, h - 1);
line2 |= pImage->getPixel(1, h - 1) << 1;
line2 |= pImage->getPixel(0, h - 1) << 2;
- line3 = 0;
+ uint32_t line3 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, h)) {
bVal = 0;
} else {
- CONTEXT = line3;
+ uint32_t CONTEXT = line3;
CONTEXT |= pImage->getPixel(w + GBAT[0], h + GBAT[1]) << 3;
CONTEXT |= line2 << 4;
CONTEXT |= line1 << 9;
@@ -992,39 +921,31 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template2_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
- uint8_t *pLine1, *pLine2, cVal;
- int32_t nStride, nStride2, k;
- int32_t nLineBytes, nBitsLeft, cc;
if (!m_pLine) {
m_pLine = pImage->m_pData;
}
- nStride = pImage->m_nStride;
- nStride2 = nStride << 1;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+ int32_t nStride = pImage->m_nStride;
+ int32_t nStride2 = nStride << 1;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
for (; m_loopIndex < GBH; m_loopIndex++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x00e5]);
+ if (m_LTP) {
pImage->copyLine(m_loopIndex, m_loopIndex - 1);
} else {
if (m_loopIndex > 1) {
- pLine1 = m_pLine - nStride2;
- pLine2 = m_pLine - nStride;
- line1 = (*pLine1++) << 1;
- line2 = *pLine2++;
- CONTEXT = (line1 & 0x0380) | ((line2 >> 3) & 0x007c);
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = m_pLine - nStride2;
+ uint8_t* pLine2 = m_pLine - nStride;
+ uint32_t line1 = (*pLine1++) << 1;
+ uint32_t line2 = *pLine2++;
+ uint32_t CONTEXT = (line1 & 0x0380) | ((line2 >> 3) & 0x007c);
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | ((*pLine1++) << 1);
line2 = (line2 << 8) | (*pLine2++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
((line1 >> k) & 0x0080) | ((line2 >> (k + 3)) & 0x0004);
@@ -1033,26 +954,26 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template2_opt3(
}
line1 <<= 8;
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
((line1 >> (7 - k)) & 0x0080) |
((line2 >> (10 - k)) & 0x0004);
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
} else {
- pLine2 = m_pLine - nStride;
- line2 = (m_loopIndex & 1) ? (*pLine2++) : 0;
- CONTEXT = (line2 >> 3) & 0x007c;
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine2 = m_pLine - nStride;
+ uint32_t line2 = (m_loopIndex & 1) ? (*pLine2++) : 0;
+ uint32_t CONTEXT = (line2 >> 3) & 0x007c;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
if (m_loopIndex & 1) {
line2 = (line2 << 8) | (*pLine2++);
}
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
((line2 >> (k + 3)) & 0x0004);
@@ -1060,14 +981,14 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template2_opt3(
m_pLine[cc] = cVal;
}
line2 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x01bd) << 1) | bVal |
(((line2 >> (10 - k))) & 0x0004);
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
}
}
m_pLine += nStride;
@@ -1086,27 +1007,23 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template2_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3;
for (; m_loopIndex < GBH; m_loopIndex++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x00e5]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x00e5]);
+ if (m_LTP) {
pImage->copyLine(m_loopIndex, m_loopIndex - 1);
} else {
- line1 = pImage->getPixel(1, m_loopIndex - 2);
+ uint32_t line1 = pImage->getPixel(1, m_loopIndex - 2);
line1 |= pImage->getPixel(0, m_loopIndex - 2) << 1;
- line2 = pImage->getPixel(1, m_loopIndex - 1);
+ uint32_t line2 = pImage->getPixel(1, m_loopIndex - 1);
line2 |= pImage->getPixel(0, m_loopIndex - 1) << 1;
- line3 = 0;
+ uint32_t line3 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, m_loopIndex)) {
bVal = 0;
} else {
- CONTEXT = line3;
+ uint32_t CONTEXT = line3;
CONTEXT |= pImage->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) << 2;
CONTEXT |= line2 << 3;
CONTEXT |= line1 << 7;
@@ -1137,35 +1054,27 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template3_opt3(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1;
- uint8_t *pLine1, cVal;
- int32_t nStride, k;
- int32_t nLineBytes, nBitsLeft, cc;
- if (!m_pLine) {
+ if (!m_pLine)
m_pLine = pImage->m_pData;
- }
- nStride = pImage->m_nStride;
- nLineBytes = ((GBW + 7) >> 3) - 1;
- nBitsLeft = GBW - (nLineBytes << 3);
+
+ int32_t nStride = pImage->m_nStride;
+ int32_t nLineBytes = ((GBW + 7) >> 3) - 1;
+ int32_t nBitsLeft = GBW - (nLineBytes << 3);
for (; m_loopIndex < GBH; m_loopIndex++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0195]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x0195]);
+ if (m_LTP) {
pImage->copyLine(m_loopIndex, m_loopIndex - 1);
} else {
if (m_loopIndex > 0) {
- pLine1 = m_pLine - nStride;
- line1 = *pLine1++;
- CONTEXT = (line1 >> 1) & 0x03f0;
- for (cc = 0; cc < nLineBytes; cc++) {
+ uint8_t* pLine1 = m_pLine - nStride;
+ uint32_t line1 = *pLine1++;
+ uint32_t CONTEXT = (line1 >> 1) & 0x03f0;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
line1 = (line1 << 8) | (*pLine1++);
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal |
((line1 >> (k + 1)) & 0x0010);
@@ -1173,32 +1082,32 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template3_opt3(
m_pLine[cc] = cVal;
}
line1 <<= 8;
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT =
((CONTEXT & 0x01f7) << 1) | bVal | ((line1 >> (8 - k)) & 0x0010);
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
} else {
- CONTEXT = 0;
- for (cc = 0; cc < nLineBytes; cc++) {
- cVal = 0;
- for (k = 7; k >= 0; k--) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ uint32_t CONTEXT = 0;
+ for (int32_t cc = 0; cc < nLineBytes; cc++) {
+ uint8_t cVal = 0;
+ for (int32_t k = 7; k >= 0; k--) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
cVal |= bVal << k;
CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal;
}
m_pLine[cc] = cVal;
}
- cVal = 0;
- for (k = 0; k < nBitsLeft; k++) {
- bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
- cVal |= bVal << (7 - k);
+ uint8_t cVal1 = 0;
+ for (int32_t k = 0; k < nBitsLeft; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);
+ cVal1 |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x01f7) << 1) | bVal;
}
- m_pLine[nLineBytes] = cVal;
+ m_pLine[nLineBytes] = cVal1;
}
}
m_pLine += nStride;
@@ -1217,25 +1126,21 @@ FXCODEC_STATUS CJBig2_GRDProc::decode_Arith_Template3_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* gbContext,
IFX_Pause* pPause) {
- FX_BOOL SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2;
for (; m_loopIndex < GBH; m_loopIndex++) {
- if (TPGDON) {
- SLTP = pArithDecoder->DECODE(&gbContext[0x0195]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 1) {
+ if (TPGDON)
+ m_LTP = m_LTP ^ pArithDecoder->DECODE(&gbContext[0x0195]);
+ if (m_LTP) {
pImage->copyLine(m_loopIndex, m_loopIndex - 1);
} else {
- line1 = pImage->getPixel(1, m_loopIndex - 1);
+ uint32_t line1 = pImage->getPixel(1, m_loopIndex - 1);
line1 |= pImage->getPixel(0, m_loopIndex - 1) << 1;
- line2 = 0;
+ uint32_t line2 = 0;
for (uint32_t w = 0; w < GBW; w++) {
+ FX_BOOL bVal;
if (USESKIP && SKIP->getPixel(w, m_loopIndex)) {
bVal = 0;
} else {
- CONTEXT = line2;
+ uint32_t CONTEXT = line2;
CONTEXT |= pImage->getPixel(w + GBAT[0], m_loopIndex + GBAT[1]) << 4;
CONTEXT |= line1 << 5;
bVal = pArithDecoder->DECODE(&gbContext[CONTEXT]);