blob: 9c11eaffe21d0d4980f3b46a00e6e13dcd5b8340 [file] [log] [blame]
Constantin Kaplinskya2adc8d2006-05-25 05:01:55 +00001/* Copyright (C) 2000-2003 Constantin Kaplinsky. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18#ifndef __RFB_TIGHTENCODER_H__
19#define __RFB_TIGHTENCODER_H__
20
21#include <rdr/MemOutStream.h>
22#include <rdr/ZlibOutStream.h>
23#include <rfb/Encoder.h>
24
25// FIXME: Check if specifying extern "C" is really necessary.
26#include <stdio.h>
27extern "C" {
28#include "jpeg/jpeglib.h"
29}
30
31namespace rfb {
32
33 struct TIGHT_CONF {
34 unsigned int maxRectSize, maxRectWidth;
35 unsigned int monoMinRectSize;
36 int idxZlibLevel, monoZlibLevel, rawZlibLevel;
37 int idxMaxColorsDivisor;
38 int jpegQuality;
39 };
40
41 //
42 // Compression level stuff. The following array contains various
43 // encoder parameters for each of 10 compression levels (0..9).
44 // Last three parameters correspond to JPEG quality levels (0..9).
45 //
46 // NOTE: s_conf[9].maxRectSize should be >= s_conf[i].maxRectSize,
47 // where i in [0..8]. RequiredBuffSize() method depends on this.
48 // FIXME: Is this comment obsolete?
49 //
50
51
52 class TightEncoder : public Encoder {
53 public:
54 static Encoder* create(SMsgWriter* writer);
55 virtual void setCompressLevel(int level);
56 virtual void setQualityLevel(int level);
57 virtual int getNumRects(const Rect &r);
58 virtual bool writeRect(const Rect& r, ImageGetter* ig, Rect* actual);
59 virtual ~TightEncoder();
60
61 private:
62 TightEncoder(SMsgWriter* writer);
63 void writeSubrect(const Rect& r, ImageGetter* ig);
64
65 SMsgWriter* writer;
66 rdr::MemOutStream mos;
67 rdr::ZlibOutStream zos[4];
68
69 static const int defaultCompressLevel;
70 static const TIGHT_CONF conf[];
71
72 const TIGHT_CONF* pconf;
73 const TIGHT_CONF* pjconf;
74 };
75
76}
77
78#endif