summaryrefslogtreecommitdiff
path: root/core/fxcodec/jbig2/JBig2_GrrdProc.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_GrrdProc.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_GrrdProc.cpp')
-rw-r--r--core/fxcodec/jbig2/JBig2_GrrdProc.cpp275
1 files changed, 131 insertions, 144 deletions
diff --git a/core/fxcodec/jbig2/JBig2_GrrdProc.cpp b/core/fxcodec/jbig2/JBig2_GrrdProc.cpp
index 17d17d558e..25c9ea2d8a 100644
--- a/core/fxcodec/jbig2/JBig2_GrrdProc.cpp
+++ b/core/fxcodec/jbig2/JBig2_GrrdProc.cpp
@@ -34,35 +34,33 @@ CJBig2_Image* CJBig2_GRRDProc::decode(CJBig2_ArithDecoder* pArithDecoder,
CJBig2_Image* CJBig2_GRRDProc::decode_Template0_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* grContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3, line4, line5;
- LTP = 0;
+ FX_BOOL LTP = FALSE;
std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
GRREG->fill(0);
for (uint32_t h = 0; h < GRH; h++) {
- if (TPGRON) {
- SLTP = pArithDecoder->DECODE(&grContext[0x0010]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 0) {
- line1 = GRREG->getPixel(1, h - 1);
+ if (TPGRON)
+ LTP = LTP ^ pArithDecoder->DECODE(&grContext[0x0010]);
+ if (!LTP) {
+ uint32_t line1 = GRREG->getPixel(1, h - 1);
line1 |= GRREG->getPixel(0, h - 1) << 1;
- line2 = 0;
- line3 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY - 1);
+ uint32_t line2 = 0;
+ uint32_t line3 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY - 1);
line3 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY - 1)
<< 1;
- line4 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
+ uint32_t line4 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY) << 1;
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX - 1, h - GRREFERENCEDY)
<< 2;
- line5 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
+ uint32_t line5 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
line5 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY + 1)
<< 1;
line5 |= GRREFERENCE->getPixel(-GRREFERENCEDX - 1, h - GRREFERENCEDY + 1)
<< 2;
for (uint32_t w = 0; w < GRW; w++) {
- CONTEXT = line5;
+ uint32_t CONTEXT = line5;
CONTEXT |= line4 << 3;
CONTEXT |= line3 << 6;
CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + GRAT[2],
@@ -71,7 +69,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_unopt(
CONTEXT |= line2 << 9;
CONTEXT |= line1 << 10;
CONTEXT |= GRREG->getPixel(w + GRAT[0], h + GRAT[1]) << 12;
- bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
+ FX_BOOL bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
GRREG->setPixel(w, h, bVal);
line1 = ((line1 << 1) | GRREG->getPixel(w + 2, h - 1)) & 0x03;
line2 = ((line2 << 1) | bVal) & 0x01;
@@ -89,23 +87,26 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_unopt(
0x07;
}
} else {
- line1 = GRREG->getPixel(1, h - 1);
+ uint32_t line1 = GRREG->getPixel(1, h - 1);
line1 |= GRREG->getPixel(0, h - 1) << 1;
- line2 = 0;
- line3 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY - 1);
+ uint32_t line2 = 0;
+ uint32_t line3 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY - 1);
line3 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY - 1)
<< 1;
- line4 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
+ uint32_t line4 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY) << 1;
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX - 1, h - GRREFERENCEDY)
<< 2;
- line5 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
+ uint32_t line5 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
line5 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY + 1)
<< 1;
line5 |= GRREFERENCE->getPixel(-GRREFERENCEDX - 1, h - GRREFERENCEDY + 1)
<< 2;
for (uint32_t w = 0; w < GRW; w++) {
- bVal = GRREFERENCE->getPixel(w, h);
+ FX_BOOL bVal = GRREFERENCE->getPixel(w, h);
if (!(TPGRON && (bVal == GRREFERENCE->getPixel(w - 1, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w + 1, h - 1)) &&
@@ -114,7 +115,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_unopt(
(bVal == GRREFERENCE->getPixel(w - 1, h + 1)) &&
(bVal == GRREFERENCE->getPixel(w, h + 1)) &&
(bVal == GRREFERENCE->getPixel(w + 1, h + 1)))) {
- CONTEXT = line5;
+ uint32_t CONTEXT = line5;
CONTEXT |= line4 << 3;
CONTEXT |= line3 << 6;
CONTEXT |= GRREFERENCE->getPixel(w - GRREFERENCEDX + GRAT[2],
@@ -152,64 +153,56 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt(
if (!GRREFERENCE->m_pData)
return nullptr;
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line1_r, line2_r, line3_r;
- uint8_t *pLine, *pLineR, cVal;
- intptr_t nStride, nStrideR, nOffset;
- int32_t k, nBits;
- int32_t GRWR, GRHR;
- int32_t GRW, GRH;
- GRW = (int32_t)CJBig2_GRRDProc::GRW;
- GRH = (int32_t)CJBig2_GRRDProc::GRH;
- LTP = 0;
- std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
+ int32_t iGRW = static_cast<int32_t>(GRW);
+ int32_t iGRH = static_cast<int32_t>(GRH);
+ std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(iGRW, iGRH));
if (!GRREG->m_pData)
return nullptr;
- pLine = GRREG->m_pData;
- pLineR = GRREFERENCE->m_pData;
- nStride = GRREG->m_nStride;
- nStrideR = GRREFERENCE->m_nStride;
- GRWR = (int32_t)GRREFERENCE->m_nWidth;
- GRHR = (int32_t)GRREFERENCE->m_nHeight;
- if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) {
+ FX_BOOL LTP = FALSE;
+ uint8_t* pLine = GRREG->m_pData;
+ uint8_t* pLineR = GRREFERENCE->m_pData;
+ intptr_t nStride = GRREG->m_nStride;
+ intptr_t nStrideR = GRREFERENCE->m_nStride;
+ int32_t GRWR = GRREFERENCE->m_nWidth;
+ int32_t GRHR = GRREFERENCE->m_nHeight;
+ if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1)
GRREFERENCEDY = 0;
- }
- nOffset = -GRREFERENCEDY * nStrideR;
- for (int32_t h = 0; h < GRH; h++) {
- if (TPGRON) {
- SLTP = pArithDecoder->DECODE(&grContext[0x0010]);
- LTP = LTP ^ SLTP;
- }
- line1 = (h > 0) ? pLine[-nStride] << 4 : 0;
+ intptr_t nOffset = -GRREFERENCEDY * nStrideR;
+ for (int32_t h = 0; h < iGRH; h++) {
+ if (TPGRON)
+ LTP = LTP ^ pArithDecoder->DECODE(&grContext[0x0010]);
+ uint32_t line1 = (h > 0) ? pLine[-nStride] << 4 : 0;
int32_t reference_h = h - GRREFERENCEDY;
FX_BOOL line1_r_ok = (reference_h > 0 && reference_h < GRHR + 1);
FX_BOOL line2_r_ok = (reference_h > -1 && reference_h < GRHR);
FX_BOOL line3_r_ok = (reference_h > -2 && reference_h < GRHR - 1);
- line1_r = line1_r_ok ? pLineR[nOffset - nStrideR] : 0;
- line2_r = line2_r_ok ? pLineR[nOffset] : 0;
- line3_r = line3_r_ok ? pLineR[nOffset + nStrideR] : 0;
- if (LTP == 0) {
- CONTEXT = (line1 & 0x1c00) | (line1_r & 0x01c0) |
- ((line2_r >> 3) & 0x0038) | ((line3_r >> 6) & 0x0007);
- for (int32_t w = 0; w < GRW; w += 8) {
- nBits = GRW - w > 8 ? 8 : GRW - w;
- if (h > 0)
+ uint32_t line1_r = line1_r_ok ? pLineR[nOffset - nStrideR] : 0;
+ uint32_t line2_r = line2_r_ok ? pLineR[nOffset] : 0;
+ uint32_t line3_r = line3_r_ok ? pLineR[nOffset + nStrideR] : 0;
+ if (!LTP) {
+ uint32_t CONTEXT = (line1 & 0x1c00) | (line1_r & 0x01c0) |
+ ((line2_r >> 3) & 0x0038) | ((line3_r >> 6) & 0x0007);
+ for (int32_t w = 0; w < iGRW; w += 8) {
+ int32_t nBits = iGRW - w > 8 ? 8 : iGRW - w;
+ if (h > 0) {
line1 = (line1 << 8) |
- (w + 8 < GRW ? pLine[-nStride + (w >> 3) + 1] << 4 : 0);
+ (w + 8 < iGRW ? pLine[-nStride + (w >> 3) + 1] << 4 : 0);
+ }
if (h > GRHR + GRREFERENCEDY + 1) {
line1_r = 0;
line2_r = 0;
line3_r = 0;
} else {
- if (line1_r_ok)
+ if (line1_r_ok) {
line1_r =
(line1_r << 8) |
(w + 8 < GRWR ? pLineR[nOffset - nStrideR + (w >> 3) + 1] : 0);
- if (line2_r_ok)
+ }
+ if (line2_r_ok) {
line2_r = (line2_r << 8) |
(w + 8 < GRWR ? pLineR[nOffset + (w >> 3) + 1] : 0);
+ }
if (line3_r_ok) {
line3_r =
(line3_r << 8) |
@@ -218,9 +211,9 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt(
line3_r = 0;
}
}
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 0; k < nBits; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
cVal |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x0cdb) << 1) | (bVal << 9) |
((line1 >> (7 - k)) & 0x0400) |
@@ -231,20 +224,23 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt(
pLine[w >> 3] = cVal;
}
} else {
- CONTEXT = (line1 & 0x1c00) | (line1_r & 0x01c0) |
- ((line2_r >> 3) & 0x0038) | ((line3_r >> 6) & 0x0007);
- for (int32_t w = 0; w < GRW; w += 8) {
- nBits = GRW - w > 8 ? 8 : GRW - w;
- if (h > 0)
+ uint32_t CONTEXT = (line1 & 0x1c00) | (line1_r & 0x01c0) |
+ ((line2_r >> 3) & 0x0038) | ((line3_r >> 6) & 0x0007);
+ for (int32_t w = 0; w < iGRW; w += 8) {
+ int32_t nBits = iGRW - w > 8 ? 8 : iGRW - w;
+ if (h > 0) {
line1 = (line1 << 8) |
- (w + 8 < GRW ? pLine[-nStride + (w >> 3) + 1] << 4 : 0);
- if (line1_r_ok)
+ (w + 8 < iGRW ? pLine[-nStride + (w >> 3) + 1] << 4 : 0);
+ }
+ if (line1_r_ok) {
line1_r =
(line1_r << 8) |
(w + 8 < GRWR ? pLineR[nOffset - nStrideR + (w >> 3) + 1] : 0);
- if (line2_r_ok)
+ }
+ if (line2_r_ok) {
line2_r = (line2_r << 8) |
(w + 8 < GRWR ? pLineR[nOffset + (w >> 3) + 1] : 0);
+ }
if (line3_r_ok) {
line3_r =
(line3_r << 8) |
@@ -252,9 +248,9 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt(
} else {
line3_r = 0;
}
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- bVal = GRREFERENCE->getPixel(w + k, h);
+ uint8_t cVal = 0;
+ for (int32_t k = 0; k < nBits; k++) {
+ FX_BOOL bVal = GRREFERENCE->getPixel(w + k, h);
if (!(TPGRON && (bVal == GRREFERENCE->getPixel(w + k - 1, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w + k, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w + k + 1, h - 1)) &&
@@ -286,37 +282,35 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template0_opt(
CJBig2_Image* CJBig2_GRRDProc::decode_Template1_unopt(
CJBig2_ArithDecoder* pArithDecoder,
JBig2ArithCtx* grContext) {
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line2, line3, line4, line5;
- LTP = 0;
+ FX_BOOL LTP = FALSE;
std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
GRREG->fill(0);
for (uint32_t h = 0; h < GRH; h++) {
- if (TPGRON) {
- SLTP = pArithDecoder->DECODE(&grContext[0x0008]);
- LTP = LTP ^ SLTP;
- }
- if (LTP == 0) {
- line1 = GRREG->getPixel(1, h - 1);
+ if (TPGRON)
+ LTP = LTP ^ pArithDecoder->DECODE(&grContext[0x0008]);
+ if (!LTP) {
+ uint32_t line1 = GRREG->getPixel(1, h - 1);
line1 |= GRREG->getPixel(0, h - 1) << 1;
line1 |= GRREG->getPixel(-1, h - 1) << 2;
- line2 = 0;
- line3 = GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY - 1);
- line4 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
+ uint32_t line2 = 0;
+ uint32_t line3 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY - 1);
+ uint32_t line4 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY) << 1;
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX - 1, h - GRREFERENCEDY)
<< 2;
- line5 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
+ uint32_t line5 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
line5 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY + 1)
<< 1;
for (uint32_t w = 0; w < GRW; w++) {
- CONTEXT = line5;
+ uint32_t CONTEXT = line5;
CONTEXT |= line4 << 2;
CONTEXT |= line3 << 5;
CONTEXT |= line2 << 6;
CONTEXT |= line1 << 7;
- bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
+ FX_BOOL bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
GRREG->setPixel(w, h, bVal);
line1 = ((line1 << 1) | GRREG->getPixel(w + 2, h - 1)) & 0x07;
line2 = ((line2 << 1) | bVal) & 0x01;
@@ -334,20 +328,23 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_unopt(
0x03;
}
} else {
- line1 = GRREG->getPixel(1, h - 1);
+ uint32_t line1 = GRREG->getPixel(1, h - 1);
line1 |= GRREG->getPixel(0, h - 1) << 1;
line1 |= GRREG->getPixel(-1, h - 1) << 2;
- line2 = 0;
- line3 = GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY - 1);
- line4 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
+ uint32_t line2 = 0;
+ uint32_t line3 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY - 1);
+ uint32_t line4 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY);
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY) << 1;
line4 |= GRREFERENCE->getPixel(-GRREFERENCEDX - 1, h - GRREFERENCEDY)
<< 2;
- line5 = GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
+ uint32_t line5 =
+ GRREFERENCE->getPixel(-GRREFERENCEDX + 1, h - GRREFERENCEDY + 1);
line5 |= GRREFERENCE->getPixel(-GRREFERENCEDX, h - GRREFERENCEDY + 1)
<< 1;
for (uint32_t w = 0; w < GRW; w++) {
- bVal = GRREFERENCE->getPixel(w, h);
+ FX_BOOL bVal = GRREFERENCE->getPixel(w, h);
if (!(TPGRON && (bVal == GRREFERENCE->getPixel(w - 1, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w + 1, h - 1)) &&
@@ -356,7 +353,7 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_unopt(
(bVal == GRREFERENCE->getPixel(w - 1, h + 1)) &&
(bVal == GRREFERENCE->getPixel(w, h + 1)) &&
(bVal == GRREFERENCE->getPixel(w + 1, h + 1)))) {
- CONTEXT = line5;
+ uint32_t CONTEXT = line5;
CONTEXT |= line4 << 2;
CONTEXT |= line3 << 5;
CONTEXT |= line2 << 6;
@@ -390,52 +387,42 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt(
if (!GRREFERENCE->m_pData)
return nullptr;
- FX_BOOL LTP, SLTP, bVal;
- uint32_t CONTEXT;
- uint32_t line1, line1_r, line2_r, line3_r;
- uint8_t *pLine, *pLineR, cVal;
- intptr_t nStride, nStrideR, nOffset;
- int32_t k, nBits;
- int32_t GRWR, GRHR;
- int32_t GRW, GRH;
- GRW = (int32_t)CJBig2_GRRDProc::GRW;
- GRH = (int32_t)CJBig2_GRRDProc::GRH;
- LTP = 0;
- std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(GRW, GRH));
+ int32_t iGRW = static_cast<int32_t>(GRW);
+ int32_t iGRH = static_cast<int32_t>(GRH);
+ std::unique_ptr<CJBig2_Image> GRREG(new CJBig2_Image(iGRW, iGRH));
if (!GRREG->m_pData)
return nullptr;
- pLine = GRREG->m_pData;
- pLineR = GRREFERENCE->m_pData;
- nStride = GRREG->m_nStride;
- nStrideR = GRREFERENCE->m_nStride;
- GRWR = (int32_t)GRREFERENCE->m_nWidth;
- GRHR = (int32_t)GRREFERENCE->m_nHeight;
+ FX_BOOL LTP = FALSE;
+ uint8_t* pLine = GRREG->m_pData;
+ uint8_t* pLineR = GRREFERENCE->m_pData;
+ intptr_t nStride = GRREG->m_nStride;
+ intptr_t nStrideR = GRREFERENCE->m_nStride;
+ int32_t GRWR = GRREFERENCE->m_nWidth;
+ int32_t GRHR = GRREFERENCE->m_nHeight;
if (GRREFERENCEDY < -GRHR + 1 || GRREFERENCEDY > GRHR - 1) {
GRREFERENCEDY = 0;
}
- nOffset = -GRREFERENCEDY * nStrideR;
- for (int32_t h = 0; h < GRH; h++) {
- if (TPGRON) {
- SLTP = pArithDecoder->DECODE(&grContext[0x0008]);
- LTP = LTP ^ SLTP;
- }
- line1 = (h > 0) ? pLine[-nStride] << 1 : 0;
+ intptr_t nOffset = -GRREFERENCEDY * nStrideR;
+ for (int32_t h = 0; h < iGRH; h++) {
+ if (TPGRON)
+ LTP = LTP ^ pArithDecoder->DECODE(&grContext[0x0008]);
+ uint32_t line1 = (h > 0) ? pLine[-nStride] << 1 : 0;
int32_t reference_h = h - GRREFERENCEDY;
FX_BOOL line1_r_ok = (reference_h > 0 && reference_h < GRHR + 1);
FX_BOOL line2_r_ok = (reference_h > -1 && reference_h < GRHR);
FX_BOOL line3_r_ok = (reference_h > -2 && reference_h < GRHR - 1);
- line1_r = line1_r_ok ? pLineR[nOffset - nStrideR] : 0;
- line2_r = line2_r_ok ? pLineR[nOffset] : 0;
- line3_r = line3_r_ok ? pLineR[nOffset + nStrideR] : 0;
- if (LTP == 0) {
- CONTEXT = (line1 & 0x0380) | ((line1_r >> 2) & 0x0020) |
- ((line2_r >> 4) & 0x001c) | ((line3_r >> 6) & 0x0003);
- for (int32_t w = 0; w < GRW; w += 8) {
- nBits = GRW - w > 8 ? 8 : GRW - w;
+ uint32_t line1_r = line1_r_ok ? pLineR[nOffset - nStrideR] : 0;
+ uint32_t line2_r = line2_r_ok ? pLineR[nOffset] : 0;
+ uint32_t line3_r = line3_r_ok ? pLineR[nOffset + nStrideR] : 0;
+ if (!LTP) {
+ uint32_t CONTEXT = (line1 & 0x0380) | ((line1_r >> 2) & 0x0020) |
+ ((line2_r >> 4) & 0x001c) | ((line3_r >> 6) & 0x0003);
+ for (int32_t w = 0; w < iGRW; w += 8) {
+ int32_t nBits = iGRW - w > 8 ? 8 : iGRW - w;
if (h > 0)
line1 = (line1 << 8) |
- (w + 8 < GRW ? pLine[-nStride + (w >> 3) + 1] << 1 : 0);
+ (w + 8 < iGRW ? pLine[-nStride + (w >> 3) + 1] << 1 : 0);
if (line1_r_ok)
line1_r =
(line1_r << 8) |
@@ -450,9 +437,9 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt(
} else {
line3_r = 0;
}
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
+ uint8_t cVal = 0;
+ for (int32_t k = 0; k < nBits; k++) {
+ FX_BOOL bVal = pArithDecoder->DECODE(&grContext[CONTEXT]);
cVal |= bVal << (7 - k);
CONTEXT = ((CONTEXT & 0x018d) << 1) | (bVal << 6) |
((line1 >> (7 - k)) & 0x0080) |
@@ -463,13 +450,13 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt(
pLine[w >> 3] = cVal;
}
} else {
- CONTEXT = (line1 & 0x0380) | ((line1_r >> 2) & 0x0020) |
- ((line2_r >> 4) & 0x001c) | ((line3_r >> 6) & 0x0003);
- for (int32_t w = 0; w < GRW; w += 8) {
- nBits = GRW - w > 8 ? 8 : GRW - w;
+ uint32_t CONTEXT = (line1 & 0x0380) | ((line1_r >> 2) & 0x0020) |
+ ((line2_r >> 4) & 0x001c) | ((line3_r >> 6) & 0x0003);
+ for (int32_t w = 0; w < iGRW; w += 8) {
+ int32_t nBits = iGRW - w > 8 ? 8 : iGRW - w;
if (h > 0)
line1 = (line1 << 8) |
- (w + 8 < GRW ? pLine[-nStride + (w >> 3) + 1] << 1 : 0);
+ (w + 8 < iGRW ? pLine[-nStride + (w >> 3) + 1] << 1 : 0);
if (line1_r_ok)
line1_r =
(line1_r << 8) |
@@ -484,9 +471,9 @@ CJBig2_Image* CJBig2_GRRDProc::decode_Template1_opt(
} else {
line3_r = 0;
}
- cVal = 0;
- for (k = 0; k < nBits; k++) {
- bVal = GRREFERENCE->getPixel(w + k, h);
+ uint8_t cVal = 0;
+ for (int32_t k = 0; k < nBits; k++) {
+ FX_BOOL bVal = GRREFERENCE->getPixel(w + k, h);
if (!(TPGRON && (bVal == GRREFERENCE->getPixel(w + k - 1, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w + k, h - 1)) &&
(bVal == GRREFERENCE->getPixel(w + k + 1, h - 1)) &&