Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
libvncserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
libvncserver
Commits
669b4c86
Commit
669b4c86
authored
May 23, 2005
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make zlib and tight handling thread safe (static -> rfbClient)
parent
dc1094f0
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
226 additions
and
214 deletions
+226
-214
rfbproto.c
libvncclient/rfbproto.c
+0
-129
tight.c
libvncclient/tight.c
+151
-63
vncviewer.c
libvncclient/vncviewer.c
+9
-0
zlib.c
libvncclient/zlib.c
+22
-22
rfbclient.h
rfb/rfbclient.h
+44
-0
No files found.
libvncclient/rfbproto.c
View file @
669b4c86
...
@@ -166,48 +166,6 @@ static void JpegSetSrcManager(j_decompress_ptr cinfo, uint8_t *compressedData,
...
@@ -166,48 +166,6 @@ static void JpegSetSrcManager(j_decompress_ptr cinfo, uint8_t *compressedData,
#endif
#endif
#endif
#endif
/* The zlib encoding requires expansion/decompression/deflation of the
compressed data in the "buffer" above into another, result buffer.
However, the size of the result buffer can be determined precisely
based on the bitsPerPixel, height and width of the rectangle. We
allocate this buffer one time to be the full size of the buffer. */
#ifdef LIBVNCSERVER_HAVE_LIBZ
static
int
raw_buffer_size
=
-
1
;
static
char
*
raw_buffer
;
static
z_stream
decompStream
;
static
rfbBool
decompStreamInited
=
FALSE
;
#endif
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
/*
* Variables for the ``tight'' encoding implementation.
*/
/* Separate buffer for compressed data. */
/* TODO: threading issues */
#define ZLIB_BUFFER_SIZE 30000
static
char
zlib_buffer
[
ZLIB_BUFFER_SIZE
];
/* Four independent compression streams for zlib library. */
static
z_stream
zlibStream
[
4
];
static
rfbBool
zlibStreamActive
[
4
]
=
{
FALSE
,
FALSE
,
FALSE
,
FALSE
};
/* Filter stuff. Should be initialized by filter initialization code. */
static
rfbBool
cutZeros
;
static
int
rectWidth
,
rectColors
;
static
char
tightPalette
[
256
*
4
];
static
uint8_t
tightPrevRow
[
2048
*
3
*
sizeof
(
uint16_t
)];
/* JPEG decoder state. */
static
rfbBool
jpegError
;
#endif
/*
/*
* ConnectToRFBServer.
* ConnectToRFBServer.
*/
*/
...
@@ -1060,93 +1018,6 @@ PrintPixelFormat(rfbPixelFormat *format)
...
@@ -1060,93 +1018,6 @@ PrintPixelFormat(rfbPixelFormat *format)
}
}
}
}
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
static
long
ReadCompactLen
(
rfbClient
*
client
)
{
long
len
;
uint8_t
b
;
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
&
b
,
1
))
return
-
1
;
len
=
(
int
)
b
&
0x7F
;
if
(
b
&
0x80
)
{
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
&
b
,
1
))
return
-
1
;
len
|=
((
int
)
b
&
0x7F
)
<<
7
;
if
(
b
&
0x80
)
{
if
(
!
ReadFromRFBServer
(
client
,
(
char
*
)
&
b
,
1
))
return
-
1
;
len
|=
((
int
)
b
&
0xFF
)
<<
14
;
}
}
return
len
;
}
/*
* JPEG source manager functions for JPEG decompression in Tight decoder.
*/
static
struct
jpeg_source_mgr
jpegSrcManager
;
static
JOCTET
*
jpegBufferPtr
;
static
size_t
jpegBufferLen
;
static
void
JpegInitSource
(
j_decompress_ptr
cinfo
)
{
jpegError
=
FALSE
;
}
static
boolean
JpegFillInputBuffer
(
j_decompress_ptr
cinfo
)
{
jpegError
=
TRUE
;
jpegSrcManager
.
bytes_in_buffer
=
jpegBufferLen
;
jpegSrcManager
.
next_input_byte
=
(
JOCTET
*
)
jpegBufferPtr
;
return
TRUE
;
}
static
void
JpegSkipInputData
(
j_decompress_ptr
cinfo
,
long
num_bytes
)
{
if
(
num_bytes
<
0
||
num_bytes
>
jpegSrcManager
.
bytes_in_buffer
)
{
jpegError
=
TRUE
;
jpegSrcManager
.
bytes_in_buffer
=
jpegBufferLen
;
jpegSrcManager
.
next_input_byte
=
(
JOCTET
*
)
jpegBufferPtr
;
}
else
{
jpegSrcManager
.
next_input_byte
+=
(
size_t
)
num_bytes
;
jpegSrcManager
.
bytes_in_buffer
-=
(
size_t
)
num_bytes
;
}
}
static
void
JpegTermSource
(
j_decompress_ptr
cinfo
)
{
/* No work necessary here. */
}
static
void
JpegSetSrcManager
(
j_decompress_ptr
cinfo
,
uint8_t
*
compressedData
,
int
compressedLen
)
{
jpegBufferPtr
=
(
JOCTET
*
)
compressedData
;
jpegBufferLen
=
(
size_t
)
compressedLen
;
jpegSrcManager
.
init_source
=
JpegInitSource
;
jpegSrcManager
.
fill_input_buffer
=
JpegFillInputBuffer
;
jpegSrcManager
.
skip_input_data
=
JpegSkipInputData
;
jpegSrcManager
.
resync_to_restart
=
jpeg_resync_to_restart
;
jpegSrcManager
.
term_source
=
JpegTermSource
;
jpegSrcManager
.
next_input_byte
=
jpegBufferPtr
;
jpegSrcManager
.
bytes_in_buffer
=
jpegBufferLen
;
cinfo
->
src
=
&
jpegSrcManager
;
}
#endif
/* avoid name clashes with LibVNCServer */
/* avoid name clashes with LibVNCServer */
#define rfbEncryptBytes rfbClientEncryptBytes
#define rfbEncryptBytes rfbClientEncryptBytes
...
...
libvncclient/tight.c
View file @
669b4c86
This diff is collapsed.
Click to expand it.
libvncclient/vncviewer.c
View file @
669b4c86
...
@@ -154,6 +154,15 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
...
@@ -154,6 +154,15 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
client
->
bufoutptr
=
client
->
buf
;
client
->
bufoutptr
=
client
->
buf
;
client
->
buffered
=
0
;
client
->
buffered
=
0
;
#ifdef LIBVNCSERVER_HAVE_LIBZ
client
->
raw_buffer_size
=
-
1
;
client
->
decompStreamInited
=
FALSE
;
#endif
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
memset
(
client
->
zlibStreamActive
,
0
,
sizeof
(
rfbBool
)
*
4
);
#endif
client
->
HandleCursorPos
=
DummyPoint
;
client
->
HandleCursorPos
=
DummyPoint
;
client
->
SoftCursorLockArea
=
DummyRect
;
client
->
SoftCursorLockArea
=
DummyRect
;
client
->
SoftCursorUnlockScreen
=
Dummy
;
client
->
SoftCursorUnlockScreen
=
Dummy
;
...
...
libvncclient/zlib.c
View file @
669b4c86
...
@@ -46,16 +46,16 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
...
@@ -46,16 +46,16 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
* buffer, this buffer allocation should only happen once, on the
* buffer, this buffer allocation should only happen once, on the
* first update.
* first update.
*/
*/
if
(
raw_buffer_size
<
((
rw
*
rh
)
*
(
BPP
/
8
)))
{
if
(
client
->
raw_buffer_size
<
((
rw
*
rh
)
*
(
BPP
/
8
)))
{
if
(
raw_buffer
!=
NULL
)
{
if
(
client
->
raw_buffer
!=
NULL
)
{
free
(
raw_buffer
);
free
(
client
->
raw_buffer
);
}
}
raw_buffer_size
=
((
rw
*
rh
)
*
(
BPP
/
8
));
client
->
raw_buffer_size
=
((
rw
*
rh
)
*
(
BPP
/
8
));
raw_buffer
=
(
char
*
)
malloc
(
raw_buffer_size
);
client
->
raw_buffer
=
(
char
*
)
malloc
(
client
->
raw_buffer_size
);
}
}
...
@@ -65,26 +65,26 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
...
@@ -65,26 +65,26 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
remaining
=
rfbClientSwap32IfLE
(
hdr
.
nBytes
);
remaining
=
rfbClientSwap32IfLE
(
hdr
.
nBytes
);
/* Need to initialize the decompressor state. */
/* Need to initialize the decompressor state. */
decompStream
.
next_in
=
(
Bytef
*
)
client
->
buffer
;
client
->
decompStream
.
next_in
=
(
Bytef
*
)
client
->
buffer
;
decompStream
.
avail_in
=
0
;
client
->
decompStream
.
avail_in
=
0
;
decompStream
.
next_out
=
(
Bytef
*
)
raw_buffer
;
client
->
decompStream
.
next_out
=
(
Bytef
*
)
client
->
raw_buffer
;
decompStream
.
avail_out
=
raw_buffer_size
;
client
->
decompStream
.
avail_out
=
client
->
raw_buffer_size
;
decompStream
.
data_type
=
Z_BINARY
;
client
->
decompStream
.
data_type
=
Z_BINARY
;
/* Initialize the decompression stream structures on the first invocation. */
/* Initialize the decompression stream structures on the first invocation. */
if
(
decompStreamInited
==
FALSE
)
{
if
(
client
->
decompStreamInited
==
FALSE
)
{
inflateResult
=
inflateInit
(
&
decompStream
);
inflateResult
=
inflateInit
(
&
client
->
decompStream
);
if
(
inflateResult
!=
Z_OK
)
{
if
(
inflateResult
!=
Z_OK
)
{
rfbClientLog
(
rfbClientLog
(
"inflateInit returned error: %d, msg: %s
\n
"
,
"inflateInit returned error: %d, msg: %s
\n
"
,
inflateResult
,
inflateResult
,
decompStream
.
msg
);
client
->
decompStream
.
msg
);
return
FALSE
;
return
FALSE
;
}
}
decompStreamInited
=
TRUE
;
client
->
decompStreamInited
=
TRUE
;
}
}
...
@@ -107,11 +107,11 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
...
@@ -107,11 +107,11 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if
(
!
ReadFromRFBServer
(
client
,
client
->
buffer
,
toRead
))
if
(
!
ReadFromRFBServer
(
client
,
client
->
buffer
,
toRead
))
return
FALSE
;
return
FALSE
;
decompStream
.
next_in
=
(
Bytef
*
)
client
->
buffer
;
client
->
decompStream
.
next_in
=
(
Bytef
*
)
client
->
buffer
;
decompStream
.
avail_in
=
toRead
;
client
->
decompStream
.
avail_in
=
toRead
;
/* Need to uncompress buffer full. */
/* Need to uncompress buffer full. */
inflateResult
=
inflate
(
&
decompStream
,
Z_SYNC_FLUSH
);
inflateResult
=
inflate
(
&
client
->
decompStream
,
Z_SYNC_FLUSH
);
/* We never supply a dictionary for compression. */
/* We never supply a dictionary for compression. */
if
(
inflateResult
==
Z_NEED_DICT
)
{
if
(
inflateResult
==
Z_NEED_DICT
)
{
...
@@ -122,15 +122,15 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
...
@@ -122,15 +122,15 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
rfbClientLog
(
rfbClientLog
(
"zlib inflate returned error: %d, msg: %s
\n
"
,
"zlib inflate returned error: %d, msg: %s
\n
"
,
inflateResult
,
inflateResult
,
decompStream
.
msg
);
client
->
decompStream
.
msg
);
return
FALSE
;
return
FALSE
;
}
}
/* Result buffer allocated to be at least large enough. We should
/* Result buffer allocated to be at least large enough. We should
* never run out of space!
* never run out of space!
*/
*/
if
((
decompStream
.
avail_in
>
0
)
&&
if
((
client
->
decompStream
.
avail_in
>
0
)
&&
(
decompStream
.
avail_out
<=
0
))
{
(
client
->
decompStream
.
avail_out
<=
0
))
{
rfbClientLog
(
"zlib inflate ran out of space!
\n
"
);
rfbClientLog
(
"zlib inflate ran out of space!
\n
"
);
return
FALSE
;
return
FALSE
;
}
}
...
@@ -142,14 +142,14 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
...
@@ -142,14 +142,14 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
if
(
inflateResult
==
Z_OK
)
{
if
(
inflateResult
==
Z_OK
)
{
/* Put the uncompressed contents of the update on the screen. */
/* Put the uncompressed contents of the update on the screen. */
CopyRectangle
(
client
,
raw_buffer
,
rx
,
ry
,
rw
,
rh
);
CopyRectangle
(
client
,
client
->
raw_buffer
,
rx
,
ry
,
rw
,
rh
);
}
}
else
{
else
{
rfbClientLog
(
rfbClientLog
(
"zlib inflate returned error: %d, msg: %s
\n
"
,
"zlib inflate returned error: %d, msg: %s
\n
"
,
inflateResult
,
inflateResult
,
decompStream
.
msg
);
client
->
decompStream
.
msg
);
return
FALSE
;
return
FALSE
;
}
}
...
...
rfb/rfbclient.h
View file @
669b4c86
...
@@ -132,6 +132,50 @@ typedef struct _rfbClient {
...
@@ -132,6 +132,50 @@ typedef struct _rfbClient {
char
*
bufoutptr
;
char
*
bufoutptr
;
int
buffered
;
int
buffered
;
/* The zlib encoding requires expansion/decompression/deflation of the
compressed data in the "buffer" above into another, result buffer.
However, the size of the result buffer can be determined precisely
based on the bitsPerPixel, height and width of the rectangle. We
allocate this buffer one time to be the full size of the buffer. */
#ifdef LIBVNCSERVER_HAVE_LIBZ
int
raw_buffer_size
;
char
*
raw_buffer
;
z_stream
decompStream
;
rfbBool
decompStreamInited
;
#endif
#ifdef LIBVNCSERVER_HAVE_LIBJPEG
/*
* Variables for the ``tight'' encoding implementation.
*/
/* Separate buffer for compressed data. */
#define ZLIB_BUFFER_SIZE 30000
char
zlib_buffer
[
ZLIB_BUFFER_SIZE
];
/* Four independent compression streams for zlib library. */
z_stream
zlibStream
[
4
];
rfbBool
zlibStreamActive
[
4
];
/* Filter stuff. Should be initialized by filter initialization code. */
rfbBool
cutZeros
;
int
rectWidth
,
rectColors
;
char
tightPalette
[
256
*
4
];
uint8_t
tightPrevRow
[
2048
*
3
*
sizeof
(
uint16_t
)];
/* JPEG decoder state. */
rfbBool
jpegError
;
struct
jpeg_source_mgr
*
jpegSrcManager
;
void
*
jpegBufferPtr
;
size_t
jpegBufferLen
;
#endif
/* cursor.c */
/* cursor.c */
uint8_t
*
rcSource
,
*
rcMask
;
uint8_t
*
rcSource
,
*
rcMask
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment