xref: /aosp_15_r20/external/pdfium/core/fxcodec/fax/faxmodule.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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_FAX_FAXMODULE_H_
8 #define CORE_FXCODEC_FAX_FAXMODULE_H_
9 
10 #include <stdint.h>
11 
12 #include <memory>
13 
14 #include "build/build_config.h"
15 #include "third_party/base/containers/span.h"
16 
17 #if BUILDFLAG(IS_WIN)
18 #include "core/fxcrt/data_vector.h"
19 #include "core/fxcrt/retain_ptr.h"
20 #endif
21 
22 class CFX_DIBBase;
23 
24 namespace fxcodec {
25 
26 class ScanlineDecoder;
27 
28 class FaxModule {
29  public:
30   static std::unique_ptr<ScanlineDecoder> CreateDecoder(
31       pdfium::span<const uint8_t> src_span,
32       int width,
33       int height,
34       int K,
35       bool EndOfLine,
36       bool EncodedByteAlign,
37       bool BlackIs1,
38       int Columns,
39       int Rows);
40 
41   // Return the ending bit position.
42   static int FaxG4Decode(const uint8_t* src_buf,
43                          uint32_t src_size,
44                          int starting_bitpos,
45                          int width,
46                          int height,
47                          int pitch,
48                          uint8_t* dest_buf);
49 
50 #if BUILDFLAG(IS_WIN)
51   // `src` must have a BPP value of 1.
52   static DataVector<uint8_t> FaxEncode(RetainPtr<CFX_DIBBase> src);
53 #endif  // BUILDFLAG(IS_WIN)
54 
55   FaxModule() = delete;
56   FaxModule(const FaxModule&) = delete;
57   FaxModule& operator=(const FaxModule&) = delete;
58 };
59 
60 }  // namespace fxcodec
61 
62 using FaxModule = fxcodec::FaxModule;
63 
64 #endif  // CORE_FXCODEC_FAX_FAXMODULE_H_
65