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