VNC updates for 0.13
cover VNC updates for 0.13
Tight JPEG and Move to ui
=========================
This set starts by adding JPEG and gradient to tight, then move all ui code in the ui/ subdirectory.
Thanks,
Since v1:
* Format patch with rename detection
* Add "lossy" parameter instead of "lossless"
* Disable lossy encodings by default
* Add a small tight fix (for indexed colors)
Since v2:
* Rebased on current master
* Removed a leak in send_jpeg_rect()
Misc
=======
* Add the missing last color while filling palette
* Rewrite the palette code without using qdict. I did some profiling using perf and a lot of cpu time was spent in qdict, mainly due to memory allocation, hash, and qobject conversion. The new code is faster and uses less memory.
Tight PNG
==========
This set introduce a new encoding: VNC_ENCODING_TIGHT_PNG (0x17) and a new tight filter VNC_TIGHT_PNG (0x0A). When the client tells it supports the 0x17 encoding, the server will use tight, but will always send encoding pixels using PNG instead of zlib. If the client also told it support JPEG, then the server can send JPEG, because PNG will only be used in the cases zlib was used in normal tight.
This encoding was introduced to speed up HTML5 based VNC clients like noVNC [1], but can also be used on devices like iPhone where PNG can be rendered in hardware.
I also made a quick patch to add support for PNG in gtk-vnc [2] and noVNC already support PNG encoding. Note: There is a bug in gtk-vnc when using pixbuf on a 16bit display, which also happens with JPEG.
[1] http://github.com/kanaka/noVNC/
[2] http://xf.iksaif.net/dev/vnc/gtk-vnc/0001-add-png-support.patch
Threaded Server
===============
Since v1:
* Moved locks from VncState to VncDisplay because it's only used in vnc_refresh
* Use trylock in vnc_refresh. If there is an encoding task still running, reschedule the refresh. This really boost performances and make the vnc server truly asynchroneous. The only blocking lock is the output_mutex which is only held during a simple memcpy().
* Fixed issues found by Paolo, except the exit condition, mainly because we can only have one queue per VncState (due to zstreams), so this is not really an issue.
* Rebased on top of jpeg and ui/ patchs
Since v2:
* renamed vnc-jobs.c vnc-jobs-async.c
* added vnc-jobs.h, refactor functions declarations, export vnc_[un]lock_display() and vnc_[un]lock_output() and use them in vnc-jobs-async.c (reported by Avi)
* rework exit condition for vnc_worker_thread_loop (Paolo)
* abord -> abort (Paolo)
* call qemu_thread_self() (Paolo)
* Coding style issues (Alexander)
* Move from empty macros to empty statis inline (Alexander)
Alexander also suggested me to use stw_be_p() defined in cpu-all.h, but when I tried to include cpu-all.h, it broke every thing. Anyway it can be done later since this code is already present in vnc.c.
Also vnc_async_encoding_start() could be cleaner if encoding members where in a specific structure, but this is a lot of changes, and as I'm also working on encodings, I want this patch to be easy to rebase. So I'll do as soon as the VNC server is merged.
Since v3:
* Encoding are data is now in specific structures, that makes vnc_async_encoding_start a lot cleaner.
* Added a missing vnc_output_lock(vs)
Corentin Chary (16):
vnc: tight: add JPEG and gradient subencoding with smooth image
detection
vnc: JPEG should be disabled if the client don't set tight quality
vnc: add lossy option
ui: move all ui components in ui/
vnc: rename vnc-encoding-* vnc-enc-*
vnc: tight: don't forget do at the last color
vnc: tight: remove a memleak in send_jpeg_rect()
vnc: tight add PNG encoding
vnc: tight: specific zlib level and filters for each compression
level
vnc: tight: stop using qdict for palette stuff
vnc: encapsulate encoding members
vnc: fix tight png memory leak
qemu-thread: add qemu_mutex/cond_destroy and qemu_mutex_exit
vnc: threaded VNC server
vnc: add missing lock for vnc_cursor_define()
vnc: tight: don't limit png rect size
Makefile | 38 +- Makefile.objs | 29 +- Makefile.target | 2 + configure | 83 ++ qemu-options.hx | 7 + qemu-thread.c | 22 + qemu-thread.h | 4 + cocoa.m => ui/cocoa.m | 0 curses.c => ui/curses.c | 0 curses_keys.h => ui/curses_keys.h | 0 d3des.c => ui/d3des.c | 0 d3des.h => ui/d3des.h | 0 keymaps.c => ui/keymaps.c | 0 keymaps.h => ui/keymaps.h | 0 sdl.c => ui/sdl.c | 0 sdl_keysym.h => ui/sdl_keysym.h | 0 sdl_zoom.c => ui/sdl_zoom.c | 0 sdl_zoom.h => ui/sdl_zoom.h | 0 sdl_zoom_template.h => ui/sdl_zoom_template.h | 0 vnc-auth-sasl.c => ui/vnc-auth-sasl.c | 0 vnc-auth-sasl.h => ui/vnc-auth-sasl.h | 0 vnc-auth-vencrypt.c => ui/vnc-auth-vencrypt.c | 0 vnc-auth-vencrypt.h => ui/vnc-auth-vencrypt.h | 0 vnchextile.h => ui/vnc-enc-hextile-template.h | 0 vnc-encoding-hextile.c => ui/vnc-enc-hextile.c | 26 +- ui/vnc-enc-tight.c | 1661 ++++++++++++++++++++++++ vnc-encoding-tight.h => ui/vnc-enc-tight.h | 21 +- vnc-encoding-zlib.c => ui/vnc-enc-zlib.c | 34 +- ui/vnc-jobs-async.c | 331 +++++ vnc-tls.h => ui/vnc-jobs-sync.c | 99 +- ui/vnc-jobs.h | 87 ++ ui/vnc-palette.c | 136 ++ ui/vnc-palette.h | 63 + vnc-tls.c => ui/vnc-tls.c | 0 vnc-tls.h => ui/vnc-tls.h | 0 vnc.c => ui/vnc.c | 165 ++- vnc.h => ui/vnc.h | 112 ++- vnc_keysym.h => ui/vnc_keysym.h | 0 x_keymap.c => ui/x_keymap.c | 0 x_keymap.h => ui/x_keymap.h | 0 vnc-encoding-tight.c | 959 -------------- 41 files changed, 2737 insertions(+), 1142 deletions(-) rename cocoa.m => ui/cocoa.m (100%) rename curses.c => ui/curses.c (100%) rename curses_keys.h => ui/curses_keys.h (100%) rename d3des.c => ui/d3des.c (100%) rename d3des.h => ui/d3des.h (100%) rename keymaps.c => ui/keymaps.c (100%) rename keymaps.h => ui/keymaps.h (100%) rename sdl.c => ui/sdl.c (100%) rename sdl_keysym.h => ui/sdl_keysym.h (100%) rename sdl_zoom.c => ui/sdl_zoom.c (100%) rename sdl_zoom.h => ui/sdl_zoom.h (100%) rename sdl_zoom_template.h => ui/sdl_zoom_template.h (100%) rename vnc-auth-sasl.c => ui/vnc-auth-sasl.c (100%) rename vnc-auth-sasl.h => ui/vnc-auth-sasl.h (100%) rename vnc-auth-vencrypt.c => ui/vnc-auth-vencrypt.c (100%) rename vnc-auth-vencrypt.h => ui/vnc-auth-vencrypt.h (100%) rename vnchextile.h => ui/vnc-enc-hextile-template.h (100%) rename vnc-encoding-hextile.c => ui/vnc-enc-hextile.c (81%) create mode 100644 ui/vnc-enc-tight.c rename vnc-encoding-tight.h => ui/vnc-enc-tight.h (92%) rename vnc-encoding-zlib.c => ui/vnc-enc-zlib.c (83%) create mode 100644 ui/vnc-jobs-async.c copy vnc-tls.h => ui/vnc-jobs-sync.c (54%) create mode 100644 ui/vnc-jobs.h create mode 100644 ui/vnc-palette.c create mode 100644 ui/vnc-palette.h rename vnc-tls.c => ui/vnc-tls.c (100%) rename vnc-tls.h => ui/vnc-tls.h (100%) rename vnc.c => ui/vnc.c (95%) rename vnc.h => ui/vnc.h (87%) rename vnc_keysym.h => ui/vnc_keysym.h (100%) rename x_keymap.c => ui/x_keymap.c (100%) rename x_keymap.h => ui/x_keymap.h (100%) delete mode 100644 vnc-encoding-tight.c
PATCH 1/16 vnc: tight: add JPEG and gradient subencoding with smooth image detection
Add gradient filter and JPEG compression with an heuristic to detect how lossy the comppression will be. This code has been adapted from libvncserver/tight.c.
JPEG support can be enabled/disabled at compile time with --enable-vnc-jpeg and --disable-vnc-jpeg.
--- Makefile.target | 1 + configure | 33 +++ vnc-encoding-tight.c | 559 +++++++++++++++++++++++++++++++++++++++++++++++++- vnc-encoding-tight.h | 5 + vnc.h | 4 + 5 files changed, 601 insertions(+), 1 deletions(-)
Makefile.target +1 -0
@@ -177,6 +177,7 @@ LIBS+=-lz QEMU_CFLAGS += $(VNC_TLS_CFLAGS) QEMU_CFLAGS += $(VNC_SASL_CFLAGS) +QEMU_CFLAGS += $(VNC_JPEG_CFLAGS) # xen backend driver support obj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
configure +33 -0
@@ -268,6 +268,7 @@ uuid="" vde="" vnc_tls="" vnc_sasl="" +vnc_jpeg="" xen="" linux_aio="" vhost_net=""
@@ -574,6 +575,10 @@ for opt do ;; --enable-vnc-sasl) vnc_sasl="yes" ;; + --disable-vnc-jpeg) vnc_jpeg="no" + ;; + --enable-vnc-jpeg) vnc_jpeg="yes" + ;; --disable-slirp) slirp="no" ;; --disable-uuid) uuid="no"
@@ -818,6 +823,8 @@ echo " --disable-vnc-tls disable TLS encryption for VNC server" echo " --enable-vnc-tls enable TLS encryption for VNC server" echo " --disable-vnc-sasl disable SASL encryption for VNC server" echo " --enable-vnc-sasl enable SASL encryption for VNC server" +echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server" +echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server" echo " --disable-curses disable curses output" echo " --enable-curses enable curses output" echo " --disable-curl disable curl connectivity"
@@ -1237,6 +1244,27 @@ EOF fi ########################################## +# VNC JPEG detection +if test "$vnc_jpeg" = "yes" ; then +cat > $TMPC <<EOF +#include <stdio.h> +#include <jpeglib.h> +int main(void) { struct jpeg_compress_struct s; jpeg_create_compress(&s); return 0; } +EOF + vnc_jpeg_cflags="" + vnc_jpeg_libs="-ljpeg" + if compile_prog "$vnc_jpeg_cflags" "$vnc_jpeg_libs" ; then + vnc_jpeg=yes + libs_softmmu="$vnc_jpeg_libs $libs_softmmu" + else + if test "$vnc_jpeg" = "yes" ; then + feature_not_found "vnc-jpeg" + fi + vnc_jpeg=no + fi +fi + +########################################## # fnmatch() probe, used for ACL routines fnmatch="no" cat > $TMPC << EOF
@@ -2064,6 +2092,7 @@ echo "Block whitelist $block_drv_whitelist" echo "Mixer emulation $mixemu" echo "VNC TLS support $vnc_tls" echo "VNC SASL support $vnc_sasl" +echo "VNC JPEG support $vnc_jpeg" if test -n "$sparc_cpu"; then echo "Target Sparc Arch $sparc_cpu" fi
@@ -2200,6 +2229,10 @@ if test "$vnc_sasl" = "yes" ; then echo "CONFIG_VNC_SASL=y" >> $config_host_mak echo "VNC_SASL_CFLAGS=$vnc_sasl_cflags" >> $config_host_mak fi +if test "$vnc_jpeg" = "yes" ; then + echo "CONFIG_VNC_JPEG=y" >> $config_host_mak + echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak +fi if test "$fnmatch" = "yes" ; then echo "CONFIG_FNMATCH=y" >> $config_host_mak fi
vnc-encoding-tight.c +558 -1
605 lines not on this page · raw message
vnc-encoding-tight.h +5 -0
@@ -173,4 +173,9 @@#define VNC_TIGHT_MIN_SOLID_SUBRECT_SIZE 2048#define VNC_TIGHT_MAX_SPLIT_TILE_SIZE 16 +#define VNC_TIGHT_JPEG_MIN_RECT_SIZE 4096 +#define VNC_TIGHT_DETECT_SUBROW_WIDTH 7 +#define VNC_TIGHT_DETECT_MIN_WIDTH 8 +#define VNC_TIGHT_DETECT_MIN_HEIGHT 8 +#endif /* VNC_ENCODING_TIGHT_H */
vnc.h +4 -0
@@ -176,6 +176,10 @@ struct VncStateBuffer tight;Buffer tight_tmp;Buffer tight_zlib; +Buffer tight_gradient; +#ifdef CONFIG_VNC_JPEG +Buffer tight_jpeg; +#endif int tight_levels[4 ];z_stream tight_stream[4 ];
Signature · 1 line
1.7.1
[Qemu-devel] Re: [PATCH 01/16] vnc: tight: add JPEG and gradient subencoding with smooth image detection
Quoted 33 lines · Corentin Chary
Add gradient filter and JPEG compression with an heuristic to detect how lossy the comppression will be. This code has been adapted from
libvncserver/tight.c.JPEG support can be enabled/disabled at compile time with --enable-vnc-jpeg and --disable-vnc-jpeg.
Signed-off-by Corentin Chary <[email protected]>--- Makefile.target | 1 + configure | 33 +++ vnc-encoding-tight.c | 559 +++++++++++++++++++++++++++++++++++++++++++++++++- vnc-encoding-tight.h | 5 + vnc.h | 4 + 5 files changed, 601 insertions(+), 1 deletions(-)Makefile.target +1
-0@@ -177,6 +177,7 @@ LIBS+=-lz QEMU_CFLAGS += $(VNC_TLS_CFLAGS) QEMU_CFLAGS += $(VNC_SASL_CFLAGS) +QEMU_CFLAGS += $(VNC_JPEG_CFLAGS) # xen backend driver support obj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.oconfigure +0
-0
configure uuid="" · line 271
Quoted 4 lines
configure +1
-0@@ -268,6 +268,7 @@ uuid="" vde="" vnc_tls="" vnc_sasl="" +vnc_jpeg=""
init it to "no"
configure
Quoted 7 lines
configure +0
-0xen="" linux_aio="" vhost_net=""##########################################
configure +2
-0+# VNC JPEG detection +if test "$vnc_jpeg" = "yes" ; then
and use here != "no" as a test as the rest of the conditions, that way you only need to look in one place to know what is the default.
Yes, no documentation yet :(
Later, Juan.
[Qemu-devel] Re: [PATCH 01/16] vnc: tight: add JPEG and gradient subencoding with smooth image detection
Quoted 45 lines · Juan Quintela
Quoted 33 lines · Corentin Chary
Add gradient filter and JPEG compression with an heuristic to detect how lossy the comppression will be. This code has been adapted from
libvncserver/tight.c.JPEG support can be enabled/disabled at compile time with --enable-vnc-jpeg and --disable-vnc-jpeg.
Signed-off-by Corentin Chary <[email protected]>---
Makefile.target | 1 +
configure | 33 +++
vnc-encoding-tight.c | 559 +++++++++++++++++++++++++++++++++++++++++++++++++-vnc-encoding-tight.h| 5 +
vnc.h | 4 +5 files changed, 601 insertions(+), 1 deletions(-)Makefile.target +1
-0@@ -177,6 +177,7 @@ LIBS+=-lz QEMU_CFLAGS += $(VNC_TLS_CFLAGS) QEMU_CFLAGS += $(VNC_SASL_CFLAGS) +QEMU_CFLAGS += $(VNC_JPEG_CFLAGS) # xen backend driver supportobj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
configure +0
-0@@ -268,6 +268,7 @@ uuid=""Quoted 4 lines
vde=""
vnc_tls=""
vnc_sasl=""
+vnc_jpeg=""init it to "no"
Quoted 3 lines
xen=""
linux_aio=""
vhost_net=""
Quoted 7 lines
configure
Quoted 3 lines
##########################################
configure +2
-0+# VNC JPEG detection +if test "$vnc_jpeg" = "yes" ; thenand use here != "no" as a test as the rest of the conditions, that way you only need to look in one place to know what is the default.
I guess the same thing apply to PNG and Threaded server. Would it be ok to send a cumulative patch to fix that ?
Thanks,
Signature · 2 lines
Corentin Chary http://xf.iksaif.net
PATCH 2/16 vnc: JPEG should be disabled if the client don't set tight quality
In reply to Corentin CharyDisable JPEG compression by default and only enable it if the VNC client has sent the requested quality.
--- vnc.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
vnc.c +1 -1
@@ -1644,7 +1644,7 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) vs->features =0 ; vs->vnc_encoding =0 ; vs->tight_compression =9 ; - vs->tight_quality =9 ; + vs->tight_quality =-1 ;/* Lossless by default */ vs->absolute =-1 ;/*
Signature · 1 line
1.7.1
PATCH 3/16 vnc: add lossy option
In reply to Corentin CharyThe lossy option can be used to enable lossy compression methods like gradient or jpeg. This patch disable them by default.
--- qemu-options.hx | 7 +++++++ vnc-encoding-tight.c | 4 ++++ vnc.c | 2 ++ vnc.h | 2 ++ 4 files changed, 15 insertions(+), 0 deletions(-)
qemu-options.hx +7 -0
@@ -828,6 +828,13 @@ empty, with a @code{deny} policy. Thus no one will be allowed to use the VNC server until the ACLs have been loaded. This can be achieved using the @code{acl} monitor command. +@item lossy + +Enable lossy compression methods (gradient, JPEG, ...). If this +option is set, VNC client may receive lossy framebuffer updates +depending on its encoding settings. Enabling this option can save +a lot of bandwidth at the expense of quality. + @end table ETEXI
vnc-encoding-tight.c +4 -0
@@ -228,6 +228,10 @@ tight_detect_smooth_image(VncState *vs, int w, int h)int compression = vs->tight_compression;int quality = vs->tight_quality; +if (!vs->vd->lossy) { +return 0 ; + } +if (ds_get_bytes_per_pixel (vs->ds) ==1 || vs->clientds.pf.bytes_per_pixel ==1 || w <VNC_TIGHT_DETECT_MIN_WIDTH || h <VNC_TIGHT_DETECT_MIN_HEIGHT ) {
vnc.c +2 -0
@@ -2482,6 +2482,8 @@ int vnc_display_open(DisplayState *ds, const char *display)#endif }else if (strncmp (options,"acl" ,3 ) ==0 ) { acl =1 ; + }else if (strncmp (options,"lossy" ,5 ) ==0 ) { + vs->lossy = true; } }
vnc.h +2 -0
@@ -33,6 +33,7 @@#include "monitor.h" #include "audio/audio.h" #include <zlib.h> +#include <stdbool.h> #include "keymaps.h"
@@ -111,6 +112,7 @@ struct VncDisplaychar *display;char *password;int auth; +bool lossy;#ifdef CONFIG_VNC_TLS int subauth;/* Used by VeNCrypt */ VncDisplayTLS tls;
Signature · 1 line
1.7.1
PATCH 4/16 ui: move all ui components in ui/
In reply to Corentin CharyMove sdl, vnc, curses and cocoa UI into ui/ to cleanup the root directory. Also remove some unnecessary explicit targets from Makefile.
--- Makefile | 38 +++----------------- Makefile.objs | 22 ++++++----- cocoa.m => ui/cocoa.m | 0 curses.c => ui/curses.c | 0 curses_keys.h => ui/curses_keys.h | 0 d3des.c => ui/d3des.c | 0 d3des.h => ui/d3des.h | 0 keymaps.c => ui/keymaps.c | 0 keymaps.h => ui/keymaps.h | 0 sdl.c => ui/sdl.c | 0 sdl_keysym.h => ui/sdl_keysym.h | 0 sdl_zoom.c => ui/sdl_zoom.c | 0 sdl_zoom.h => ui/sdl_zoom.h | 0 sdl_zoom_template.h => ui/sdl_zoom_template.h | 0 vnc-auth-sasl.c => ui/vnc-auth-sasl.c | 0 vnc-auth-sasl.h => ui/vnc-auth-sasl.h | 0 vnc-auth-vencrypt.c => ui/vnc-auth-vencrypt.c | 0 vnc-auth-vencrypt.h => ui/vnc-auth-vencrypt.h | 0 .../vnc-encoding-hextile.c | 0 vnc-encoding-tight.c => ui/vnc-encoding-tight.c | 0 vnc-encoding-tight.h => ui/vnc-encoding-tight.h | 0 vnc-encoding-zlib.c => ui/vnc-encoding-zlib.c | 0 vnc-tls.c => ui/vnc-tls.c | 0 vnc-tls.h => ui/vnc-tls.h | 0 vnc.c => ui/vnc.c | 0 vnc.h => ui/vnc.h | 0 vnc_keysym.h => ui/vnc_keysym.h | 0 vnchextile.h => ui/vnchextile.h | 0 x_keymap.c => ui/x_keymap.c | 0 x_keymap.h => ui/x_keymap.h | 0 30 files changed, 17 insertions(+), 43 deletions(-) rename cocoa.m => ui/cocoa.m (100%) rename curses.c => ui/curses.c (100%) rename curses_keys.h => ui/curses_keys.h (100%) rename d3des.c => ui/d3des.c (100%) rename d3des.h => ui/d3des.h (100%) rename keymaps.c => ui/keymaps.c (100%) rename keymaps.h => ui/keymaps.h (100%) rename sdl.c => ui/sdl.c (100%) rename sdl_keysym.h => ui/sdl_keysym.h (100%) rename sdl_zoom.c => ui/sdl_zoom.c (100%) rename sdl_zoom.h => ui/sdl_zoom.h (100%) rename sdl_zoom_template.h => ui/sdl_zoom_template.h (100%) rename vnc-auth-sasl.c => ui/vnc-auth-sasl.c (100%) rename vnc-auth-sasl.h => ui/vnc-auth-sasl.h (100%) rename vnc-auth-vencrypt.c => ui/vnc-auth-vencrypt.c (100%) rename vnc-auth-vencrypt.h => ui/vnc-auth-vencrypt.h (100%) rename vnc-encoding-hextile.c => ui/vnc-encoding-hextile.c (100%) rename vnc-encoding-tight.c => ui/vnc-encoding-tight.c (100%) rename vnc-encoding-tight.h => ui/vnc-encoding-tight.h (100%) rename vnc-encoding-zlib.c => ui/vnc-encoding-zlib.c (100%) rename vnc-tls.c => ui/vnc-tls.c (100%) rename vnc-tls.h => ui/vnc-tls.h (100%) rename vnc.c => ui/vnc.c (100%) rename vnc.h => ui/vnc.h (100%) rename vnc_keysym.h => ui/vnc_keysym.h (100%) rename vnchextile.h => ui/vnchextile.h (100%) rename x_keymap.c => ui/x_keymap.c (100%) rename x_keymap.h => ui/x_keymap.h (100%)
Makefile +5 -33
@@ -96,42 +96,14 @@ audio/audio.o audio/fmodaudio.o: QEMU_CFLAGS += $(FMOD_CFLAGS) QEMU_CFLAGS+=$(CURL_CFLAGS) -cocoa.o: cocoa.m +ui/cocoa.o: ui/cocoa.m -keymaps.o: keymaps.c keymaps.h +ui/sdl.o audio/sdlaudio.o ui/sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) -sdl_zoom.o: sdl_zoom.c sdl_zoom.h sdl_zoom_template.h - -sdl.o: sdl.c keymaps.h sdl_keysym.h sdl_zoom.h - -sdl.o audio/sdlaudio.o sdl_zoom.o baum.o: QEMU_CFLAGS += $(SDL_CFLAGS) - -acl.o: acl.h acl.c - -vnc.h: vnc-tls.h vnc-auth-vencrypt.h vnc-auth-sasl.h keymaps.h - -vnc.o: vnc.c vnc.h vnc_keysym.h vnchextile.h d3des.c d3des.h acl.h - -vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS) - -vnc-tls.o: vnc-tls.c vnc.h - -vnc-auth-vencrypt.o: vnc-auth-vencrypt.c vnc.h - -vnc-auth-sasl.o: vnc-auth-sasl.c vnc.h - -vnc-encoding-zlib.o: vnc-encoding-zlib.c vnc.h - -vnc-encoding-hextile.o: vnc-encoding-hextile.c vnc.h - -vnc-encoding-tight.o: vnc-encoding-tight.c vnc.h vnc-encoding-tight.h - -curses.o: curses.c keymaps.h curses_keys.h +ui/vnc.o: QEMU_CFLAGS += $(VNC_TLS_CFLAGS) bt-host.o: QEMU_CFLAGS += $(BLUEZ_CFLAGS) -iov.o: iov.c iov.h - ###################################################################### qemu-img.o: qemu-img-cmds.h
@@ -159,7 +131,7 @@ clean: # avoid old build problems by removing potentially incorrect old files rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~ - rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d + rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d net/*.o net/*.d ui/*.o ui/*.d rm -f qemu-img-cmds.h $(MAKE) -C tests clean for d in $(ALL_SUBDIRS) libhw32 libhw64 libuser libdis libdis-user; do \
@@ -343,4 +315,4 @@ tarbin: $(mandir)/man8/qemu-nbd.8 # Include automatically generated dependency files --include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d) +-include $(wildcard *.d audio/*.d slirp/*.d block/*.d net/*.d ui/*.d)
Makefile.objs +12 -10
@@ -102,16 +102,18 @@ audio-obj-$(CONFIG_AUDIO_WIN_INT) += audio_win_int.o audio-obj-y += wavcapture.o common-obj-y += $(addprefix audio/, $(audio-obj-y)) -common-obj-y += keymaps.o -common-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o -common-obj-$(CONFIG_CURSES) += curses.o -common-obj-y += vnc.o acl.o d3des.o -common-obj-y += vnc-encoding-zlib.o vnc-encoding-hextile.o -common-obj-y += vnc-encoding-tight.o -common-obj-y += iov.o -common-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o -common-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o -common-obj-$(CONFIG_COCOA) += cocoa.o +ui-obj-y += keymaps.o +ui-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o +ui-obj-$(CONFIG_CURSES) += curses.o +ui-obj-y += vnc.o d3des.o +ui-obj-y += vnc-encoding-zlib.o vnc-encoding-hextile.o +ui-obj-y += vnc-encoding-tight.o +ui-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o +ui-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o +ui-obj-$(CONFIG_COCOA) += cocoa.o +common-obj-y += $(addprefix ui/, $(ui-obj-y)) + +common-obj-y += iov.o acl.o common-obj-$(CONFIG_IOTHREAD) += qemu-thread.o common-obj-y += notify.o event_notifier.o common-obj-y += qemu-timer.o
ui/cocoa.m renamed from cocoa.m +0 -0
ui/curses.c renamed from curses.c +0 -0
ui/curses_keys.h renamed from curses_keys.h +0 -0
ui/d3des.c renamed from d3des.c +0 -0
ui/d3des.h renamed from d3des.h +0 -0
ui/keymaps.c renamed from keymaps.c +0 -0
ui/keymaps.h renamed from keymaps.h +0 -0
ui/sdl.c renamed from sdl.c +0 -0
ui/sdl_keysym.h renamed from sdl_keysym.h +0 -0
ui/sdl_zoom.c renamed from sdl_zoom.c +0 -0
ui/sdl_zoom.h renamed from sdl_zoom.h +0 -0
ui/sdl_zoom_template.h renamed from sdl_zoom_template.h +0 -0
ui/vnc-auth-sasl.c renamed from vnc-auth-sasl.c +0 -0
ui/vnc-auth-sasl.h renamed from vnc-auth-sasl.h +0 -0
ui/vnc-auth-vencrypt.c renamed from vnc-auth-vencrypt.c +0 -0
ui/vnc-auth-vencrypt.h renamed from vnc-auth-vencrypt.h +0 -0
ui/vnc-encoding-hextile.c renamed from vnc-encoding-hextile.c +0 -0
ui/vnc-encoding-tight.c renamed from vnc-encoding-tight.c +0 -0
ui/vnc-encoding-tight.h renamed from vnc-encoding-tight.h +0 -0
ui/vnc-encoding-zlib.c renamed from vnc-encoding-zlib.c +0 -0
ui/vnc-tls.c renamed from vnc-tls.c +0 -0
ui/vnc-tls.h renamed from vnc-tls.h +0 -0
ui/vnc.c renamed from vnc.c +0 -0
ui/vnc.h renamed from vnc.h +0 -0
ui/vnc_keysym.h renamed from vnc_keysym.h +0 -0
ui/vnchextile.h renamed from vnchextile.h +0 -0
ui/x_keymap.c renamed from x_keymap.c +0 -0
ui/x_keymap.h renamed from x_keymap.h +0 -0
Signature · 1 line
1.7.1
PATCH 5/16 vnc: rename vnc-encoding-* vnc-enc-*
In reply to Corentin CharyFor the same reason that we don't use vnc-authentication-sasl.c but vnc-auth-sals.c. Because it's tooooo long.
---
Makefile.objs | 4 ++--
ui/{vnchextile.h => vnc-enc-hextile-template.h} | 0
ui/{vnc-encoding-hextile.c => vnc-enc-hextile.c} | 12 ++++++------
ui/{vnc-encoding-tight.c => vnc-enc-tight.c} | 2 +-
ui/{vnc-encoding-tight.h => vnc-enc-tight.h} | 0
ui/{vnc-encoding-zlib.c => vnc-enc-zlib.c} | 0
6 files changed, 9 insertions(+), 9 deletions(-)
rename ui/{vnchextile.h => vnc-enc-hextile-template.h} (100%)
rename ui/{vnc-encoding-hextile.c => vnc-enc-hextile.c} (93%)
rename ui/{vnc-encoding-tight.c => vnc-enc-tight.c} (99%)
rename ui/{vnc-encoding-tight.h => vnc-enc-tight.h} (100%)
rename ui/{vnc-encoding-zlib.c => vnc-enc-zlib.c} (100%)Makefile.objs +2 -2
@@ -106,8 +106,8 @@ ui-obj-y += keymaps.o ui-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o ui-obj-$(CONFIG_CURSES) += curses.o ui-obj-y += vnc.o d3des.o -ui-obj-y += vnc-encoding-zlib.o vnc-encoding-hextile.o -ui-obj-y += vnc-encoding-tight.o +ui-obj-y += vnc-enc-zlib.o vnc-enc-hextile.o +ui-obj-y += vnc-enc-tight.o ui-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o ui-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o ui-obj-$(CONFIG_COCOA) += cocoa.o
ui/vnc-enc-hextile-template.h renamed from ui/vnchextile.h +0 -0
ui/vnc-enc-hextile.c renamed from ui/vnc-encoding-hextile.c +6 -6
@@ -33,32 +33,32 @@ static void hextile_enc_cord(uint8_t *ptr, int x, int y, int w, int h) }#define BPP 8 -#include "vnchextile.h" +#include "vnc-enc-hextile-template.h" #undef BPP#define BPP 16 -#include "vnchextile.h" +#include "vnc-enc-hextile-template.h" #undef BPP#define BPP 32 -#include "vnchextile.h" +#include "vnc-enc-hextile-template.h" #undef BPP#define GENERIC #define BPP 8 -#include "vnchextile.h" +#include "vnc-enc-hextile-template.h" #undef BPP#undef GENERIC#define GENERIC #define BPP 16 -#include "vnchextile.h" +#include "vnc-enc-hextile-template.h" #undef BPP#undef GENERIC#define GENERIC #define BPP 32 -#include "vnchextile.h" +#include "vnc-enc-hextile-template.h" #undef BPP#undef GENERIC
ui/vnc-enc-tight.c renamed from ui/vnc-encoding-tight.c +1 -1
@@ -37,7 +37,7 @@#include "qdict.h" #include "qint.h" #include "vnc.h" -#include "vnc-encoding-tight.h" +#include "vnc-enc-tight.h" /* Compression level stuff. The following array contains various encoder parameters for each of 10 compression levels (0..9).
ui/vnc-enc-tight.h renamed from ui/vnc-encoding-tight.h +0 -0
ui/vnc-enc-zlib.c renamed from ui/vnc-encoding-zlib.c +0 -0
Signature · 1 line
1.7.1
PATCH 6/16 vnc: tight: don't forget do at the last color
In reply to Corentin CharyWhile using indexed colors, the last color was never added to the palette. Triggered with ubuntu livecd.
--- ui/vnc-enc-tight.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
ui/vnc-enc-tight.c +1 -1
@@ -393,11 +393,11 @@ static int tight_palette_insert(QDict *palette, uint32_t rgb, int bpp, int max)if (data[i] == ci) { \continue ; \ }else { \ + ci = data[i]; \if (!tight_palette_insert (*palette, (uint32_t )ci, \ bpp, max)) { \return 0 ; \ } \ - ci = data[i]; \ } \ } \ \
Signature · 1 line
1.7.1
PATCH 7/16 vnc: tight: remove a memleak in send_jpeg_rect()
In reply to Corentin Charybuf was never freed.
--- ui/vnc-enc-tight.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-)
ui/vnc-enc-tight.c +3 -2
@@ -1247,8 +1247,6 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)if (ds_get_bytes_per_pixel (vs->ds) ==1 )return send_full_color_rect (vs, w, h); - buf =qemu_malloc (w *3 ); - row[0 ] = buf;buffer_reserve (&vs->tight_jpeg,2048 ); cinfo.err =jpeg_std_error (&jerr);
@@ -1270,10 +1268,13 @@ static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)jpeg_start_compress (&cinfo, true); + buf =qemu_malloc (w *3 ); + row[0 ] = buf;for (dy =0 ; dy < h; dy++) {jpeg_prepare_row (vs, buf, x, y + dy, w);jpeg_write_scanlines (&cinfo, row,1 ); } +qemu_free (buf);jpeg_finish_compress (&cinfo);jpeg_destroy_compress (&cinfo);
Signature · 1 line
1.7.1
PATCH 8/16 vnc: tight add PNG encoding
In reply to Corentin CharyIntroduce a new encoding: VNC_ENCODING_TIGHT_PNG (0x17) and a new tight filter VNC_TIGHT_PNG (0x0A). When the client tells it supports the 0x17 encoding, the server will use tight, but will always send encoding pixels using PNG instead of zlib. If the client also told it support JPEG, then the server can send JPEG, because PNG will only be used in the cases zlib was used in normal tight.
This encoding was introduced to speed up HTML5 based VNC clients like noVNC [1], but can also be used on devices like iPhone where PNG can be rendered in hardware.
[1] http://github.com/kanaka/noVNC/
--- Makefile.target | 1 + configure | 37 +++++++ ui/vnc-enc-tight.c | 277 ++++++++++++++++++++++++++++++++++++++++++++++------ ui/vnc-enc-tight.h | 17 ++-- ui/vnc.c | 9 +- ui/vnc.h | 11 ++ 6 files changed, 311 insertions(+), 41 deletions(-)
Makefile.target +1 -0
@@ -178,6 +178,7 @@ LIBS+=-lz QEMU_CFLAGS += $(VNC_TLS_CFLAGS) QEMU_CFLAGS += $(VNC_SASL_CFLAGS) QEMU_CFLAGS += $(VNC_JPEG_CFLAGS) +QEMU_CFLAGS += $(VNC_PNG_CFLAGS) # xen backend driver support obj-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
configure +37 -0
@@ -269,6 +269,7 @@ vde="" vnc_tls="" vnc_sasl="" vnc_jpeg="" +vnc_png="" xen="" linux_aio="" vhost_net=""
@@ -579,6 +580,10 @@ for opt do ;; --enable-vnc-jpeg) vnc_jpeg="yes" ;; + --disable-vnc-png) vnc_png="no" + ;; + --enable-vnc-png) vnc_png="yes" + ;; --disable-slirp) slirp="no" ;; --disable-uuid) uuid="no"
@@ -825,6 +830,8 @@ echo " --disable-vnc-sasl disable SASL encryption for VNC server" echo " --enable-vnc-sasl enable SASL encryption for VNC server" echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server" echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server" +echo " --disable-vnc-png disable PNG compression for VNC server" +echo " --enable-vnc-png enable PNG compression for VNC server" echo " --disable-curses disable curses output" echo " --enable-curses enable curses output" echo " --disable-curl disable curl connectivity"
@@ -1265,6 +1272,31 @@ EOF fi ########################################## +# VNC PNG detection +if test "$vnc_png" = "yes" ; then +cat > $TMPC <<EOF +//#include <stdio.h> +#include <png.h> +int main(void) { + png_structp png_ptr; + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + return 0; +} +EOF + vnc_png_cflags="" + vnc_png_libs="-lpng" + if compile_prog "$vnc_png_cflags" "$vnc_png_libs" ; then + vnc_png=yes + libs_softmmu="$vnc_png_libs $libs_softmmu" + else + if test "$vnc_png" = "yes" ; then + feature_not_found "vnc-png" + fi + vnc_png=no + fi +fi + +########################################## # fnmatch() probe, used for ACL routines fnmatch="no" cat > $TMPC << EOF
@@ -2093,6 +2125,7 @@ echo "Mixer emulation $mixemu" echo "VNC TLS support $vnc_tls" echo "VNC SASL support $vnc_sasl" echo "VNC JPEG support $vnc_jpeg" +echo "VNC PNG support $vnc_png" if test -n "$sparc_cpu"; then echo "Target Sparc Arch $sparc_cpu" fi
@@ -2233,6 +2266,10 @@ if test "$vnc_jpeg" = "yes" ; then echo "CONFIG_VNC_JPEG=y" >> $config_host_mak echo "VNC_JPEG_CFLAGS=$vnc_jpeg_cflags" >> $config_host_mak fi +if test "$vnc_png" = "yes" ; then + echo "CONFIG_VNC_PNG=y" >> $config_host_mak + echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak +fi if test "$fnmatch" = "yes" ; then echo "CONFIG_FNMATCH=y" >> $config_host_mak fi
ui/vnc-enc-tight.c +247 -30
425 lines not on this page · raw message
ui/vnc-enc-tight.h +10 -7
@@ -42,8 +42,9 @@* bit 3: if 1, then compression stream 3 should be reset; * bits 7-4: if 1000 (0x08), then the compression type is "fill", * if 1001 (0x09), then the compression type is "jpeg", +* if 1010 (0x0A), then the compression type is "png", * if 0xxx, then the compression type is "basic", -* values greater than 1001 are not valid. +* values greater than 1010 are not valid. * * If the compression type is "basic", then bits 6..4 of the * compression control byte (those xxx in 0xxx) specify the following:
@@ -53,17 +54,17 @@* bit 6: if 1, then a "filter id" byte is following this byte. * *-- The data that follows after the compression control byte described -* above depends on the compression type ("fill", "jpeg" or "basic"). +* above depends on the compression type ("fill", "jpeg", "png" or "basic"). * *-- If the compression type is "fill", then the only pixel value follows, in * client pixel format (see NOTE 1). This value applies to all pixels of the * rectangle. * -*-- If the compression type is "jpeg", the following data stream looks like -* this: +*-- If the compression type is "jpeg" or "png", the following data stream +* looks like this: * * 1..3 bytes: data size (N) in compact representation; -* N bytes: JPEG image. +* N bytes: JPEG or PNG image. * * Data size is compactly represented in one, two or three bytes, according * to the following scheme:
@@ -144,7 +145,7 @@ *-- NOTE 2. The decoder must reset compression streams' states before * decoding the rectangle, if some of bits 0,1,2,3 in the compression control * byte are set to 1. Note that the decoder must reset zlib streams even if - * the compression type is "fill" or "jpeg". + * the compression type is "fill", "jpeg" or "png". * *-- NOTE 3. The "gradient" filter and "jpeg" compression may be used only * when bits-per-pixel value is either 16 or 32, not 8.
@@ -158,7 +159,8 @@#define VNC_TIGHT_EXPLICIT_FILTER 0x04#define VNC_TIGHT_FILL 0x08#define VNC_TIGHT_JPEG 0x09 -#define VNC_TIGHT_MAX_SUBENCODING 0x09 +#define VNC_TIGHT_PNG 0x0A +#define VNC_TIGHT_MAX_SUBENCODING 0x0A/* Filters to improve compression efficiency */ #define VNC_TIGHT_FILTER_COPY 0x00
@@ -174,6 +176,7 @@#define VNC_TIGHT_MAX_SPLIT_TILE_SIZE 16#define VNC_TIGHT_JPEG_MIN_RECT_SIZE 4096 +#define VNC_TIGHT_PNG_MIN_RECT_SIZE 4096#define VNC_TIGHT_DETECT_SUBROW_WIDTH 7#define VNC_TIGHT_DETECT_MIN_WIDTH 8#define VNC_TIGHT_DETECT_MIN_HEIGHT 8
ui/vnc.c +5 -4
@@ -351,10 +351,6 @@ void do_info_vnc(Monitor *mon, QObject **ret_data) } } -static inline uint32_t vnc_has_feature (VncState *vs,int feature) { -return (vs->features & (1 << feature)); -} -/* TODO 1) Get the queue working for IO. 2) there is some weirdness when using the -S option (the screen is grey
@@ -659,6 +655,7 @@ static int send_framebuffer_update(VncState *vs, int x, int y, int w, int h) n =vnc_hextile_send_framebuffer_update (vs, x, y, w, h);break ;case VNC_ENCODING_TIGHT : +case VNC_ENCODING_TIGHT_PNG : n =vnc_tight_send_framebuffer_update (vs, x, y, w, h);break ;default :
@@ -1669,6 +1666,10 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) vs->features |=VNC_FEATURE_TIGHT_MASK ; vs->vnc_encoding = enc;break ; +case VNC_ENCODING_TIGHT_PNG : + vs->features |=VNC_FEATURE_TIGHT_PNG_MASK ; + vs->vnc_encoding = enc; +break ;case VNC_ENCODING_ZLIB : vs->features |=VNC_FEATURE_ZLIB_MASK ; vs->vnc_encoding = enc;
ui/vnc.h +11 -0
@@ -182,6 +182,9 @@ struct VncState#ifdef CONFIG_VNC_JPEG Buffer tight_jpeg;#endif +#ifdef CONFIG_VNC_PNG +Buffer tight_png; +#endif int tight_levels[4 ];z_stream tight_stream[4 ];
@@ -245,6 +248,7 @@ enum {#define VNC_ENCODING_HEXTILE 0x00000005#define VNC_ENCODING_ZLIB 0x00000006#define VNC_ENCODING_TIGHT 0x00000007 +#define VNC_ENCODING_TIGHT_PNG 0x00000017#define VNC_ENCODING_ZLIBHEX 0x00000008#define VNC_ENCODING_TRLE 0x0000000f#define VNC_ENCODING_ZRLE 0x00000010
@@ -275,6 +279,7 @@ enum {#define VNC_TIGHT_CCB_TYPE_MASK (0x0f << 4)#define VNC_TIGHT_CCB_TYPE_FILL (0x08 << 4)#define VNC_TIGHT_CCB_TYPE_JPEG (0x09 << 4) +#define VNC_TIGHT_CCB_TYPE_PNG (0x0A << 4)#define VNC_TIGHT_CCB_BASIC_MAX (0x07 << 4)#define VNC_TIGHT_CCB_BASIC_ZLIB (0x03 << 4)#define VNC_TIGHT_CCB_BASIC_FILTER (0x04 << 4)
@@ -293,6 +298,7 @@ enum {#define VNC_FEATURE_ZLIB 5#define VNC_FEATURE_COPYRECT 6#define VNC_FEATURE_RICH_CURSOR 7 +#define VNC_FEATURE_TIGHT_PNG 8#define VNC_FEATURE_RESIZE_MASK (1 << VNC_FEATURE_RESIZE)#define VNC_FEATURE_HEXTILE_MASK (1 << VNC_FEATURE_HEXTILE)
@@ -302,6 +308,7 @@ enum {#define VNC_FEATURE_ZLIB_MASK (1 << VNC_FEATURE_ZLIB)#define VNC_FEATURE_COPYRECT_MASK (1 << VNC_FEATURE_COPYRECT)#define VNC_FEATURE_RICH_CURSOR_MASK (1 << VNC_FEATURE_RICH_CURSOR) +#define VNC_FEATURE_TIGHT_PNG_MASK (1 << VNC_FEATURE_TIGHT_PNG)/* Client -> Server message IDs */
@@ -405,6 +412,10 @@ void buffer_append(Buffer *buffer, const void *data, size_t len);char *vnc_socket_local_addr (const char *format,int fd);char *vnc_socket_remote_addr (const char *format,int fd); +static inline uint32_t vnc_has_feature (VncState *vs,int feature) { +return (vs->features & (1 << feature)); +} +/* Framebuffer */ void vnc_framebuffer_update (VncState *vs,int x,int y,int w,int h,int32_t encoding);
Signature · 1 line
1.7.1
PATCH 9/16 vnc: tight: specific zlib level and filters for each compression level
In reply to Corentin CharyDisable png filters for lower compression levels. This should lower the CPU consumption and reduce encoding time.
This isn't in tight_conf because:
* tight_conf structure must not change, because it's shared with other tight implementations (libvncserver, etc..).
* it'd exceed the 80 col limit.
* PNG_ macros are only defined if CONFIG_VNC_PNG is defined
--- ui/vnc-enc-tight.c | 19 ++++++++++++++++++- 1 files changed, 18 insertions(+), 1 deletions(-)
ui/vnc-enc-tight.c +18 -1
@@ -69,6 +69,21 @@ static const struct { };#ifdef CONFIG_VNC_PNG +static const struct { +int png_zlib_level, png_filters; +} tight_png_conf[] = { + {0 ,PNG_NO_FILTERS }, + {1 ,PNG_NO_FILTERS }, + {2 ,PNG_NO_FILTERS }, + {3 ,PNG_NO_FILTERS }, + {4 ,PNG_NO_FILTERS }, + {5 ,PNG_ALL_FILTERS }, + {6 ,PNG_ALL_FILTERS }, + {7 ,PNG_ALL_FILTERS }, + {8 ,PNG_ALL_FILTERS }, + {9 ,PNG_ALL_FILTERS }, +}; +static int send_png_rect (VncState *vs,int x,int y,int w,int h,QDict *palette);
@@ -1424,7 +1439,8 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,png_infop info_ptr;png_colorp png_palette =NULL ;size_t offset; -int level = tight_conf[vs->tight_compression].raw_zlib_level; +int level = tight_png_conf[vs->tight_compression].png_zlib_level; +int filters = tight_png_conf[vs->tight_compression].png_filters;uint8_t *buf;int dy;
@@ -1443,6 +1459,7 @@ static int send_png_rect(VncState *vs, int x, int y, int w, int h,png_set_write_fn (png_ptr, (void *) vs, png_write_data, png_flush_data);png_set_compression_level (png_ptr, level); +png_set_filter (png_ptr,PNG_FILTER_TYPE_DEFAULT , filters);if (palette) { color_type =PNG_COLOR_TYPE_PALETTE ;
Signature · 1 line
1.7.1
PATCH 10/16 vnc: tight: stop using qdict for palette stuff
In reply to Corentin CharyProfiling with callgrind seems to show that a lot of time is spent in the palette code (mostly due to memory allocation and qdict to int conversion).
This patch adds a VncPalette implementation. The palette is stored in a hash table, like qdict, but which does way less memory allocations, and doesn't suffer from the QObject overhead.
--- Makefile.objs | 2 +- ui/vnc-enc-tight.c | 163 +++++++++++---------------------------------------- ui/vnc-palette.c | 136 +++++++++++++++++++++++++++++++++++++++++++ ui/vnc-palette.h | 63 ++++++++++++++++++++ 4 files changed, 235 insertions(+), 129 deletions(-) create mode 100644 ui/vnc-palette.c create mode 100644 ui/vnc-palette.h
Makefile.objs +1 -1
@@ -107,7 +107,7 @@ ui-obj-$(CONFIG_SDL) += sdl.o sdl_zoom.o x_keymap.o ui-obj-$(CONFIG_CURSES) += curses.o ui-obj-y += vnc.o d3des.o ui-obj-y += vnc-enc-zlib.o vnc-enc-hextile.o -ui-obj-y += vnc-enc-tight.o +ui-obj-y += vnc-enc-tight.o vnc-palette.o ui-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o ui-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o ui-obj-$(CONFIG_COCOA) += cocoa.o
ui/vnc-enc-tight.c +35 -128
324 lines not on this page · raw message
ui/vnc-palette.c new file +132 -0
132 lines not on this page · raw message
ui/vnc-palette.h new file +59 -0
59 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 11/16 vnc: encapsulate encoding members
In reply to Corentin CharyThis will allow to implement the threaded VNC server in a more cleaner way.
--- ui/vnc-enc-hextile.c | 14 ++-- ui/vnc-enc-tight.c | 194 +++++++++++++++++++++++++------------------------- ui/vnc-enc-zlib.c | 34 +++++----- ui/vnc.c | 8 +- ui/vnc.h | 58 ++++++++------- 5 files changed, 157 insertions(+), 151 deletions(-)
ui/vnc-enc-hextile.c +7 -7
@@ -75,7 +75,7 @@ int vnc_hextile_send_framebuffer_update(VncState *vs, int x, has_fg = has_bg =0 ;for (j = y; j < (y + h); j +=16 ) {for (i = x; i < (x + w); i +=16 ) { - vs->send_hextile_tile (vs, i, j, + vs->hextile.send_tile (vs, i, j,MIN (16 , x + w - i),MIN (16 , y + h - j), last_bg, last_fg, &has_bg, &has_fg); }
@@ -91,25 +91,25 @@ void vnc_hextile_set_pixel_conversion(VncState *vs, int generic)if (!generic) {switch (vs->ds->surface->pf.bits_per_pixel) {case 8 : - vs->send_hextile_tile = send_hextile_tile_8; + vs->hextile.send_tile = send_hextile_tile_8;break ;case 16 : - vs->send_hextile_tile = send_hextile_tile_16; + vs->hextile.send_tile = send_hextile_tile_16;break ;case 32 : - vs->send_hextile_tile = send_hextile_tile_32; + vs->hextile.send_tile = send_hextile_tile_32;break ; } }else {switch (vs->ds->surface->pf.bits_per_pixel) {case 8 : - vs->send_hextile_tile = send_hextile_tile_generic_8; + vs->hextile.send_tile = send_hextile_tile_generic_8;break ;case 16 : - vs->send_hextile_tile = send_hextile_tile_generic_16; + vs->hextile.send_tile = send_hextile_tile_generic_16;break ;case 32 : - vs->send_hextile_tile = send_hextile_tile_generic_32; + vs->hextile.send_tile = send_hextile_tile_generic_32;break ; } }
ui/vnc-enc-tight.c +97 -97
542 lines not on this page · raw message
ui/vnc-enc-zlib.c +17 -17
@@ -47,21 +47,21 @@ void vnc_zlib_zfree(void *x, void *addr)static void vnc_zlib_start (VncState *vs) { -buffer_reset (&vs->zlib); +buffer_reset (&vs->zlib.zlib);// make the output buffer be the zlib buffer, so we can compress it later - vs->zlib_tmp = vs->output; - vs->output = vs->zlib; + vs->zlib.tmp = vs->output; + vs->output = vs->zlib.zlib; }static int vnc_zlib_stop (VncState *vs) { -z_streamp zstream = &vs->zlib_stream; +z_streamp zstream = &vs->zlib.stream;int previous_out;// switch back to normal output/zlib buffers - vs->zlib = vs->output; - vs->output = vs->zlib_tmp; + vs->zlib.zlib = vs->output; + vs->output = vs->zlib.tmp;// compress the zlib buffer
@@ -75,7 +75,7 @@ static int vnc_zlib_stop(VncState *vs) zstream->zalloc = vnc_zlib_zalloc; zstream->zfree = vnc_zlib_zfree; - err =deflateInit2 (zstream, vs->tight_compression,Z_DEFLATED ,MAX_WBITS , + err =deflateInit2 (zstream, vs->tight.compression,Z_DEFLATED ,MAX_WBITS ,MAX_MEM_LEVEL ,Z_DEFAULT_STRATEGY );if (err !=Z_OK ) {
@@ -83,24 +83,24 @@ static int vnc_zlib_stop(VncState *vs)return -1 ; } - vs->zlib_level = vs->tight_compression; + vs->zlib.level = vs->tight.compression; zstream->opaque = vs; } -if (vs->tight_compression != vs->zlib_level) { -if (deflateParams (zstream, vs->tight_compression, +if (vs->tight.compression != vs->zlib.level) { +if (deflateParams (zstream, vs->tight.compression,Z_DEFAULT_STRATEGY ) !=Z_OK ) {return -1 ; } - vs->zlib_level = vs->tight_compression; + vs->zlib.level = vs->tight.compression; }// reserve memory in output buffer -buffer_reserve (&vs->output, vs->zlib.offset +64 ); +buffer_reserve (&vs->output, vs->zlib.zlib.offset +64 );// set pointers - zstream->next_in = vs->zlib.buffer; - zstream->avail_in = vs->zlib.offset; + zstream->next_in = vs->zlib.zlib.buffer; + zstream->avail_in = vs->zlib.zlib.offset; zstream->next_out = vs->output.buffer + vs->output.offset; zstream->avail_out = vs->output.capacity - vs->output.offset; zstream->data_type =Z_BINARY ;
@@ -145,8 +145,8 @@ int vnc_zlib_send_framebuffer_update(VncState *vs, int x, int y, int w, int h)void vnc_zlib_clear (VncState *vs) { -if (vs->zlib_stream.opaque) { -deflateEnd (&vs->zlib_stream); +if (vs->zlib.stream.opaque) { +deflateEnd (&vs->zlib.stream); } -buffer_free (&vs->zlib); +buffer_free (&vs->zlib.zlib); }
ui/vnc.c +4 -4
@@ -1640,8 +1640,8 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) vs->features =0 ; vs->vnc_encoding =0 ; - vs->tight_compression =9 ; - vs->tight_quality =-1 ;/* Lossless by default */ + vs->tight.compression =9 ; + vs->tight.quality =-1 ;/* Lossless by default */ vs->absolute =-1 ;/*
@@ -1693,10 +1693,10 @@ static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings) vs->features |=VNC_FEATURE_WMVI_MASK ;break ; case VNC_ENCODING_COMPRESSLEVEL0 ... VNC_ENCODING_COMPRESSLEVEL0 + 9: - vs->tight_compression = (enc &0x0F ); + vs->tight.compression = (enc &0x0F );break ; case VNC_ENCODING_QUALITYLEVEL0 ... VNC_ENCODING_QUALITYLEVEL0 + 9: - vs->tight_quality = (enc &0x0F ); + vs->tight.quality = (enc &0x0F );break ;default :VNC_DEBUG ("Unknown encoding: %d (0x%.8x): %d\n" , i, enc, enc);
ui/vnc.h +32 -26
70 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 12/16 vnc: fix tight png memory leak
In reply to Corentin CharyThe tight.png buffer was never released.
--- ui/vnc-enc-tight.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
ui/vnc-enc-tight.c +3 -0
@@ -1659,4 +1659,7 @@ void vnc_tight_clear(VncState *vs)#ifdef CONFIG_VNC_JPEG buffer_free (&vs->tight.jpeg);#endif +#ifdef CONFIG_VNC_PNG +buffer_free (&vs->tight.png); +#endif }
Signature · 1 line
1.7.1
PATCH 13/16 qemu-thread: add qemu_mutex/cond_destroy and qemu_mutex_exit
In reply to Corentin CharyAdd some missing functions in qemu-thread. Currently qemu-thread is only used for io-thread but it will used by the vnc server soon and we need those functions instead of calling pthread directly.
--- qemu-thread.c | 22 ++++++++++++++++++++++ qemu-thread.h | 4 ++++ 2 files changed, 26 insertions(+), 0 deletions(-)
qemu-thread.c +22 -0
@@ -34,6 +34,15 @@ void qemu_mutex_init(QemuMutex *mutex)error_exit (err, __func__); } +void qemu_mutex_destroy (QemuMutex *mutex) +{ +int err; + + err =pthread_mutex_destroy (&mutex->lock); +if (err) +error_exit (err, __func__); +} +void qemu_mutex_lock (QemuMutex *mutex) {int err;
@@ -90,6 +99,15 @@ void qemu_cond_init(QemuCond *cond)error_exit (err, __func__); } +void qemu_cond_destroy (QemuCond *cond) +{ +int err; + + err =pthread_cond_destroy (&cond->cond); +if (err) +error_exit (err, __func__); +} +void qemu_cond_signal (QemuCond *cond) {int err;
@@ -168,3 +186,7 @@ int qemu_thread_equal(QemuThread *thread1, QemuThread *thread2)return pthread_equal (thread1->thread, thread2->thread); } +void qemu_thread_exit (void *retval) +{ +pthread_exit (retval); +}
qemu-thread.h +4 -0
@@ -20,12 +20,14 @@ typedef struct QemuCond QemuCond;typedef struct QemuThread QemuThread ;void qemu_mutex_init (QemuMutex *mutex); +void qemu_mutex_destroy (QemuMutex *mutex);void qemu_mutex_lock (QemuMutex *mutex);int qemu_mutex_trylock (QemuMutex *mutex);int qemu_mutex_timedlock (QemuMutex *mutex,uint64_t msecs);void qemu_mutex_unlock (QemuMutex *mutex);void qemu_cond_init (QemuCond *cond); +void qemu_cond_destroy (QemuCond *cond);void qemu_cond_signal (QemuCond *cond);void qemu_cond_broadcast (QemuCond *cond);void qemu_cond_wait (QemuCond *cond,QemuMutex *mutex);
@@ -37,4 +39,6 @@ void qemu_thread_create(QemuThread *thread,void qemu_thread_signal (QemuThread *thread,int sig);void qemu_thread_self (QemuThread *thread);int qemu_thread_equal (QemuThread *thread1,QemuThread *thread2); +void qemu_thread_exit (void *retval); +#endif
Signature · 1 line
1.7.1
PATCH 14/16 vnc: threaded VNC server
In reply to Corentin CharyImplement a threaded VNC server using the producer-consumer model. The main thread will push encoding jobs (a list a rectangles to update) in a queue, and the VNC worker thread will consume that queue and send framebuffer updates to the output buffer.
The threaded VNC server can be enabled with ./configure --enable-vnc-thread.
If you don't want it, just use ./configure --disable-vnc-thread and a syncrhonous queue of job will be used (which as exactly the same behavior as the old queue). If you disable the VNC thread, all thread related code will not be built and there will be no overhead.
--- Makefile.objs | 7 +- configure | 13 ++ ui/vnc-jobs-async.c | 331 +++++++++++++++++++++++++++++++++++++++++++++++++++ ui/vnc-jobs-sync.c | 73 +++++++++++ ui/vnc-jobs.h | 87 ++++++++++++++ ui/vnc.c | 144 +++++++++++++++++++---- ui/vnc.h | 53 ++++++++- 7 files changed, 682 insertions(+), 26 deletions(-) create mode 100644 ui/vnc-jobs-async.c create mode 100644 ui/vnc-jobs-sync.c create mode 100644 ui/vnc-jobs.h
Makefile.objs +6 -1
@@ -111,10 +111,15 @@ ui-obj-y += vnc-enc-tight.o vnc-palette.o ui-obj-$(CONFIG_VNC_TLS) += vnc-tls.o vnc-auth-vencrypt.o ui-obj-$(CONFIG_VNC_SASL) += vnc-auth-sasl.o ui-obj-$(CONFIG_COCOA) += cocoa.o +ifdef CONFIG_VNC_THREAD +ui-obj-y += vnc-jobs-async.o +else +ui-obj-y += vnc-jobs-sync.o +endif common-obj-y += $(addprefix ui/, $(ui-obj-y)) common-obj-y += iov.o acl.o -common-obj-$(CONFIG_IOTHREAD) += qemu-thread.o +common-obj-$(CONFIG_THREAD) += qemu-thread.o common-obj-y += notify.o event_notifier.o common-obj-y += qemu-timer.o
configure +13 -0
@@ -270,6 +270,7 @@ vnc_tls="" vnc_sasl="" vnc_jpeg="" vnc_png="" +vnc_thread="" xen="" linux_aio="" vhost_net=""
@@ -584,6 +585,10 @@ for opt do ;; --enable-vnc-png) vnc_png="yes" ;; + --disable-vnc-thread) vnc_thread="no" + ;; + --enable-vnc-thread) vnc_thread="yes" + ;; --disable-slirp) slirp="no" ;; --disable-uuid) uuid="no"
@@ -832,6 +837,8 @@ echo " --disable-vnc-jpeg disable JPEG lossy compression for VNC server" echo " --enable-vnc-jpeg enable JPEG lossy compression for VNC server" echo " --disable-vnc-png disable PNG compression for VNC server" echo " --enable-vnc-png enable PNG compression for VNC server" +echo " --disable-vnc-thread disable threaded VNC server" +echo " --enable-vnc-thread enable threaded VNC server" echo " --disable-curses disable curses output" echo " --enable-curses enable curses output" echo " --disable-curl disable curl connectivity"
@@ -2126,6 +2133,7 @@ echo "VNC TLS support $vnc_tls" echo "VNC SASL support $vnc_sasl" echo "VNC JPEG support $vnc_jpeg" echo "VNC PNG support $vnc_png" +echo "VNC thread $vnc_thread" if test -n "$sparc_cpu"; then echo "Target Sparc Arch $sparc_cpu" fi
@@ -2270,6 +2278,10 @@ if test "$vnc_png" = "yes" ; then echo "CONFIG_VNC_PNG=y" >> $config_host_mak echo "VNC_PNG_CFLAGS=$vnc_png_cflags" >> $config_host_mak fi +if test "$vnc_thread" = "yes" ; then + echo "CONFIG_VNC_THREAD=y" >> $config_host_mak + echo "CONFIG_THREAD=y" >> $config_host_mak +fi if test "$fnmatch" = "yes" ; then echo "CONFIG_FNMATCH=y" >> $config_host_mak fi
@@ -2346,6 +2358,7 @@ if test "$xen" = "yes" ; then fi if test "$io_thread" = "yes" ; then echo "CONFIG_IOTHREAD=y" >> $config_host_mak + echo "CONFIG_THREAD=y" >> $config_host_mak fi if test "$linux_aio" = "yes" ; then echo "CONFIG_LINUX_AIO=y" >> $config_host_mak
ui/vnc-jobs-async.c new file +331 -0
331 lines not on this page · raw message
ui/vnc-jobs-sync.c new file +73 -0
73 lines not on this page · raw message
ui/vnc-jobs.h new file +87 -0
87 lines not on this page · raw message
ui/vnc.c +120 -24
364 lines not on this page · raw message
ui/vnc.h +52 -1
89 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 15/16 vnc: add missing lock for vnc_cursor_define()
In reply to Corentin CharyAll vnc_write() calls must be locked (except the ones present before the protocol initialization).
--- ui/vnc.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
ui/vnc.c +2 -0
@@ -794,6 +794,7 @@ static int vnc_cursor_define(VncState *vs)int isize;if (vnc_has_feature (vs,VNC_FEATURE_RICH_CURSOR )) { +vnc_lock_output (vs);vnc_write_u8 (vs,VNC_MSG_SERVER_FRAMEBUFFER_UPDATE );vnc_write_u8 (vs,0 );/* padding */ vnc_write_u16 (vs,1 );/* # of rects */
@@ -802,6 +803,7 @@ static int vnc_cursor_define(VncState *vs) isize = c->width * c->height * vs->clientds.pf.bytes_per_pixel;vnc_write_pixels_generic (vs, &pf, c->data, isize);vnc_write (vs, vs->vd->cursor_mask, vs->vd->cursor_msize); +vnc_unlock_output (vs);return 0 ; }return -1 ;
Signature · 1 line
1.7.1
PATCH 16/16 vnc: tight: don't limit png rect size
In reply to Corentin CharyPNG was introduced because some vnc HTML5 clients like noVNC have slow zlib decoding, but really fast PNG rendering. This means that if PNG is enabled we should send only PNG (and JPEG, fill), and never something compressed directly with zlib.
--- ui/vnc-enc-tight.c | 4 ---- ui/vnc-enc-tight.h | 1 - 2 files changed, 0 insertions(+), 5 deletions(-)
ui/vnc-enc-tight.c +0 -4
@@ -97,10 +97,6 @@ static bool tight_can_send_png_rect(VncState *vs, int w, int h) vs->clientds.pf.bytes_per_pixel == 1) {return false; } - -if (w * h <VNC_TIGHT_PNG_MIN_RECT_SIZE ) { -return false; - } return true; }#endif
ui/vnc-enc-tight.h +0 -1
@@ -176,7 +176,6 @@#define VNC_TIGHT_MAX_SPLIT_TILE_SIZE 16#define VNC_TIGHT_JPEG_MIN_RECT_SIZE 4096 -#define VNC_TIGHT_PNG_MIN_RECT_SIZE 4096#define VNC_TIGHT_DETECT_SUBROW_WIDTH 7#define VNC_TIGHT_DETECT_MIN_WIDTH 8#define VNC_TIGHT_DETECT_MIN_HEIGHT 8
Signature · 1 line
1.7.1