summaryrefslogtreecommitdiffstats
path: root/x11vnc/misc/turbovnc/convert_rfbserver
blob: 81267ac687e1cabfa78024e7aec40bd4835108f0 (plain)
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
52
53
54
55
56
#!/usr/bin/perl
#
# This script has been (or is hereby) released into the public domain by
# its author, Karl J. Runge <runge@karlrunge.com>. This applies worldwide.
# 
# In case this is not legally possible: Karl J. Runge grants anyone the
# right to use this work for any purpose, without any conditions, unless
# such conditions are required by law.

$saw_mark = 0;
$done = 0;

while (<>) {
	if (! $saw_mark && /case rfbEncodingServerIdentity:/) 		{
		$saw_mark = 1;
	}
	if ($saw_mark && !$done && /default:/) {
		print;

		print <<END;
                /* for turbovnc */
#define rfbJpegQualityLevel1       0xFFFFFE01
#define rfbJpegQualityLevel100     0xFFFFFE64
#define rfbJpegSubsamp1X           0xFFFFFD00
#define rfbJpegSubsamp4X           0xFFFFFD01
#define rfbJpegSubsamp2X           0xFFFFFD02
#define rfbJpegSubsampGray         0xFFFFFD03

                if ( enc >= (uint32_t)rfbJpegSubsamp1X &&
                         enc <= (uint32_t)rfbJpegSubsampGray ) {
                    /* XXX member really should be tightSubsample not correMaxWidth */
                    cl->correMaxWidth = enc & 0xFF;
                    rfbLog("Using JPEG subsampling %d for client %s\\n",
                           cl->correMaxWidth, cl->host);
                } else if ( enc >= (uint32_t)rfbEncodingQualityLevel0 &&
                            enc <= (uint32_t)rfbEncodingQualityLevel9 ) {
                    static int JPEG_QUAL[10] = {
                       5, 10, 15, 25, 37, 50, 60, 70, 75, 80
                    };
                    cl->tightQualityLevel = JPEG_QUAL[enc & 0x0F];
                    /* XXX member really should be tightSubsample not correMaxWidth */
                    cl->correMaxWidth = 2;
                    rfbLog("Using image level Subsample %d  Quality %d for client %s\\n",
                           cl->correMaxWidth, cl->tightQualityLevel, cl->host);
                } else if ( enc >= (uint32_t)rfbJpegQualityLevel1 &&
                            enc <= (uint32_t)rfbJpegQualityLevel100 ) {
                    cl->tightQualityLevel = enc & 0xFF;
                    rfbLog("Using image quality level %d for client %s\\n",
                           cl->tightQualityLevel, cl->host);
                } else
END
		$done = 1;
		next;
	}
	print;
}
OpenPOWER on IntegriCloud