blob: 18b01f8a4f4b151dc6ed10e6e86eee8742019354 [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:
Pierre Ossman316a3242014-01-15 12:40:20 +010031 TightDecoder(CMsgReader* reader);
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000032 virtual ~TightDecoder();
Pierre Ossman316a3242014-01-15 12:40:20 +010033 virtual void readRect(const Rect& r, CMsgHandler* handler);
DRC33c15e32011-11-03 18:49:21 +000034
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000035 private:
Pierre Ossman7b5c0692014-03-17 14:35:51 +010036 rdr::U32 readCompact(rdr::InStream* is);
37
DRC33c15e32011-11-03 18:49:21 +000038 void tightDecode8(const Rect& r);
39 void tightDecode16(const Rect& r);
40 void tightDecode32(const Rect& r);
41
42 void DecompressJpegRect8(const Rect& r);
43 void DecompressJpegRect16(const Rect& r);
44 void DecompressJpegRect32(const Rect& r);
45
DRCa5004a32011-11-04 04:51:17 +000046 void FilterGradient8(rdr::U8 *netbuf, rdr::U8* buf, int stride,
47 const Rect& r);
48 void FilterGradient16(rdr::U8 *netbuf, rdr::U16* buf, int stride,
49 const Rect& r);
50 void FilterGradient24(rdr::U8 *netbuf, rdr::U32* buf, int stride,
51 const Rect& r);
52 void FilterGradient32(rdr::U8 *netbuf, rdr::U32* buf, int stride,
53 const Rect& r);
DRC33c15e32011-11-03 18:49:21 +000054
55 void directFillRect8(const Rect& r, Pixel pix);
56 void directFillRect16(const Rect& r, Pixel pix);
57 void directFillRect32(const Rect& r, Pixel pix);
58
DRC33c15e32011-11-03 18:49:21 +000059 CMsgHandler* handler;
60 rdr::InStream* is;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000061 rdr::ZlibInStream zis[4];
DRC33c15e32011-11-03 18:49:21 +000062 JpegDecompressor jd;
63 PixelFormat clientpf;
64 PixelFormat serverpf;
65 bool directDecode;
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +000066 };
67
68 // Compression control
69 const unsigned int rfbTightExplicitFilter = 0x04;
70 const unsigned int rfbTightFill = 0x08;
71 const unsigned int rfbTightJpeg = 0x09;
72 const unsigned int rfbTightMaxSubencoding = 0x09;
73
74 // Filters to improve compression efficiency
75 const unsigned int rfbTightFilterCopy = 0x00;
76 const unsigned int rfbTightFilterPalette = 0x01;
77 const unsigned int rfbTightFilterGradient = 0x02;
78}
79
80#endif