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

Side by Side Diff: core/src/fxcodec/jbig2/JBig2_HuffmanTable.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
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanTable.h ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_HuffmanTable.h" 7 #include "JBig2_HuffmanTable.h"
8 8
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 17 matching lines...) Expand all
28 28
29 CJBig2_HuffmanTable::~CJBig2_HuffmanTable() { 29 CJBig2_HuffmanTable::~CJBig2_HuffmanTable() {
30 FX_Free(CODES); 30 FX_Free(CODES);
31 FX_Free(PREFLEN); 31 FX_Free(PREFLEN);
32 FX_Free(RANGELEN); 32 FX_Free(RANGELEN);
33 FX_Free(RANGELOW); 33 FX_Free(RANGELOW);
34 } 34 }
35 void CJBig2_HuffmanTable::init() { 35 void CJBig2_HuffmanTable::init() {
36 HTOOB = FALSE; 36 HTOOB = FALSE;
37 NTEMP = 0; 37 NTEMP = 0;
38 CODES = NULL; 38 CODES = nullptr;
39 PREFLEN = NULL; 39 PREFLEN = nullptr;
40 RANGELEN = NULL; 40 RANGELEN = nullptr;
41 RANGELOW = NULL; 41 RANGELOW = nullptr;
42 } 42 }
43 int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable, 43 int CJBig2_HuffmanTable::parseFromStandardTable(const JBig2TableLine* pTable,
44 int nLines, 44 int nLines,
45 FX_BOOL bHTOOB) { 45 FX_BOOL bHTOOB) {
46 int CURLEN, LENMAX, CURCODE, CURTEMP;
47 int* LENCOUNT;
48 int* FIRSTCODE;
49 HTOOB = bHTOOB; 46 HTOOB = bHTOOB;
50 NTEMP = nLines; 47 NTEMP = nLines;
51 CODES = FX_Alloc(int, NTEMP); 48 CODES = FX_Alloc(int, NTEMP);
52 PREFLEN = FX_Alloc(int, NTEMP); 49 PREFLEN = FX_Alloc(int, NTEMP);
53 RANGELEN = FX_Alloc(int, NTEMP); 50 RANGELEN = FX_Alloc(int, NTEMP);
54 RANGELOW = FX_Alloc(int, NTEMP); 51 RANGELOW = FX_Alloc(int, NTEMP);
55 LENMAX = 0; 52 int LENMAX = 0;
56 for (int i = 0; i < NTEMP; i++) { 53 for (FX_DWORD i = 0; i < NTEMP; ++i) {
57 PREFLEN[i] = pTable[i].PREFLEN; 54 PREFLEN[i] = pTable[i].PREFLEN;
58 RANGELEN[i] = pTable[i].RANDELEN; 55 RANGELEN[i] = pTable[i].RANDELEN;
59 RANGELOW[i] = pTable[i].RANGELOW; 56 RANGELOW[i] = pTable[i].RANGELOW;
60 if (PREFLEN[i] > LENMAX) { 57 if (PREFLEN[i] > LENMAX) {
61 LENMAX = PREFLEN[i]; 58 LENMAX = PREFLEN[i];
62 } 59 }
63 } 60 }
64 LENCOUNT = FX_Alloc(int, LENMAX + 1); 61 int* LENCOUNT = FX_Alloc(int, LENMAX + 1);
65 JBIG2_memset(LENCOUNT, 0, sizeof(int) * (LENMAX + 1)); 62 JBIG2_memset(LENCOUNT, 0, sizeof(int) * (LENMAX + 1));
66 FIRSTCODE = FX_Alloc(int, LENMAX + 1); 63 int* FIRSTCODE = FX_Alloc(int, LENMAX + 1);
67 for (int i = 0; i < NTEMP; i++) { 64 for (FX_DWORD i = 0; i < NTEMP; ++i)
68 LENCOUNT[PREFLEN[i]]++; 65 ++LENCOUNT[PREFLEN[i]];
69 } 66
70 CURLEN = 1; 67 int CURLEN = 1;
71 FIRSTCODE[0] = 0; 68 FIRSTCODE[0] = 0;
72 LENCOUNT[0] = 0; 69 LENCOUNT[0] = 0;
73 while (CURLEN <= LENMAX) { 70 while (CURLEN <= LENMAX) {
74 FIRSTCODE[CURLEN] = (FIRSTCODE[CURLEN - 1] + LENCOUNT[CURLEN - 1]) << 1; 71 FIRSTCODE[CURLEN] = (FIRSTCODE[CURLEN - 1] + LENCOUNT[CURLEN - 1]) << 1;
75 CURCODE = FIRSTCODE[CURLEN]; 72 int CURCODE = FIRSTCODE[CURLEN];
76 CURTEMP = 0; 73 FX_DWORD CURTEMP = 0;
77 while (CURTEMP < NTEMP) { 74 while (CURTEMP < NTEMP) {
78 if (PREFLEN[CURTEMP] == CURLEN) { 75 if (PREFLEN[CURTEMP] == CURLEN) {
79 CODES[CURTEMP] = CURCODE; 76 CODES[CURTEMP] = CURCODE;
80 CURCODE = CURCODE + 1; 77 CURCODE = CURCODE + 1;
81 } 78 }
82 CURTEMP = CURTEMP + 1; 79 CURTEMP = CURTEMP + 1;
83 } 80 }
84 CURLEN = CURLEN + 1; 81 CURLEN = CURLEN + 1;
85 } 82 }
86 FX_Free(LENCOUNT); 83 FX_Free(LENCOUNT);
(...skipping 15 matching lines...) Expand all
102 99
103 HTOOB = cTemp & 0x01; 100 HTOOB = cTemp & 0x01;
104 unsigned char HTPS = ((cTemp >> 1) & 0x07) + 1; 101 unsigned char HTPS = ((cTemp >> 1) & 0x07) + 1;
105 unsigned char HTRS = ((cTemp >> 4) & 0x07) + 1; 102 unsigned char HTRS = ((cTemp >> 4) & 0x07) + 1;
106 FX_DWORD HTLOW; 103 FX_DWORD HTLOW;
107 FX_DWORD HTHIGH; 104 FX_DWORD HTHIGH;
108 if (pStream->readInteger(&HTLOW) == -1 || 105 if (pStream->readInteger(&HTLOW) == -1 ||
109 pStream->readInteger(&HTHIGH) == -1 || HTLOW > HTHIGH) { 106 pStream->readInteger(&HTHIGH) == -1 || HTLOW > HTHIGH) {
110 return FALSE; 107 return FALSE;
111 } 108 }
109
112 FX_DWORD nSize = 16; 110 FX_DWORD nSize = 16;
113 PREFLEN = FX_Alloc(int, nSize); 111 PREFLEN = FX_Alloc(int, nSize);
114 RANGELEN = FX_Alloc(int, nSize); 112 RANGELEN = FX_Alloc(int, nSize);
115 RANGELOW = FX_Alloc(int, nSize); 113 RANGELOW = FX_Alloc(int, nSize);
116 FX_DWORD CURRANGELOW = HTLOW; 114 FX_DWORD CURRANGELOW = HTLOW;
117 NTEMP = 0; 115 NTEMP = 0;
118 do { 116 do {
119 HT_CHECK_MEMORY_ADJUST 117 HT_CHECK_MEMORY_ADJUST
120 if ((pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) || 118 if ((pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) ||
121 (pStream->readNBits(HTRS, &RANGELEN[NTEMP]) == -1)) { 119 (pStream->readNBits(HTRS, &RANGELEN[NTEMP]) == -1)) {
122 return FALSE; 120 return FALSE;
123 } 121 }
124 RANGELOW[NTEMP] = CURRANGELOW; 122 RANGELOW[NTEMP] = CURRANGELOW;
125 CURRANGELOW = CURRANGELOW + (1 << RANGELEN[NTEMP]); 123 CURRANGELOW = CURRANGELOW + (1 << RANGELEN[NTEMP]);
126 NTEMP = NTEMP + 1; 124 NTEMP = NTEMP + 1;
127 } while (CURRANGELOW < HTHIGH); 125 } while (CURRANGELOW < HTHIGH);
128 HT_CHECK_MEMORY_ADJUST 126 HT_CHECK_MEMORY_ADJUST
129 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) 127 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1)
130 return FALSE; 128 return FALSE;
131 129
132 RANGELEN[NTEMP] = 32; 130 RANGELEN[NTEMP] = 32;
133 RANGELOW[NTEMP] = HTLOW - 1; 131 RANGELOW[NTEMP] = HTLOW - 1;
134 NTEMP = NTEMP + 1; 132 ++NTEMP;
135 HT_CHECK_MEMORY_ADJUST 133 HT_CHECK_MEMORY_ADJUST
136 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) 134 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1)
137 return FALSE; 135 return FALSE;
138 136
139 RANGELEN[NTEMP] = 32; 137 RANGELEN[NTEMP] = 32;
140 RANGELOW[NTEMP] = HTHIGH; 138 RANGELOW[NTEMP] = HTHIGH;
141 NTEMP = NTEMP + 1; 139 NTEMP = NTEMP + 1;
142 if (HTOOB) { 140 if (HTOOB) {
143 HT_CHECK_MEMORY_ADJUST 141 HT_CHECK_MEMORY_ADJUST
144 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1) 142 if (pStream->readNBits(HTPS, &PREFLEN[NTEMP]) == -1)
145 return FALSE; 143 return FALSE;
146 NTEMP = NTEMP + 1; 144
145 ++NTEMP;
147 } 146 }
148 CODES = FX_Alloc(int, NTEMP); 147 CODES = FX_Alloc(int, NTEMP);
149 int LENMAX = 0; 148 int LENMAX = 0;
150 for (int i = 0; i < NTEMP; i++) { 149 for (FX_DWORD i = 0; i < NTEMP; ++i) {
151 if (PREFLEN[i] > LENMAX) { 150 if (PREFLEN[i] > LENMAX) {
152 LENMAX = PREFLEN[i]; 151 LENMAX = PREFLEN[i];
153 } 152 }
154 } 153 }
155 154
156 std::vector<int> LENCOUNT(LENMAX + 1); 155 std::vector<int> LENCOUNT(LENMAX + 1);
157 for (int i = 0; i < NTEMP; ++i) 156 for (FX_DWORD i = 0; i < NTEMP; ++i)
158 LENCOUNT[PREFLEN[i]]++; 157 LENCOUNT[PREFLEN[i]]++;
159 LENCOUNT[0] = 0; 158 LENCOUNT[0] = 0;
160 159
161 std::vector<int> FIRSTCODE(LENMAX + 1); 160 std::vector<int> FIRSTCODE(LENMAX + 1);
162 FIRSTCODE[0] = 0; 161 FIRSTCODE[0] = 0;
163 for (int i = 0; i <= LENMAX; ++i) { 162 for (int i = 0; i <= LENMAX; ++i) {
164 FIRSTCODE[i] = (FIRSTCODE[i - 1] + LENCOUNT[i - 1]) << 1; 163 FIRSTCODE[i] = (FIRSTCODE[i - 1] + LENCOUNT[i - 1]) << 1;
165 int CURCODE = FIRSTCODE[i]; 164 int CURCODE = FIRSTCODE[i];
166 for (int j = 0; j < NTEMP; ++j) { 165 for (FX_DWORD j = 0; j < NTEMP; ++j) {
167 if (PREFLEN[j] == i) 166 if (PREFLEN[j] == i)
168 CODES[j] = CURCODE++; 167 CODES[j] = CURCODE++;
169 } 168 }
170 } 169 }
171 return TRUE; 170 return TRUE;
172 } 171 }
OLDNEW
« no previous file with comments | « core/src/fxcodec/jbig2/JBig2_HuffmanTable.h ('k') | core/src/fxge/ge/fx_ge_linux.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698