• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_
8 #define CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_string.h"
13 
14 class CCodec_ScanlineDecoder;
15 class CPDF_Dictionary;
16 
17 // Indexed by 8-bit char code, contains unicode code points.
18 extern const uint16_t PDFDocEncoding[256];
19 
20 ByteString PDF_NameDecode(const ByteStringView& orig);
21 ByteString PDF_NameDecode(const ByteString& orig);
22 ByteString PDF_NameEncode(const ByteString& orig);
23 ByteString PDF_EncodeString(const ByteString& src, bool bHex);
24 WideString PDF_DecodeText(const uint8_t* pData, uint32_t size);
25 WideString PDF_DecodeText(const ByteString& bstr);
26 ByteString PDF_EncodeText(const wchar_t* pString, int len);
27 ByteString PDF_EncodeText(const WideString& str);
28 
29 bool FlateEncode(const uint8_t* src_buf,
30                  uint32_t src_size,
31                  uint8_t** dest_buf,
32                  uint32_t* dest_size);
33 
34 // This used to have more parameters like the predictor and bpc, but there was
35 // only one caller, so the interface has been simplified, the values are hard
36 // coded, and dead code has been removed.
37 bool PngEncode(const uint8_t* src_buf,
38                uint32_t src_size,
39                uint8_t** dest_buf,
40                uint32_t* dest_size);
41 
42 uint32_t FlateDecode(const uint8_t* src_buf,
43                      uint32_t src_size,
44                      uint8_t** dest_buf,
45                      uint32_t* dest_size);
46 
47 uint32_t RunLengthDecode(const uint8_t* src_buf,
48                          uint32_t src_size,
49                          uint8_t** dest_buf,
50                          uint32_t* dest_size);
51 
52 std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFaxDecoder(
53     const uint8_t* src_buf,
54     uint32_t src_size,
55     int width,
56     int height,
57     const CPDF_Dictionary* pParams);
58 
59 std::unique_ptr<CCodec_ScanlineDecoder> FPDFAPI_CreateFlateDecoder(
60     const uint8_t* src_buf,
61     uint32_t src_size,
62     int width,
63     int height,
64     int nComps,
65     int bpc,
66     const CPDF_Dictionary* pParams);
67 
68 uint32_t A85Decode(const uint8_t* src_buf,
69                    uint32_t src_size,
70                    uint8_t** dest_buf,
71                    uint32_t* dest_size);
72 
73 uint32_t HexDecode(const uint8_t* src_buf,
74                    uint32_t src_size,
75                    uint8_t** dest_buf,
76                    uint32_t* dest_size);
77 
78 uint32_t FPDFAPI_FlateOrLZWDecode(bool bLZW,
79                                   const uint8_t* src_buf,
80                                   uint32_t src_size,
81                                   CPDF_Dictionary* pParams,
82                                   uint32_t estimated_size,
83                                   uint8_t** dest_buf,
84                                   uint32_t* dest_size);
85 
86 bool PDF_DataDecode(const uint8_t* src_buf,
87                     uint32_t src_size,
88                     const CPDF_Dictionary* pDict,
89                     uint32_t estimated_size,
90                     bool bImageAcc,
91                     uint8_t** dest_buf,
92                     uint32_t* dest_size,
93                     ByteString* ImageEncoding,
94                     CPDF_Dictionary** pImageParms);
95 
96 #endif  // CORE_FPDFAPI_PARSER_FPDF_PARSER_DECODE_H_
97