VNC Updates for 0.13
v2 cover VNC Updates for 0.13
This set contains all my patchs related to tight and threaded vnc server.
Since v1:
* Add a fix for jpeg and png with non-24bpp displays
* Better default values for vnc options in ./configure
* Fixed Tight PNG to use its own encoding number (-260)
* Cleaned tight send_sub_rect()
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 [1] (-260) and a new tight filter VNC_TIGHT_PNG (0x0A). When the client tells it supports the -260 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 [2], 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 [3] 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://wiki.qemu.org/VNC_Tight_PNG
[2] http://github.com/kanaka/noVNC/
[3] 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 (18):
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: fix rgb_prepare_row
vnc: tight: split send_sub_rect
vnc: better default values for VNC options
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 | 1715 ++++++++++++++++++++++++ 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 | 167 ++- vnc.h => ui/vnc.h | 115 ++- 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, 2796 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 v2 1/18 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="" attr=""
@@ -575,6 +576,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"
@@ -825,6 +830,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"
@@ -1246,6 +1253,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
@@ -2094,6 +2122,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
@@ -2231,6 +2260,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
PATCH v2 2/18 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 v2 3/18 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
@@ -835,6 +835,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 v2 4/18 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 \
@@ -344,4 +316,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 v2 5/18 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 v2 6/18 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 v2 7/18 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 v2 8/18 vnc: tight add PNG encoding
In reply to Corentin CharyIntroduce a new encoding: VNC_ENCODING_TIGHT_PNG [1] (-269) with a new tight filter VNC_TIGHT_PNG (0x0A). When the client tells it supports the Tight PNG 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 [2], but can also be used on devices like iPhone where PNG can be rendered in hardware.
[1] http://wiki.qemu.org/VNC_Tight_PNG
[2] http://github.com/kanaka/noVNC/
--- Makefile.target | 1 + configure | 37 ++++++ ui/vnc-enc-tight.c | 316 +++++++++++++++++++++++++++++++++++++++++++++------- ui/vnc-enc-tight.h | 16 ++- ui/vnc.c | 11 +- ui/vnc.h | 15 +++- 6 files changed, 342 insertions(+), 54 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="" attr=""
@@ -580,6 +581,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"
@@ -832,6 +837,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"
@@ -1274,6 +1281,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
@@ -2123,6 +2155,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
@@ -2264,6 +2297,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 +274 -42
502 lines not on this page · raw message
ui/vnc-enc-tight.h +9 -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
ui/vnc.c +7 -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
@@ -661,6 +657,9 @@ static int send_framebuffer_update(VncState *vs, int x, int y, int w, int h)case VNC_ENCODING_TIGHT : n =vnc_tight_send_framebuffer_update (vs, x, y, w, h);break ; +case VNC_ENCODING_TIGHT_PNG : + n =vnc_tight_png_send_framebuffer_update (vs, x, y, w, h); +break ;default :vnc_framebuffer_update (vs, x, y, w, h,VNC_ENCODING_RAW ); n =vnc_raw_send_framebuffer_update (vs, x, y, w, h);
@@ -1669,6 +1668,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 +14 -1
@@ -172,6 +172,7 @@ struct VncState/* Encoding specific */ /* Tight */ +int tight_type;uint8_t tight_quality;uint8_t tight_compression;uint8_t tight_pixel24;
@@ -182,6 +183,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 ];
@@ -259,6 +263,7 @@ enum {#define VNC_ENCODING_POINTER_TYPE_CHANGE 0XFFFFFEFF/* -257 */ #define VNC_ENCODING_EXT_KEY_EVENT 0XFFFFFEFE/* -258 */ #define VNC_ENCODING_AUDIO 0XFFFFFEFD/* -259 */ +#define VNC_ENCODING_TIGHT_PNG 0xFFFFFEFC/* -260 */ #define VNC_ENCODING_WMVi 0x574D5669/*****************************************************************************
@@ -275,6 +280,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 +299,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 +309,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 +413,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);
@@ -423,8 +435,9 @@ void vnc_zlib_zfree(void *x, void *addr);int vnc_zlib_send_framebuffer_update (VncState *vs,int x,int y,int w,int h);void vnc_zlib_clear (VncState *vs); -int vnc_tight_send_framebuffer_update (VncState *vs,int x,int y,int w,int h); +int vnc_tight_png_send_framebuffer_update (VncState *vs,int x,int y, +int w,int h);void vnc_tight_clear (VncState *vs);#endif /* __QEMU_VNC_H */
Signature · 1 line
1.7.1
Re: [Qemu-devel] [PATCH v2 08/18] vnc: tight add PNG encoding
Quoted 5 lines · Corentin Chary
Introduce a new encoding:
VNC_ENCODING_TIGHT_PNG[1] (-269) with a new tight filterVNC_TIGHT_PNG(0x0A). When the client tells it supports the Tight PNG 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.
I know that VNC_ENCODING_TIGHT_PNG / -260 is already allocated to QEMU in the RFB specification. Who is the authority for allocating tight filter numbers, and have they recorded/approved use of 0x0A for this PNG capability ?
Regards,
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Re: [Qemu-devel] [PATCH v2 08/18] vnc: tight add PNG encoding
Quoted 7 lines · Daniel P. Berrange
Quoted 5 lines · Corentin Chary
Introduce a new encoding:
VNC_ENCODING_TIGHT_PNG[1] (-269) with a new tight filterVNC_TIGHT_PNG(0x0A). When the client tells it supports the Tight PNG 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.
Quoted 5 lines
I know that
VNC_ENCODING_TIGHT_PNG/ -260 is already allocated to QEMU in the RFB specification. Who is the authority for allocating tight filter numbers, and have they recorded/approved use of0x0Afor this PNG capability ?
Tight PNG should considered as a new encoding, not as a tight pseudo encoding. When using Tight PNG, the server will send rect updates with -260, not 7.
We discussed that issue on #qemu-gsoc, and Anthony told me htat:
"if it gets sent with a different encoding, then you don't need anyone's approval, you just need an encoding number
but if it's a pseudo-encoding that modifies an existing encoding, then the author of the existing encoding must be on board"
Thanks,
Signature · 2 lines
Corentin Chary http://xf.iksaif.net
Re: [Qemu-devel] [PATCH v2 08/18] vnc: tight add PNG encoding
Quoted 8 lines · Corentin Chary
Quoted 7 lines · Daniel P. Berrange
Quoted 5 lines · Corentin Chary
Introduce a new encoding:
VNC_ENCODING_TIGHT_PNG[1] (-269) with a new tight filterVNC_TIGHT_PNG(0x0A). When the client tells it supports the Tight PNG 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.
Quoted 8 lines
Quoted 5 lines
I know that
VNC_ENCODING_TIGHT_PNG/ -260 is already allocated to QEMU in the RFB specification. Who is the authority for allocating tight filter numbers, and have they recorded/approved use of0x0Afor this PNG capability ?Tight PNG should considered as a new encoding, not as a tight pseudo encoding. When using Tight PNG, the server will send rect updates with -260, not 7.
Why layer this into the rest of the Tight protocol decoding then ? What benefit does it offer over a more straightforward standalone "PNG" encoding, that was completely independant of any tight based encoding.
Regards,
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Re: [Qemu-devel] [PATCH v2 08/18] vnc: tight add PNG encoding
Quoted 15 lines · Daniel P. Berrange
Quoted 14 lines · Corentin Chary
Quoted 12 lines · Daniel P. Berrange
Quoted 5 lines · Corentin Chary
Introduce a new encoding:
VNC_ENCODING_TIGHT_PNG[1] (-269) with a new tight filterVNC_TIGHT_PNG(0x0A). When the client tells it supports the Tight PNG 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.I know that
VNC_ENCODING_TIGHT_PNG/ -260 is already allocated to QEMU in the RFB specification. Who is the authority for allocating tight filter numbers, and have they recorded/approved use of0x0Afor this PNG capability ?
Quoted 7 lines
Quoted 2 lines
Tight PNG should considered as a new encoding, not as a tight pseudo encoding. When using Tight PNG, the server will send rect updates with -260, not 7.
Why layer this into the rest of the Tight protocol decoding then ? What benefit does it offer over a more straightforward standalone "PNG" encoding, that was completely independant of any tight based encoding.
Because:
- we also want a lossy encoding (Jpeg) for some parts (adaptive choice between jpeg and png/zlib based on update frequency is comming soon).
- we want the "fill" encoding for solid color rectangles
A standalone "PNG" encoding would work for some use case, and could be added later, but Tight PNG is more than that.
Signature · 2 lines
Corentin Chary http://xf.iksaif.net
Re: [Qemu-devel] [PATCH v2 08/18] vnc: tight add PNG encoding
Quoted 2 lines
- we also want a lossy encoding (Jpeg) for some parts (adaptive choice between jpeg and png/zlib based on update frequency is comming soon).
Please note that Tight PNG can already switch from PNG to JPEG like the original Tight was able to switch from Basic/Indexed to Jpeg (if lossy encoding are enabled,
and if the client sent a Tight quality).
Signature · 2 lines
Corentin Chary http://xf.iksaif.net
PATCH v2 9/18 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
@@ -73,6 +73,21 @@ static int tight_send_framebuffer_update(VncState *vs, int x, int y, int w, int h);#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);
@@ -1425,7 +1440,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;
@@ -1444,6 +1460,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 v2 10/18 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 +136 -0
136 lines not on this page · raw message
ui/vnc-palette.h new file +63 -0
63 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 11/18 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 | 204 +++++++++++++++++++++++++------------------------- ui/vnc-enc-zlib.c | 34 ++++---- ui/vnc.c | 8 +- ui/vnc.h | 59 ++++++++------- 5 files changed, 163 insertions(+), 156 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 +102 -102
582 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
@@ -1642,8 +1642,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 ;/*
@@ -1695,10 +1695,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 +33 -26
72 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH v2 12/18 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
@@ -1674,4 +1674,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 v2 13/18 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 v2 14/18 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="" attr=""
@@ -585,6 +586,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"
@@ -839,6 +844,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"
@@ -2156,6 +2163,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
@@ -2301,6 +2309,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
@@ -2377,6 +2389,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 v2 15/18 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
@@ -796,6 +796,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 */
@@ -804,6 +805,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 v2 16/18 vnc: tight: fix rgb_prepare_row
In reply to Corentin Charyrgb_prepare_row bpp depends on the server display surface, not the client.
--- ui/vnc-enc-tight.c | 15 ++++++++++----- 1 files changed, 10 insertions(+), 5 deletions(-)
ui/vnc-enc-tight.c +10 -5
@@ -1180,12 +1180,17 @@ DEFINE_RGB_GET_ROW_FUNCTION(32)static void rgb_prepare_row (VncState *vs,uint8_t *dst,int x,int y,int count) { -if (vs->tight.pixel24) -rgb_prepare_row24 (vs, dst, x, y, count); -else if (ds_get_bytes_per_pixel (vs->ds) ==4 ) -rgb_prepare_row32 (vs, dst, x, y, count); -else +if (ds_get_bytes_per_pixel (vs->ds) ==4 ) { +if (vs->ds->surface->pf.rmax ==0xFF && + vs->ds->surface->pf.gmax ==0xFF && + vs->ds->surface->pf.bmax ==0xFF ) { +rgb_prepare_row24 (vs, dst, x, y, count); + }else { +rgb_prepare_row32 (vs, dst, x, y, count); + } + }else {rgb_prepare_row16 (vs, dst, x, y, count); + } }#endif /* CONFIG_VNC_JPEG or CONFIG_VNC_PNG */
Signature · 1 line
1.7.1
PATCH v2 17/18 vnc: tight: split send_sub_rect
In reply to Corentin CharySplit send_sub_rect in send_sub_rect_jpeg and send_sub_rect_nojpeg to remove all these #ifdef CONFIG_JPEG.
--- ui/vnc-enc-tight.c | 80 +++++++++++++++++++++++++++++++++++---------------- 1 files changed, 55 insertions(+), 25 deletions(-)
ui/vnc-enc-tight.c +55 -25
@@ -1452,34 +1452,39 @@ static void vnc_tight_stop(VncState *vs) vs->output = vs->tight.tmp; } -static int send_sub_rect (VncState *vs,int x,int y,int w,int h) +static int send_sub_rect_nojpeg (VncState *vs,int x,int y,int w,int h, +int bg,int fg,int colors,VncPalette *palette) { -VncPalette *palette =NULL ; -uint32_t bg =0 , fg =0 ; -int colors; -int ret =0 ; - -vnc_framebuffer_update (vs, x, y, w, h, vs->tight.type); +int ret; -vnc_tight_start (vs); -vnc_raw_send_framebuffer_update (vs, x, y, w, h); -vnc_tight_stop (vs); +if (colors ==0 ) { +if (tight_detect_smooth_image (vs, w, h)) { + ret =send_gradient_rect (vs, x, y, w, h); + }else { + ret =send_full_color_rect (vs, x, y, w, h); + } + }else if (colors ==1 ) { + ret =send_solid_rect (vs); + }else if (colors ==2 ) { + ret =send_mono_rect (vs, x, y, w, h, bg, fg); + }else if (colors <=256 ) { + ret =send_palette_rect (vs, x, y, w, h, palette); + } +return ret; +} - colors =tight_fill_palette (vs, x, y, w * h, &fg, &bg, &palette); +#ifdef CONFIG_VNC_JPEG +static int send_sub_rect_jpeg (VncState *vs,int x,int y,int w,int h, +int bg,int fg,int colors, +VncPalette *palette) +{ +int ret;if (colors ==0 ) {if (tight_detect_smooth_image (vs, w, h)) { -if (vs->tight.quality ==-1 ) { - ret =send_gradient_rect (vs, x, y, w, h); - }else { -#ifdef CONFIG_VNC_JPEG -int quality = tight_conf[vs->tight.quality].jpeg_quality; +int quality = tight_conf[vs->tight.quality].jpeg_quality; - ret =send_jpeg_rect (vs, x, y, w, h, quality); -#else - ret =send_full_color_rect (vs, x, y, w, h); -#endif - } + ret =send_jpeg_rect (vs, x, y, w, h, quality); }else { ret =send_full_color_rect (vs, x, y, w, h); }
@@ -1488,8 +1493,7 @@ static int send_sub_rect(VncState *vs, int x, int y, int w, int h) }else if (colors ==2 ) { ret =send_mono_rect (vs, x, y, w, h, bg, fg); }else if (colors <=256 ) { -#ifdef CONFIG_VNC_JPEG -if (colors >96 && vs->tight.quality !=-1 && vs->tight.quality <=3 && +if (colors >96 &&tight_detect_smooth_image (vs, w, h)) {int quality = tight_conf[vs->tight.quality].jpeg_quality;
@@ -1497,10 +1501,36 @@ static int send_sub_rect(VncState *vs, int x, int y, int w, int h) } else { ret =send_palette_rect (vs, x, y, w, h, palette); } -#else - ret =send_palette_rect (vs, x, y, w, h, palette); + } +return ret; +}#endif + +static int send_sub_rect (VncState *vs,int x,int y,int w,int h) +{ +VncPalette *palette =NULL ; +uint32_t bg =0 , fg =0 ; +int colors; +int ret =0 ; + +vnc_framebuffer_update (vs, x, y, w, h, vs->tight.type); + +vnc_tight_start (vs); +vnc_raw_send_framebuffer_update (vs, x, y, w, h); +vnc_tight_stop (vs); + + colors =tight_fill_palette (vs, x, y, w * h, &fg, &bg, &palette); + +#ifdef CONFIG_VNC_JPEG +if (vs->tight.quality !=-1 ) { + ret =send_sub_rect_jpeg (vs, x, y, w, h, bg, fg, colors, palette); + }else { + ret =send_sub_rect_nojpeg (vs, x, y, w, h, bg, fg, colors, palette); } +#else + ret =send_sub_rect_nojpeg (vs, x, y, w, h, bg, fg, colors, palette); +#endif +palette_destroy (palette);return ret; }
Signature · 1 line
1.7.1
PATCH v2 18/18 vnc: better default values for VNC options
In reply to Corentin Charyvnc_jpeg and vnc_png are now "auto" by default, this means that if the dependencies are installed (libjpeg or libpng), then they will be enabled.
vnc_thread is disabled by default. It should be enabled by default as soon as it's stable enougth.
--- configure | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
configure +7 -7
@@ -270,7 +270,7 @@ vnc_tls="" vnc_sasl="" vnc_jpeg="" vnc_png="" -vnc_thread="" +vnc_thread="no" xen="" linux_aio="" attr=""
@@ -842,7 +842,7 @@ 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 " --disable-vnc-png disable PNG compression for VNC server (default)" 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"
@@ -1268,7 +1268,7 @@ fi ########################################## # VNC JPEG detection -if test "$vnc_jpeg" = "yes" ; then +if test "$vnc_jpeg" != "no" ; then cat > $TMPC <<EOF #include <stdio.h> #include <jpeglib.h>
@@ -1289,7 +1289,7 @@ fi ########################################## # VNC PNG detection -if test "$vnc_png" = "yes" ; then +if test "$vnc_png" != "no" ; then cat > $TMPC <<EOF //#include <stdio.h> #include <png.h>
@@ -2301,15 +2301,15 @@ 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 +if test "$vnc_jpeg" != "no" ; 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 +if test "$vnc_png" != "no" ; 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 +if test "$vnc_thread" != "no" ; then echo "CONFIG_VNC_THREAD=y" >> $config_host_mak echo "CONFIG_THREAD=y" >> $config_host_mak fi
Signature · 1 line
1.7.1
Quoted 7 lines · On Wednesday 07 July 2010 13:57:48 Corentin Chary wrote:
This set contains all my patchs related to tight and threaded vnc server.
Since v1:
* Add a fix for jpeg and png with non-24bpp displays
* Better default values for vnc options in ./configure
* Fixed Tight PNG to use its own encoding number (-260)
* Cleaned tightsend_sub_rect()
[ snip ]
Can anybody comment on the likelihood of this being committed in 0.13?
I'd like to evaluate some particular use cases with these VNC changes, however if it is not likely to be in 0.13 I will, unfortunately, have to bump my evaluations to a lower priority.
Thanks,
-Rick
Quoted 10 lines · Rick Vernam
Quoted 7 lines · On Wednesday 07 July 2010 13:57:48 Corentin Chary wrote:
This set contains all my patchs related to tight and threaded vnc server.
Since v1:
* Add a fix for jpeg and png with non-24bpp displays
* Better default values for vnc options in ./configure
* Fixed Tight PNG to use its own encoding number (-260)
* Cleaned tightsend_sub_rect()[ snip ]
Quoted 10 lines
Can anybody comment on the likelihood of this being committed in 0.13?
I'd like to evaluate some particular use cases with these VNC changes, however if it is not likely to be in 0.13 I will, unfortunately, have to bump my evaluations to a lower priority.
Thanks,
-Rick
Anthony told me that it'll be there for 0.13.
Signature · 2 lines
Corentin Chary http://xf.iksaif.net