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

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

Issue 1356373003: Fix a bunch of sign mismatch warnings. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: fix a couple more trivial comparison warnings... maybe they got lost in the merge Created 5 years, 2 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_HuffmanDecoder.h" 7 #include "JBig2_HuffmanDecoder.h"
8 8
9 #include "JBig2_Define.h" 9 #include "JBig2_Define.h"
10 10
11 CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream) { 11 CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream)
12 m_pStream = pStream; 12 : m_pStream(pStream) {
13 } 13 }
14
14 CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder() {} 15 CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder() {}
16
15 int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable, 17 int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable,
16 int* nResult) { 18 int* nResult) {
17 int i;
18 int nVal = 0; 19 int nVal = 0;
19 int nBits = 0; 20 int nBits = 0;
20 FX_DWORD nTmp;
21 while (1) { 21 while (1) {
22 if (m_pStream->read1Bit(&nTmp) == -1) { 22 FX_DWORD nTmp;
23 if (m_pStream->read1Bit(&nTmp) == -1)
23 return -1; 24 return -1;
24 } 25
25 nVal = (nVal << 1) | nTmp; 26 nVal = (nVal << 1) | nTmp;
26 nBits++; 27 ++nBits;
27 for (i = 0; i < pTable->NTEMP; i++) { 28 for (FX_DWORD i = 0; i < pTable->NTEMP; ++i) {
28 if ((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) { 29 if ((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) {
29 if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1)) { 30 if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1))
30 return JBIG2_OOB; 31 return JBIG2_OOB;
32
33 if (m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1)
34 return -1;
35
36 if (pTable->HTOOB) {
37 if (i == pTable->NTEMP - 3)
38 *nResult = pTable->RANGELOW[i] - nTmp;
39 else
40 *nResult = pTable->RANGELOW[i] + nTmp;
41 return 0;
31 } 42 }
32 if (m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1) { 43
33 return -1; 44 if (i == pTable->NTEMP - 2)
34 } 45 *nResult = pTable->RANGELOW[i] - nTmp;
35 if (pTable->HTOOB) { 46 else
36 if (i == pTable->NTEMP - 3) { 47 *nResult = pTable->RANGELOW[i] + nTmp;
37 *nResult = pTable->RANGELOW[i] - nTmp; 48 return 0;
38 return 0;
39 } else {
40 *nResult = pTable->RANGELOW[i] + nTmp;
41 return 0;
42 }
43 } else {
44 if (i == pTable->NTEMP - 2) {
45 *nResult = pTable->RANGELOW[i] - nTmp;
46 return 0;
47 } else {
48 *nResult = pTable->RANGELOW[i] + nTmp;
49 return 0;
50 }
51 }
52 } 49 }
53 } 50 }
54 } 51 }
55 return -2; 52 return -2;
56 } 53 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanDecoder.h ('k') | core/src/fxcodec/jbig2/JBig2_HuffmanTable.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698