Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(587)

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.cpp

Issue 1319713003: Make a bunch of JBig2 classes independent of CJBig2_Object. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: more Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "JBig2_ArithIntDecoder.h" 7 #include "JBig2_ArithIntDecoder.h"
8
9 #include "../../../include/fxcrt/fx_memory.h"
10
8 CJBig2_ArithIntDecoder::CJBig2_ArithIntDecoder() { 11 CJBig2_ArithIntDecoder::CJBig2_ArithIntDecoder() {
9 IAx = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), 512); 12 IAx = (JBig2ArithCtx*)FX_AllocOrDie(sizeof(JBig2ArithCtx), 512);
10 JBIG2_memset(IAx, 0, sizeof(JBig2ArithCtx) * 512); 13 JBIG2_memset(IAx, 0, sizeof(JBig2ArithCtx) * 512);
11 } 14 }
12 CJBig2_ArithIntDecoder::~CJBig2_ArithIntDecoder() { 15 CJBig2_ArithIntDecoder::~CJBig2_ArithIntDecoder() {
13 m_pModule->JBig2_Free(IAx); 16 FX_Free(IAx);
14 } 17 }
15 int CJBig2_ArithIntDecoder::decode(CJBig2_ArithDecoder* pArithDecoder, 18 int CJBig2_ArithIntDecoder::decode(CJBig2_ArithDecoder* pArithDecoder,
16 int* nResult) { 19 int* nResult) {
17 int PREV, V; 20 int PREV, V;
18 int S, D; 21 int S, D;
19 int nNeedBits, nTemp, i; 22 int nNeedBits, nTemp, i;
20 PREV = 1; 23 PREV = 1;
21 S = pArithDecoder->DECODE(IAx + PREV); 24 S = pArithDecoder->DECODE(IAx + PREV);
22 PREV = (PREV << 1) | S; 25 PREV = (PREV << 1) | S;
23 D = pArithDecoder->DECODE(IAx + PREV); 26 D = pArithDecoder->DECODE(IAx + PREV);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 V = -V; 75 V = -V;
73 } 76 }
74 *nResult = V; 77 *nResult = V;
75 if (S == 1 && V == 0) { 78 if (S == 1 && V == 0) {
76 return JBIG2_OOB; 79 return JBIG2_OOB;
77 } 80 }
78 return 0; 81 return 0;
79 } 82 }
80 CJBig2_ArithIaidDecoder::CJBig2_ArithIaidDecoder(unsigned char SBSYMCODELENA) { 83 CJBig2_ArithIaidDecoder::CJBig2_ArithIaidDecoder(unsigned char SBSYMCODELENA) {
81 SBSYMCODELEN = SBSYMCODELENA; 84 SBSYMCODELEN = SBSYMCODELENA;
82 IAID = (JBig2ArithCtx*)m_pModule->JBig2_Malloc2(sizeof(JBig2ArithCtx), 85 IAID =
83 (1 << SBSYMCODELEN)); 86 (JBig2ArithCtx*)FX_AllocOrDie(sizeof(JBig2ArithCtx), (1 << SBSYMCODELEN));
84 JBIG2_memset(IAID, 0, sizeof(JBig2ArithCtx) * (int)(1 << SBSYMCODELEN)); 87 JBIG2_memset(IAID, 0, sizeof(JBig2ArithCtx) * (int)(1 << SBSYMCODELEN));
85 } 88 }
86 CJBig2_ArithIaidDecoder::~CJBig2_ArithIaidDecoder() { 89 CJBig2_ArithIaidDecoder::~CJBig2_ArithIaidDecoder() {
87 m_pModule->JBig2_Free(IAID); 90 FX_Free(IAID);
88 } 91 }
89 int CJBig2_ArithIaidDecoder::decode(CJBig2_ArithDecoder* pArithDecoder, 92 int CJBig2_ArithIaidDecoder::decode(CJBig2_ArithDecoder* pArithDecoder,
90 int* nResult) { 93 int* nResult) {
91 int PREV; 94 int PREV;
92 int D; 95 int D;
93 int i; 96 int i;
94 PREV = 1; 97 PREV = 1;
95 for (i = 0; i < SBSYMCODELEN; i++) { 98 for (i = 0; i < SBSYMCODELEN; i++) {
96 D = pArithDecoder->DECODE(IAID + PREV); 99 D = pArithDecoder->DECODE(IAID + PREV);
97 PREV = (PREV << 1) | D; 100 PREV = (PREV << 1) | D;
98 } 101 }
99 PREV = PREV - (1 << SBSYMCODELEN); 102 PREV = PREV - (1 << SBSYMCODELEN);
100 *nResult = PREV; 103 *nResult = PREV;
101 return 0; 104 return 0;
102 } 105 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_ArithIntDecoder.h ('k') | core/src/fxcodec/jbig2/JBig2_BitStream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698