blob: 9a28fb9b966f21d5e916a13cac72e1242608ef64 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
DRC33c15e32011-11-03 18:49:21 +00002 * Copyright (C) 2011 D. R. Commander. All Rights Reserved.
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00003 *
4 * This is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this software; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
17 * USA.
18 */
19#ifndef __RFB_TIGHTDECODER_H__
20#define __RFB_TIGHTDECODER_H__
21
22#include <rdr/ZlibInStream.h>
23#include <rfb/Decoder.h>
DRC33c15e32011-11-03 18:49:21 +000024#include <rfb/JpegDecompressor.h>
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000025
26namespace rfb {
27
28 class TightDecoder : public Decoder {
DRC33c15e32011-11-03 18:49:21 +000029
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000030 public:
31 static Decoder* create(CMsgReader* reader);
32 virtual void readRect(const Rect& r, CMsgHandler* handler);
33 virtual ~TightDecoder();
DRC33c15e32011-11-03 18:49:21 +000034
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000035 private:
DRC33c15e32011-11-03 18:49:21 +000036 void tightDecode8(const Rect& r);
37 void tightDecode16(const Rect& r);
38 void tightDecode32(const Rect& r);
39
40 void DecompressJpegRect8(const Rect& r);
41 void DecompressJpegRect16(const Rect& r);
42 void DecompressJpegRect32(const Rect& r);
43
44 void FilterGradient8(rdr::InStream* is, rdr::U8* buf, int stride,
45 const Rect& r, int dataSize);
46 void FilterGradient16(rdr::InStream* is, rdr::U16* buf, int stride,
47 const Rect& r, int dataSize);
48 void FilterGradient24(rdr::InStream* is, rdr::U32* buf, int stride,
49 const Rect& r, int dataSize);
50 void FilterGradient32(rdr::InStream* is, rdr::U32* buf, int stride,
51 const Rect& r, int dataSize);
52
53 void directFillRect8(const Rect& r, Pixel pix);
54 void directFillRect16(const Rect& r, Pixel pix);
55 void directFillRect32(const Rect& r, Pixel pix);
56
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000057 TightDecoder(CMsgReader* reader);
DRC33c15e32011-11-03 18:49:21 +000058
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000059 CMsgReader* reader;
DRC33c15e32011-11-03 18:49:21 +000060 CMsgHandler* handler;
61 rdr::InStream* is;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000062 rdr::ZlibInStream zis[4];
DRC33c15e32011-11-03 18:49:21 +000063 JpegDecompressor jd;
64 PixelFormat clientpf;
65 PixelFormat serverpf;
66 bool directDecode;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000067 };
68
69 // Compression control
70 const unsigned int rfbTightExplicitFilter = 0x04;
71 const unsigned int rfbTightFill = 0x08;
72 const unsigned int rfbTightJpeg = 0x09;
73 const unsigned int rfbTightMaxSubencoding = 0x09;
74
75 // Filters to improve compression efficiency
76 const unsigned int rfbTightFilterCopy = 0x00;
77 const unsigned int rfbTightFilterPalette = 0x01;
78 const unsigned int rfbTightFilterGradient = 0x02;
79}
80
81#endif