7#include "core/fxcodec/jbig2/JBig2_ArithDecoder.h"
11#include "core/fxcodec/jbig2/JBig2_BitStream.h"
12#include "third_party/base/check_op.h"
18 {0x5601, 1, 1,
true}, {0x3401, 2, 6,
false}, {0x1801, 3, 9,
false},
19 {0x0AC1, 4, 12,
false}, {0x0521, 5, 29,
false}, {0x0221, 38, 33,
false},
20 {0x5601, 7, 6,
true}, {0x5401, 8, 14,
false}, {0x4801, 9, 14,
false},
21 {0x3801, 10, 14,
false}, {0x3001, 11, 17,
false}, {0x2401, 12, 18,
false},
22 {0x1C01, 13, 20,
false}, {0x1601, 29, 21,
false}, {0x5601, 15, 14,
true},
23 {0x5401, 16, 14,
false}, {0x5101, 17, 15,
false}, {0x4801, 18, 16,
false},
24 {0x3801, 19, 17,
false}, {0x3401, 20, 18,
false}, {0x3001, 21, 19,
false},
25 {0x2801, 22, 19,
false}, {0x2401, 23, 20,
false}, {0x2201, 24, 21,
false},
26 {0x1C01, 25, 22,
false}, {0x1801, 26, 23,
false}, {0x1601, 27, 24,
false},
27 {0x1401, 28, 25,
false}, {0x1201, 29, 26,
false}, {0x1101, 30, 27,
false},
28 {0x0AC1, 31, 28,
false}, {0x09C1, 32, 29,
false}, {0x08A1, 33, 30,
false},
29 {0x0521, 34, 31,
false}, {0x0441, 35, 32,
false}, {0x02A1, 36, 33,
false},
30 {0x0221, 37, 34,
false}, {0x0141, 38, 35,
false}, {0x0111, 39, 36,
false},
31 {0x0085, 40, 37,
false}, {0x0049, 41, 38,
false}, {0x0025, 42, 39,
false},
32 {0x0015, 43, 40,
false}, {0x0009, 44, 41,
false}, {0x0005, 45, 42,
false},
33 {0x0001, 45, 43,
false}, {0x5601, 46, 46,
false}};
35const unsigned int kDefaultAValue = 0x8000;
46 DCHECK_LT(m_I,
std::size(kQeTable));
52 DCHECK_LT(m_I,
std::size(kQeTable));
58 m_B = m_pStream->getCurByte_arith();
59 m_C = (m_B ^ 0xff) << 16;
69 CHECK_LT(pCX
->I(),
std::size(kQeTable));
73 if ((m_C >> 16) < m_A) {
74 if (m_A & kDefaultAValue)
91 unsigned char B1 = m_pStream->getNextByte_arith();
96 case StreamState::kDataAvailable:
98 m_State = StreamState::kDecodingFinished;
100 case StreamState::kDecodingFinished:
102 m_State = StreamState::kLooping;
104 case StreamState::kLooping:
111 m_pStream->incByteIdx();
113 m_C = m_C + 0xfe00 - (m_B << 9);
117 m_pStream->incByteIdx();
118 m_B = m_pStream->getCurByte_arith();
119 m_C = m_C + 0xff00 - (m_B << 8);
123 if (!m_pStream->IsInBounds())
134 }
while ((m_A & kDefaultAValue) == 0);
CJBig2_ArithDecoder(CJBig2_BitStream *pStream)
int Decode(JBig2ArithCtx *pCX)
int DecodeNLPS(const JBig2ArithQe &qe)
int DecodeNMPS(const JBig2ArithQe &qe)