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 | 6 |
7 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" | 7 #include "core/fpdfapi/fpdf_parser/include/fpdf_parser_decode.h" |
8 | 8 |
9 #include <limits.h> | 9 #include <limits.h> |
10 #include <utility> | 10 #include <utility> |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 int width, | 232 int width, |
233 int height, | 233 int height, |
234 const CPDF_Dictionary* pParams) { | 234 const CPDF_Dictionary* pParams) { |
235 int K = 0; | 235 int K = 0; |
236 FX_BOOL EndOfLine = FALSE; | 236 FX_BOOL EndOfLine = FALSE; |
237 FX_BOOL ByteAlign = FALSE; | 237 FX_BOOL ByteAlign = FALSE; |
238 FX_BOOL BlackIs1 = FALSE; | 238 FX_BOOL BlackIs1 = FALSE; |
239 int Columns = 1728; | 239 int Columns = 1728; |
240 int Rows = 0; | 240 int Rows = 0; |
241 if (pParams) { | 241 if (pParams) { |
242 K = pParams->GetIntegerBy("K"); | 242 K = pParams->GetIntegerFor("K"); |
243 EndOfLine = pParams->GetIntegerBy("EndOfLine"); | 243 EndOfLine = pParams->GetIntegerFor("EndOfLine"); |
244 ByteAlign = pParams->GetIntegerBy("EncodedByteAlign"); | 244 ByteAlign = pParams->GetIntegerFor("EncodedByteAlign"); |
245 BlackIs1 = pParams->GetIntegerBy("BlackIs1"); | 245 BlackIs1 = pParams->GetIntegerFor("BlackIs1"); |
246 Columns = pParams->GetIntegerBy("Columns", 1728); | 246 Columns = pParams->GetIntegerFor("Columns", 1728); |
247 Rows = pParams->GetIntegerBy("Rows"); | 247 Rows = pParams->GetIntegerFor("Rows"); |
248 if (Rows > USHRT_MAX) { | 248 if (Rows > USHRT_MAX) { |
249 Rows = 0; | 249 Rows = 0; |
250 } | 250 } |
251 if (Columns <= 0 || Rows < 0 || Columns > USHRT_MAX || Rows > USHRT_MAX) { | 251 if (Columns <= 0 || Rows < 0 || Columns > USHRT_MAX || Rows > USHRT_MAX) { |
252 return nullptr; | 252 return nullptr; |
253 } | 253 } |
254 } | 254 } |
255 return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder( | 255 return CPDF_ModuleMgr::Get()->GetFaxModule()->CreateDecoder( |
256 src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1, | 256 src_buf, src_size, width, height, K, EndOfLine, ByteAlign, BlackIs1, |
257 Columns, Rows); | 257 Columns, Rows); |
(...skipping 25 matching lines...) Expand all Loading... |
283 const uint8_t* src_buf, | 283 const uint8_t* src_buf, |
284 uint32_t src_size, | 284 uint32_t src_size, |
285 int width, | 285 int width, |
286 int height, | 286 int height, |
287 int nComps, | 287 int nComps, |
288 int bpc, | 288 int bpc, |
289 const CPDF_Dictionary* pParams) { | 289 const CPDF_Dictionary* pParams) { |
290 int predictor = 0; | 290 int predictor = 0; |
291 int Colors = 0, BitsPerComponent = 0, Columns = 0; | 291 int Colors = 0, BitsPerComponent = 0, Columns = 0; |
292 if (pParams) { | 292 if (pParams) { |
293 predictor = pParams->GetIntegerBy("Predictor"); | 293 predictor = pParams->GetIntegerFor("Predictor"); |
294 Colors = pParams->GetIntegerBy("Colors", 1); | 294 Colors = pParams->GetIntegerFor("Colors", 1); |
295 BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8); | 295 BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8); |
296 Columns = pParams->GetIntegerBy("Columns", 1); | 296 Columns = pParams->GetIntegerFor("Columns", 1); |
297 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { | 297 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { |
298 return nullptr; | 298 return nullptr; |
299 } | 299 } |
300 } | 300 } |
301 return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder( | 301 return CPDF_ModuleMgr::Get()->GetFlateModule()->CreateDecoder( |
302 src_buf, src_size, width, height, nComps, bpc, predictor, Colors, | 302 src_buf, src_size, width, height, nComps, bpc, predictor, Colors, |
303 BitsPerComponent, Columns); | 303 BitsPerComponent, Columns); |
304 } | 304 } |
305 | 305 |
306 uint32_t FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, | 306 uint32_t FPDFAPI_FlateOrLZWDecode(FX_BOOL bLZW, |
307 const uint8_t* src_buf, | 307 const uint8_t* src_buf, |
308 uint32_t src_size, | 308 uint32_t src_size, |
309 CPDF_Dictionary* pParams, | 309 CPDF_Dictionary* pParams, |
310 uint32_t estimated_size, | 310 uint32_t estimated_size, |
311 uint8_t*& dest_buf, | 311 uint8_t*& dest_buf, |
312 uint32_t& dest_size) { | 312 uint32_t& dest_size) { |
313 int predictor = 0; | 313 int predictor = 0; |
314 FX_BOOL bEarlyChange = TRUE; | 314 FX_BOOL bEarlyChange = TRUE; |
315 int Colors = 0, BitsPerComponent = 0, Columns = 0; | 315 int Colors = 0, BitsPerComponent = 0, Columns = 0; |
316 if (pParams) { | 316 if (pParams) { |
317 predictor = pParams->GetIntegerBy("Predictor"); | 317 predictor = pParams->GetIntegerFor("Predictor"); |
318 bEarlyChange = pParams->GetIntegerBy("EarlyChange", 1); | 318 bEarlyChange = pParams->GetIntegerFor("EarlyChange", 1); |
319 Colors = pParams->GetIntegerBy("Colors", 1); | 319 Colors = pParams->GetIntegerFor("Colors", 1); |
320 BitsPerComponent = pParams->GetIntegerBy("BitsPerComponent", 8); | 320 BitsPerComponent = pParams->GetIntegerFor("BitsPerComponent", 8); |
321 Columns = pParams->GetIntegerBy("Columns", 1); | 321 Columns = pParams->GetIntegerFor("Columns", 1); |
322 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { | 322 if (!CheckFlateDecodeParams(Colors, BitsPerComponent, Columns)) { |
323 return (uint32_t)-1; | 323 return (uint32_t)-1; |
324 } | 324 } |
325 } | 325 } |
326 return CPDF_ModuleMgr::Get()->GetFlateModule()->FlateOrLZWDecode( | 326 return CPDF_ModuleMgr::Get()->GetFlateModule()->FlateOrLZWDecode( |
327 bLZW, src_buf, src_size, bEarlyChange, predictor, Colors, | 327 bLZW, src_buf, src_size, bEarlyChange, predictor, Colors, |
328 BitsPerComponent, Columns, estimated_size, dest_buf, dest_size); | 328 BitsPerComponent, Columns, estimated_size, dest_buf, dest_size); |
329 } | 329 } |
330 | 330 |
331 FX_BOOL PDF_DataDecode(const uint8_t* src_buf, | 331 FX_BOOL PDF_DataDecode(const uint8_t* src_buf, |
332 uint32_t src_size, | 332 uint32_t src_size, |
333 const CPDF_Dictionary* pDict, | 333 const CPDF_Dictionary* pDict, |
334 uint8_t*& dest_buf, | 334 uint8_t*& dest_buf, |
335 uint32_t& dest_size, | 335 uint32_t& dest_size, |
336 CFX_ByteString& ImageEncoding, | 336 CFX_ByteString& ImageEncoding, |
337 CPDF_Dictionary*& pImageParms, | 337 CPDF_Dictionary*& pImageParms, |
338 uint32_t last_estimated_size, | 338 uint32_t last_estimated_size, |
339 FX_BOOL bImageAcc) { | 339 FX_BOOL bImageAcc) { |
340 CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectBy("Filter") : nullptr; | 340 CPDF_Object* pDecoder = pDict ? pDict->GetDirectObjectFor("Filter") : nullptr; |
341 if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) | 341 if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) |
342 return FALSE; | 342 return FALSE; |
343 | 343 |
344 CPDF_Object* pParams = | 344 CPDF_Object* pParams = |
345 pDict ? pDict->GetDirectObjectBy("DecodeParms") : nullptr; | 345 pDict ? pDict->GetDirectObjectFor("DecodeParms") : nullptr; |
346 | 346 |
347 std::vector<std::pair<CFX_ByteString, CPDF_Object*>> DecoderArray; | 347 std::vector<std::pair<CFX_ByteString, CPDF_Object*>> DecoderArray; |
348 if (CPDF_Array* pDecoders = pDecoder->AsArray()) { | 348 if (CPDF_Array* pDecoders = pDecoder->AsArray()) { |
349 CPDF_Array* pParamsArray = ToArray(pParams); | 349 CPDF_Array* pParamsArray = ToArray(pParams); |
350 for (size_t i = 0; i < pDecoders->GetCount(); i++) { | 350 for (size_t i = 0; i < pDecoders->GetCount(); i++) { |
351 DecoderArray.push_back( | 351 DecoderArray.push_back( |
352 {pDecoders->GetStringAt(i), | 352 {pDecoders->GetStringAt(i), |
353 pParamsArray ? pParamsArray->GetDictAt(i) : nullptr}); | 353 pParamsArray ? pParamsArray->GetDictAt(i) : nullptr}); |
354 } | 354 } |
355 } else { | 355 } else { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 uint32_t src_size, | 572 uint32_t src_size, |
573 uint8_t*& dest_buf, | 573 uint8_t*& dest_buf, |
574 uint32_t& dest_size) { | 574 uint32_t& dest_size) { |
575 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); | 575 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); |
576 if (pEncoders) { | 576 if (pEncoders) { |
577 return pEncoders->GetFlateModule()->FlateOrLZWDecode( | 577 return pEncoders->GetFlateModule()->FlateOrLZWDecode( |
578 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); | 578 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); |
579 } | 579 } |
580 return 0; | 580 return 0; |
581 } | 581 } |
OLD | NEW |