summaryrefslogtreecommitdiff
path: root/core/fxcodec
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-09-17 19:15:30 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-17 19:15:30 +0000
commita828c6a9af31ccdb52189f819cd82b2f53bef38d (patch)
tree9cbc91ea33ed2c665a36ed2c6eb82f58fd574123 /core/fxcodec
parent231320c4acdcc2404e495ace6cb14f33f591b629 (diff)
downloadpdfium-a828c6a9af31ccdb52189f819cd82b2f53bef38d.tar.xz
Use more booleans within JBig2ArithCtx.
Change-Id: I41535238715926795f5c588dcae0834bf3a789d0 Reviewed-on: https://pdfium-review.googlesource.com/42606 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'core/fxcodec')
-rw-r--r--core/fxcodec/jbig2/JBig2_ArithDecoder.cpp41
-rw-r--r--core/fxcodec/jbig2/JBig2_ArithDecoder.h7
2 files changed, 24 insertions, 24 deletions
diff --git a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp
index b3a851524e..0e9304af6f 100644
--- a/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp
+++ b/core/fxcodec/jbig2/JBig2_ArithDecoder.cpp
@@ -13,22 +13,22 @@ namespace {
const JBig2ArithCtx::JBig2ArithQe kQeTable[] = {
// Stupid hack to keep clang-format from reformatting this badly.
- {0x5601, 1, 1, 1}, {0x3401, 2, 6, 0}, {0x1801, 3, 9, 0},
- {0x0AC1, 4, 12, 0}, {0x0521, 5, 29, 0}, {0x0221, 38, 33, 0},
- {0x5601, 7, 6, 1}, {0x5401, 8, 14, 0}, {0x4801, 9, 14, 0},
- {0x3801, 10, 14, 0}, {0x3001, 11, 17, 0}, {0x2401, 12, 18, 0},
- {0x1C01, 13, 20, 0}, {0x1601, 29, 21, 0}, {0x5601, 15, 14, 1},
- {0x5401, 16, 14, 0}, {0x5101, 17, 15, 0}, {0x4801, 18, 16, 0},
- {0x3801, 19, 17, 0}, {0x3401, 20, 18, 0}, {0x3001, 21, 19, 0},
- {0x2801, 22, 19, 0}, {0x2401, 23, 20, 0}, {0x2201, 24, 21, 0},
- {0x1C01, 25, 22, 0}, {0x1801, 26, 23, 0}, {0x1601, 27, 24, 0},
- {0x1401, 28, 25, 0}, {0x1201, 29, 26, 0}, {0x1101, 30, 27, 0},
- {0x0AC1, 31, 28, 0}, {0x09C1, 32, 29, 0}, {0x08A1, 33, 30, 0},
- {0x0521, 34, 31, 0}, {0x0441, 35, 32, 0}, {0x02A1, 36, 33, 0},
- {0x0221, 37, 34, 0}, {0x0141, 38, 35, 0}, {0x0111, 39, 36, 0},
- {0x0085, 40, 37, 0}, {0x0049, 41, 38, 0}, {0x0025, 42, 39, 0},
- {0x0015, 43, 40, 0}, {0x0009, 44, 41, 0}, {0x0005, 45, 42, 0},
- {0x0001, 45, 43, 0}, {0x5601, 46, 46, 0}};
+ {0x5601, 1, 1, true}, {0x3401, 2, 6, false}, {0x1801, 3, 9, false},
+ {0x0AC1, 4, 12, false}, {0x0521, 5, 29, false}, {0x0221, 38, 33, false},
+ {0x5601, 7, 6, true}, {0x5401, 8, 14, false}, {0x4801, 9, 14, false},
+ {0x3801, 10, 14, false}, {0x3001, 11, 17, false}, {0x2401, 12, 18, false},
+ {0x1C01, 13, 20, false}, {0x1601, 29, 21, false}, {0x5601, 15, 14, true},
+ {0x5401, 16, 14, false}, {0x5101, 17, 15, false}, {0x4801, 18, 16, false},
+ {0x3801, 19, 17, false}, {0x3401, 20, 18, false}, {0x3001, 21, 19, false},
+ {0x2801, 22, 19, false}, {0x2401, 23, 20, false}, {0x2201, 24, 21, false},
+ {0x1C01, 25, 22, false}, {0x1801, 26, 23, false}, {0x1601, 27, 24, false},
+ {0x1401, 28, 25, false}, {0x1201, 29, 26, false}, {0x1101, 30, 27, false},
+ {0x0AC1, 31, 28, false}, {0x09C1, 32, 29, false}, {0x08A1, 33, 30, false},
+ {0x0521, 34, 31, false}, {0x0441, 35, 32, false}, {0x02A1, 36, 33, false},
+ {0x0221, 37, 34, false}, {0x0141, 38, 35, false}, {0x0111, 39, 36, false},
+ {0x0085, 40, 37, false}, {0x0049, 41, 38, false}, {0x0025, 42, 39, false},
+ {0x0015, 43, 40, false}, {0x0009, 44, 41, false}, {0x0005, 45, 42, false},
+ {0x0001, 45, 43, false}, {0x5601, 46, 46, false}};
const unsigned int kDefaultAValue = 0x8000;
@@ -37,17 +37,16 @@ const unsigned int kDefaultAValue = 0x8000;
JBig2ArithCtx::JBig2ArithCtx() = default;
int JBig2ArithCtx::DecodeNLPS(const JBig2ArithQe& qe) {
- // TODO(thestig): |D|, |MPS| and friends probably should be booleans.
- int D = 1 - m_MPS;
- if (qe.nSwitch == 1)
- m_MPS = 1 - m_MPS;
+ bool D = !m_MPS;
+ if (qe.bSwitch)
+ m_MPS = !m_MPS;
m_I = qe.NLPS;
return D;
}
int JBig2ArithCtx::DecodeNMPS(const JBig2ArithQe& qe) {
m_I = qe.NMPS;
- return m_MPS;
+ return MPS();
}
CJBig2_ArithDecoder::CJBig2_ArithDecoder(CJBig2_BitStream* pStream)
diff --git a/core/fxcodec/jbig2/JBig2_ArithDecoder.h b/core/fxcodec/jbig2/JBig2_ArithDecoder.h
index 0a233237b2..c2fed50187 100644
--- a/core/fxcodec/jbig2/JBig2_ArithDecoder.h
+++ b/core/fxcodec/jbig2/JBig2_ArithDecoder.h
@@ -12,6 +12,7 @@
#include "core/fxcrt/unowned_ptr.h"
class CJBig2_BitStream;
+struct JBig2ArithQe;
class JBig2ArithCtx {
public:
@@ -19,7 +20,7 @@ class JBig2ArithCtx {
uint16_t Qe;
uint8_t NMPS;
uint8_t NLPS;
- uint8_t nSwitch;
+ bool bSwitch;
};
JBig2ArithCtx();
@@ -27,11 +28,11 @@ class JBig2ArithCtx {
int DecodeNLPS(const JBig2ArithQe& qe);
int DecodeNMPS(const JBig2ArithQe& qe);
- unsigned int MPS() const { return m_MPS; }
+ unsigned int MPS() const { return m_MPS ? 1 : 0; }
unsigned int I() const { return m_I; }
private:
- unsigned int m_MPS = 0;
+ bool m_MPS = 0;
unsigned int m_I = 0;
};