From b048f791a15f2da781a01eba5b09eb9d389f9c11 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 4 Aug 2015 12:19:10 -0700 Subject: clang-format all pdfium code. No behavior change. Generated by: find . -name '*.cpp' -o -name '*.h' | \ grep -E -v 'third_party|thirdparties|lpng_v163' | \ xargs ../../buildtools/mac/clang-format -i See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion. BUG=none R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1265503005 . --- core/src/fxcodec/jbig2/JBig2_ArithDecoder.h | 197 ++++++++++++++-------------- 1 file changed, 95 insertions(+), 102 deletions(-) (limited to 'core/src/fxcodec/jbig2/JBig2_ArithDecoder.h') diff --git a/core/src/fxcodec/jbig2/JBig2_ArithDecoder.h b/core/src/fxcodec/jbig2/JBig2_ArithDecoder.h index 33bbe39d0d..0258014927 100644 --- a/core/src/fxcodec/jbig2/JBig2_ArithDecoder.h +++ b/core/src/fxcodec/jbig2/JBig2_ArithDecoder.h @@ -1,7 +1,7 @@ // Copyright 2014 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. - + // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com #ifndef _JBIG2_ARITHMETIC_DECODER_H_ @@ -10,121 +10,114 @@ #include "JBig2_BitStream.h" #include "JBig2_ArithQe.h" typedef struct { - unsigned int MPS; - unsigned int I; + unsigned int MPS; + unsigned int I; } JBig2ArithCtx; -class CJBig2_ArithDecoder : public CJBig2_Object -{ -public: - - CJBig2_ArithDecoder(CJBig2_BitStream *pStream); +class CJBig2_ArithDecoder : public CJBig2_Object { + public: + CJBig2_ArithDecoder(CJBig2_BitStream* pStream); - ~CJBig2_ArithDecoder(); + ~CJBig2_ArithDecoder(); - int DECODE(JBig2ArithCtx *pCX); -private: + int DECODE(JBig2ArithCtx* pCX); - void INITDEC(); + private: + void INITDEC(); - void BYTEIN(); - unsigned char B; - unsigned int C; - unsigned int A; - unsigned int CT; - CJBig2_BitStream *m_pStream; + void BYTEIN(); + unsigned char B; + unsigned int C; + unsigned int A; + unsigned int CT; + CJBig2_BitStream* m_pStream; }; -inline CJBig2_ArithDecoder::CJBig2_ArithDecoder(CJBig2_BitStream *pStream) -{ - m_pStream = pStream; - INITDEC(); -} -inline CJBig2_ArithDecoder::~CJBig2_ArithDecoder() -{ +inline CJBig2_ArithDecoder::CJBig2_ArithDecoder(CJBig2_BitStream* pStream) { + m_pStream = pStream; + INITDEC(); } -inline void CJBig2_ArithDecoder::INITDEC() -{ - B = m_pStream->getCurByte_arith(); - C = (B ^ 0xff) << 16;; - BYTEIN(); - C = C << 7; - CT = CT - 7; - A = 0x8000; +inline CJBig2_ArithDecoder::~CJBig2_ArithDecoder() {} +inline void CJBig2_ArithDecoder::INITDEC() { + B = m_pStream->getCurByte_arith(); + C = (B ^ 0xff) << 16; + ; + BYTEIN(); + C = C << 7; + CT = CT - 7; + A = 0x8000; } -inline void CJBig2_ArithDecoder::BYTEIN() -{ - unsigned char B1; - if(B == 0xff) { - B1 = m_pStream->getNextByte_arith(); - if(B1 > 0x8f) { - CT = 8; - } else { - m_pStream->incByteIdx(); - B = B1; - C = C + 0xfe00 - (B << 9); - CT = 7; - } +inline void CJBig2_ArithDecoder::BYTEIN() { + unsigned char B1; + if (B == 0xff) { + B1 = m_pStream->getNextByte_arith(); + if (B1 > 0x8f) { + CT = 8; } else { - m_pStream->incByteIdx(); - B = m_pStream->getCurByte_arith(); - C = C + 0xff00 - (B << 8); - CT = 8; + m_pStream->incByteIdx(); + B = B1; + C = C + 0xfe00 - (B << 9); + CT = 7; } + } else { + m_pStream->incByteIdx(); + B = m_pStream->getCurByte_arith(); + C = C + 0xff00 - (B << 8); + CT = 8; + } } -inline int CJBig2_ArithDecoder::DECODE(JBig2ArithCtx *pCX) -{ - if (!pCX || pCX->I >= JBIG2_QE_NUM) { - return 0; - } +inline int CJBig2_ArithDecoder::DECODE(JBig2ArithCtx* pCX) { + if (!pCX || pCX->I >= JBIG2_QE_NUM) { + return 0; + } - int D; - const JBig2ArithQe * qe = &QeTable[pCX->I]; - A = A - qe->Qe; - if((C >> 16) < A) { - if(A & 0x8000) { - D = pCX->MPS; - } else { - if(A < qe->Qe) { - D = 1 - pCX->MPS; - if(qe->nSwitch == 1) { - pCX->MPS = 1 - pCX->MPS; - } - pCX->I = qe->NLPS; - } else { - D = pCX->MPS; - pCX->I = qe->NMPS; - } - do { - if (CT == 0) { - BYTEIN(); - } - A <<= 1; - C <<= 1; - CT--; - } while ((A & 0x8000) == 0); - } + int D; + const JBig2ArithQe* qe = &QeTable[pCX->I]; + A = A - qe->Qe; + if ((C >> 16) < A) { + if (A & 0x8000) { + D = pCX->MPS; } else { - C -= A << 16; - if(A < qe->Qe) { - A = qe->Qe; - D = pCX->MPS; - pCX->I = qe->NMPS; - } else { - A = qe->Qe; - D = 1 - pCX->MPS; - if(qe->nSwitch == 1) { - pCX->MPS = 1 - pCX->MPS; - } - pCX->I = qe->NLPS; + if (A < qe->Qe) { + D = 1 - pCX->MPS; + if (qe->nSwitch == 1) { + pCX->MPS = 1 - pCX->MPS; + } + pCX->I = qe->NLPS; + } else { + D = pCX->MPS; + pCX->I = qe->NMPS; + } + do { + if (CT == 0) { + BYTEIN(); } - do { - if (CT == 0) { - BYTEIN(); - } - A <<= 1; - C <<= 1; - CT--; - } while ((A & 0x8000) == 0); + A <<= 1; + C <<= 1; + CT--; + } while ((A & 0x8000) == 0); + } + } else { + C -= A << 16; + if (A < qe->Qe) { + A = qe->Qe; + D = pCX->MPS; + pCX->I = qe->NMPS; + } else { + A = qe->Qe; + D = 1 - pCX->MPS; + if (qe->nSwitch == 1) { + pCX->MPS = 1 - pCX->MPS; + } + pCX->I = qe->NLPS; } - return D; + do { + if (CT == 0) { + BYTEIN(); + } + A <<= 1; + C <<= 1; + CT--; + } while ((A & 0x8000) == 0); + } + return D; } #endif -- cgit v1.2.3