blob: ed8e1e9c90dde3e2525aad5d7e993cc6a48d4657 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#ifndef PL_PNGFILTER_HH
#define PL_PNGFILTER_HH
// This pipeline applies or reverses the application of a PNG filter as described in the PNG
// specification.
// NOTE: In its current implementation, this filter always encodes using the "up" filter, but it
// decodes all the filters.
#include <qpdf/Pipeline.hh>
class Pl_PNGFilter: public Pipeline
{
public:
// Encoding is only partially supported
enum action_e { a_encode, a_decode };
Pl_PNGFilter(
char const* identifier,
Pipeline* next,
action_e action,
unsigned int columns,
unsigned int samples_per_pixel = 1,
unsigned int bits_per_sample = 8);
~Pl_PNGFilter() override = default;
void write(unsigned char const* data, size_t len) override;
void finish() override;
private:
void decodeSub();
void decodeUp();
void decodeAverage();
void decodePaeth();
void processRow();
void encodeRow();
void decodeRow();
int PaethPredictor(int a, int b, int c);
action_e action;
unsigned int bytes_per_row;
unsigned int bytes_per_pixel;
unsigned char* cur_row; // points to buf1 or buf2
unsigned char* prev_row; // points to buf1 or buf2
std::shared_ptr<unsigned char> buf1;
std::shared_ptr<unsigned char> buf2;
size_t pos;
size_t incoming;
};
#endif // PL_PNGFILTER_HH
|