| 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 <limits.h> | 7 #include <limits.h> |
| 8 #include "../../../include/fpdfapi/fpdf_parser.h" | 8 #include "../../../include/fpdfapi/fpdf_parser.h" |
| 9 #include "../../../include/fpdfapi/fpdf_module.h" | 9 #include "../../../include/fpdfapi/fpdf_module.h" |
| 10 #include "../../../include/fxcodec/fx_codec.h" | 10 #include "../../../include/fxcodec/fx_codec.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 const CPDF_Dictionary* pDict, | 324 const CPDF_Dictionary* pDict, |
| 325 uint8_t*& dest_buf, | 325 uint8_t*& dest_buf, |
| 326 FX_DWORD& dest_size, | 326 FX_DWORD& dest_size, |
| 327 CFX_ByteString& ImageEncoding, | 327 CFX_ByteString& ImageEncoding, |
| 328 CPDF_Dictionary*& pImageParms, | 328 CPDF_Dictionary*& pImageParms, |
| 329 FX_DWORD last_estimated_size, | 329 FX_DWORD last_estimated_size, |
| 330 FX_BOOL bImageAcc) | 330 FX_BOOL bImageAcc) |
| 331 | 331 |
| 332 { | 332 { |
| 333 CPDF_Object* pDecoder = | 333 CPDF_Object* pDecoder = |
| 334 pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : NULL; | 334 pDict ? pDict->GetElementValue(FX_BSTRC("Filter")) : nullptr; |
| 335 if (!pDecoder || (pDecoder->GetType() != PDFOBJ_ARRAY && !pDecoder->IsName())) | 335 if (!pDecoder || (!pDecoder->IsArray() && !pDecoder->IsName())) |
| 336 return FALSE; | 336 return FALSE; |
| 337 | 337 |
| 338 CPDF_Object* pParams = | 338 CPDF_Object* pParams = |
| 339 pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : NULL; | 339 pDict ? pDict->GetElementValue(FX_BSTRC("DecodeParms")) : nullptr; |
| 340 CFX_ByteStringArray DecoderList; | 340 CFX_ByteStringArray DecoderList; |
| 341 CFX_PtrArray ParamList; | 341 CFX_PtrArray ParamList; |
| 342 if (pDecoder->GetType() == PDFOBJ_ARRAY) { | 342 if (CPDF_Array* pDecoders = pDecoder->AsArray()) { |
| 343 if (pParams && pParams->GetType() != PDFOBJ_ARRAY) { | 343 CPDF_Array* pParamsArray = ToArray(pParams); |
| 344 pParams = NULL; | 344 if (!pParamsArray) |
| 345 } | 345 pParams = nullptr; |
| 346 CPDF_Array* pDecoders = (CPDF_Array*)pDecoder; | 346 |
| 347 for (FX_DWORD i = 0; i < pDecoders->GetCount(); i++) { | 347 for (FX_DWORD i = 0; i < pDecoders->GetCount(); i++) { |
| 348 CFX_ByteStringC str = pDecoders->GetConstString(i); | 348 CFX_ByteStringC str = pDecoders->GetConstString(i); |
| 349 DecoderList.Add(str); | 349 DecoderList.Add(str); |
| 350 if (pParams) { | 350 ParamList.Add(pParams ? pParamsArray->GetDict(i) : nullptr); |
| 351 ParamList.Add(((CPDF_Array*)pParams)->GetDict(i)); | |
| 352 } else { | |
| 353 ParamList.Add(NULL); | |
| 354 } | |
| 355 } | 351 } |
| 356 } else { | 352 } else { |
| 357 DecoderList.Add(pDecoder->GetConstString()); | 353 DecoderList.Add(pDecoder->GetConstString()); |
| 358 ParamList.Add(pParams ? pParams->GetDict() : NULL); | 354 ParamList.Add(pParams ? pParams->GetDict() : nullptr); |
| 359 } | 355 } |
| 360 uint8_t* last_buf = (uint8_t*)src_buf; | 356 uint8_t* last_buf = (uint8_t*)src_buf; |
| 361 FX_DWORD last_size = src_size; | 357 FX_DWORD last_size = src_size; |
| 362 for (int i = 0; i < DecoderList.GetSize(); i++) { | 358 for (int i = 0; i < DecoderList.GetSize(); i++) { |
| 363 int estimated_size = | 359 int estimated_size = |
| 364 i == DecoderList.GetSize() - 1 ? last_estimated_size : 0; | 360 i == DecoderList.GetSize() - 1 ? last_estimated_size : 0; |
| 365 CFX_ByteString decoder = DecoderList[i]; | 361 CFX_ByteString decoder = DecoderList[i]; |
| 366 // Use ToDictionary here because we can push NULL into the ParamList. | 362 // Use ToDictionary here because we can push NULL into the ParamList. |
| 367 CPDF_Dictionary* pParam = | 363 CPDF_Dictionary* pParam = |
| 368 ToDictionary(static_cast<CPDF_Object*>(ParamList[i])); | 364 ToDictionary(static_cast<CPDF_Object*>(ParamList[i])); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 FX_DWORD src_size, | 573 FX_DWORD src_size, |
| 578 uint8_t*& dest_buf, | 574 uint8_t*& dest_buf, |
| 579 FX_DWORD& dest_size) { | 575 FX_DWORD& dest_size) { |
| 580 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); | 576 CCodec_ModuleMgr* pEncoders = CPDF_ModuleMgr::Get()->GetCodecModule(); |
| 581 if (pEncoders) { | 577 if (pEncoders) { |
| 582 return pEncoders->GetFlateModule()->FlateOrLZWDecode( | 578 return pEncoders->GetFlateModule()->FlateOrLZWDecode( |
| 583 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); | 579 FALSE, src_buf, src_size, FALSE, 0, 0, 0, 0, 0, dest_buf, dest_size); |
| 584 } | 580 } |
| 585 return 0; | 581 return 0; |
| 586 } | 582 } |
| OLD | NEW |