1//========================================================================
2//
3// DCTStream.h
4//
5// This file is licensed under the GPLv2 or later
6//
7// Copyright 2005 Jeff Muizelaar <jeff@infidigm.net>
8// Copyright 2005 Martin Kretzschmar <martink@gnome.org>
9// Copyright 2005-2007, 2009-2011, 2017, 2019, 2021 Albert Astals Cid <aacid@kde.org>
10// Copyright 2010 Carlos Garcia Campos <carlosgc@gnome.org>
11// Copyright 2011 Daiki Ueno <ueno@unixuser.org>
12// Copyright 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
13// Copyright 2020 LluĂ­s Batlle i Rossell <viric@viric.name>
14//
15//========================================================================
16
17#ifndef DCTSTREAM_H
18#define DCTSTREAM_H
19
20#include "poppler-config.h"
21#include <cstdio>
22#include <cstdlib>
23#include <cstddef>
24#include <csetjmp>
25#ifdef HAVE_UNISTD_H
26# include <unistd.h>
27#endif
28#include <cstring>
29#include <cctype>
30#include "goo/gmem.h"
31#include "goo/gfile.h"
32#include "Error.h"
33#include "Object.h"
34#include "Decrypt.h"
35#include "Stream.h"
36
37extern "C" {
38#include <jpeglib.h>
39#include <jerror.h>
40}
41
42struct str_src_mgr
43{
44 struct jpeg_source_mgr pub;
45 JOCTET buffer;
46 Stream *str;
47 int index;
48};
49
50struct str_error_mgr
51{
52 struct jpeg_error_mgr pub;
53 jmp_buf setjmp_buffer;
54 int width;
55 int height;
56};
57
58class DCTStream : public FilterStream
59{
60public:
61 DCTStream(Stream *strA, int colorXformA, Dict *dict, int recursion);
62 ~DCTStream() override;
63 StreamKind getKind() const override { return strDCT; }
64 void reset() override;
65 int getChar() override;
66 int lookChar() override;
67 GooString *getPSFilter(int psLevel, const char *indent) override;
68 bool isBinary(bool last = true) const override;
69
70private:
71 void init();
72
73 bool hasGetChars() override { return true; }
74 bool readLine();
75 int getChars(int nChars, unsigned char *buffer) override;
76
77 int colorXform;
78 JSAMPLE *current;
79 JSAMPLE *limit;
80 struct jpeg_decompress_struct cinfo;
81 struct str_error_mgr err;
82 struct str_src_mgr src;
83 JSAMPARRAY row_buffer;
84};
85
86#endif
87

source code of poppler/poppler/DCTStream.h