1 // Copyright 2016 The PDFium Authors 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_FXCODEC_FLATE_FLATEMODULE_H_ 8 #define CORE_FXCODEC_FLATE_FLATEMODULE_H_ 9 10 #include <stdint.h> 11 12 #include <memory> 13 14 #include "core/fxcrt/data_vector.h" 15 #include "core/fxcrt/fx_memory_wrappers.h" 16 #include "third_party/base/containers/span.h" 17 18 namespace fxcodec { 19 20 class ScanlineDecoder; 21 22 class FlateModule { 23 public: 24 static std::unique_ptr<ScanlineDecoder> CreateDecoder( 25 pdfium::span<const uint8_t> src_span, 26 int width, 27 int height, 28 int nComps, 29 int bpc, 30 int predictor, 31 int Colors, 32 int BitsPerComponent, 33 int Columns); 34 35 static uint32_t FlateOrLZWDecode( 36 bool bLZW, 37 pdfium::span<const uint8_t> src_span, 38 bool bEarlyChange, 39 int predictor, 40 int Colors, 41 int BitsPerComponent, 42 int Columns, 43 uint32_t estimated_size, 44 std::unique_ptr<uint8_t, FxFreeDeleter>* dest_buf, 45 uint32_t* dest_size); 46 47 static DataVector<uint8_t> Encode(pdfium::span<const uint8_t> src_span); 48 49 FlateModule() = delete; 50 FlateModule(const FlateModule&) = delete; 51 FlateModule& operator=(const FlateModule&) = delete; 52 }; 53 54 } // namespace fxcodec 55 56 using FlateModule = fxcodec::FlateModule; 57 58 #endif // CORE_FXCODEC_FLATE_FLATEMODULE_H_ 59