OLD | NEW |
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 // Original code is licensed as follows: | 6 // Original code is licensed as follows: |
7 /* | 7 /* |
8 * Copyright 2006 Jeremias Maerki. | 8 * Copyright 2006 Jeremias Maerki. |
9 * | 9 * |
10 * Licensed under the Apache License, Version 2.0 (the "License"); | 10 * Licensed under the Apache License, Version 2.0 (the "License"); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 for (int32_t i = 0; i < sizeof(FACTOR_SETS) / sizeof(int32_t); i++) { | 176 for (int32_t i = 0; i < sizeof(FACTOR_SETS) / sizeof(int32_t); i++) { |
177 if (FACTOR_SETS[i] == numECWords) { | 177 if (FACTOR_SETS[i] == numECWords) { |
178 table = i; | 178 table = i; |
179 break; | 179 break; |
180 } | 180 } |
181 } | 181 } |
182 if (table < 0) { | 182 if (table < 0) { |
183 e = BCExceptionIllegalArgument; | 183 e = BCExceptionIllegalArgument; |
184 return (FX_WCHAR*)""; | 184 return (FX_WCHAR*)""; |
185 } | 185 } |
186 FX_WORD* ecc = FX_Alloc(FX_WORD, numECWords); | 186 uint16_t* ecc = FX_Alloc(uint16_t, numECWords); |
187 FXSYS_memset(ecc, 0, numECWords * sizeof(FX_WORD)); | 187 FXSYS_memset(ecc, 0, numECWords * sizeof(uint16_t)); |
188 for (int32_t l = start; l < start + len; l++) { | 188 for (int32_t l = start; l < start + len; l++) { |
189 FX_WORD m = ecc[numECWords - 1] ^ codewords.GetAt(l); | 189 uint16_t m = ecc[numECWords - 1] ^ codewords.GetAt(l); |
190 for (int32_t k = numECWords - 1; k > 0; k--) { | 190 for (int32_t k = numECWords - 1; k > 0; k--) { |
191 if (m != 0 && FACTORS[table][k] != 0) { | 191 if (m != 0 && FACTORS[table][k] != 0) { |
192 ecc[k] = (FX_WORD)(ecc[k - 1] ^ | 192 ecc[k] = (uint16_t)(ecc[k - 1] ^ |
193 ALOG[(LOG[m] + LOG[FACTORS[table][k]]) % 255]); | 193 ALOG[(LOG[m] + LOG[FACTORS[table][k]]) % 255]); |
194 } else { | 194 } else { |
195 ecc[k] = ecc[k - 1]; | 195 ecc[k] = ecc[k - 1]; |
196 } | 196 } |
197 } | 197 } |
198 if (m != 0 && FACTORS[table][0] != 0) { | 198 if (m != 0 && FACTORS[table][0] != 0) { |
199 ecc[0] = (FX_WORD)ALOG[(LOG[m] + LOG[FACTORS[table][0]]) % 255]; | 199 ecc[0] = (uint16_t)ALOG[(LOG[m] + LOG[FACTORS[table][0]]) % 255]; |
200 } else { | 200 } else { |
201 ecc[0] = 0; | 201 ecc[0] = 0; |
202 } | 202 } |
203 } | 203 } |
204 CFX_WideString strecc; | 204 CFX_WideString strecc; |
205 for (int32_t j = 0; j < numECWords; j++) { | 205 for (int32_t j = 0; j < numECWords; j++) { |
206 strecc += (FX_WCHAR)ecc[numECWords - j - 1]; | 206 strecc += (FX_WCHAR)ecc[numECWords - j - 1]; |
207 } | 207 } |
208 FX_Free(ecc); | 208 FX_Free(ecc); |
209 return strecc; | 209 return strecc; |
210 } | 210 } |
OLD | NEW |