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

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: 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 CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream) { 8 CJBig2_HuffmanDecoder::CJBig2_HuffmanDecoder(CJBig2_BitStream* pStream)
9 m_pStream = pStream; 9 : m_pStream(pStream) {
10 } 10 }
11
11 CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder() {} 12 CJBig2_HuffmanDecoder::~CJBig2_HuffmanDecoder() {}
13
12 int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable, 14 int CJBig2_HuffmanDecoder::decodeAValue(CJBig2_HuffmanTable* pTable,
13 int* nResult) { 15 int* nResult) {
14 int i;
15 int nVal = 0; 16 int nVal = 0;
16 int nBits = 0; 17 int nBits = 0;
17 FX_DWORD nTmp;
18 while (1) { 18 while (1) {
19 if (m_pStream->read1Bit(&nTmp) == -1) { 19 FX_DWORD nTmp;
20 if (m_pStream->read1Bit(&nTmp) == -1)
20 return -1; 21 return -1;
21 } 22
22 nVal = (nVal << 1) | nTmp; 23 nVal = (nVal << 1) | nTmp;
23 nBits++; 24 ++nBits;
24 for (i = 0; i < pTable->NTEMP; i++) { 25 for (FX_DWORD i = 0; i < pTable->NTEMP; ++i) {
25 if ((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) { 26 if ((pTable->PREFLEN[i] == nBits) && (pTable->CODES[i] == nVal)) {
26 if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1)) { 27 if ((pTable->HTOOB == 1) && (i == pTable->NTEMP - 1))
27 return JBIG2_OOB; 28 return JBIG2_OOB;
29
30 if (m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1)
31 return -1;
32
33 if (pTable->HTOOB) {
34 if (i == pTable->NTEMP - 3)
35 *nResult = pTable->RANGELOW[i] - nTmp;
36 else
37 *nResult = pTable->RANGELOW[i] + nTmp;
38 return 0;
28 } 39 }
29 if (m_pStream->readNBits(pTable->RANGELEN[i], &nTmp) == -1) { 40
30 return -1; 41 if (i == pTable->NTEMP - 2)
31 } 42 *nResult = pTable->RANGELOW[i] - nTmp;
32 if (pTable->HTOOB) { 43 else
33 if (i == pTable->NTEMP - 3) { 44 *nResult = pTable->RANGELOW[i] + nTmp;
34 *nResult = pTable->RANGELOW[i] - nTmp; 45 return 0;
35 return 0;
36 } else {
37 *nResult = pTable->RANGELOW[i] + nTmp;
38 return 0;
39 }
40 } else {
41 if (i == pTable->NTEMP - 2) {
42 *nResult = pTable->RANGELOW[i] - nTmp;
43 return 0;
44 } else {
45 *nResult = pTable->RANGELOW[i] + nTmp;
46 return 0;
47 }
48 }
49 } 46 }
50 } 47 }
51 } 48 }
52 return -2; 49 return -2;
53 } 50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698