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_ArithIntDecoder.cpp | 165 +++++++++++------------ 1 file changed, 81 insertions(+), 84 deletions(-) (limited to 'core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp') diff --git a/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp b/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp index 1e115848a3..3aab2fb3e6 100644 --- a/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp +++ b/core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp @@ -1,105 +1,102 @@ // 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 #include "JBig2_ArithIntDecoder.h" -CJBig2_ArithIntDecoder::CJBig2_ArithIntDecoder() -{ - IAx = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), 512); - JBIG2_memset(IAx, 0, sizeof(JBig2ArithCtx) * 512); +CJBig2_ArithIntDecoder::CJBig2_ArithIntDecoder() { + IAx = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), 512); + JBIG2_memset(IAx, 0, sizeof(JBig2ArithCtx) * 512); } -CJBig2_ArithIntDecoder::~CJBig2_ArithIntDecoder() -{ - m_pModule->JBig2_Free(IAx); +CJBig2_ArithIntDecoder::~CJBig2_ArithIntDecoder() { + m_pModule->JBig2_Free(IAx); } -int CJBig2_ArithIntDecoder::decode(CJBig2_ArithDecoder *pArithDecoder, int *nResult) -{ - int PREV, V; - int S, D; - int nNeedBits, nTemp, i; - PREV = 1; - S = pArithDecoder->DECODE(IAx + PREV); - PREV = (PREV << 1) | S; +int CJBig2_ArithIntDecoder::decode(CJBig2_ArithDecoder* pArithDecoder, + int* nResult) { + int PREV, V; + int S, D; + int nNeedBits, nTemp, i; + PREV = 1; + S = pArithDecoder->DECODE(IAx + PREV); + PREV = (PREV << 1) | S; + D = pArithDecoder->DECODE(IAx + PREV); + PREV = (PREV << 1) | D; + if (D) { D = pArithDecoder->DECODE(IAx + PREV); PREV = (PREV << 1) | D; - if(D) { + if (D) { + D = pArithDecoder->DECODE(IAx + PREV); + PREV = (PREV << 1) | D; + if (D) { D = pArithDecoder->DECODE(IAx + PREV); PREV = (PREV << 1) | D; - if(D) { - D = pArithDecoder->DECODE(IAx + PREV); - PREV = (PREV << 1) | D; - if(D) { - D = pArithDecoder->DECODE(IAx + PREV); - PREV = (PREV << 1) | D; - if(D) { - D = pArithDecoder->DECODE(IAx + PREV); - PREV = (PREV << 1) | D; - if(D) { - nNeedBits = 32; - V = 4436; - } else { - nNeedBits = 12; - V = 340; - } - } else { - nNeedBits = 8; - V = 84; - } - } else { - nNeedBits = 6; - V = 20; - } + if (D) { + D = pArithDecoder->DECODE(IAx + PREV); + PREV = (PREV << 1) | D; + if (D) { + nNeedBits = 32; + V = 4436; + } else { + nNeedBits = 12; + V = 340; + } } else { - nNeedBits = 4; - V = 4; + nNeedBits = 8; + V = 84; } + } else { + nNeedBits = 6; + V = 20; + } } else { - nNeedBits = 2; - V = 0; - } - nTemp = 0; - for(i = 0; i < nNeedBits; i++) { - D = pArithDecoder->DECODE(IAx + PREV); - if(PREV < 256) { - PREV = (PREV << 1) | D; - } else { - PREV = (((PREV << 1) | D) & 511) | 256; - } - nTemp = (nTemp << 1) | D; - } - V += nTemp; - if(S == 1 && V > 0) { - V = -V; + nNeedBits = 4; + V = 4; } - *nResult = V; - if(S == 1 && V == 0) { - return JBIG2_OOB; + } else { + nNeedBits = 2; + V = 0; + } + nTemp = 0; + for (i = 0; i < nNeedBits; i++) { + D = pArithDecoder->DECODE(IAx + PREV); + if (PREV < 256) { + PREV = (PREV << 1) | D; + } else { + PREV = (((PREV << 1) | D) & 511) | 256; } - return 0; + nTemp = (nTemp << 1) | D; + } + V += nTemp; + if (S == 1 && V > 0) { + V = -V; + } + *nResult = V; + if (S == 1 && V == 0) { + return JBIG2_OOB; + } + return 0; } -CJBig2_ArithIaidDecoder::CJBig2_ArithIaidDecoder(unsigned char SBSYMCODELENA) -{ - SBSYMCODELEN = SBSYMCODELENA; - IAID = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), (1 << SBSYMCODELEN)); - JBIG2_memset(IAID, 0, sizeof(JBig2ArithCtx) * (int)(1 << SBSYMCODELEN)); +CJBig2_ArithIaidDecoder::CJBig2_ArithIaidDecoder(unsigned char SBSYMCODELENA) { + SBSYMCODELEN = SBSYMCODELENA; + IAID = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), + (1 << SBSYMCODELEN)); + JBIG2_memset(IAID, 0, sizeof(JBig2ArithCtx) * (int)(1 << SBSYMCODELEN)); } -CJBig2_ArithIaidDecoder::~CJBig2_ArithIaidDecoder() -{ - m_pModule->JBig2_Free(IAID); +CJBig2_ArithIaidDecoder::~CJBig2_ArithIaidDecoder() { + m_pModule->JBig2_Free(IAID); } -int CJBig2_ArithIaidDecoder::decode(CJBig2_ArithDecoder *pArithDecoder, int *nResult) -{ - int PREV; - int D; - int i; - PREV = 1; - for(i = 0; i < SBSYMCODELEN; i++) { - D = pArithDecoder->DECODE(IAID + PREV); - PREV = (PREV << 1) | D; - } - PREV = PREV - (1 << SBSYMCODELEN); - *nResult = PREV; - return 0; +int CJBig2_ArithIaidDecoder::decode(CJBig2_ArithDecoder* pArithDecoder, + int* nResult) { + int PREV; + int D; + int i; + PREV = 1; + for (i = 0; i < SBSYMCODELEN; i++) { + D = pArithDecoder->DECODE(IAID + PREV); + PREV = (PREV << 1) | D; + } + PREV = PREV - (1 << SBSYMCODELEN); + *nResult = PREV; + return 0; } -- cgit v1.2.3