qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move
@ 2010-06-07  6:08 Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 1/6] vnc: tight: add JPEG and gradient subencoding with smooth image detection Corentin Chary
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Corentin Chary @ 2010-06-07  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Corentin Chary, Anthony Liguori, Alexander Graf, Adam Litke

Hi,
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)

Corentin Chary (6):
  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

 Makefile                                       |   38 +-
 Makefile.objs                                  |   22 +-
 Makefile.target                                |    1 +
 configure                                      |   33 +
 qemu-options.hx                                |    7 +
 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 |   12 +-
 ui/vnc-enc-tight.c                             | 1522 ++++++++++++++++++++++++
 vnc-encoding-tight.h => ui/vnc-enc-tight.h     |    5 +
 vnc-encoding-zlib.c => ui/vnc-enc-zlib.c       |    0
 vnc-tls.c => ui/vnc-tls.c                      |    0
 vnc-tls.h => ui/vnc-tls.h                      |    0
 vnc.c => ui/vnc.c                              |    4 +-
 vnc.h => ui/vnc.h                              |    6 +
 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                           |  961 ---------------
 34 files changed, 1600 insertions(+), 1011 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 (93%)
 create mode 100644 ui/vnc-enc-tight.c
 rename vnc-encoding-tight.h => ui/vnc-enc-tight.h (97%)
 rename vnc-encoding-zlib.c => ui/vnc-enc-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 (99%)
 rename vnc.h => ui/vnc.h (99%)
 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 1/6] vnc: tight: add JPEG and gradient subencoding with smooth image detection
  2010-06-07  6:08 [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move Corentin Chary
@ 2010-06-07  6:08 ` Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 2/6] vnc: JPEG should be disabled if the client don't set tight quality Corentin Chary
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Corentin Chary @ 2010-06-07  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Corentin Chary, Anthony Liguori, Alexander Graf, Adam Litke

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 <corentincj@iksaif.net>
---
 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(-)

diff --git a/Makefile.target b/Makefile.target
index d06c679..decdcfa 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -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
diff --git a/configure b/configure
index 653c8d2..679f2fc 100755
--- a/configure
+++ b/configure
@@ -263,6 +263,7 @@ uuid=""
 vde=""
 vnc_tls=""
 vnc_sasl=""
+vnc_jpeg=""
 xen=""
 linux_aio=""
 vhost_net=""
@@ -547,6 +548,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"
@@ -779,6 +784,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"
@@ -1191,6 +1198,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
@@ -2019,6 +2047,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
@@ -2158,6 +2187,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
diff --git a/vnc-encoding-tight.c b/vnc-encoding-tight.c
index efb57e7..495745e 100644
--- a/vnc-encoding-tight.c
+++ b/vnc-encoding-tight.c
@@ -26,8 +26,16 @@
  * THE SOFTWARE.
  */
 
+
+#include "qemu-common.h"
+
+#ifdef CONFIG_VNC_JPEG
+#include <stdio.h>
+#include <jpeglib.h>
+#endif
 #include <stdbool.h>
 
+#include "bswap.h"
 #include "qdict.h"
 #include "qint.h"
 #include "vnc.h"
@@ -58,6 +66,206 @@ static const struct {
 };
 
 /*
+ * Code to guess if given rectangle is suitable for smooth image
+ * compression (by applying "gradient" filter or JPEG coder).
+ */
+
+static uint
+tight_detect_smooth_image24(VncState *vs, int w, int h)
+{
+    int off;
+    int x, y, d, dx;
+    uint c;
+    uint stats[256];
+    int pixels = 0;
+    int pix, left[3];
+    uint errors;
+    unsigned char *buf = vs->tight.buffer;
+
+    /*
+     * If client is big-endian, color samples begin from the second
+     * byte (offset 1) of a 32-bit pixel value.
+     */
+    off = !!(vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG);
+
+    memset(stats, 0, sizeof (stats));
+
+    for (y = 0, x = 0; y < h && x < w;) {
+        for (d = 0; d < h - y && d < w - x - VNC_TIGHT_DETECT_SUBROW_WIDTH;
+             d++) {
+            for (c = 0; c < 3; c++) {
+                left[c] = buf[((y+d)*w+x+d)*4+off+c] & 0xFF;
+            }
+            for (dx = 1; dx <= VNC_TIGHT_DETECT_SUBROW_WIDTH; dx++) {
+                for (c = 0; c < 3; c++) {
+                    pix = buf[((y+d)*w+x+d+dx)*4+off+c] & 0xFF;
+                    stats[abs(pix - left[c])]++;
+                    left[c] = pix;
+                }
+                pixels++;
+            }
+        }
+        if (w > h) {
+            x += h;
+            y = 0;
+        } else {
+            x = 0;
+            y += w;
+        }
+    }
+
+    /* 95% smooth or more ... */
+    if (stats[0] * 33 / pixels >= 95) {
+        return 0;
+    }
+
+    errors = 0;
+    for (c = 1; c < 8; c++) {
+        errors += stats[c] * (c * c);
+        if (stats[c] == 0 || stats[c] > stats[c-1] * 2) {
+            return 0;
+        }
+    }
+    for (; c < 256; c++) {
+        errors += stats[c] * (c * c);
+    }
+    errors /= (pixels * 3 - stats[0]);
+
+    return errors;
+}
+
+#define DEFINE_DETECT_FUNCTION(bpp)                                     \
+                                                                        \
+    static uint                                                         \
+    tight_detect_smooth_image##bpp(VncState *vs, int w, int h) {        \
+        bool endian;                                                    \
+        uint##bpp##_t pix;                                              \
+        int max[3], shift[3];                                           \
+        int x, y, d, dx;                                                \
+        uint c;                                                         \
+        uint stats[256];                                                \
+        int pixels = 0;                                                 \
+        int sample, sum, left[3];                                       \
+        uint errors;                                                    \
+        unsigned char *buf = vs->tight.buffer;                          \
+                                                                        \
+        endian = ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) !=        \
+                  (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG));     \
+                                                                        \
+                                                                        \
+        max[0] = vs->clientds.pf.rmax;                                  \
+        max[1] = vs->clientds.pf.gmax;                                  \
+        max[2] = vs->clientds.pf.bmax;                                  \
+        shift[0] = vs->clientds.pf.rshift;                              \
+        shift[1] = vs->clientds.pf.gshift;                              \
+        shift[2] = vs->clientds.pf.bshift;                              \
+                                                                        \
+        memset(stats, 0, sizeof(stats));                                \
+                                                                        \
+        y = 0, x = 0;                                                   \
+        while (y < h && x < w) {                                        \
+            for (d = 0; d < h - y &&                                    \
+                     d < w - x - VNC_TIGHT_DETECT_SUBROW_WIDTH; d++) {  \
+                pix = ((uint##bpp##_t *)buf)[(y+d)*w+x+d];              \
+                if (endian) {                                           \
+                    pix = bswap_##bpp(pix);                             \
+                }                                                       \
+                for (c = 0; c < 3; c++) {                               \
+                    left[c] = (int)(pix >> shift[c] & max[c]);          \
+                }                                                       \
+                for (dx = 1; dx <= VNC_TIGHT_DETECT_SUBROW_WIDTH;       \
+                     dx++) {                                            \
+                    pix = ((uint##bpp##_t *)buf)[(y+d)*w+x+d+dx];       \
+                    if (endian) {                                       \
+                        pix = bswap_##bpp(pix);                         \
+                    }                                                   \
+                    sum = 0;                                            \
+                    for (c = 0; c < 3; c++) {                           \
+                        sample = (int)(pix >> shift[c] & max[c]);       \
+                        sum += abs(sample - left[c]);                   \
+                        left[c] = sample;                               \
+                    }                                                   \
+                    if (sum > 255) {                                    \
+                        sum = 255;                                      \
+                    }                                                   \
+                    stats[sum]++;                                       \
+                    pixels++;                                           \
+                }                                                       \
+            }                                                           \
+            if (w > h) {                                                \
+                x += h;                                                 \
+                y = 0;                                                  \
+            } else {                                                    \
+                x = 0;                                                  \
+                y += w;                                                 \
+            }                                                           \
+        }                                                               \
+                                                                        \
+        if ((stats[0] + stats[1]) * 100 / pixels >= 90) {               \
+            return 0;                                                   \
+        }                                                               \
+                                                                        \
+        errors = 0;                                                     \
+        for (c = 1; c < 8; c++) {                                       \
+            errors += stats[c] * (c * c);                               \
+            if (stats[c] == 0 || stats[c] > stats[c-1] * 2) {           \
+                return 0;                                               \
+            }                                                           \
+        }                                                               \
+        for (; c < 256; c++) {                                          \
+            errors += stats[c] * (c * c);                               \
+        }                                                               \
+        errors /= (pixels - stats[0]);                                  \
+                                                                        \
+        return errors;                                                  \
+    }
+
+DEFINE_DETECT_FUNCTION(16)
+DEFINE_DETECT_FUNCTION(32)
+
+static int
+tight_detect_smooth_image(VncState *vs, int w, int h)
+{
+    uint errors;
+    int compression = vs->tight_compression;
+    int quality = vs->tight_quality;
+
+    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) {
+        return 0;
+    }
+
+    if (vs->tight_quality != -1) {
+        if (w * h < VNC_TIGHT_JPEG_MIN_RECT_SIZE) {
+            return 0;
+        }
+    } else {
+        if (w * h < tight_conf[compression].gradient_min_rect_size) {
+            return 0;
+        }
+    }
+
+    if (vs->clientds.pf.bytes_per_pixel == 4) {
+        if (vs->tight_pixel24) {
+            errors = tight_detect_smooth_image24(vs, w, h);
+            if (vs->tight_quality != -1) {
+                return (errors < tight_conf[quality].jpeg_threshold24);
+            }
+            return (errors < tight_conf[compression].gradient_threshold24);
+        } else {
+            errors = tight_detect_smooth_image32(vs, w, h);
+        }
+    } else {
+        errors = tight_detect_smooth_image16(vs, w, h);
+    }
+    if (quality != -1) {
+        return (errors < tight_conf[quality].jpeg_threshold);
+    }
+    return (errors < tight_conf[compression].gradient_threshold);
+}
+
+/*
  * Code to determine how many different colors used in rectangle.
  */
 
@@ -337,6 +545,133 @@ DEFINE_MONO_ENCODE_FUNCTION(16)
 DEFINE_MONO_ENCODE_FUNCTION(32)
 
 /*
+ * ``Gradient'' filter for 24-bit color samples.
+ * Should be called only when redMax, greenMax and blueMax are 255.
+ * Color components assumed to be byte-aligned.
+ */
+
+static void
+tight_filter_gradient24(VncState *vs, uint8_t *buf, int w, int h)
+{
+    uint32_t *buf32;
+    uint32_t pix32;
+    int shift[3];
+    int *prev;
+    int here[3], upper[3], left[3], upperleft[3];
+    int prediction;
+    int x, y, c;
+
+    buf32 = (uint32_t *)buf;
+    memset(vs->tight_gradient.buffer, 0, w * 3 * sizeof(int));
+
+    if ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) ==
+        (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG)) {
+        shift[0] = vs->clientds.pf.rshift;
+        shift[1] = vs->clientds.pf.gshift;
+        shift[2] = vs->clientds.pf.bshift;
+    } else {
+        shift[0] = 24 - vs->clientds.pf.rshift;
+        shift[1] = 24 - vs->clientds.pf.gshift;
+        shift[2] = 24 - vs->clientds.pf.bshift;
+    }
+
+    for (y = 0; y < h; y++) {
+        for (c = 0; c < 3; c++) {
+            upper[c] = 0;
+            here[c] = 0;
+        }
+        prev = (int *)vs->tight_gradient.buffer;
+        for (x = 0; x < w; x++) {
+            pix32 = *buf32++;
+            for (c = 0; c < 3; c++) {
+                upperleft[c] = upper[c];
+                left[c] = here[c];
+                upper[c] = *prev;
+                here[c] = (int)(pix32 >> shift[c] & 0xFF);
+                *prev++ = here[c];
+
+                prediction = left[c] + upper[c] - upperleft[c];
+                if (prediction < 0) {
+                    prediction = 0;
+                } else if (prediction > 0xFF) {
+                    prediction = 0xFF;
+                }
+                *buf++ = (char)(here[c] - prediction);
+            }
+        }
+    }
+}
+
+
+/*
+ * ``Gradient'' filter for other color depths.
+ */
+
+#define DEFINE_GRADIENT_FILTER_FUNCTION(bpp)                            \
+                                                                        \
+    static void                                                         \
+    tight_filter_gradient##bpp(VncState *vs, uint##bpp##_t *buf,        \
+                               int w, int h) {                          \
+        uint##bpp##_t pix, diff;                                        \
+        bool endian;                                                    \
+        int *prev;                                                      \
+        int max[3], shift[3];                                           \
+        int here[3], upper[3], left[3], upperleft[3];                   \
+        int prediction;                                                 \
+        int x, y, c;                                                    \
+                                                                        \
+        memset (vs->tight_gradient.buffer, 0, w * 3 * sizeof(int));     \
+                                                                        \
+        endian = ((vs->clientds.flags & QEMU_BIG_ENDIAN_FLAG) !=        \
+                  (vs->ds->surface->flags & QEMU_BIG_ENDIAN_FLAG));     \
+                                                                        \
+        max[0] = vs->clientds.pf.rmax;                                  \
+        max[1] = vs->clientds.pf.gmax;                                  \
+        max[2] = vs->clientds.pf.bmax;                                  \
+        shift[0] = vs->clientds.pf.rshift;                              \
+        shift[1] = vs->clientds.pf.gshift;                              \
+        shift[2] = vs->clientds.pf.bshift;                              \
+                                                                        \
+        for (y = 0; y < h; y++) {                                       \
+            for (c = 0; c < 3; c++) {                                   \
+                upper[c] = 0;                                           \
+                here[c] = 0;                                            \
+            }                                                           \
+            prev = (int *)vs->tight_gradient.buffer;                    \
+            for (x = 0; x < w; x++) {                                   \
+                pix = *buf;                                             \
+                if (endian) {                                           \
+                    pix = bswap_##bpp(pix);                             \
+                }                                                       \
+                diff = 0;                                               \
+                for (c = 0; c < 3; c++) {                               \
+                    upperleft[c] = upper[c];                            \
+                    left[c] = here[c];                                  \
+                    upper[c] = *prev;                                   \
+                    here[c] = (int)(pix >> shift[c] & max[c]);          \
+                    *prev++ = here[c];                                  \
+                                                                        \
+                    prediction = left[c] + upper[c] - upperleft[c];     \
+                    if (prediction < 0) {                               \
+                        prediction = 0;                                 \
+                    } else if (prediction > max[c]) {                   \
+                        prediction = max[c];                            \
+                    }                                                   \
+                    diff |= ((here[c] - prediction) & max[c])           \
+                        << shift[c];                                    \
+                }                                                       \
+                if (endian) {                                           \
+                    diff = bswap_##bpp(diff);                           \
+                }                                                       \
+                *buf++ = diff;                                          \
+            }                                                           \
+        }                                                               \
+    }
+
+DEFINE_GRADIENT_FILTER_FUNCTION(16)
+DEFINE_GRADIENT_FILTER_FUNCTION(32)
+
+/*
  * Check if a rectangle is all of the same color. If needSameColor is
  * set to non-zero, then also check that its color equals to the
  * *colorPtr value. The result is 1 if the test is successfull, and in
@@ -704,6 +1039,41 @@ static void write_palette(const char *key, QObject *obj, void *opaque)
     }
 }
 
+static bool send_gradient_rect(VncState *vs, int w, int h)
+{
+    int stream = 3;
+    int level = tight_conf[vs->tight_compression].gradient_zlib_level;
+    size_t bytes;
+
+    if (vs->clientds.pf.bytes_per_pixel == 1)
+        return send_full_color_rect(vs, w, h);
+
+    vnc_write_u8(vs, (stream | VNC_TIGHT_EXPLICIT_FILTER) << 4);
+    vnc_write_u8(vs, VNC_TIGHT_FILTER_GRADIENT);
+
+    buffer_reserve(&vs->tight_gradient, w * 3 * sizeof (int));
+
+    if (vs->tight_pixel24) {
+        tight_filter_gradient24(vs, vs->tight.buffer, w, h);
+        bytes = 3;
+    } else if (vs->clientds.pf.bytes_per_pixel == 4) {
+        tight_filter_gradient32(vs, (uint32_t *)vs->tight.buffer, w, h);
+        bytes = 4;
+    } else {
+        tight_filter_gradient16(vs, (uint16_t *)vs->tight.buffer, w, h);
+        bytes = 2;
+    }
+
+    buffer_reset(&vs->tight_gradient);
+
+    bytes = w * h * bytes;
+    vs->tight.offset = bytes;
+
+    bytes = tight_compress_data(vs, stream, bytes,
+                                level, Z_FILTERED);
+    return (bytes >= 0);
+}
+
 static int send_palette_rect(VncState *vs, int w, int h, struct QDict *palette)
 {
     int stream = 2;
@@ -758,6 +1128,164 @@ static int send_palette_rect(VncState *vs, int w, int h, struct QDict *palette)
     return (bytes >= 0);
 }
 
+/*
+ * JPEG compression stuff.
+ */
+#ifdef CONFIG_VNC_JPEG
+static void jpeg_prepare_row24(VncState *vs, uint8_t *dst, int x, int y,
+                                     int count)
+{
+    VncDisplay *vd = vs->vd;
+    uint32_t *fbptr;
+    uint32_t pix;
+
+    fbptr = (uint32_t *)(vd->server->data + y * ds_get_linesize(vs->ds) +
+                         x * ds_get_bytes_per_pixel(vs->ds));
+
+    while (count--) {
+        pix = *fbptr++;
+        *dst++ = (uint8_t)(pix >> vs->ds->surface->pf.rshift);
+        *dst++ = (uint8_t)(pix >> vs->ds->surface->pf.gshift);
+        *dst++ = (uint8_t)(pix >> vs->ds->surface->pf.bshift);
+    }
+}
+
+#define DEFINE_JPEG_GET_ROW_FUNCTION(bpp)                               \
+                                                                        \
+    static void                                                         \
+    jpeg_prepare_row##bpp(VncState *vs, uint8_t *dst,                   \
+                                int x, int y, int count)                \
+    {                                                                   \
+        VncDisplay *vd = vs->vd;                                        \
+        uint##bpp##_t *fbptr;                                           \
+        uint##bpp##_t pix;                                              \
+        int r, g, b;                                                    \
+                                                                        \
+        fbptr = (uint##bpp##_t *)                                       \
+            (vd->server->data + y * ds_get_linesize(vs->ds) +           \
+             x * ds_get_bytes_per_pixel(vs->ds));                       \
+                                                                        \
+        while (count--) {                                               \
+            pix = *fbptr++;                                             \
+                                                                        \
+            r = (int)((pix >> vs->ds->surface->pf.rshift)               \
+                      & vs->ds->surface->pf.rmax);                      \
+            g = (int)((pix >> vs->ds->surface->pf.gshift)               \
+                      & vs->ds->surface->pf.gmax);                      \
+            b = (int)((pix >> vs->ds->surface->pf.bshift)               \
+                      & vs->ds->surface->pf.bmax);                      \
+                                                                        \
+            *dst++ = (uint8_t)((r * 255 + vs->ds->surface->pf.rmax / 2) \
+                               / vs->ds->surface->pf.rmax);             \
+            *dst++ = (uint8_t)((g * 255 + vs->ds->surface->pf.gmax / 2) \
+                               / vs->ds->surface->pf.gmax);             \
+            *dst++ = (uint8_t)((b * 255 + vs->ds->surface->pf.bmax / 2) \
+                               / vs->ds->surface->pf.bmax);             \
+        }                                                               \
+    }
+
+DEFINE_JPEG_GET_ROW_FUNCTION(16)
+DEFINE_JPEG_GET_ROW_FUNCTION(32)
+
+static void jpeg_prepare_row(VncState *vs, uint8_t *dst, int x, int y,
+                                       int count)
+{
+    if (vs->tight_pixel24)
+        jpeg_prepare_row24(vs, dst, x, y, count);
+    else if (ds_get_bytes_per_pixel(vs->ds) == 4)
+        jpeg_prepare_row32(vs, dst, x, y, count);
+    else
+        jpeg_prepare_row16(vs, dst, x, y, count);
+}
+
+/*
+ * Destination manager implementation for JPEG library.
+ */
+
+/* This is called once per encoding */
+static void jpeg_init_destination(j_compress_ptr cinfo)
+{
+    VncState *vs = cinfo->client_data;
+    Buffer *buffer = &vs->tight_jpeg;
+
+    cinfo->dest->next_output_byte = (JOCTET *)buffer->buffer + buffer->offset;
+    cinfo->dest->free_in_buffer = (size_t)(buffer->capacity - buffer->offset);
+}
+
+/* This is called when we ran out of buffer (shouldn't happen!) */
+static boolean jpeg_empty_output_buffer(j_compress_ptr cinfo)
+{
+    VncState *vs = cinfo->client_data;
+    Buffer *buffer = &vs->tight_jpeg;
+
+    buffer->offset = buffer->capacity;
+    buffer_reserve(buffer, 2048);
+    jpeg_init_destination(cinfo);
+    return TRUE;
+}
+
+/* This is called when we are done processing data */
+static void jpeg_term_destination(j_compress_ptr cinfo)
+{
+    VncState *vs = cinfo->client_data;
+    Buffer *buffer = &vs->tight_jpeg;
+
+    buffer->offset = buffer->capacity - cinfo->dest->free_in_buffer;
+}
+
+static int send_jpeg_rect(VncState *vs, int x, int y, int w, int h, int quality)
+{
+    struct jpeg_compress_struct cinfo;
+    struct jpeg_error_mgr jerr;
+    struct jpeg_destination_mgr manager;
+    JSAMPROW row[1];
+    uint8_t *buf;
+    int dy;
+
+    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);
+    jpeg_create_compress(&cinfo);
+
+    cinfo.client_data = vs;
+    cinfo.image_width = w;
+    cinfo.image_height = h;
+    cinfo.input_components = 3;
+    cinfo.in_color_space = JCS_RGB;
+
+    jpeg_set_defaults(&cinfo);
+    jpeg_set_quality(&cinfo, quality, true);
+
+    manager.init_destination = jpeg_init_destination;
+    manager.empty_output_buffer = jpeg_empty_output_buffer;
+    manager.term_destination = jpeg_term_destination;
+    cinfo.dest = &manager;
+
+    jpeg_start_compress(&cinfo, true);
+
+    for (dy = 0; dy < h; dy++) {
+        jpeg_prepare_row(vs, buf, x, y + dy, w);
+        jpeg_write_scanlines(&cinfo, row, 1);
+    }
+
+    jpeg_finish_compress(&cinfo);
+    jpeg_destroy_compress(&cinfo);
+
+    vnc_write_u8(vs, VNC_TIGHT_JPEG << 4);
+
+    tight_send_compact_size(vs, vs->tight_jpeg.offset);
+    vnc_write(vs, vs->tight_jpeg.buffer, vs->tight_jpeg.offset);
+    buffer_reset(&vs->tight_jpeg);
+
+    return 1;
+}
+#endif /* CONFIG_VNC_JPEG */
+
 static void vnc_tight_start(VncState *vs)
 {
     buffer_reset(&vs->tight);
@@ -790,13 +1318,38 @@ static int send_sub_rect(VncState *vs, int x, int y, int w, int h)
     colors = tight_fill_palette(vs, x, y, w * h, &fg, &bg, &palette);
 
     if (colors == 0) {
-        ret = send_full_color_rect(vs, w, h);
+        if (tight_detect_smooth_image(vs, w, h)) {
+            if (vs->tight_quality == -1) {
+                ret = send_gradient_rect(vs, w, h);
+            } else {
+#ifdef CONFIG_VNC_JPEG
+                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, w, h);
+#endif
+            }
+        } else {
+            ret = send_full_color_rect(vs, w, h);
+        }
     } else if (colors == 1) {
         ret = send_solid_rect(vs);
     } else if (colors == 2) {
         ret = send_mono_rect(vs, w, h, bg, fg);
     } else if (colors <= 256) {
+#ifdef CONFIG_VNC_JPEG
+        if (colors > 96 && vs->tight_quality != -1 && vs->tight_quality <= 3 &&
+            tight_detect_smooth_image(vs, w, h)) {
+            int quality = tight_conf[vs->tight_quality].jpeg_quality;
+
+            ret = send_jpeg_rect(vs, x, y, w, h, quality);
+        } else {
+            ret = send_palette_rect(vs, w, h, palette);
+        }
+#else
         ret = send_palette_rect(vs, w, h, palette);
+#endif
     }
     QDECREF(palette);
     return ret;
@@ -958,4 +1511,8 @@ void vnc_tight_clear(VncState *vs)
 
     buffer_free(&vs->tight);
     buffer_free(&vs->tight_zlib);
+    buffer_free(&vs->tight_gradient);
+#ifdef CONFIG_VNC_JPEG
+    buffer_free(&vs->tight_jpeg);
+#endif
 }
diff --git a/vnc-encoding-tight.h b/vnc-encoding-tight.h
index 64d1062..9b0910c 100644
--- a/vnc-encoding-tight.h
+++ b/vnc-encoding-tight.h
@@ -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 */
diff --git a/vnc.h b/vnc.h
index 7b64cf7..2a9024d 100644
--- a/vnc.h
+++ b/vnc.h
@@ -176,6 +176,10 @@ struct VncState
     Buffer 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];
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 2/6] vnc: JPEG should be disabled if the client don't set tight quality
  2010-06-07  6:08 [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 1/6] vnc: tight: add JPEG and gradient subencoding with smooth image detection Corentin Chary
@ 2010-06-07  6:08 ` Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 3/6] vnc: add lossy option Corentin Chary
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Corentin Chary @ 2010-06-07  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Corentin Chary, Anthony Liguori, Alexander Graf, Adam Litke

Disable JPEG compression by default and only enable it if the
VNC client has sent the requested quality.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 vnc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/vnc.c b/vnc.c
index ed0e096..9cf38d1 100644
--- a/vnc.c
+++ b/vnc.c
@@ -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;
 
     /*
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 3/6] vnc: add lossy option
  2010-06-07  6:08 [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 1/6] vnc: tight: add JPEG and gradient subencoding with smooth image detection Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 2/6] vnc: JPEG should be disabled if the client don't set tight quality Corentin Chary
@ 2010-06-07  6:08 ` Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 4/6] ui: move all ui components in ui/ Corentin Chary
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Corentin Chary @ 2010-06-07  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Corentin Chary, Anthony Liguori, Alexander Graf, Adam Litke

The lossy option can be used to enable lossy compression
methods like gradient or jpeg. This patch disable them by
default.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 qemu-options.hx      |    7 +++++++
 vnc-encoding-tight.c |    4 ++++
 vnc.c                |    2 ++
 vnc.h                |    2 ++
 4 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/qemu-options.hx b/qemu-options.hx
index a6928b7..cf33a54 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -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
 
diff --git a/vnc-encoding-tight.c b/vnc-encoding-tight.c
index 495745e..4257bd0 100644
--- a/vnc-encoding-tight.c
+++ b/vnc-encoding-tight.c
@@ -230,6 +230,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) {
diff --git a/vnc.c b/vnc.c
index 9cf38d1..ccd7aad 100644
--- a/vnc.c
+++ b/vnc.c
@@ -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;
         }
     }
 
diff --git a/vnc.h b/vnc.h
index 2a9024d..ec90cd3 100644
--- a/vnc.h
+++ b/vnc.h
@@ -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 VncDisplay
     char *display;
     char *password;
     int auth;
+    bool lossy;
 #ifdef CONFIG_VNC_TLS
     int subauth; /* Used by VeNCrypt */
     VncDisplayTLS tls;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 4/6] ui: move all ui components in ui/
  2010-06-07  6:08 [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move Corentin Chary
                   ` (2 preceding siblings ...)
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 3/6] vnc: add lossy option Corentin Chary
@ 2010-06-07  6:08 ` Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 5/6] vnc: rename vnc-encoding-* vnc-enc-* Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 6/6] vnc: tight: don't forget to add the last color Corentin Chary
  5 siblings, 0 replies; 7+ messages in thread
From: Corentin Chary @ 2010-06-07  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Corentin Chary, Anthony Liguori, Alexander Graf, Adam Litke

Move sdl, vnc, curses and cocoa UI into ui/ to cleanup
the root directory. Also remove some unnecessary explicit
targets from Makefile.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 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%)

diff --git a/Makefile b/Makefile
index 221fbd8..f0295da 100644
--- a/Makefile
+++ b/Makefile
@@ -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)
diff --git a/Makefile.objs b/Makefile.objs
index 9796dcb..d5973ba 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -100,16 +100,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
diff --git a/cocoa.m b/ui/cocoa.m
similarity index 100%
rename from cocoa.m
rename to ui/cocoa.m
diff --git a/curses.c b/ui/curses.c
similarity index 100%
rename from curses.c
rename to ui/curses.c
diff --git a/curses_keys.h b/ui/curses_keys.h
similarity index 100%
rename from curses_keys.h
rename to ui/curses_keys.h
diff --git a/d3des.c b/ui/d3des.c
similarity index 100%
rename from d3des.c
rename to ui/d3des.c
diff --git a/d3des.h b/ui/d3des.h
similarity index 100%
rename from d3des.h
rename to ui/d3des.h
diff --git a/keymaps.c b/ui/keymaps.c
similarity index 100%
rename from keymaps.c
rename to ui/keymaps.c
diff --git a/keymaps.h b/ui/keymaps.h
similarity index 100%
rename from keymaps.h
rename to ui/keymaps.h
diff --git a/sdl.c b/ui/sdl.c
similarity index 100%
rename from sdl.c
rename to ui/sdl.c
diff --git a/sdl_keysym.h b/ui/sdl_keysym.h
similarity index 100%
rename from sdl_keysym.h
rename to ui/sdl_keysym.h
diff --git a/sdl_zoom.c b/ui/sdl_zoom.c
similarity index 100%
rename from sdl_zoom.c
rename to ui/sdl_zoom.c
diff --git a/sdl_zoom.h b/ui/sdl_zoom.h
similarity index 100%
rename from sdl_zoom.h
rename to ui/sdl_zoom.h
diff --git a/sdl_zoom_template.h b/ui/sdl_zoom_template.h
similarity index 100%
rename from sdl_zoom_template.h
rename to ui/sdl_zoom_template.h
diff --git a/vnc-auth-sasl.c b/ui/vnc-auth-sasl.c
similarity index 100%
rename from vnc-auth-sasl.c
rename to ui/vnc-auth-sasl.c
diff --git a/vnc-auth-sasl.h b/ui/vnc-auth-sasl.h
similarity index 100%
rename from vnc-auth-sasl.h
rename to ui/vnc-auth-sasl.h
diff --git a/vnc-auth-vencrypt.c b/ui/vnc-auth-vencrypt.c
similarity index 100%
rename from vnc-auth-vencrypt.c
rename to ui/vnc-auth-vencrypt.c
diff --git a/vnc-auth-vencrypt.h b/ui/vnc-auth-vencrypt.h
similarity index 100%
rename from vnc-auth-vencrypt.h
rename to ui/vnc-auth-vencrypt.h
diff --git a/vnc-encoding-hextile.c b/ui/vnc-encoding-hextile.c
similarity index 100%
rename from vnc-encoding-hextile.c
rename to ui/vnc-encoding-hextile.c
diff --git a/vnc-encoding-tight.c b/ui/vnc-encoding-tight.c
similarity index 100%
rename from vnc-encoding-tight.c
rename to ui/vnc-encoding-tight.c
diff --git a/vnc-encoding-tight.h b/ui/vnc-encoding-tight.h
similarity index 100%
rename from vnc-encoding-tight.h
rename to ui/vnc-encoding-tight.h
diff --git a/vnc-encoding-zlib.c b/ui/vnc-encoding-zlib.c
similarity index 100%
rename from vnc-encoding-zlib.c
rename to ui/vnc-encoding-zlib.c
diff --git a/vnc-tls.c b/ui/vnc-tls.c
similarity index 100%
rename from vnc-tls.c
rename to ui/vnc-tls.c
diff --git a/vnc-tls.h b/ui/vnc-tls.h
similarity index 100%
rename from vnc-tls.h
rename to ui/vnc-tls.h
diff --git a/vnc.c b/ui/vnc.c
similarity index 100%
rename from vnc.c
rename to ui/vnc.c
diff --git a/vnc.h b/ui/vnc.h
similarity index 100%
rename from vnc.h
rename to ui/vnc.h
diff --git a/vnc_keysym.h b/ui/vnc_keysym.h
similarity index 100%
rename from vnc_keysym.h
rename to ui/vnc_keysym.h
diff --git a/vnchextile.h b/ui/vnchextile.h
similarity index 100%
rename from vnchextile.h
rename to ui/vnchextile.h
diff --git a/x_keymap.c b/ui/x_keymap.c
similarity index 100%
rename from x_keymap.c
rename to ui/x_keymap.c
diff --git a/x_keymap.h b/ui/x_keymap.h
similarity index 100%
rename from x_keymap.h
rename to ui/x_keymap.h
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 5/6] vnc: rename vnc-encoding-* vnc-enc-*
  2010-06-07  6:08 [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move Corentin Chary
                   ` (3 preceding siblings ...)
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 4/6] ui: move all ui components in ui/ Corentin Chary
@ 2010-06-07  6:08 ` Corentin Chary
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 6/6] vnc: tight: don't forget to add the last color Corentin Chary
  5 siblings, 0 replies; 7+ messages in thread
From: Corentin Chary @ 2010-06-07  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Corentin Chary, Anthony Liguori, Alexander Graf, Adam Litke

For the same reason that we don't use vnc-authentication-sasl.c but
vnc-auth-sals.c. Because it's tooooo long.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 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%)

diff --git a/Makefile.objs b/Makefile.objs
index d5973ba..22622a9 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -104,8 +104,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
diff --git a/ui/vnchextile.h b/ui/vnc-enc-hextile-template.h
similarity index 100%
rename from ui/vnchextile.h
rename to ui/vnc-enc-hextile-template.h
diff --git a/ui/vnc-encoding-hextile.c b/ui/vnc-enc-hextile.c
similarity index 93%
rename from ui/vnc-encoding-hextile.c
rename to ui/vnc-enc-hextile.c
index 728f25e..fa4b264 100644
--- a/ui/vnc-encoding-hextile.c
+++ b/ui/vnc-enc-hextile.c
@@ -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
 
diff --git a/ui/vnc-encoding-tight.c b/ui/vnc-enc-tight.c
similarity index 99%
rename from ui/vnc-encoding-tight.c
rename to ui/vnc-enc-tight.c
index 4257bd0..6db5570 100644
--- a/ui/vnc-encoding-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -39,7 +39,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).
diff --git a/ui/vnc-encoding-tight.h b/ui/vnc-enc-tight.h
similarity index 100%
rename from ui/vnc-encoding-tight.h
rename to ui/vnc-enc-tight.h
diff --git a/ui/vnc-encoding-zlib.c b/ui/vnc-enc-zlib.c
similarity index 100%
rename from ui/vnc-encoding-zlib.c
rename to ui/vnc-enc-zlib.c
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Qemu-devel] [PATCH v2 6/6] vnc: tight: don't forget to add the last color
  2010-06-07  6:08 [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move Corentin Chary
                   ` (4 preceding siblings ...)
  2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 5/6] vnc: rename vnc-encoding-* vnc-enc-* Corentin Chary
@ 2010-06-07  6:08 ` Corentin Chary
  5 siblings, 0 replies; 7+ messages in thread
From: Corentin Chary @ 2010-06-07  6:08 UTC (permalink / raw)
  To: qemu-devel; +Cc: Corentin Chary, Anthony Liguori, Alexander Graf, Adam Litke

While using indexed colors, the last color was never added to the palette.
Triggered with ubuntu livecd.

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
---
 ui/vnc-enc-tight.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 6db5570..77fcdf7 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -395,11 +395,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];                                           \
             }                                                           \
         }                                                               \
                                                                         \
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-06-07  6:07 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07  6:08 [Qemu-devel] [PATCH v2 0/6] vnc updates and ui move Corentin Chary
2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 1/6] vnc: tight: add JPEG and gradient subencoding with smooth image detection Corentin Chary
2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 2/6] vnc: JPEG should be disabled if the client don't set tight quality Corentin Chary
2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 3/6] vnc: add lossy option Corentin Chary
2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 4/6] ui: move all ui components in ui/ Corentin Chary
2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 5/6] vnc: rename vnc-encoding-* vnc-enc-* Corentin Chary
2010-06-07  6:08 ` [Qemu-devel] [PATCH v2 6/6] vnc: tight: don't forget to add the last color Corentin Chary

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).