• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 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_SRC_FPDFAPI_FPDF_PARSER_FILTERS_INT_H_
8 #define CORE_SRC_FPDFAPI_FPDF_PARSER_FILTERS_INT_H_
9 
10 class CPDF_DecryptFilter : public CFX_DataFilter
11 {
12 public:
13     CPDF_DecryptFilter(CPDF_CryptoHandler* pCryptoHandler, FX_DWORD objnum, FX_DWORD gennum);
14     virtual ~CPDF_DecryptFilter();
15     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
16     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf);
17     CPDF_CryptoHandler*	m_pCryptoHandler;
18     FX_LPVOID		m_pContext;
19     FX_DWORD		m_ObjNum, m_GenNum;
20 };
21 class CPDF_FlateFilter : public CFX_DataFilter
22 {
23 public:
24     CPDF_FlateFilter();
25     virtual ~CPDF_FlateFilter();
26     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
v_FilterFinish(CFX_BinaryBuf & dest_buf)27     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf) {}
28     void*			m_pContext;
29     FX_BYTE			m_DestBuffer[FPDF_FILTER_BUFFER_SIZE];
30 };
31 class CPDF_LzwFilter : public CFX_DataFilter
32 {
33 public:
34     CPDF_LzwFilter(FX_BOOL bEarlyChange);
~CPDF_LzwFilter()35     virtual ~CPDF_LzwFilter() {}
36     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
v_FilterFinish(CFX_BinaryBuf & dest_buf)37     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf) {}
38     FX_BOOL			m_bEarlyChange;
39     FX_DWORD		m_CodeArray[5021];
40     FX_DWORD		m_nCodes;
41     FX_DWORD		m_CodeLen;
42     FX_DWORD		m_OldCode;
43     FX_BYTE			m_LastChar;
44     FX_DWORD		m_nLeftBits, m_LeftBits;
45     FX_BYTE			m_DecodeStack[4000];
46     FX_DWORD		m_StackLen;
47     void			AddCode(FX_DWORD prefix_code, FX_BYTE append_char);
48     void			DecodeString(FX_DWORD code);
49 };
50 class CPDF_PredictorFilter : public CFX_DataFilter
51 {
52 public:
53     CPDF_PredictorFilter(int predictor, int colors, int bpc, int cols);
54     virtual ~CPDF_PredictorFilter();
55     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
v_FilterFinish(CFX_BinaryBuf & dest_buf)56     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf) {}
57     FX_BOOL			m_bTiff;
58     FX_DWORD		m_Pitch, m_Bpp;
59     FX_LPBYTE		m_pRefLine, m_pCurLine;
60     FX_DWORD		m_iLine, m_LineInSize;
61 };
62 class CPDF_AsciiHexFilter : public CFX_DataFilter
63 {
64 public:
65     CPDF_AsciiHexFilter();
~CPDF_AsciiHexFilter()66     virtual ~CPDF_AsciiHexFilter() {}
67     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
v_FilterFinish(CFX_BinaryBuf & dest_buf)68     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf) {}
69     int				m_State;
70     int				m_FirstDigit;
71 };
72 class CPDF_Ascii85Filter : public CFX_DataFilter
73 {
74 public:
75     CPDF_Ascii85Filter();
~CPDF_Ascii85Filter()76     virtual ~CPDF_Ascii85Filter() {}
77     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
v_FilterFinish(CFX_BinaryBuf & dest_buf)78     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf) {}
79     int				m_State;
80     int				m_CharCount;
81     FX_DWORD		m_CurDWord;
82 };
83 class CPDF_RunLenFilter : public CFX_DataFilter
84 {
85 public:
86     CPDF_RunLenFilter();
~CPDF_RunLenFilter()87     virtual ~CPDF_RunLenFilter() {}
88     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
v_FilterFinish(CFX_BinaryBuf & dest_buf)89     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf) {}
90     int				m_State;
91     FX_DWORD		m_Count;
92 };
93 class CPDF_JpegFilter : public CFX_DataFilter
94 {
95 public:
96     CPDF_JpegFilter();
97     virtual ~CPDF_JpegFilter();
98     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
v_FilterFinish(CFX_BinaryBuf & dest_buf)99     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf) {}
100     void*			m_pContext;
101     CFX_BinaryBuf	m_InputBuf;
102     FX_LPBYTE		m_pScanline;
103     int				m_Pitch, m_Height, m_Width, m_nComps, m_iLine;
104     FX_BOOL			m_bGotHeader;
105 };
106 class CPDF_FaxFilter : public CFX_DataFilter
107 {
108 public:
109     CPDF_FaxFilter();
110     virtual ~CPDF_FaxFilter();
111     FX_BOOL			Initialize(int Encoding, int bEndOfLine, int bByteAlign, int bBlack, int nRows, int nColumns);
112     virtual	void	v_FilterIn(FX_LPCBYTE src_buf, FX_DWORD src_size, CFX_BinaryBuf& dest_buf);
113     virtual void	v_FilterFinish(CFX_BinaryBuf& dest_buf);
114     int				m_Encoding, m_bEndOfLine, m_bByteAlign, m_bBlack;
115     int				m_nRows, m_nColumns, m_Pitch, m_iRow;
116     FX_LPBYTE		m_pScanlineBuf, m_pRefBuf;
117     CFX_BinaryBuf	m_InputBuf;
118     int				m_InputBitPos;
119     void			ProcessData(FX_LPCBYTE src_buf, FX_DWORD src_size, int& bitpos, FX_BOOL bFinish,
120                                 CFX_BinaryBuf& dest_buf);
121     FX_BOOL			ReadLine(FX_LPCBYTE src_buf, int bitsize, int& bitpos);
122 };
123 
124 #endif  // CORE_SRC_FPDFAPI_FPDF_PARSER_FILTERS_INT_H_
125