diff options
author | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
---|---|---|
committer | Nico Weber <thakis@chromium.org> | 2015-08-04 13:00:21 -0700 |
commit | 9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f (patch) | |
tree | c97037f398d714665aefccb6eb54d0969ad7030c /core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp | |
parent | 780cee82236d1b3b0f9b01a22424e4b8ec9a6f12 (diff) | |
download | pdfium-9d8ec5a6e37e8d1d4d4edca9040de234e2d4728f.tar.xz |
XFA: clang-format all pdfium code.
No behavior change.
Generated by:
find . -name '*.cpp' -o -name '*.h' | \
grep -E -v 'third_party|thirdparties|lpng_v163|tiff_v403' | \
xargs ../../buildtools/mac/clang-format -i
Then manually merged https://codereview.chromium.org/1269223002/
See thread "tabs vs spaces" on pdfium@googlegroups.com for discussion.
BUG=none
Diffstat (limited to 'core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp')
-rw-r--r-- | core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp | 165 |
1 files changed, 81 insertions, 84 deletions
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; } |